-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathglobal.go
204 lines (174 loc) · 4.13 KB
/
global.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
/*
* Coinbase Golang API Library
*
* Copyright (C) 2017 Lukas Matt <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package coinbase
import (
"fmt"
"time"
)
// AccountId is a unique ID for your wallet
//
// Example:
// 2bbf394c-193b-5b2a-9155-3b4732659ede
type AccountId string
//// API Structs /////////////////
type Error struct {
Id string `json:"id"`
Message string `json:"message"`
}
type APIName struct {
Name string `json:"name"`
}
/*
Example Response:
"pagination": {
"ending_before": null,
"starting_after": null,
"limit": 25,
"order": "desc",
"previous_uri": null,
"next_uri": null
},
*/
type APIPagination struct {
Ending_before string
Starting_after string
Limit int
Order string
Previous_uri string
Next_uri string
}
/*
Example Response:
"balance": {
"amount": "39.59000000",
"currency": "BTC"
},
*/
type APIBalance struct {
Amount float64 `json:",string"`
Currency string
}
/*
Example Response:
"to": {
"id": "a6b4c2df-a62c-5d68-822a-dd4e2102e703",
"resource": "user",
"resource_path": "/v2/users/a6b4c2df-a62c-5d68-822a-dd4e2102e703"
},
*/
type APIResource struct {
Id string
Resource string
Resource_path string
}
/*
Example Response:
{
"id": "67e0eaec-07d7-54c4-a72c-2e92826897df",
"status": "completed",
"payment_method": {
"id": "83562370-3e5c-51db-87da-752af5ab9559",
"resource": "payment_method",
"resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
},
"transaction": {
"id": "441b9494-b3f0-5b98-b9b0-4d82c21c252a",
"resource": "transaction",
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
},
"amount": {
"amount": "1.00000000",
"currency": "BTC"
},
"total": {
"amount": "10.25",
"currency": "USD"
},
"subtotal": {
"amount": "10.10",
"currency": "USD"
},
"created_at": "2015-01-31T20:49:02Z",
"updated_at": "2015-02-11T16:54:02-08:00",
"resource": "buy",
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/buys/67e0eaec-07d7-54c4-a72c-2e92826897df",
"committed": true,
"instant": false,
"fee": {
"amount": "0.15",
"currency": "USD"
},
"payout_at": "2015-02-18T16:54:00-08:00"
}
*/
type APIWalletTransferData struct {
Id string
Status string
Payment_method APIResource
Transaction APIResource
Amount APIBalance
Total APIBalance
Subtotal APIBalance
Created_at *time.Time
Updated_at *time.Time
Resource string
Resource_path string
Committed bool
Instant bool
Fee APIBalance
Payout_at string
}
type APIWalletTransferList struct {
Pagination APIPagination
Data []APIWalletTransferData
Errors []Error
}
type APIWalletTransfer struct {
Data APIWalletTransferData
Errors []Error
}
/*
Example request:
{
"amount": "10",
"currency": "BTC",
"payment_method": "83562370-3e5c-51db-87da-752af5ab9559"
}
*/
type APIWalletTransferOrder struct {
Amount *float64 `json:"amount"`
Total *float64 `json:"total"`
Currency string `json:"currency"`
Payment_method string `json:"payment_method"`
Agree_btc_amount_varies bool `json:"agree_btc_amount_varies"`
Commit bool `json:"commit"`
Quote bool `json:"quote"`
}
//// Configuration Structs //
type ConfigPrice struct{
From string
To string
Date time.Time
}
//// Helper Functions ///////
// pathHelper is a simple wrapper for Sprintf
// and exists only to reduce import expressions
func pathHelper(f string, p... interface{}) string {
return fmt.Sprintf(f, p...)
}