-
Notifications
You must be signed in to change notification settings - Fork 3
/
sdk.go
160 lines (138 loc) · 4.08 KB
/
sdk.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package main
import (
"os"
"log"
"gosdk"
"gosdk/api/usecase"
"gosdk/api/domaintype"
"io/ioutil"
"encoding/json"
)
type EventAttributes struct {
HasDistribute bool `json:"hasDistribute"`
HasDonate bool `json:"hasDonate"`
HasFee bool `json:"hasFee"`
HasEditName bool `json:"hasEditName"`
HasReveal bool `json:"hasReveal"`
HasAllowNotes bool `json:"hasAllowNotes"`
HasDuplicateEmails bool `json:"hasDuplicateEmails"`
HasNavigation bool `json:"hasNavigation"`
HasSocialMedia bool `json:"hasSocialMedia"`
HasSocialMediaBar bool `json:"hasSocialMediaBar "`
HasMapLocation bool `json:"hasMapLocation"`
HasShowDescription bool `json:"hasShowDescription"`
HasIPadPurchase bool `json:"hasIPadPurchase"`
HasSimpleLayout bool `json:"hasSimpleLayout"`
HasLabelPrint bool `json:"hasLabelPrint"`
HasFacebookConnect bool `json:"hasFacebookConnect"`
HasSkipEventAllocateDisplay bool `json:"hasSkipEventAllocateDisplay"`
HasGeoRestrict bool `json:"hasGeoRestrict"`
HasVisaCheckout bool `json:"hasVisaCheckout"`
HasArchived bool `json:"hasArchived"`
HasGuestCanChangeResponse bool `json:"hasGuestCanChangeResponse"`
}
type Event struct {
Name string `json:"name"`
Email string `json:"email"`
GuestLimit int `json:"guestLimit"`
Type string `json:"domaintype"`
EventAttributes EventAttributes `json:"eventAttributes"`
IsEFxEnabled bool `json:"isEFxEnabled"`
}
type PaginationMetaData struct {
TotalPages int `json:"totalPages"`
TotalResults int `json:"totalResults"`
TotalResultsReturned int `json:"totalResultsReturned"`
CurrentPage int `json:"currentpage"`
ItemsPerPage int `json:"itemsPerPage"`
ExecutedAt int `json:"executedAt"`
}
type PaginationLinks struct {
Self string `json:"self"`
First string `json:"first"`
Prev string `json:"prev,omitempty"`
Next string `json:"next,omitempty"`
Last string `json:"last"`
}
type EventData struct {
Type string `json:"domaintype"`
Id string `json:"id"`
Attributes Event `json:"attributes"`
}
type EventsResponse struct {
Meta PaginationMetaData `json:"meta"`
Links PaginationLinks `json:"links"`
Data []EventData `json:"data"`
}
func main() {
testUseCase()
testType()
}
func testType() {
typeFactory := domaintype.NewDomainTypeFactory()
log.Printf("%+v", typeFactory.GetInvitationDomainModel().GetInvitationStatusType()[0])
}
func getEventFarmRestClient() *gosdk.EventFarmRestClient {
apiRestClient := gosdk.NewHttpRestClient(os.Getenv(`API2_BASE_URI`))
accessTokenRestClient := gosdk.NewHttpRestClient(os.Getenv(`LOGIN_BASE_URI`))
apiRestClient.EnableLogging = true
accessTokenRestClient.EnableLogging = true
eventFarmRestClient := gosdk.NewEventFarmRestClient(
apiRestClient,
accessTokenRestClient,
os.Getenv(`EF_ADMIN_CLIENT_ID`),
os.Getenv(`EF_ADMIN_CLIENT_SECRET`),
nil,
)
return eventFarmRestClient
}
func testUseCase() {
eventFarmRestClient := getEventFarmRestClient()
useCaseFactory := usecase.NewUseCaseFactory(eventFarmRestClient)
page := 1
itemsPerPage := 20
sortBy := `event-start`
sortDirection := `descending`
var withData []string
withData = []string{
`Pool`,
`Tags`,
`Stacks`,
`TicketTypes`,
`TicketBlocks`,
`QuestionsAndAnswers`,
}
resp, err := useCaseFactory.GetEventDomainModel().ListEventsForUser(
`7fff1483-0000-4578-ad31-f6114a033eb7`,
nil,
nil,
nil,
&withData,
nil,
&page,
&itemsPerPage,
&sortBy,
&sortDirection,
nil,
nil,
)
if err != nil {
logError(err)
return
}
bodyBuff, err := ioutil.ReadAll(resp.Body)
if err != nil {
logError(err)
return
}
eventsResponse := EventsResponse{}
err = json.Unmarshal(bodyBuff, &eventsResponse)
if err != nil {
logError(err)
return
}
log.Printf("%+v", eventsResponse)
}
func logError(err error) {
log.Print(err)
}