forked from stripe/stripe-go
/
client.go
51 lines (41 loc) · 1.44 KB
/
client.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
// Package bitcointransaction provides the /bitcoin/transactions APIs.
package bitcointransaction
import (
"net/http"
stripe "github.com/stripe/stripe-go"
"github.com/stripe/stripe-go/form"
)
// Client is used to invoke /bitcoin/receivers/:receiver_id/transactions APIs.
type Client struct {
B stripe.Backend
Key string
}
// List returns a list of bitcoin transactions.
func List(params *stripe.BitcoinTransactionListParams) *Iter {
return getC().List(params)
}
// List returns a list of bitcoin transactions.
func (c Client) List(listParams *stripe.BitcoinTransactionListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s/transactions",
stripe.StringValue(listParams.Receiver))
list := &stripe.BitcoinTransactionList{}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
}
// Iter is an iterator for bitcoin transactions.
type Iter struct {
*stripe.Iter
}
// BitcoinTransaction returns the bitcoin transaction which the iterator is currently pointing to.
func (i *Iter) BitcoinTransaction() *stripe.BitcoinTransaction {
return i.Current().(*stripe.BitcoinTransaction)
}
func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}