Skip to content

Commit

Permalink
Changed files names and included events API
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogarin committed Feb 23, 2021
1 parent cb453e9 commit c5f4050
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 39 deletions.
45 changes: 45 additions & 0 deletions examples/events/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"fmt"
"log"

webexteams "github.com/jbogarin/go-cisco-webex-teams/sdk"
)

// Client is Webex Teams API client
var Client *webexteams.Client

func main() {
Client = webexteams.NewClient()

/*
Events
*/

// GET events
eventQueryParams := &webexteams.ListEventsQueryParams{
Resource: "messages",
From: "2021-02-23T00:00:00.000Z",
To: "2021-02-23T12:00:00.000Z",
}

events, _, err := Client.Events.ListEvents(eventQueryParams)
if err != nil {
log.Fatal(err)
}
for id, event := range events.Items {
fmt.Println("GET:", id, event.ID, event.Created, event.Data.ID)
}

// GET events/<ID>

eventGet, _, err := Client.Events.GetEvent("<EVENT ID>")
if err != nil {
log.Fatal(err)
}
fmt.Println("GET <ID>:", eventGet.ID, eventGet.Data.Text, eventGet.Created, eventGet.Data.PersonEmail, eventGet.Data.RoomType)

}
2 changes: 2 additions & 0 deletions sdk/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Client struct {

// API Services
Contents *ContentsService
Events *EventsService
Devices *DevicesService
Licenses *LicensesService
Memberships *MembershipsService
Expand Down Expand Up @@ -54,6 +55,7 @@ func NewClient() *Client {

// API Services
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)
Expand Down
File renamed without changes.
106 changes: 106 additions & 0 deletions sdk/events_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package webexteams

import (
"fmt"
"strings"

"time"

"github.com/go-resty/resty/v2"
"github.com/google/go-querystring/query"
)

// EventsService is the service to communicate with the Events API endpoint
type EventsService service

// Event is the Event definition
type Event struct {
ID string `json:"id,omitempty"` // A unique identifier for the event.
Resource string `json:"resource,omitempty"` // The type of resource in the event.
AppID string `json:"appId,omitempty"` // The ID of the application for the event.
ActorID string `json:"actorId,omitempty"` // The personId of the person who made the change.
OrgID string `json:"orgId,omitempty"` // The ID of the organization for the event.
Created time.Time `json:"created,omitempty"` // The date and time of the event.
ActorOrgID string `json:"actorOrgId,omitempty"` // The orgId of the person who made the change.
Data struct {
ID string `json:"id,omitempty"` // Action ID.
RoomID string `json:"roomId,omitempty"` // Room ID where the event happened.
RoomType string `json:"roomType,omitempty"` // Room type where the event happened.
Text string `json:"text,omitempty"` // Text related to the event, in the case of a message.
PersonID string `json:"personId,omitempty"` // Person ID of the user who triggered the event.
PersonEmail string `json:"personEmail,omitempty"` // Person Email of the user who triggered the event.
Created string `json:"created,omitempty"` // The date and time of the event.
} `json:"data,omitempty"` // data
}

// Events is the Events definition
type Events struct {
Items []Event `json:"items,omitempty"` //
}

// ListEventsQueryParams defines the query parameters for this request
type ListEventsQueryParams struct {
Resource string `url:"resource,omitempty"` // List events with a specific resource type. Possible values: messages, memberships, tabs, rooms, attachmentActions
Type string `url:"type,omitempty"` // List events with a specific event type. Possible values: created, updated, deleted
ActorID string `url:"actorId,omitempty"` // List events performed by this person, by ID.
From string `url:"from,omitempty"` // List events which occurred after a specific date and time.
To string `url:"to,omitempty"` // List events which occurred before a specific date and time. If unspecified or set to a time in the future, lists events up to the present.
Max int `url:"max,omitempty"` // Limit the maximum number of events in the response. The maximum value is 200 Default: 100
}

// ListEvents List Events
/* List events in your organization. Several query parameters are available to filter the response.
Long result sets will be split into pages.
@param resource List events with a specific resource type. Possible values: messages, memberships, tabs, rooms, attachmentActions
@param type List events with a specific event type. Possible values: created, updated, deleted
@param actorId List events performed by this person, by ID.
@param from List events which occurred after a specific date and time.
@param to List events which occurred before a specific date and time. If unspecified or set to a time in the future, lists events up to the present.
@param max Limit the maximum number of events in the response. The maximum value is 200 Default: 100
*/
func (s *EventsService) ListEvents(listEventsQueryParams *ListEventsQueryParams) (*Events, *resty.Response, error) {

path := "/events"

queryString, _ := query.Values(listEventsQueryParams)

response, err := RestyClient.R().
SetQueryString(queryString.Encode()).
SetResult(&Events{}).
SetError(&Error{}).
Get(path)

if err != nil {
return nil, nil, err
}

result := response.Result().(*Events)
return result, response, err

}

// GetEvent Get Event Details
/* Shows details for an event, by event ID.
Specify the event ID in the eventId parameter in the URI.
@param eventId The unique identifier for the event.
*/
func (s *EventsService) GetEvent(eventID string) (*Event, *resty.Response, error) {

path := "/events/{eventId}"
path = strings.Replace(path, "{"+"eventId"+"}", fmt.Sprintf("%v", eventID), -1)

response, err := RestyClient.R().
SetResult(&Event{}).
SetError(&Error{}).
Get(path)

if err != nil {
return nil, nil, err
}

result := response.Result().(*Event)
return result, response, err

}
76 changes: 38 additions & 38 deletions sdk/meetings_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,57 @@ type MeetingInvitee struct {

// MeetingCreateRequest is the Create Meeting Request Parameters
type MeetingCreateRequest struct {
Title string `json:"title,omitempty"`
Agenda string `json:"agenda,omitempty"`
Password string `json:"password,omitempty"`
Start time.Time `json:"start,omitempty"`
End time.Time `json:"end,omitempty"`
Timezone string `json:"timezone,omitempty"`
Recurrence string `json:"recurrence,omitempty"`
EnabledAutoRecordMeeting string `json:"enabledAutoRecordMeeting,omitempty"`
AllowAnyUserToBeCoHost string `json:"allowAnyUserToBeCoHost,omitempty"`
Invitees []MeetingInvitee `json:"invitees,omitempty"`
Title string `json:"title,omitempty"` // Meeting title.
Agenda string `json:"agenda,omitempty"` // Meeting agenda. The agenda can be a maximum of 2500 characters long.
Password string `json:"password,omitempty"` // Meeting password.
Start time.Time `json:"start,omitempty"` // Date and time for the start of meeting in any ISO 8601 compliant format. start cannot be before current date and time or after end.
End time.Time `json:"end,omitempty"` // Date and time for the end of meeting in any ISO 8601 compliant format. end cannot be before current date and time or before start.
Timezone string `json:"timezone,omitempty"` // Time zone in which meeting was originally scheduled (conforming with the IANA time zone database).
Recurrence string `json:"recurrence,omitempty"` // Meeting series recurrence rule (conforming with RFC 2445), applying only to meeting series.
EnabledAutoRecordMeeting string `json:"enabledAutoRecordMeeting,omitempty"` // Whether or not meeting is recorded automatically.
AllowAnyUserToBeCoHost string `json:"allowAnyUserToBeCoHost,omitempty"` // Whether or not to allow any invitee to be a cohost.
Invitees []MeetingInvitee `json:"invitees,omitempty"` // Invitees for meeting.
}

// MeetingTelephony is the Meeting Telephony definition
type MeetingTelephony struct {
AccessCode string `json:"accessCode,omitempty"`
AccessCode string `json:"accessCode,omitempty"` // Code for authenticating a user to join teleconference.
CallInNumbers struct {
Label string `json:"label,omitempty"`
CallInNumber string `json:"callInNumber,omitempty"`
TollType string `json:"tollType,omitempty"`
} `json:",omitempty"`
} `json:",omitempty"` // Array of call-in numbers for joining teleconference from a phone.
Links struct {
Rel string `json:"rel,omitempty"`
HREF string `json:"href,omitempty"`
Method string `json:"method,omitempty"`
} `json:"links,omitempty"`
Rel string `json:"rel,omitempty"` // Link relation describing how the target resource is related to the current context (conforming with RFC5998).
HREF string `json:"href,omitempty"` // Target resource URI (conforming with RFC5998).
Method string `json:"method,omitempty"` // Target resource method (conforming with RFC5998).
} `json:"links,omitempty"` // HATEOAS information of global call-in numbers for joining teleconference from a phone.
}

