forked from bpancost/sila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_add_registration_data.go
61 lines (53 loc) · 2.38 KB
/
entity_add_registration_data.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
package sila
import "github.com/kappapay/silaclient/domain"
func (client ClientImpl) AddRegistrationData(userHandle string) AddRegistrationData {
return &AddRegistrationDataMsg{
Header: client.generateHeader().setUserHandle(userHandle),
}
}
type AddRegistrationDataMsg struct {
Header *Header `json:"header"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
IdentityAlias string `json:"identity_alias,omitempty"`
IdentityValue string `json:"identity_value,omitempty"`
AddressAlias string `json:"address_alias,omitempty"`
StreetAddress1 string `json:"street_address_1,omitempty"`
StreetAddress2 string `json:"street_address_2,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country string `json:"country,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
DataType domain.RegistrationDataType `json:"-"`
}
func (msg *AddRegistrationDataMsg) SetEmail(email string) AddRegistrationData {
msg.Email = email
msg.DataType = domain.EmailDataType
return msg
}
func (msg *AddRegistrationDataMsg) SetPhone(phone string) AddRegistrationData {
msg.Phone = phone
msg.DataType = domain.PhoneDataType
return msg
}
func (msg *AddRegistrationDataMsg) SetIdentity(identityAlias string, identityValue string) AddRegistrationData {
msg.IdentityAlias = identityAlias
msg.IdentityValue = identityValue
msg.DataType = domain.IdentityDataType
return msg
}
func (msg *AddRegistrationDataMsg) SetAddress(address domain.RegistrationAddress) AddRegistrationData {
msg.StreetAddress1 = address.StreetAddress1
msg.StreetAddress2 = address.StreetAddress2
msg.City = address.City
msg.State = address.State
msg.Country = address.Country
msg.PostalCode = address.PostalCode
msg.DataType = domain.IdentityDataType
return msg
}
func (msg *AddRegistrationDataMsg) Do(userWalletPrivateKey string) (domain.ModifyRegistrationDataResponse, error) {
var responseBody domain.ModifyRegistrationDataResponse
err := instance.performCallWithUserAuth("/add/"+string(msg.DataType), msg, &responseBody, userWalletPrivateKey)
return responseBody, err
}