-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.go
47 lines (42 loc) · 1.86 KB
/
interfaces.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
package mono
import (
"context"
"io"
"net/http"
"time"
)
// Unmarshaller allows to specify custom struct for unmarshalling response.
type Unmarshaller interface {
Unmarshal(bts []byte, v interface{}) error
}
// HTTPClient defines which methods the library uses from `http.Client`.
// This also allows to unit-test the library.
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
// Public is the client for accessing public API.
type Public interface {
// Currency get basic list of currency.
// The bank refreshes this list once in a five minutes or less.
Currency(ctx context.Context) ([]CurrencyInfo, error)
}
// Personal is the client for accessing Personal API.
type Personal interface {
// ClientInfo gets info about the client for whom the token belongs.
ClientInfo(ctx context.Context) (*UserInfo, error)
// Statements gets transactions for the specified time period.
// The duration period can be 2682000 max, which is 31 days + 1 hour.
// The bank defines the limitation.
// This value is defined in the constant `MaxAllowedDuration`.
Statements(ctx context.Context, account string, from, to time.Time) ([]StatementItem, error)
// LatestStatements is the shortcut for `Statements`, where the `to` value is the current moment.
LatestStatements(ctx context.Context, account string, from time.Time) ([]StatementItem, error)
// SetWebhook sets the webhook.
SetWebhook(ctx context.Context, webhook string) error
// ParseWebhook is a func that allows to extract the webhook data from the request.
ParseWebhook(ctx context.Context, reader io.ReadCloser) (*WebhookData, error)
// ListenForWebhooks returns channel and handler func.
// The client needs to register the handler func.
// Client will start receiving webhooks on the channel once they arrive to the handler.
ListenForWebhooks(ctx context.Context) (<-chan WebhookData, http.HandlerFunc)
}