-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintrafibalance.go
188 lines (164 loc) · 6.33 KB
/
intrafibalance.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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package increase
import (
"context"
"errors"
"fmt"
"net/http"
"time"
"github.com/Increase/increase-go/internal/apijson"
"github.com/Increase/increase-go/internal/requestconfig"
"github.com/Increase/increase-go/option"
)
// IntrafiBalanceService contains methods and other services that help with
// interacting with the increase API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewIntrafiBalanceService] method instead.
type IntrafiBalanceService struct {
Options []option.RequestOption
}
// NewIntrafiBalanceService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewIntrafiBalanceService(opts ...option.RequestOption) (r *IntrafiBalanceService) {
r = &IntrafiBalanceService{}
r.Options = opts
return
}
// Get IntraFi balances by bank
func (r *IntrafiBalanceService) IntrafiBalance(ctx context.Context, accountID string, opts ...option.RequestOption) (res *IntrafiBalance, err error) {
opts = append(r.Options[:], opts...)
if accountID == "" {
err = errors.New("missing required account_id parameter")
return
}
path := fmt.Sprintf("accounts/%s/intrafi_balance", accountID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// When using IntraFi, each account's balance over the standard FDIC insurance
// amount are swept to various other institutions. Funds are rebalanced across
// banks as needed once per business day.
type IntrafiBalance struct {
// The identifier of this balance.
ID string `json:"id,required"`
// Each entry represents a balance held at a different bank. IntraFi separates the
// total balance across many participating banks in the network.
Balances []IntrafiBalanceBalance `json:"balances,required"`
// The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the account
// currency.
Currency IntrafiBalanceCurrency `json:"currency,required"`
// The date this balance reflects.
EffectiveDate time.Time `json:"effective_date,required" format:"date"`
// The total balance, in minor units of `currency`. Increase reports this balance
// to IntraFi daily.
TotalBalance int64 `json:"total_balance,required"`
// A constant representing the object's type. For this resource it will always be
// `intrafi_balance`.
Type IntrafiBalanceType `json:"type,required"`
JSON intrafiBalanceJSON `json:"-"`
}
// intrafiBalanceJSON contains the JSON metadata for the struct [IntrafiBalance]
type intrafiBalanceJSON struct {
ID apijson.Field
Balances apijson.Field
Currency apijson.Field
EffectiveDate apijson.Field
TotalBalance apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IntrafiBalance) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r intrafiBalanceJSON) RawJSON() string {
return r.raw
}
type IntrafiBalanceBalance struct {
// The identifier of this balance.
ID string `json:"id,required"`
// The balance, in minor units of `currency`, held with this bank.
Balance int64 `json:"balance,required"`
// The name of the bank holding these funds.
Bank string `json:"bank,required"`
// The primary location of the bank.
BankLocation IntrafiBalanceBalancesBankLocation `json:"bank_location,required,nullable"`
// The Federal Deposit Insurance Corporation (FDIC) certificate number of the bank.
// Because many banks have the same or similar names, this can be used to uniquely
// identify the institution.
FdicCertificateNumber string `json:"fdic_certificate_number,required"`
JSON intrafiBalanceBalanceJSON `json:"-"`
}
// intrafiBalanceBalanceJSON contains the JSON metadata for the struct
// [IntrafiBalanceBalance]
type intrafiBalanceBalanceJSON struct {
ID apijson.Field
Balance apijson.Field
Bank apijson.Field
BankLocation apijson.Field
FdicCertificateNumber apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IntrafiBalanceBalance) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r intrafiBalanceBalanceJSON) RawJSON() string {
return r.raw
}
// The primary location of the bank.
type IntrafiBalanceBalancesBankLocation struct {
// The bank's city.
City string `json:"city,required"`
// The bank's state.
State string `json:"state,required"`
JSON intrafiBalanceBalancesBankLocationJSON `json:"-"`
}
// intrafiBalanceBalancesBankLocationJSON contains the JSON metadata for the struct
// [IntrafiBalanceBalancesBankLocation]
type intrafiBalanceBalancesBankLocationJSON struct {
City apijson.Field
State apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IntrafiBalanceBalancesBankLocation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r intrafiBalanceBalancesBankLocationJSON) RawJSON() string {
return r.raw
}
// The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the account
// currency.
type IntrafiBalanceCurrency string
const (
IntrafiBalanceCurrencyCad IntrafiBalanceCurrency = "CAD"
IntrafiBalanceCurrencyChf IntrafiBalanceCurrency = "CHF"
IntrafiBalanceCurrencyEur IntrafiBalanceCurrency = "EUR"
IntrafiBalanceCurrencyGbp IntrafiBalanceCurrency = "GBP"
IntrafiBalanceCurrencyJpy IntrafiBalanceCurrency = "JPY"
IntrafiBalanceCurrencyUsd IntrafiBalanceCurrency = "USD"
)
func (r IntrafiBalanceCurrency) IsKnown() bool {
switch r {
case IntrafiBalanceCurrencyCad, IntrafiBalanceCurrencyChf, IntrafiBalanceCurrencyEur, IntrafiBalanceCurrencyGbp, IntrafiBalanceCurrencyJpy, IntrafiBalanceCurrencyUsd:
return true
}
return false
}
// A constant representing the object's type. For this resource it will always be
// `intrafi_balance`.
type IntrafiBalanceType string
const (
IntrafiBalanceTypeIntrafiBalance IntrafiBalanceType = "intrafi_balance"
)
func (r IntrafiBalanceType) IsKnown() bool {
switch r {
case IntrafiBalanceTypeIntrafiBalance:
return true
}
return false
}