diff --git a/README.md b/README.md index 787da5b..117202a 100644 --- a/README.md +++ b/README.md @@ -16,19 +16,35 @@ go get github.com/iterate/whereby-api-go package main import ( + "context" + "fmt" + "log" + "os" + "time" + "github.com/iterate/whereby-api-go" ) func main() { - wb := whereby.NewClient("my-api-key") - meeting, err := wb.CreateMeeting(whereby.CreateMeetingInput{ - Start: time.Now(), - End: time.Now().Add(time.Hour), - }) - - fmt.Println(meeting.URL) + 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: +```shell +go test ./... -tags functional -whereby-api-key key ``` ## Legal @@ -37,3 +53,4 @@ Copyright (c) 2020 Mindcare AS. Developed by [Iterate](https://iterate.no). Licensed under the [MIT license](LICENSE.txt). + diff --git a/client_test.go b/client_test.go index 9e77070..df7d0af 100644 --- a/client_test.go +++ b/client_test.go @@ -1,6 +1,7 @@ package whereby import ( + "context" "net/http" "testing" "time" @@ -25,3 +26,10 @@ type mockClient struct { func (m *mockClient) Do(req *http.Request) (*http.Response, error) { return m.DoFunc(req) } + +func testContext(t *testing.T) (context.Context, context.CancelFunc) { + if ddl, ok := t.Deadline(); ok { + return context.WithDeadline(context.Background(), ddl) + } + return context.WithCancel(context.Background()) +} diff --git a/create_meeting.go b/create_meeting.go index 60e045d..aa9ad6c 100644 --- a/create_meeting.go +++ b/create_meeting.go @@ -11,89 +11,92 @@ import ( "time" ) -type createMeetingInInt struct { +type createMeetingPayload struct { IsLocked bool `json:"isLocked"` RoomNamePrefix string `json:"roomNamePrefix,omitempty"` RoomNamePattern string `json:"roomNamePattern,omitempty"` RoomMode string `json:"roomMode,omitempty"` - Start string `json:"startDate"` + Start string `json:"startDate,omitempty"` End string `json:"endDate"` Fields []string `json:"fields,omitempty"` } +type CreateMeetingOutput = GetMeetingOutput + // 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. -func (c *Client) CreateMeeting(input CreateMeetingInput) (*GetMeetingOutput, error) { - return c.CreateMeetingWithContext(context.Background(), input) -} - -// CreateMeetingWithContext is the same as CreateMeeting with a user-specified -// context. -func (c *Client) CreateMeetingWithContext(ctx context.Context, input CreateMeetingInput) (*GetMeetingOutput, error) { +func (c *Client) CreateMeeting(ctx context.Context, input CreateMeetingInput) (CreateMeetingOutput, error) { + var out CreateMeetingOutput if err := validateCreateMeetingInput(input); err != nil { - return nil, err + return out, err } payload, err := json.Marshal(c.getCreateMeetingInput(input)) if err != nil { - return nil, fmt.Errorf("failed to encode request body: %w", err) + return out, fmt.Errorf("failed to encode request body: %w", err) } req, err := http.NewRequestWithContext(ctx, http.MethodPost, createMeetingEndpoint, bytes.NewBuffer(payload)) if err != nil { - return nil, fmt.Errorf("failed create request: %w", err) + return out, fmt.Errorf("failed create request: %w", err) } req.Header.Set("content-type", "application/json") res, err := c.do(req) if err != nil { - return nil, fmt.Errorf("failed to make request to the Whereby API: %w", err) + return out, fmt.Errorf("failed to make request to the Whereby API: %w", err) + } + + if res.StatusCode < 200 || res.StatusCode > 299 { + return out, handleBadStatus(res) } - if res.StatusCode != http.StatusCreated { - return nil, fmt.Errorf("unexpected status %d from Whereby", res.StatusCode) + var innerRes meeting + if err := json.NewDecoder(res.Body).Decode(&innerRes); err != nil { + return out, fmt.Errorf("failed to decode payload from Whereby: %w", err) } - var out meeting - if err := json.NewDecoder(res.Body).Decode(&out); err != nil { - return nil, fmt.Errorf("failed to decode payload from Whereby: %w", err) + if err := createGetMeetingOutput(&out, innerRes); err != nil { + return out, err } - return createGetMeetingOutput(out) + return out, nil } // createGetMeetingOutput creates the user-friendly output object from the // internal JSON representation. -func createGetMeetingOutput(in meeting) (*GetMeetingOutput, error) { - var out GetMeetingOutput - - out.MeetingID = in.MeetingId - out.URL = in.RoomURL - out.HostURL = in.HostRoomURL +func createGetMeetingOutput(dst *GetMeetingOutput, src meeting) error { + dst.MeetingID = src.MeetingId + dst.URL = src.RoomURL + if hu := src.HostRoomURL; hu != nil { + dst.HostURL = *hu + } - start, err := time.Parse(time.RFC3339, in.StartDate) - if err != nil { - return &out, fmt.Errorf("failed to parse meeting start time %s: %w", in.StartDate, err) + if sd := src.StartDate; sd != nil && *sd != "" { + start, err := time.Parse(time.RFC3339, *sd) + if err != nil { + return err + } + dst.Start = start } - out.Start = start - end, err := time.Parse(time.RFC3339, in.EndDate) + end, err := time.Parse(time.RFC3339, src.EndDate) if err != nil { - return &out, fmt.Errorf("failed to parse meeting end time %s: %w", in.EndDate, err) + return err } - out.End = end + dst.End = end - return &out, nil + return nil } // getCreateMeetingInput converts the CreateMeetingInput object into the inner // representation for JSON marshalling. -func (c *Client) getCreateMeetingInput(in CreateMeetingInput) createMeetingInInt { - var out createMeetingInInt +func (c *Client) getCreateMeetingInput(in CreateMeetingInput) createMeetingPayload { + var out createMeetingPayload out.IsLocked = in.IsLocked out.RoomNamePrefix = in.RoomNamePrefix out.RoomNamePattern = string(in.RoomNamePattern) @@ -109,12 +112,14 @@ func (c *Client) getCreateMeetingInput(in CreateMeetingInput) createMeetingInInt // validateCreateMeetingInput validates the provided CreateMeetingInput. func validateCreateMeetingInput(input CreateMeetingInput) error { - if input.RoomNamePrefix != "" && !strings.HasPrefix(input.RoomNamePrefix, "/") { - return errors.New(`room name prefix must begin with a slash ("/")`) + if input.RoomNamePrefix != "" { + if strings.ToLower(input.RoomNamePrefix) != input.RoomNamePrefix { + return errors.New("room name should be lowercase") + } } - if input.Start.IsZero() || input.End.IsZero() { - return errors.New("both start and end times must be specified") + if input.End.IsZero() { + return errors.New("meeting end time must be specified") } return nil diff --git a/create_meeting_test.go b/create_meeting_test.go index 3a020cc..058deb7 100644 --- a/create_meeting_test.go +++ b/create_meeting_test.go @@ -2,6 +2,7 @@ package whereby import ( "bytes" + "context" "io/ioutil" "net/http" "testing" @@ -21,7 +22,7 @@ func TestClient_CreateMeeting(t *testing.T) { c: httpClient, } - res, err := c.CreateMeeting(CreateMeetingInput{ + res, err := c.CreateMeeting(context.Background(), CreateMeetingInput{ IsLocked: true, Start: mustTimeFunc(t)(time.Parse(time.RFC3339, "2020-05-12T16:42:49Z")), End: mustTimeFunc(t)(time.Parse(time.RFC3339, "2020-05-12T17:42:49Z")), diff --git a/delete_meeting.go b/delete_meeting.go index e72ab03..8f2b311 100644 --- a/delete_meeting.go +++ b/delete_meeting.go @@ -13,13 +13,7 @@ import ( // // See https://whereby.dev/http-api/#/paths/~1meetings~1{meetingId}/delete for // more details. -func (c *Client) DeleteMeeting(meetingID string) error { - return c.DeleteMeetingWithContext(context.Background(), meetingID) -} - -// DeleteMeetingWithContext is the same as DeleteMeeting with a user-specified -// context. -func (c *Client) DeleteMeetingWithContext(ctx context.Context, meetingID string) error { +func (c *Client) DeleteMeeting(ctx context.Context, meetingID string) error { endpoint := strings.Replace(deleteMeetingEndpoint, "{meetingId}", meetingID, -1) req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint, nil) if err != nil { @@ -31,8 +25,8 @@ func (c *Client) DeleteMeetingWithContext(ctx context.Context, meetingID string) return fmt.Errorf("failed to make request to the Whereby API: %w", err) } - if res.StatusCode != http.StatusNoContent { - return fmt.Errorf("unexpected status %d from Whereby", res.StatusCode) + if res.StatusCode < 200 || res.StatusCode > 299 { + return handleBadStatus(res) } return nil diff --git a/delete_meeting_test.go b/delete_meeting_test.go index 6d166d6..65b9779 100644 --- a/delete_meeting_test.go +++ b/delete_meeting_test.go @@ -1,6 +1,7 @@ package whereby import ( + "context" "net/http" "testing" ) @@ -16,7 +17,7 @@ func TestClient_DeleteMeeting(t *testing.T) { c: httpClient, } - err := c.DeleteMeeting("1") + err := c.DeleteMeeting(context.Background(), "1") if err != nil { t.Errorf("want no err; got %v", err) } diff --git a/error.go b/error.go new file mode 100644 index 0000000..9bb2780 --- /dev/null +++ b/error.go @@ -0,0 +1,49 @@ +package whereby + +import ( + "encoding/json" + "errors" + "fmt" + "net/http" + "time" +) + +var ErrNotFound = errors.New("meeting not found") +var ErrInvalidCredentials = errors.New("invalid credentials") + +type RateLimitedError struct { + timeLeft time.Duration +} + +func (e RateLimitedError) Error() string { + return "rate limited" +} + +func (e RateLimitedError) TimeLeft() time.Duration { + return e.timeLeft +} + +func handleBadStatus(r *http.Response) error { + switch r.StatusCode { + case http.StatusNotFound: + return ErrNotFound + case http.StatusUnauthorized: + return ErrInvalidCredentials + case http.StatusTooManyRequests: + var rlr rateLimitResponse + if err := json.NewDecoder(r.Body).Decode(&rlr); err == nil && rlr.Data.MSLeft != nil { + defer r.Body.Close() + return RateLimitedError{timeLeft: time.Duration(*rlr.Data.MSLeft) * time.Millisecond} + } + return RateLimitedError{} + default: + return fmt.Errorf("unexpected status %d from Whereby", r.StatusCode) + } +} + +type rateLimitResponse struct { + Description string `json:"error"` + Data struct { + MSLeft *int `json:"ms_left"` + } `json:"data,omitempty"` +} diff --git a/event.go b/event.go index 4fb65b1..691e77c 100644 --- a/event.go +++ b/event.go @@ -18,27 +18,68 @@ const ( ) type CreateMeetingInput struct { - IsLocked bool - RoomNamePrefix string + // 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 - RoomMode RoomMode - Start time.Time - End time.Time - WithHostURL bool + + // 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 GetMeetingOutput struct { + // The ID of the meeting. MeetingID string - Start time.Time - End time.Time - URL string - HostURL 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 meeting struct { - MeetingId string `json:"meetingId"` - StartDate string `json:"startDate"` - EndDate string `json:"endDate"` - RoomURL string `json:"roomUrl"` - HostRoomURL string `json:"hostRoomUrl,omitempty"` + MeetingId string `json:"meetingId"` + StartDate *string `json:"startDate,omitempty"` + EndDate string `json:"endDate"` + RoomURL string `json:"roomUrl"` + HostRoomURL *string `json:"hostRoomUrl,omitempty"` } diff --git a/example_client_test.go b/example_client_test.go index 4182dd3..cc769fb 100644 --- a/example_client_test.go +++ b/example_client_test.go @@ -1,19 +1,21 @@ -package whereby +package whereby_test import ( + "context" "fmt" "log" "os" "time" + + "github.com/iterate/whereby-api-go" ) // Create a meeting and print the URL to stdout func ExampleClient_CreateMeeting() { - wb := NewClient(os.Getenv("WHEREBY_API_KEY")) + wb := whereby.NewClient(os.Getenv("WHEREBY_API_KEY")) - meeting, err := wb.CreateMeeting(CreateMeetingInput{ - Start: time.Now(), - End: time.Now().Add(time.Hour), + meeting, err := wb.CreateMeeting(context.Background(), whereby.CreateMeetingInput{ + End: time.Now().Add(time.Hour), }) if err != nil { @@ -22,4 +24,3 @@ func ExampleClient_CreateMeeting() { fmt.Println(meeting.URL) } - diff --git a/functional_test.go b/functional_test.go new file mode 100644 index 0000000..1a0ca40 --- /dev/null +++ b/functional_test.go @@ -0,0 +1,59 @@ +//go:build functional +// +build functional + +package whereby_test + +import ( + "context" + "flag" + "testing" + "time" + + "github.com/iterate/whereby-api-go" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var apiKey = flag.String("whereby-api-key", "", "Whereby API key") + +func TestClient(t *testing.T) { + if *apiKey == "" { + t.Fatal("no API key defined") + } + ctx := context.Background() + if dl, ok := t.Deadline(); ok { + c2, ccl := context.WithDeadline(ctx, dl) + ctx = c2 + defer ccl() + } + client := whereby.NewClient(*apiKey) + + t.Run("Create, get, delete", func(t *testing.T) { + createRes, err := client.CreateMeeting(ctx, whereby.CreateMeetingInput{ + IsLocked: true, + RoomNamePrefix: "some-prefix-", + RoomNamePattern: whereby.UUIDNamePattern, + RoomMode: whereby.NormalMode, + End: time.Now().Add(time.Hour * 2), + WithHostURL: true, + }) + require.NoError(t, err) + + getRes, err := client.GetMeeting(ctx, createRes.MeetingID, whereby.WithHostURL(true)) + assert.NoError(t, err) + assert.Equal(t, createRes.MeetingID, getRes.MeetingID) + + err = client.DeleteMeeting(ctx, getRes.MeetingID) + assert.NoError(t, err) + + _, err = client.GetMeeting(ctx, getRes.MeetingID) + assert.ErrorIs(t, err, whereby.ErrNotFound) + }) + + t.Run("Invalid credentials", func(t *testing.T) { + badClient := whereby.NewClient("invalid-credentials") + + _, err := badClient.GetMeeting(ctx, "2cba3bec-b78e-4ae3-a2cc-d781de733d2a") + assert.ErrorIs(t, err, whereby.ErrInvalidCredentials) + }) +} diff --git a/get_meeting.go b/get_meeting.go index e251fcf..0829974 100644 --- a/get_meeting.go +++ b/get_meeting.go @@ -12,34 +12,53 @@ import ( // // See https://whereby.dev/http-api/#/paths/~1meetings~1{meetingId}/get for more // details. -func (c *Client) GetMeeting(meetingID string) (*GetMeetingOutput, error) { - return c.GetMeetingWithContext(context.Background(), meetingID) -} +func (c *Client) GetMeeting(ctx context.Context, meetingID string, opts ...GetMeetingOpt) (GetMeetingOutput, error) { + var out GetMeetingOutput + var os getMeetingOpts + for _, f := range opts { + if err := f(&os); err != nil { + return out, err + } + } -// GetMeetingWithContext is the same as GetMeeting with a user-specified -// context. -func (c *Client) GetMeetingWithContext(ctx context.Context, meetingID string) (*GetMeetingOutput, error) { endpoint := strings.Replace(getMeetingEndpoint, "{meetingId}", meetingID, -1) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil) if err != nil { - return nil, fmt.Errorf("failed create request: %w", err) + return out, fmt.Errorf("failed create request: %w", err) } req.Header.Set("content-type", "application/json") res, err := c.do(req) if err != nil { - return nil, fmt.Errorf("failed to make request to the Whereby API: %w", err) + return out, fmt.Errorf("failed to make request to the Whereby API: %w", err) } - if res.StatusCode != http.StatusCreated { - return nil, fmt.Errorf("unexpected status %d from Whereby", res.StatusCode) + if res.StatusCode < 200 || res.StatusCode > 299 { + return out, handleBadStatus(res) } - var out meeting - if err := json.NewDecoder(res.Body).Decode(&out); err != nil { - return nil, fmt.Errorf("failed to decode payload from Whereby: %w", err) + var innerRes meeting + if err := json.NewDecoder(res.Body).Decode(&innerRes); err != nil { + return out, fmt.Errorf("failed to decode payload from Whereby: %w", err) } - return createGetMeetingOutput(out) + if err := createGetMeetingOutput(&out, innerRes); err != nil { + return out, err + } + return out, nil +} + +type getMeetingOpts struct { + WithHostURL bool +} + +// GetMeetingOpt is an option for GetMeeting. +type GetMeetingOpt func(*getMeetingOpts) error + +func WithHostURL(include bool) GetMeetingOpt { + return func(os *getMeetingOpts) error { + os.WithHostURL = include + return nil + } } diff --git a/get_meeting_test.go b/get_meeting_test.go index 08a1462..1035c6e 100644 --- a/get_meeting_test.go +++ b/get_meeting_test.go @@ -10,6 +10,8 @@ import ( func TestClient_GetMeeting(t *testing.T) { t.Run("With valid request/response", func(t *testing.T) { + ctx, ccl := testContext(t) + defer ccl() httpClient := &mockClient{DoFunc: func(req *http.Request) (*http.Response, error) { body := `{"meetingId":"1","startDate":"2020-05-12T16:42:49Z","endDate":"2020-05-12T17:42:49Z","roomUrl":"http://example.com","hostRoomUrl":"http://example.com/host-room"}` return &http.Response{ @@ -22,7 +24,7 @@ func TestClient_GetMeeting(t *testing.T) { c: httpClient, } - res, err := c.GetMeeting("1") + res, err := c.GetMeeting(ctx, "1") if err != nil { t.Errorf("want no err; got %v", err) } @@ -39,6 +41,8 @@ func TestClient_GetMeeting(t *testing.T) { }) t.Run("With invalid response", func(t *testing.T) { + ctx, ccl := testContext(t) + defer ccl() httpClient := &mockClient{DoFunc: func(req *http.Request) (*http.Response, error) { body := `{"meetingId":"1","startDate":"2020-05-12T16:42:49Z",` return &http.Response{ @@ -49,7 +53,7 @@ func TestClient_GetMeeting(t *testing.T) { }} c := Client{c: httpClient} - _, err := c.GetMeeting("1") + _, err := c.GetMeeting(ctx, "1") if err == nil { t.Errorf("want err; got %v", err) } diff --git a/go.mod b/go.mod index 014cfef..7729fcc 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/iterate/whereby-api-go go 1.15 -require golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 +require ( + github.com/stretchr/testify v1.7.0 + golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 +) diff --git a/go.sum b/go.sum index 7ffa456..cff3a4d 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -102,11 +103,14 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -346,6 +350,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/wherebyiface/client.go b/wherebyiface/client.go deleted file mode 100644 index 40e0e0b..0000000 --- a/wherebyiface/client.go +++ /dev/null @@ -1,19 +0,0 @@ -package wherebyiface - -import ( - "context" - "github.com/iterate/whereby-api-go" -) - -// Client is an interface for the Whereby client that can be used for mocking -// and dependency injection. -type Client interface { - CreateMeeting(input whereby.CreateMeetingInput) (*whereby.GetMeetingOutput, error) - CreateMeetingWithContext(ctx context.Context, input whereby.CreateMeetingInput) (*whereby.GetMeetingOutput, error) - - DeleteMeeting(meetingId string) error - DeleteMeetingWithContext(ctx context.Context, meetingId string) error - - GetMeeting(meetingId string) (*whereby.GetMeetingOutput, error) - GetMeetingWithContext(ctx context.Context, meetingId string) (*whereby.GetMeetingOutput, error) -} diff --git a/wherebyiface/client_test.go b/wherebyiface/client_test.go deleted file mode 100644 index 7c3b700..0000000 --- a/wherebyiface/client_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package wherebyiface - -import "github.com/iterate/whereby-api-go" - -// Interface guard. This will fail at compile time if the interface is no longer -// implemented by the standard client. -var _ Client = (*whereby.Client)(nil)