-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.go
76 lines (66 loc) · 2.81 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
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
// Package raidenclient creates a generic client to access sub-clients that
// correspond to the various API calls that any Raiden node supports.
package raidenclient
import (
"net/http"
"github.com/cpurta/go-raiden-client/address"
"github.com/cpurta/go-raiden-client/channels"
"github.com/cpurta/go-raiden-client/config"
"github.com/cpurta/go-raiden-client/connections"
"github.com/cpurta/go-raiden-client/payments"
"github.com/cpurta/go-raiden-client/pending_transfers"
"github.com/cpurta/go-raiden-client/tokens"
)
// NewClient will return a Raiden client that is able to access all of the API
// calls that are currently available on a Raiden node. This provides access to
// the various sub-clients that correspond to the various API calls available.
func NewClient(config *config.Config, httpClient *http.Client) *Client {
return &Client{
AddressClient: address.NewClient(config, httpClient),
TokensClient: tokens.NewClient(config, httpClient),
ChannelsClient: channels.NewClient(config, httpClient),
PaymentsClient: payments.NewClient(config, httpClient),
ConnectionsClient: connections.NewClient(config, httpClient),
PendingTransfersClient: pendingtransfers.NewClient(config, httpClient),
}
}
// Client provides access to API sub-clients that correspond to the various API
// calls that a Raiden node supports.
type Client struct {
AddressClient *address.Client
TokensClient *tokens.Client
ChannelsClient *channels.Client
PaymentsClient *payments.Client
ConnectionsClient *connections.Client
PendingTransfersClient *pendingtransfers.Client
}
// Address returns the Address sub-client to access the address being used by the
// Raiden node.
func (client *Client) Address() *address.Client {
return client.AddressClient
}
// Tokens returns the Tokens sub-client that will be able to register, get, and
// list token networks.
func (client *Client) Tokens() *tokens.Client {
return client.TokensClient
}
// Channels returns the Channels sub-client that will be able to open, close and
// increase the deposit of a micro-payment channel.
func (client *Client) Channels() *channels.Client {
return client.ChannelsClient
}
// Payments returns the Payments sub-client that will be able to query all of the
// pending payments.
func (client *Client) Payments() *payments.Client {
return client.PaymentsClient
}
// Connections returns the Connections sub-client that will be able to list, join
// and leave token networks.
func (client *Client) Connections() *connections.Client {
return client.ConnectionsClient
}
// PendingTransfers returns the PendingTransfers sub-client that will be able to
// query all pending transfers by token or a channel.
func (client *Client) PendingTransfers() *pendingtransfers.Client {
return client.PendingTransfersClient
}