-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintrafiexclusion.go
219 lines (195 loc) · 8.24 KB
/
intrafiexclusion.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package increase
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"time"
"github.com/Increase/increase-go/internal/apijson"
"github.com/Increase/increase-go/internal/apiquery"
"github.com/Increase/increase-go/internal/param"
"github.com/Increase/increase-go/internal/requestconfig"
"github.com/Increase/increase-go/option"
"github.com/Increase/increase-go/packages/pagination"
)
// IntrafiExclusionService 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 [NewIntrafiExclusionService] method instead.
type IntrafiExclusionService struct {
Options []option.RequestOption
}
// NewIntrafiExclusionService 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 NewIntrafiExclusionService(opts ...option.RequestOption) (r *IntrafiExclusionService) {
r = &IntrafiExclusionService{}
r.Options = opts
return
}
// Create an IntraFi Exclusion
func (r *IntrafiExclusionService) New(ctx context.Context, body IntrafiExclusionNewParams, opts ...option.RequestOption) (res *IntrafiExclusion, err error) {
opts = append(r.Options[:], opts...)
path := "intrafi_exclusions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Get an IntraFi Exclusion
func (r *IntrafiExclusionService) Get(ctx context.Context, intrafiExclusionID string, opts ...option.RequestOption) (res *IntrafiExclusion, err error) {
opts = append(r.Options[:], opts...)
if intrafiExclusionID == "" {
err = errors.New("missing required intrafi_exclusion_id parameter")
return
}
path := fmt.Sprintf("intrafi_exclusions/%s", intrafiExclusionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// List IntraFi Exclusions
func (r *IntrafiExclusionService) List(ctx context.Context, query IntrafiExclusionListParams, opts ...option.RequestOption) (res *pagination.Page[IntrafiExclusion], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "intrafi_exclusions"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List IntraFi Exclusions
func (r *IntrafiExclusionService) ListAutoPaging(ctx context.Context, query IntrafiExclusionListParams, opts ...option.RequestOption) *pagination.PageAutoPager[IntrafiExclusion] {
return pagination.NewPageAutoPager(r.List(ctx, query, opts...))
}
// Archive an IntraFi Exclusion
func (r *IntrafiExclusionService) Archive(ctx context.Context, intrafiExclusionID string, opts ...option.RequestOption) (res *IntrafiExclusion, err error) {
opts = append(r.Options[:], opts...)
if intrafiExclusionID == "" {
err = errors.New("missing required intrafi_exclusion_id parameter")
return
}
path := fmt.Sprintf("intrafi_exclusions/%s/archive", intrafiExclusionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return
}
// Certain institutions may be excluded per Entity when sweeping funds into the
// IntraFi network. This is useful when an Entity already has deposits at a
// particular bank, and does not want to sweep additional funds to it. It may take
// 5 business days for an exclusion to be processed.
type IntrafiExclusion struct {
// The identifier of this exclusion request.
ID string `json:"id,required"`
// The name of the excluded institution.
BankName string `json:"bank_name,required"`
// The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which
// the exclusion was created.
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
// The entity for which this institution is excluded.
EntityID string `json:"entity_id,required"`
// When this was exclusion was confirmed by IntraFi.
ExcludedAt time.Time `json:"excluded_at,required,nullable" format:"date-time"`
// The Federal Deposit Insurance Corporation's certificate number for the
// institution.
FdicCertificateNumber string `json:"fdic_certificate_number,required,nullable"`
// The idempotency key you chose for this object. This value is unique across
// Increase and is used to ensure that a request is only processed once. Learn more
// about [idempotency](https://increase.com/documentation/idempotency-keys).
IdempotencyKey string `json:"idempotency_key,required,nullable"`
// The status of the exclusion request.
Status IntrafiExclusionStatus `json:"status,required"`
// When this was exclusion was submitted to IntraFi by Increase.
SubmittedAt time.Time `json:"submitted_at,required,nullable" format:"date-time"`
// A constant representing the object's type. For this resource it will always be
// `intrafi_exclusion`.
Type IntrafiExclusionType `json:"type,required"`
JSON intrafiExclusionJSON `json:"-"`
}
// intrafiExclusionJSON contains the JSON metadata for the struct
// [IntrafiExclusion]
type intrafiExclusionJSON struct {
ID apijson.Field
BankName apijson.Field
CreatedAt apijson.Field
EntityID apijson.Field
ExcludedAt apijson.Field
FdicCertificateNumber apijson.Field
IdempotencyKey apijson.Field
Status apijson.Field
SubmittedAt apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *IntrafiExclusion) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r intrafiExclusionJSON) RawJSON() string {
return r.raw
}
// The status of the exclusion request.
type IntrafiExclusionStatus string
const (
IntrafiExclusionStatusPending IntrafiExclusionStatus = "pending"
IntrafiExclusionStatusCompleted IntrafiExclusionStatus = "completed"
IntrafiExclusionStatusArchived IntrafiExclusionStatus = "archived"
)
func (r IntrafiExclusionStatus) IsKnown() bool {
switch r {
case IntrafiExclusionStatusPending, IntrafiExclusionStatusCompleted, IntrafiExclusionStatusArchived:
return true
}
return false
}
// A constant representing the object's type. For this resource it will always be
// `intrafi_exclusion`.
type IntrafiExclusionType string
const (
IntrafiExclusionTypeIntrafiExclusion IntrafiExclusionType = "intrafi_exclusion"
)
func (r IntrafiExclusionType) IsKnown() bool {
switch r {
case IntrafiExclusionTypeIntrafiExclusion:
return true
}
return false
}
type IntrafiExclusionNewParams struct {
// The name of the financial institution to be excluded.
BankName param.Field[string] `json:"bank_name,required"`
// The identifier of the Entity whose deposits will be excluded.
EntityID param.Field[string] `json:"entity_id,required"`
}
func (r IntrafiExclusionNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type IntrafiExclusionListParams struct {
// Return the page of entries after this one.
Cursor param.Field[string] `query:"cursor"`
// Filter IntraFi Exclusions for those belonging to the specified Entity.
EntityID param.Field[string] `query:"entity_id"`
// Filter records to the one with the specified `idempotency_key` you chose for
// that object. This value is unique across Increase and is used to ensure that a
// request is only processed once. Learn more about
// [idempotency](https://increase.com/documentation/idempotency-keys).
IdempotencyKey param.Field[string] `query:"idempotency_key"`
// Limit the size of the list that is returned. The default (and maximum) is 100
// objects.
Limit param.Field[int64] `query:"limit"`
}
// URLQuery serializes [IntrafiExclusionListParams]'s query parameters as
// `url.Values`.
func (r IntrafiExclusionListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}