forked from tonicpow/go-handcash-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinitions.go
174 lines (150 loc) · 5 KB
/
definitions.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
package handcash
// CurrencyCode is an enum for supported currencies
type CurrencyCode string
// CurrencyCode enums
const (
CurrencyARS CurrencyCode = "ARS"
CurrencyAUD CurrencyCode = "AUD"
CurrencyBRL CurrencyCode = "BRL"
CurrencyBSV CurrencyCode = "BSV"
CurrencyCAD CurrencyCode = "CAD"
CurrencyCHF CurrencyCode = "CHF"
CurrencyCNY CurrencyCode = "CNY"
CurrencyCOP CurrencyCode = "COP"
CurrencyCZK CurrencyCode = "CZK"
CurrencyDKK CurrencyCode = "DKK"
CurrencyEUR CurrencyCode = "EUR"
CurrencyGBP CurrencyCode = "GBP"
CurrencyHKD CurrencyCode = "HKD"
CurrencyJPY CurrencyCode = "JPY"
CurrencyMXN CurrencyCode = "MXN"
CurrencyNOK CurrencyCode = "NOK"
CurrencyNZD CurrencyCode = "NZD"
CurrencyPHP CurrencyCode = "PHP"
CurrencyRUB CurrencyCode = "RUB"
CurrencySAT CurrencyCode = "SAT"
CurrencySEK CurrencyCode = "SEK"
CurrencySGD CurrencyCode = "SGD"
CurrencyTHB CurrencyCode = "THB"
CurrencyUSD CurrencyCode = "USD"
CurrencyZAR CurrencyCode = "ZAR"
)
// Profile are the user fields returned by the public and private profile endpoints
type Profile struct {
PublicProfile PublicProfile `json:"publicProfile"`
PrivateProfile PrivateProfile `json:"privateProfile"`
}
// PublicProfile is the public profile
type PublicProfile struct {
AvatarURL string `json:"avatarUrl"`
DisplayName string `json:"displayName"`
Handle string `json:"handle"`
ID string `json:"id"`
LocalCurrencyCode CurrencyCode `json:"localCurrencyCode"`
Paymail string `json:"paymail"`
}
// PrivateProfile is the private profile
type PrivateProfile struct {
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
}
// Participant is used for payments
type Participant struct {
Alias string `json:"alias"`
DisplayName string `json:"displayName"`
ProfilePictureURL string `json:"profilePictureUrl"`
ResponseNote string `json:"responseNote"`
Type ParticipantType `json:"type"`
}
// PaymentResponse is returned from the GetPayment function
type PaymentResponse struct {
AppAction AppAction `json:"appAction"`
Attachments []*Attachment `json:"attachments"`
FiatCurrencyCode CurrencyCode `json:"fiatCurrencyCode"`
FiatExchangeRate float64 `json:"fiatExchangeRate"`
Note string `json:"note"`
Participants []*Participant `json:"participants"`
RawTransactionHex string `json:"rawTransactionHex,omitempty"`
SatoshiAmount uint64 `json:"satoshiAmount"`
SatoshiFees uint64 `json:"satoshiFees"`
Time uint64 `json:"time"`
TransactionID string `json:"transactionId"`
Type PaymentType `json:"type"`
}
// PaymentRequest is used for GetPayment()
type PaymentRequest struct {
TransactionID string `json:"transactionId"`
}
// BalanceRequest is used for GetSpendableBalance()
type BalanceRequest struct {
CurrencyCode CurrencyCode `json:"currencyCode"`
}
// AppAction enum
type AppAction string
// AppAction enum
const (
AppActionLike AppAction = "like"
AppActionPublish AppAction = "publish"
AppActionTip AppAction = "tip"
AppActionTipGroup AppAction = "tip-group"
)
// AttachmentFormat enum
type AttachmentFormat string
// AttachmentFormat enum
const (
AttachmentFormatBase64 AttachmentFormat = "base64"
AttachmentFormatHex AttachmentFormat = "hex"
AttachmentFormatJSON AttachmentFormat = "json"
)
// Attachment is for additional data
type Attachment struct {
Format AttachmentFormat `json:"format,omitempty"`
Value interface{} `json:"value,omitempty"`
}
// Payment is used by PayParameters
type Payment struct {
Amount float64 `json:"amount"`
CurrencyCode CurrencyCode `json:"currencyCode"`
To string `json:"to"`
}
// PayParameters is used by Pay()
type PayParameters struct {
AppAction AppAction `json:"appAction,omitempty"`
Attachment *Attachment `json:"attachment,omitempty"`
Description string `json:"description,omitempty"`
Receivers []*Payment `json:"receivers,omitempty"`
}
// PaymentType enum
type PaymentType string
// PaymentType enum
const (
PaymentSend PaymentType = "send"
)
// ParticipantType enum
type ParticipantType string
// ParticipantType enum
const (
ParticipantUser ParticipantType = "user"
)
// oAuthHeaders are used for signed requests
type oAuthHeaders struct {
OauthPublicKey string `json:"oauth-publickey"`
OauthSignature string `json:"oauth-signature"`
OauthTimestamp string `json:"oauth-timestamp"`
}
// signedRequest is used to communicate with HandCash Connect API
type signedRequest struct {
Body interface{} `json:"body"`
Headers oAuthHeaders `json:"headers"`
JSON bool `json:"json"`
Method string `json:"method"`
URI string `json:"uri"`
}
// requestBody is for constructing the request
type requestBody struct {
authToken string
}
// errorResponse is the error response
type errorResponse struct {
Message string `json:"message"`
}