-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_client.go
79 lines (67 loc) · 2.45 KB
/
api_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package webexteams
import (
"os"
"github.com/go-resty/resty/v2"
)
// RestyClient is the REST Client
var RestyClient *resty.Client
const apiURL = "https://webexapis.com/v1"
// Client manages communication with the Webex Teams API API v1.0.0
// In most cases there should be only one, shared, APIClient.
type Client struct {
common service // Reuse a single struct instead of allocating one for each service on the heap.
// API Services
AdminAuditEvents *AdminAuditEventsService
Contents *ContentsService
Events *EventsService
Devices *DevicesService
Licenses *LicensesService
Memberships *MembershipsService
Messages *MessagesService
Organizations *OrganizationsService
People *PeopleService
Recordings *RecordingsService
Roles *RolesService
Rooms *RoomsService
TeamMemberships *TeamMembershipsService
Teams *TeamsService
Webhooks *WebhooksService
}
type service struct {
client *Client
}
// SetAuthToken defines the Authorization token sent in the request
func (s *Client) SetAuthToken(accessToken string) {
RestyClient.SetAuthToken(accessToken)
}
// NewClient creates a new API client. Requires a userAgent string describing your application.
// optionally a custom http.Client to allow for advanced features such as caching.
func NewClient() *Client {
client := resty.New()
c := &Client{}
RestyClient = client
RestyClient.SetHostURL(apiURL)
if os.Getenv("WEBEX_TEAMS_ACCESS_TOKEN") != "" {
RestyClient.SetAuthToken(os.Getenv("WEBEX_TEAMS_ACCESS_TOKEN"))
}
// API Services
c.AdminAuditEvents = (*AdminAuditEventsService)(&c.common)
c.Contents = (*ContentsService)(&c.common)
c.Events = (*EventsService)(&c.common)
c.Devices = (*DevicesService)(&c.common)
c.Licenses = (*LicensesService)(&c.common)
c.Memberships = (*MembershipsService)(&c.common)
c.Messages = (*MessagesService)(&c.common)
c.Organizations = (*OrganizationsService)(&c.common)
c.People = (*PeopleService)(&c.common)
c.Recordings = (*RecordingsService)(&c.common)
c.Roles = (*RolesService)(&c.common)
c.Rooms = (*RoomsService)(&c.common)
c.TeamMemberships = (*TeamMembershipsService)(&c.common)
c.Teams = (*TeamsService)(&c.common)
c.Webhooks = (*WebhooksService)(&c.common)
return c
}
// Error indicates an error from the invocation of a Webex API. See
// the following documentation for error context: https://developer.webex.com/docs/api/basics#api-errors.
type Error struct{}