-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfundingevent.go
More file actions
215 lines (189 loc) · 8.1 KB
/
fundingevent.go
File metadata and controls
215 lines (189 loc) · 8.1 KB
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package lithic
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"time"
"github.com/lithic-com/lithic-go/internal/apijson"
"github.com/lithic-com/lithic-go/internal/apiquery"
"github.com/lithic-com/lithic-go/internal/param"
"github.com/lithic-com/lithic-go/internal/requestconfig"
"github.com/lithic-com/lithic-go/option"
"github.com/lithic-com/lithic-go/packages/pagination"
)
// FundingEventService contains methods and other services that help with
// interacting with the lithic 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 [NewFundingEventService] method instead.
type FundingEventService struct {
Options []option.RequestOption
}
// NewFundingEventService 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 NewFundingEventService(opts ...option.RequestOption) (r *FundingEventService) {
r = &FundingEventService{}
r.Options = opts
return
}
// Get funding event for program by id
func (r *FundingEventService) Get(ctx context.Context, fundingEventToken string, opts ...option.RequestOption) (res *FundingEvent, err error) {
opts = slices.Concat(r.Options, opts)
if fundingEventToken == "" {
err = errors.New("missing required funding_event_token parameter")
return
}
path := fmt.Sprintf("v1/funding_events/%s", fundingEventToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Get all funding events for program
func (r *FundingEventService) List(ctx context.Context, query FundingEventListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FundingEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "v1/funding_events"
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
}
// Get all funding events for program
func (r *FundingEventService) ListAutoPaging(ctx context.Context, query FundingEventListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FundingEvent] {
return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
}
// Get funding event details by id
func (r *FundingEventService) GetDetails(ctx context.Context, fundingEventToken string, opts ...option.RequestOption) (res *FundingEventGetDetailsResponse, err error) {
opts = slices.Concat(r.Options, opts)
if fundingEventToken == "" {
err = errors.New("missing required funding_event_token parameter")
return
}
path := fmt.Sprintf("v1/funding_events/%s/details", fundingEventToken)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
type FundingEvent struct {
// Unique token ID
Token string `json:"token" api:"required" format:"uuid"`
// Collection resource type
CollectionResourceType FundingEventCollectionResourceType `json:"collection_resource_type" api:"required"`
// IDs of collections, further information can be gathered from the appropriate
// collection API based on collection_resource_type
CollectionTokens []string `json:"collection_tokens" api:"required" format:"uuid"`
// Time of the creation
Created time.Time `json:"created" api:"required" format:"date-time"`
// Time of the high watermark
HighWatermark time.Time `json:"high_watermark" api:"required" format:"date-time"`
// Network settlement summary breakdown by network settlement date
NetworkSettlementSummary []FundingEventNetworkSettlementSummary `json:"network_settlement_summary" api:"required"`
// Time of the previous high watermark
PreviousHighWatermark time.Time `json:"previous_high_watermark" api:"required" format:"date-time"`
// Time of the update
Updated time.Time `json:"updated" api:"required" format:"date-time"`
JSON fundingEventJSON `json:"-"`
}
// fundingEventJSON contains the JSON metadata for the struct [FundingEvent]
type fundingEventJSON struct {
Token apijson.Field
CollectionResourceType apijson.Field
CollectionTokens apijson.Field
Created apijson.Field
HighWatermark apijson.Field
NetworkSettlementSummary apijson.Field
PreviousHighWatermark apijson.Field
Updated apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FundingEvent) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fundingEventJSON) RawJSON() string {
return r.raw
}
// Collection resource type
type FundingEventCollectionResourceType string
const (
FundingEventCollectionResourceTypeBookTransfer FundingEventCollectionResourceType = "BOOK_TRANSFER"
FundingEventCollectionResourceTypePayment FundingEventCollectionResourceType = "PAYMENT"
)
func (r FundingEventCollectionResourceType) IsKnown() bool {
switch r {
case FundingEventCollectionResourceTypeBookTransfer, FundingEventCollectionResourceTypePayment:
return true
}
return false
}
type FundingEventNetworkSettlementSummary struct {
NetworkSettlementDate time.Time `json:"network_settlement_date" api:"required" format:"date"`
SettledGrossAmount int64 `json:"settled_gross_amount" api:"required"`
JSON fundingEventNetworkSettlementSummaryJSON `json:"-"`
}
// fundingEventNetworkSettlementSummaryJSON contains the JSON metadata for the
// struct [FundingEventNetworkSettlementSummary]
type fundingEventNetworkSettlementSummaryJSON struct {
NetworkSettlementDate apijson.Field
SettledGrossAmount apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FundingEventNetworkSettlementSummary) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fundingEventNetworkSettlementSummaryJSON) RawJSON() string {
return r.raw
}
type FundingEventGetDetailsResponse struct {
// Unique token ID
Token string `json:"token" api:"required" format:"uuid"`
// URL of the settlement details
SettlementDetailsURL string `json:"settlement_details_url" api:"required" format:"uri"`
// URL of the settlement summary
SettlementSummaryURL string `json:"settlement_summary_url" api:"required" format:"uri"`
JSON fundingEventGetDetailsResponseJSON `json:"-"`
}
// fundingEventGetDetailsResponseJSON contains the JSON metadata for the struct
// [FundingEventGetDetailsResponse]
type fundingEventGetDetailsResponseJSON struct {
Token apijson.Field
SettlementDetailsURL apijson.Field
SettlementSummaryURL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FundingEventGetDetailsResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r fundingEventGetDetailsResponseJSON) RawJSON() string {
return r.raw
}
type FundingEventListParams struct {
// A cursor representing an item's token before which a page of results should end.
// Used to retrieve the previous page of results before this item.
EndingBefore param.Field[string] `query:"ending_before" format:"uuid"`
// Page size (for pagination).
PageSize param.Field[int64] `query:"page_size"`
// A cursor representing an item's token after which a page of results should
// begin. Used to retrieve the next page of results after this item.
StartingAfter param.Field[string] `query:"starting_after"`
}
// URLQuery serializes [FundingEventListParams]'s query parameters as `url.Values`.
func (r FundingEventListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}