// Meeting is the Meeting definition
type Meeting struct {
ID string `json:"id,omitempty"`
MeetingSeriesID string `json:"meetingSeriesId,omitempty"`
MeetingNumber string `json:"meetingNumber,omitempty"`
Title string `json:"title,omitempty"`
Agenda string `json:"agenda,omitempty"`
Password string `json:"password,omitempty"`
MeetingType string `json:"meetingType,omitempty"`
State string `json:"state,omitempty"`
Timezone string `json:"timezone,omitempty"`
Start time.Time `json:"start,omitempty"`
End time.Time `json:"end,omitempty"`
Recurrence string `json:"recurrence,omitempty"`
HostUserID string `json:"hostUserId,omitempty"`
HostDisplayName string `json:"hostDisplayName,omitempty"`
HostEmail string `json:"hostEmail,omitempty"`
HostKey string `json:"hostKey,omitempty"`
WebLink string `json:"webLink,omitempty"`
SIPAddress string `json:"sipAddress,omitempty"`
DialInIPAddress string `json:"dialInIpAddress,omitempty"`
EnabledAutoRecordMeeting bool `json:"enabledAutoRecordingMeeting,omitempty"`
AllowAnyUserToBeCoHost bool `json:"allowAnyUserToBeCoHost,omitempty"`
Telephony []MeetingTelephony `json:"telephony,omitempty"`
ID string `json:"id,omitempty"` // Unique identifier for meeting
MeetingSeriesID string `json:"meetingSeriesId,omitempty"` // Unique identifier for meeting series.
MeetingNumber string `json:"meetingNumber,omitempty"` // Meeting number.
Title string `json:"title,omitempty"` // Meeting title.
Agenda string `json:"agenda,omitempty"` // Meeting agenda. The agenda can be a maximum of 2500 characters long.
Password string `json:"password,omitempty"` // Meeting password.
MeetingType string `json:"meetingType,omitempty"` // One Of: meetingSeries, scheduledMeeting o meeting
State string `json:"state,omitempty"` // Meeting state.
Timezone string `json:"timezone,omitempty"` // Time zone of start and end, conforming with the IANA time zone database.
Start time.Time `json:"start,omitempty"` // Start time for meeting in ISO 8601 compliant format.
End time.Time `json:"end,omitempty"` // End time for meeting in ISO 8601 compliant format.
Recurrence string `json:"recurrence,omitempty"` // Meeting series recurrence rule (conforming with RFC 2445), applying only to recurring meeting series.
HostUserID string `json:"hostUserId,omitempty"` // Unique identifier for meeting host.
HostDisplayName string `json:"hostDisplayName,omitempty"` // Display name for meeting host.
HostEmail string `json:"hostEmail,omitempty"` // Email address for meeting host.
HostKey string `json:"hostKey,omitempty"` // Key for joining meeting as host.
WebLink string `json:"webLink,omitempty"` // Link to meeting information page where meeting client will be launched if the meeting is ready for start or join.
SIPAddress string `json:"sipAddress,omitempty"` // SIP address for callback from a video system.
DialInIPAddress string `json:"dialInIpAddress,omitempty"` // IP address for callback from a video system.
EnabledAutoRecordMeeting bool `json:"enabledAutoRecordingMeeting,omitempty"` // Whether or not meeting is recorded automatically.
AllowAnyUserToBeCoHost bool `json:"allowAnyUserToBeCoHost,omitempty"` // Whether or not to allow any invitee to be a cohost
Telephony []MeetingTelephony `json:"telephony,omitempty"` // Information for callbacks from meeting to phone or for joining a teleconference using a phone.
}

// Meetings is the List of Meetings
Expand Down
2 changes: 1 addition & 1 deletion sdk/messages_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Message struct {
ToPersonEmail string `json:"toPersonEmail,omitempty"` // Person email (for type=direct).
Text string `json:"text,omitempty"` // Message in plain text format.
Markdown string `json:"markdown,omitempty"` // Message in markdown format.
Html string `json:"html,omitempty"` // Message in HTML format.
HTML string `json:"html,omitempty"` // Message in HTML format.
Files []string `json:"files,omitempty"` // File URL array.
PersonID string `json:"personId,omitempty"` // Person ID.
PersonEmail string `json:"personEmail,omitempty"` // Person Email.
Expand Down
File renamed without changes.

0 comments on commit c5f4050

Please sign in to comment.