-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcredits.ts
214 lines (186 loc) · 7.09 KB
/
credits.ts
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
import * as LedgerAPI from './ledger';
import {
Ledger,
LedgerCreateEntryByExternalIDParams,
LedgerCreateEntryByExternalIDResponse,
LedgerCreateEntryParams,
LedgerCreateEntryResponse,
LedgerListByExternalIDParams,
LedgerListByExternalIDResponse,
LedgerListByExternalIDResponsesPage,
LedgerListParams,
LedgerListResponse,
LedgerListResponsesPage,
} from './ledger';
import * as TopUpsAPI from './top-ups';
import {
TopUpCreateByExternalIDParams,
TopUpCreateByExternalIDResponse,
TopUpCreateParams,
TopUpCreateResponse,
TopUpListByExternalIDParams,
TopUpListByExternalIDResponse,
TopUpListByExternalIDResponsesPage,
TopUpListParams,
TopUpListResponse,
TopUpListResponsesPage,
TopUps,
} from './top-ups';
import { Page, type PageParams } from '../../../pagination';
export class Credits extends APIResource {
ledger: LedgerAPI.Ledger = new LedgerAPI.Ledger(this._client);
topUps: TopUpsAPI.TopUps = new TopUpsAPI.TopUps(this._client);
/**
* Returns a paginated list of unexpired, non-zero credit blocks for a customer.
*
* If `include_all_blocks` is set to `true`, all credit blocks (including expired
* and depleted blocks) will be included in the response.
*
* Note that `currency` defaults to credits if not specified. To use a real world
* currency, set `currency` to an ISO 4217 string.
*/
list(
customerId: string,
query?: CreditListParams,
options?: Core.RequestOptions,
): Core.PagePromise<CreditListResponsesPage, CreditListResponse>;
list(
customerId: string,
options?: Core.RequestOptions,
): Core.PagePromise<CreditListResponsesPage, CreditListResponse>;
list(
customerId: string,
query: CreditListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<CreditListResponsesPage, CreditListResponse> {
if (isRequestOptions(query)) {
return this.list(customerId, {}, query);
}
return this._client.getAPIList(`/customers/${customerId}/credits`, CreditListResponsesPage, {
query,
...options,
});
}
/**
* Returns a paginated list of unexpired, non-zero credit blocks for a customer.
*
* If `include_all_blocks` is set to `true`, all credit blocks (including expired
* and depleted blocks) will be included in the response.
*
* Note that `currency` defaults to credits if not specified. To use a real world
* currency, set `currency` to an ISO 4217 string.
*/
listByExternalId(
externalCustomerId: string,
query?: CreditListByExternalIDParams,
options?: Core.RequestOptions,
): Core.PagePromise<CreditListByExternalIDResponsesPage, CreditListByExternalIDResponse>;
listByExternalId(
externalCustomerId: string,
options?: Core.RequestOptions,
): Core.PagePromise<CreditListByExternalIDResponsesPage, CreditListByExternalIDResponse>;
listByExternalId(
externalCustomerId: string,
query: CreditListByExternalIDParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<CreditListByExternalIDResponsesPage, CreditListByExternalIDResponse> {
if (isRequestOptions(query)) {
return this.listByExternalId(externalCustomerId, {}, query);
}
return this._client.getAPIList(
`/customers/external_customer_id/${externalCustomerId}/credits`,
CreditListByExternalIDResponsesPage,
{ query, ...options },
);
}
}
export class CreditListResponsesPage extends Page<CreditListResponse> {}
export class CreditListByExternalIDResponsesPage extends Page<CreditListByExternalIDResponse> {}
export interface CreditListResponse {
id: string;
balance: number;
effective_date: string | null;
expiry_date: string | null;
maximum_initial_balance: number | null;
per_unit_cost_basis: string | null;
status: 'active' | 'pending_payment';
}
export interface CreditListByExternalIDResponse {
id: string;
balance: number;
effective_date: string | null;
expiry_date: string | null;
maximum_initial_balance: number | null;
per_unit_cost_basis: string | null;
status: 'active' | 'pending_payment';
}
export interface CreditListParams extends PageParams {
/**
* The ledger currency or custom pricing unit to use.
*/
currency?: string | null;
/**
* If set to True, all expired and depleted blocks, as well as active block will be
* returned.
*/
include_all_blocks?: boolean;
}
export interface CreditListByExternalIDParams extends PageParams {
/**
* The ledger currency or custom pricing unit to use.
*/
currency?: string | null;
/**
* If set to True, all expired and depleted blocks, as well as active block will be
* returned.
*/
include_all_blocks?: boolean;
}
Credits.CreditListResponsesPage = CreditListResponsesPage;
Credits.CreditListByExternalIDResponsesPage = CreditListByExternalIDResponsesPage;
Credits.Ledger = Ledger;
Credits.LedgerListResponsesPage = LedgerListResponsesPage;
Credits.LedgerListByExternalIDResponsesPage = LedgerListByExternalIDResponsesPage;
Credits.TopUps = TopUps;
Credits.TopUpListResponsesPage = TopUpListResponsesPage;
Credits.TopUpListByExternalIDResponsesPage = TopUpListByExternalIDResponsesPage;
export declare namespace Credits {
export {
type CreditListResponse as CreditListResponse,
type CreditListByExternalIDResponse as CreditListByExternalIDResponse,
CreditListResponsesPage as CreditListResponsesPage,
CreditListByExternalIDResponsesPage as CreditListByExternalIDResponsesPage,
type CreditListParams as CreditListParams,
type CreditListByExternalIDParams as CreditListByExternalIDParams,
};
export {
Ledger as Ledger,
type LedgerListResponse as LedgerListResponse,
type LedgerCreateEntryResponse as LedgerCreateEntryResponse,
type LedgerCreateEntryByExternalIDResponse as LedgerCreateEntryByExternalIDResponse,
type LedgerListByExternalIDResponse as LedgerListByExternalIDResponse,
LedgerListResponsesPage as LedgerListResponsesPage,
LedgerListByExternalIDResponsesPage as LedgerListByExternalIDResponsesPage,
type LedgerListParams as LedgerListParams,
type LedgerCreateEntryParams as LedgerCreateEntryParams,
type LedgerCreateEntryByExternalIDParams as LedgerCreateEntryByExternalIDParams,
type LedgerListByExternalIDParams as LedgerListByExternalIDParams,
};
export {
TopUps as TopUps,
type TopUpCreateResponse as TopUpCreateResponse,
type TopUpListResponse as TopUpListResponse,
type TopUpCreateByExternalIDResponse as TopUpCreateByExternalIDResponse,
type TopUpListByExternalIDResponse as TopUpListByExternalIDResponse,
TopUpListResponsesPage as TopUpListResponsesPage,
TopUpListByExternalIDResponsesPage as TopUpListByExternalIDResponsesPage,
type TopUpCreateParams as TopUpCreateParams,
type TopUpListParams as TopUpListParams,
type TopUpCreateByExternalIDParams as TopUpCreateByExternalIDParams,
type TopUpListByExternalIDParams as TopUpListByExternalIDParams,
};
}