whereby

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 9 Imported by: 0

README

whereby-api-go

A Whereby API client for Go.

See the pkg.go.dev for more documentation for this module.

Installation

go get github.com/iterate/whereby-api-go

Usage

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	"github.com/iterate/whereby-api-go"
)

func main() {
	wb := whereby.NewClient(os.Getenv("WHEREBY_API_KEY"))

	meeting, err := wb.CreateMeeting(context.Background(), whereby.CreateMeetingInput{
		End: time.Now().Add(time.Hour),
	})

	if err != nil {
		log.Printf("Something went wrong: %v\n", err)
	}

	fmt.Println(meeting.URL)
}

Contributing

You may run a simple functional test by passing the functional tag to go test and setting the -whereby-api-key flag:

go test ./... -tags functional -whereby-api-key key

Copyright (c) 2020 Mindcare AS.

Developed by Iterate.

Licensed under the MIT license.

Documentation

Overview

Package whereby contains a client for communicating with the Whereby API.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredentials = errors.New("invalid credentials")
View Source
var ErrNotFound = errors.New("meeting not found")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Whereby client. It must be created using NewClient.

func NewClient

func NewClient(key string) *Client

NewClient creates a new Whereby client.

func (*Client) CreateMeeting

func (c *Client) CreateMeeting(ctx context.Context, input CreateMeetingInput) (CreateMeetingOutput, error)

CreateMeeting creates a meeting as specified. It will also create a transient room that is guaranteed to be available for specified start and end time. Some time after the meeting has ended, the transient room will be automatically deleted. The URL to this room is present in the response.

See https://whereby.dev/http-api/#/paths/~1meetings/post for more details.

Example

Create a meeting and print the URL to stdout

wb := whereby.NewClient(os.Getenv("WHEREBY_API_KEY"))

meeting, err := wb.CreateMeeting(context.Background(), whereby.CreateMeetingInput{
	End: time.Now().Add(time.Hour),
})

if err != nil {
	log.Printf("Something went wrong: %v\n", err)
}

fmt.Println(meeting.URL)
Output:

func (*Client) DeleteMeeting

func (c *Client) DeleteMeeting(ctx context.Context, meetingID string) error

DeleteMeeting deletes the specified meeting. The endpoint is idempotent, meaning it will return the same response even if the meeting has already been deleted.

See https://whereby.dev/http-api/#/paths/~1meetings~1{meetingId}/delete for more details.

func (*Client) GetMeeting

func (c *Client) GetMeeting(ctx context.Context, meetingID string, opts ...GetMeetingOpt) (GetMeetingOutput, error)

GetMeeting returns the specified meeting.

See https://whereby.dev/http-api/#/paths/~1meetings~1{meetingId}/get for more details.

type CreateMeetingInput

type CreateMeetingInput struct {
	// The initial lock state of the room. If true, only hosts will be able to
	// let in other participants and change lock state.
	IsLocked bool

	// This will be used as the prefix for the room name. The string should be
	// lowercase, and spaces will be automatically removed.
	RoomNamePrefix string

	// The format of the randomly generated room name. uuid is the default room
	// name pattern and follows the usual 8-4-4-4-12 pattern. human-short
	// generates a shorter string made up of six distinguishable characters.
	RoomNamePattern RoomNamePattern

	// The mode of the created transient room. normal is the default room mode
	// and should be used for meetings up to 4 participants. group should be
	// used for meetings that require more than 4 participants.
	RoomMode RoomMode

	// When the meeting starts. By default in UTC but a timezone can be
	// specified, e.g. 2021-05-07T17:42:49-05:00. This date must be in
	// the future.
	//
	// Deprecated: Value is ignored
	Start time.Time

	// When the meeting ends. By default in UTC but a timezone can be
	// specified, e.g. 2021-05-07T17:42:49-05:00. This has to be the same or
	// after the current date.
	End time.Time

	// Include hostRoomUrl field in the meeting response.
	WithHostURL bool
}

type CreateMeetingOutput

type CreateMeetingOutput = GetMeetingOutput

type GetMeetingOpt

type GetMeetingOpt func(*getMeetingOpts) error

GetMeetingOpt is an option for GetMeeting.

func WithHostURL

func WithHostURL(include bool) GetMeetingOpt

type GetMeetingOutput

type GetMeetingOutput struct {
	// The ID of the meeting.
	MeetingID string

	// When the meeting starts. Always in UTC, regardless of the input timezone.
	Start time.Time

	// When the meeting ends. Always in UTC, regardless of the input timezone.
	End time.Time

	// The URL to room where the meeting will be hosted.
	URL string

	// The URL to room where the meeting will be hosted which will also make
	// the user the host of the meeting. A host will get additional privileges
	// like locking the room, and removing and muting participants, so you
	//should be careful with whom you share this URL. The user will only become
	// a host if the meeting is on-going (some additional slack is added to
	// allow a host joining the meeting ahead of time or if the meeting goes
	// over time). This field is optional and will only provided if requested
	// through fields parameter.
	HostURL string
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type RateLimitedError

type RateLimitedError struct {
	// contains filtered or unexported fields
}

func (RateLimitedError) Error

func (e RateLimitedError) Error() string

func (RateLimitedError) TimeLeft

func (e RateLimitedError) TimeLeft() time.Duration

type RoomMode

type RoomMode string
const (
	DefaultMode RoomMode = ""
	GroupMode   RoomMode = "group"
	NormalMode  RoomMode = "normal"
)

type RoomNamePattern

type RoomNamePattern string
const (
	DefaultNamePattern       RoomNamePattern = ""
	UUIDNamePattern          RoomNamePattern = "uuid"
	HumanReadableNamePattern RoomNamePattern = "human-short"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL