/
output.go
151 lines (116 loc) · 5.01 KB
/
output.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
package dto
import (
"github.com/savannahghi/firebasetools"
"github.com/savannahghi/onboarding/pkg/onboarding/domain"
"github.com/savannahghi/profileutils"
)
// BusinessPartnerEdge is used to serialize GraphQL Relay edges for organization
type BusinessPartnerEdge struct {
Cursor *string `json:"cursor"`
Node *domain.BusinessPartner `json:"node"`
}
// BusinessPartnerConnection is used to serialize GraphQL Relay connections for organizations
type BusinessPartnerConnection struct {
Edges []*BusinessPartnerEdge `json:"edges"`
PageInfo *firebasetools.PageInfo `json:"pageInfo"`
}
// AgentConnection is used to serialize GraphQL Relay connections for agents
type AgentConnection struct {
Edges []AgentEdge `json:"edges"`
PageInfo firebasetools.PageInfo `json:"pageInfo"`
}
// AgentEdge is used to serialize GraphQL Edges for an agent
type AgentEdge struct {
Cursor string `json:"cursor"`
Node Agent `json:"node"`
}
// Agent represents agent with details inferred from their user profile
type Agent struct {
ID string `json:"id"`
PrimaryPhone string `json:"primaryPhone"`
PrimaryEmailAddress *string `json:"primaryEmailAddress"`
SecondaryPhoneNumbers []string `json:"secondaryPhoneNumbers"`
SecondaryEmailAddresses []string `json:"secondaryEmailAddresses"`
TermsAccepted bool `json:"termsAccepted,omitempty"`
Suspended bool `json:"suspended"`
PhotoUploadID string `json:"photoUploadID,omitempty"`
UserBioData profileutils.BioData `json:"userBioData,omitempty"`
// Resend PIN helps inform the whether a send new temporary PIN
// True when the user hasn't performed the initial sign up to change PIN
ResendPIN bool `json:"resendPIN"`
Roles []RoleOutput `json:"roles"`
}
// Admin represents agent with details inferred from their user profile
type Admin struct {
ID string `json:"id"`
PrimaryPhone string `json:"primaryPhone"`
PrimaryEmailAddress *string `json:"primaryEmailAddress"`
SecondaryPhoneNumbers []string `json:"secondaryPhoneNumbers"`
SecondaryEmailAddresses []string `json:"secondaryEmailAddresses"`
TermsAccepted bool `json:"termsAccepted,omitempty"`
Suspended bool `json:"suspended"`
PhotoUploadID string `json:"photoUploadID,omitempty"`
UserBioData profileutils.BioData `json:"userBioData,omitempty"`
// Resend PIN helps inform the whether a send new temporary PIN
// True when the user hasn't performed the initial sign up to change PIN
ResendPIN bool `json:"resendPIN"`
Roles []RoleOutput `json:"roles"`
}
// AccountRecoveryPhonesResponse payload sent back to the frontend when recovery an account
type AccountRecoveryPhonesResponse struct {
MaskedPhoneNumbers []string `json:"maskedPhoneNumbers"`
UnMaskedPhoneNumbers []string `json:"unmaskedPhoneNumbers"`
}
// OKResp is used to return OK response in inter-service calls
type OKResp struct {
Status string `json:"status,omitempty"`
Response interface{} `json:"response,omitempty"`
}
// NewOKResp a shortcut to create an instance of OKResp
func NewOKResp(rawResponse interface{}) *OKResp {
return &OKResp{
Status: "OK",
Response: rawResponse,
}
}
// CreatedUserResponse is used to return a created user
type CreatedUserResponse struct {
UID string `json:"uid,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Email string `json:"email,omitempty"`
PhoneNumber string `json:"phone_number,omitempty"`
PhotoURL string `json:"photo_url,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
}
// SupplierLogin is the response returned after the user has successfully login to edi
type SupplierLogin struct {
Branches *BranchConnection `json:"branches,omitempty"`
Supplier *profileutils.Supplier `json:"supplier,omitempty"`
}
// UserInfo is a collection of standard profile information for a user.
type UserInfo struct {
DisplayName string `json:"displayName,omitempty"`
Email string `json:"email,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
PhotoURL string `json:"photoUrl,omitempty"`
// In the ProviderUserInfo[] ProviderID can be a short domain name (e.g. google.com),
// or the identity of an OpenID identity provider.
// In UserRecord.UserInfo it will return the constant string "firebase".
ProviderID string `json:"providerId,omitempty"`
UID string `json:"rawId,omitempty"`
}
// RoleOutput is the formatted output with scopes and permissions
type RoleOutput struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Active bool `json:"active"`
Scopes []string `json:"scopes"`
Permissions []profileutils.Permission `json:"permissions"`
Users []*profileutils.UserProfile `json:"users"`
}
// GroupedNavigationActions is the list of Navigation Actions sorted into primary and secondary actions
type GroupedNavigationActions struct {
Primary []domain.NavigationAction `json:"primary,omitempty"`
Secondary []domain.NavigationAction `json:"secondary,omitempty"`
}