/
input.go
378 lines (331 loc) · 12.2 KB
/
input.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
package dto
import (
"net/url"
"time"
"github.com/savannahghi/enumutils"
"github.com/savannahghi/feedlib"
"github.com/savannahghi/firebasetools"
"github.com/savannahghi/onboarding/pkg/onboarding/domain"
"github.com/savannahghi/profileutils"
"github.com/savannahghi/scalarutils"
dm "gitlab.slade360emr.com/go/commontools/accounting/pkg/domain"
)
// UserProfileInput is used to create or update a user's profile.
type UserProfileInput struct {
PhotoUploadID *string `json:"photoUploadID"`
DateOfBirth *scalarutils.Date `json:"dateOfBirth,omitempty"`
Gender *enumutils.Gender `json:"gender,omitempty"`
FirstName *string `json:"lastName"`
LastName *string `json:"firstName"`
}
// PostVisitSurveyInput is used to send the results of post-visit surveys to the
// server.
type PostVisitSurveyInput struct {
LikelyToRecommend int `json:"likelyToRecommend" firestore:"likelyToRecommend"`
Criticism string `json:"criticism" firestore:"criticism"`
Suggestions string `json:"suggestions" firestore:"suggestions"`
}
// BusinessPartnerFilterInput is used to supply filter parameters for organizatiom filter inputs
type BusinessPartnerFilterInput struct {
Search *string `json:"search"`
Name *string `json:"name"`
SladeCode *string `json:"slade_code"`
}
// ToURLValues transforms the filter input to `url.Values`
func (i *BusinessPartnerFilterInput) ToURLValues() (values url.Values) {
vals := url.Values{}
if i.Search != nil {
vals.Add("search", *i.Search)
}
if i.Name != nil {
vals.Add("name", *i.Name)
}
if i.SladeCode != nil {
vals.Add("slade_code", *i.SladeCode)
}
return vals
}
// BusinessPartnerSortInput is used to supply sort input for organization list queries
type BusinessPartnerSortInput struct {
Name *enumutils.SortOrder `json:"name"`
SladeCode *enumutils.SortOrder `json:"slade_code"`
}
// ToURLValues transforms the filter input to `url.Values`
func (i *BusinessPartnerSortInput) ToURLValues() (values url.Values) {
vals := url.Values{}
if i.Name != nil {
if *i.Name == enumutils.SortOrderAsc {
vals.Add("order_by", "name")
} else {
vals.Add("order_by", "-name")
}
}
if i.SladeCode != nil {
if *i.Name == enumutils.SortOrderAsc {
vals.Add("slade_code", "number")
} else {
vals.Add("slade_code", "-number")
}
}
return vals
}
// BranchSortInput is used to supply sorting input for location list queries
type BranchSortInput struct {
Name *enumutils.SortOrder `json:"name"`
SladeCode *enumutils.SortOrder `json:"slade_code"`
}
// ToURLValues transforms the sort input to `url.Values`
func (i *BranchSortInput) ToURLValues() (values url.Values) {
vals := url.Values{}
if i.Name != nil {
if *i.Name == enumutils.SortOrderAsc {
vals.Add("order_by", "name")
} else {
vals.Add("order_by", "-name")
}
}
if i.SladeCode != nil {
if *i.SladeCode == enumutils.SortOrderAsc {
vals.Add("slade_code", "number")
} else {
vals.Add("slade_code", "-number")
}
}
return vals
}
// SignUpInput represents the user information required to create a new account
type SignUpInput struct {
PhoneNumber *string `json:"phoneNumber"`
PIN *string `json:"pin"`
Flavour feedlib.Flavour `json:"flavour"`
OTP *string `json:"otp"`
}
// BranchEdge is used to serialize GraphQL Relay edges for locations
type BranchEdge struct {
Cursor *string `json:"cursor"`
Node *domain.Branch `json:"node"`
}
// BranchConnection is used tu serialize GraphQL Relay connections for locations
type BranchConnection struct {
Edges []*BranchEdge `json:"edges"`
PageInfo *firebasetools.PageInfo `json:"pageInfo"`
}
// BranchFilterInput is used to supply filter parameters for locatioon list queries
type BranchFilterInput struct {
Search *string `json:"search"`
SladeCode *string `json:"sladeCode"`
ParentOrganizationID *string `json:"parentOrganizationID"`
}
// ToURLValues transforms the filter input to `url.Values`
func (i *BranchFilterInput) ToURLValues() url.Values {
vals := url.Values{}
if i.Search != nil {
vals.Add("search", *i.Search)
}
if i.SladeCode != nil {
vals.Add("slade_code", *i.SladeCode)
}
if i.ParentOrganizationID != nil {
vals.Add("parent", *i.ParentOrganizationID)
}
return vals
}
// PhoneNumberPayload used when verifying a phone number.
type PhoneNumberPayload struct {
PhoneNumber *string `json:"phoneNumber"`
}
// SetPrimaryPhoneNumberPayload used when veriying and setting a user's primary phone number via REST
type SetPrimaryPhoneNumberPayload struct {
PhoneNumber *string `json:"phoneNumber"`
OTP *string `json:"otp"`
}
// ChangePINRequest payload to set or change PIN information
type ChangePINRequest struct {
PhoneNumber string `json:"phoneNumber"`
PIN string `json:"pin"`
OTP string `json:"otp"`
}
// LoginPayload used when calling the REST API to log a user in
type LoginPayload struct {
PhoneNumber *string `json:"phoneNumber"`
PIN *string `json:"pin"`
Flavour feedlib.Flavour `json:"flavour"`
}
// SendRetryOTPPayload is used when calling the REST API to resend an otp
type SendRetryOTPPayload struct {
Phone *string `json:"phoneNumber"`
RetryStep *int `json:"retryStep"`
AppID *string `json:"appId"`
}
// RefreshTokenExchangePayload is marshalled into JSON
// and sent to the Firebase Auth REST API when exchanging a
// refresh token for an ID token that can be used to make API calls
type RefreshTokenExchangePayload struct {
GrantType string `json:"grant_type"`
RefreshToken string `json:"refresh_token"`
}
// RefreshTokenPayload is used when calling the REST API to
// exchange a Refresh Token for new ID Token
type RefreshTokenPayload struct {
RefreshToken *string `json:"refreshToken"`
}
// UIDPayload is the user ID used in some inter-service requests
type UIDPayload struct {
UID *string `json:"uid"`
}
// UpdateCoversPayload is used to make a REST
// request to update a user's covers in their user profile
type UpdateCoversPayload struct {
UID *string `json:"uid"`
PayerName *string `json:"payerName"`
MemberName *string `json:"memberName"`
MemberNumber *string `json:"memberNumber"`
PayerSladeCode *int `json:"payerSladeCode"`
BeneficiaryID *int `json:"beneficiaryID"`
EffectivePolicyNumber *string `json:"effectivePolicyNumber"`
ValidFrom *time.Time `json:"validFrom"`
ValidTo *time.Time `json:"validTo"`
}
// UIDsPayload is an input of a slice of users' UIDs used
// for ISC requests to retrieve contact details of the users
type UIDsPayload struct {
UIDs []string `json:"uids"`
}
// UserAddressInput represents a user's geo location input
type UserAddressInput struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Locality *string `json:"locality"`
Name *string `json:"name"`
PlaceID *string `json:"placeID"`
FormattedAddress *string `json:"formattedAddress"`
}
// NHIFDetailsInput represents a user's thin NHIF input details
type NHIFDetailsInput struct {
MembershipNumber string `json:"membershipNumber"`
Employment domain.EmploymentType `json:"employmentType"`
IDDocType enumutils.IdentificationDocType `json:"IDDocType"`
IDNumber string `json:"IDNumber"`
IdentificationCardPhotoID string `json:"identificationCardPhotoID"`
NHIFCardPhotoID string `json:"nhifCardPhotoID"`
}
// PushTokenPayload represents user device push token
type PushTokenPayload struct {
PushToken string `json:"pushTokens"`
UID string `json:"uid"`
}
// EmailNotificationPayload is the email payload used to send email
// supplier and admins for KYC requests
type EmailNotificationPayload struct {
SupplierName string `json:"supplier_name"`
PartnerType string `json:"partner_type"`
AccountType string `json:"account_type"`
SubjectTitle string `json:"subject_title"`
EmailBody string `json:"email_body"`
EmailAddress string `json:"email_address"`
PrimaryPhone string `json:"primary_phone"`
}
// UserProfilePayload is used to update a user's profile.
// This payload is used for REST endpoints
type UserProfilePayload struct {
UID *string `json:"uid"`
PhotoUploadID *string `json:"photoUploadID"`
DateOfBirth *scalarutils.Date `json:"dateOfBirth,omitempty"`
Gender *enumutils.Gender `json:"gender,omitempty"`
FirstName *string `json:"lastName"`
LastName *string `json:"firstName"`
}
// PermissionInput input required to create a permission
type PermissionInput struct {
Action string
Resource string
}
// RolePayload used when adding roles to a user
type RolePayload struct {
PhoneNumber *string `json:"phoneNumber"`
Role *profileutils.RoleType `json:"role"`
}
// RegisterAgentInput provides the data payload required to create an Agent
type RegisterAgentInput struct {
FirstName string `json:"lastName"`
LastName string `json:"firstName"`
Gender enumutils.Gender `json:"gender"`
PhoneNumber string `json:"phoneNumber"`
Email string `json:"email"`
DateOfBirth scalarutils.Date `json:"dateOfBirth"`
// ID of the Role being assigned to the new agent
RoleIDs []string `json:"roleIDs"`
}
// RegisterAdminInput provides the data payload required to create an Admin
type RegisterAdminInput struct {
FirstName string `json:"lastName"`
LastName string `json:"firstName"`
Gender enumutils.Gender `json:"gender"`
PhoneNumber string `json:"phoneNumber"`
Email string `json:"email"`
DateOfBirth scalarutils.Date `json:"dateOfBirth"`
// ID of the Role being assigned to the new employee
RoleIDs []string `json:"roleIDs"`
}
// AgentFilterInput is used to supply filter parameters for agent filter inputs
type AgentFilterInput struct {
PhoneNumber string `json:"phoneNumber"`
}
//CustomerPubSubMessagePayload is an `onboarding` PubSub message struct for commontools
type CustomerPubSubMessagePayload struct {
CustomerPayload dm.CustomerPayload `json:"customerPayload"`
UID string `json:"uid"`
}
//SupplierPubSubMessagePayload is an `onboarding` PubSub message struct for commontools
type SupplierPubSubMessagePayload struct {
SupplierPayload dm.SupplierPayload `json:"supplierPayload"`
UID string `json:"uid"`
}
// AssignRolePayload is the payload used to assign a role to a user
type AssignRolePayload struct {
UserID string `json:"userID"`
RoleID string `json:"roleID"`
}
// DeleteRolePayload is the payload used to delete a role
type DeleteRolePayload struct {
Name string `json:"name"`
RoleID string `json:"roleID"`
}
// RoleInput represents the information required when creating a role
type RoleInput struct {
Name string `json:"name"`
Description string `json:"description"`
Scopes []string `json:"scopes"`
}
// RolePermissionInput input required to create a permission
type RolePermissionInput struct {
RoleID string `json:"roleID"`
Scopes []string `json:"scopes"`
}
// OtpPayload used when sending OTP messages
type OtpPayload struct {
PhoneNumber *string `json:"phoneNumber"`
AppID *string `json:"appId"`
}
// RetrieveUserProfileInput will be used to fetch a user profile by either email address or phone
type RetrieveUserProfileInput struct {
Email *string `json:"email" firestore:"emailAddress"`
PhoneNumber *string `json:"phone" firestore:"phoneNumber"`
}
//ProfileSuspensionInput is the input required to suspend/unsuspend a PRO account
type ProfileSuspensionInput struct {
ID string `json:"id"`
RoleIDs []string `json:"roleIDs"`
Reason string `json:"reason"`
}
// CheckPermissionPayload is the payload used when checking if a user is authorized
type CheckPermissionPayload struct {
UID *string `json:"uid"`
Permission *profileutils.Permission `json:"permission"`
}
// RoleRevocationInput is the input when revoking a user's role
type RoleRevocationInput struct {
ProfileID string
RoleID string
Reason string
}