@spritz-finance/api-client 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spritz-api-client.d.ts +89 -26
- package/dist/spritz-api-client.js +52 -46
- package/dist/spritz-api-client.mjs +52 -46
- package/package.json +5 -5
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
1
|
import { DocumentNode } from 'graphql';
|
|
3
2
|
|
|
4
3
|
declare enum Environment {
|
|
@@ -978,15 +977,61 @@ interface RenameBankAccount_renamePayableAccount_BankAccount {
|
|
|
978
977
|
institution: RenameBankAccount_renamePayableAccount_BankAccount_institution | null;
|
|
979
978
|
}
|
|
980
979
|
|
|
980
|
+
type Headers = Record<string, string | null | undefined>;
|
|
981
|
+
|
|
981
982
|
interface QueryParams<V = any> {
|
|
982
983
|
query: DocumentNode;
|
|
983
|
-
variables?: V;
|
|
984
|
+
variables?: V | undefined;
|
|
984
985
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
986
|
+
type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
987
|
+
declare class SpritzClient {
|
|
988
|
+
private baseGraphURL;
|
|
989
|
+
private baseRestURL;
|
|
990
|
+
private timeout;
|
|
991
|
+
private apiKey;
|
|
992
|
+
private integrationKey;
|
|
993
|
+
constructor({ environment, timeout, // 5 minutes
|
|
994
|
+
apiKey, integrationKey, }: {
|
|
995
|
+
environment: Environment;
|
|
996
|
+
timeout?: number | undefined;
|
|
997
|
+
integrationKey: string | undefined;
|
|
998
|
+
apiKey: string | undefined;
|
|
999
|
+
});
|
|
989
1000
|
query<Q = any, V = any>({ query, variables }: QueryParams<V>): Promise<Q>;
|
|
1001
|
+
request<Response, Request extends Record<string, any> = Record<string, any>>({ method, path, body, }: {
|
|
1002
|
+
method: HTTPMethod;
|
|
1003
|
+
path: string;
|
|
1004
|
+
body?: Request | undefined;
|
|
1005
|
+
}): Promise<Response>;
|
|
1006
|
+
sendQuery<V = any>({ query: documentNodeQuery, variables: inputVariables, }: QueryParams<V>): Promise<{
|
|
1007
|
+
response: Response;
|
|
1008
|
+
controller: AbortController;
|
|
1009
|
+
headers: {
|
|
1010
|
+
traceId: string | null;
|
|
1011
|
+
requestId: string | null;
|
|
1012
|
+
};
|
|
1013
|
+
}>;
|
|
1014
|
+
sendRequest({ method, path, body, }: {
|
|
1015
|
+
method: HTTPMethod;
|
|
1016
|
+
path: string;
|
|
1017
|
+
body: Record<string, any> | undefined;
|
|
1018
|
+
}): Promise<{
|
|
1019
|
+
response: Response;
|
|
1020
|
+
controller: AbortController;
|
|
1021
|
+
headers: {
|
|
1022
|
+
traceId: string | null;
|
|
1023
|
+
requestId: string | null;
|
|
1024
|
+
};
|
|
1025
|
+
}>;
|
|
1026
|
+
private sendHTTPRequest;
|
|
1027
|
+
private getResponseHeaders;
|
|
1028
|
+
private fetchWithTimeout;
|
|
1029
|
+
private buildGraphRequest;
|
|
1030
|
+
private buildRestRequest;
|
|
1031
|
+
private defaultHeaders;
|
|
1032
|
+
private calculateContentLength;
|
|
1033
|
+
protected authHeaders(): Headers;
|
|
1034
|
+
private makeStatusError;
|
|
990
1035
|
}
|
|
991
1036
|
|
|
992
1037
|
type CreateInputMapping$1 = {
|
|
@@ -1001,7 +1046,7 @@ type CreateMutationMapping$1 = {
|
|
|
1001
1046
|
};
|
|
1002
1047
|
declare class BankAccountService {
|
|
1003
1048
|
private client;
|
|
1004
|
-
constructor(client:
|
|
1049
|
+
constructor(client: SpritzClient);
|
|
1005
1050
|
list(): Promise<UserBankAccounts_bankAccounts[]>;
|
|
1006
1051
|
rename(accountId: string, name: string): Promise<RenameBankAccount_renamePayableAccount_BankAccount>;
|
|
1007
1052
|
delete(accountId: string): Promise<DeletePayableAccount_deletePayableAccount_BankAccount>;
|
|
@@ -1050,7 +1095,7 @@ interface CreateUSBill_addUSBill {
|
|
|
1050
1095
|
|
|
1051
1096
|
declare class BillService {
|
|
1052
1097
|
private client;
|
|
1053
|
-
constructor(client:
|
|
1098
|
+
constructor(client: SpritzClient);
|
|
1054
1099
|
list(): Promise<UserBills_bills[]>;
|
|
1055
1100
|
rename(accountId: string, name: string): Promise<RenameBankAccount_renamePayableAccount_Bill>;
|
|
1056
1101
|
delete(accountId: string): Promise<DeletePayableAccount_deletePayableAccount_Bill>;
|
|
@@ -1059,14 +1104,14 @@ declare class BillService {
|
|
|
1059
1104
|
|
|
1060
1105
|
declare class InstitutionService {
|
|
1061
1106
|
private client;
|
|
1062
|
-
constructor(client:
|
|
1107
|
+
constructor(client: SpritzClient);
|
|
1063
1108
|
popularUSBillInstitutions(type?: BillType): Promise<PopularBillInstitutions_popularUSBillInstitutions[]>;
|
|
1064
1109
|
searchUSBillInstitutions(searchTerm: string, type?: BillType): Promise<SearchUSBillInstitutions_searchUSBillInstitutions[]>;
|
|
1065
1110
|
}
|
|
1066
1111
|
|
|
1067
1112
|
declare class PaymentService {
|
|
1068
1113
|
private client;
|
|
1069
|
-
constructor(client:
|
|
1114
|
+
constructor(client: SpritzClient);
|
|
1070
1115
|
listForAccount(accountId: string): Promise<AccountPayments_paymentsForAccount[]>;
|
|
1071
1116
|
getForPaymentRequest(paymentRequestId: string): Promise<PaymentRequestPayment_paymentForPaymentRequest | null>;
|
|
1072
1117
|
}
|
|
@@ -1103,16 +1148,15 @@ interface CreatePaymentRequestInput {
|
|
|
1103
1148
|
}
|
|
1104
1149
|
|
|
1105
1150
|
type PaymentRequest = CreatePaymentRequest_createDirectPayment;
|
|
1106
|
-
type Web3PaymentParams = GetSpritzPayParams_spritzPayParams;
|
|
1107
1151
|
declare class PaymentRequestService {
|
|
1108
1152
|
private client;
|
|
1109
|
-
constructor(client:
|
|
1153
|
+
constructor(client: SpritzClient);
|
|
1110
1154
|
create(input: CreatePaymentRequestInput): Promise<CreatePaymentRequest_createDirectPayment>;
|
|
1111
1155
|
transactionPrice(paymentAmount: number): Promise<number>;
|
|
1112
1156
|
getWeb3PaymentParams(input: {
|
|
1113
1157
|
paymentRequest: PaymentRequest;
|
|
1114
1158
|
paymentTokenAddress: string;
|
|
1115
|
-
}): Promise<
|
|
1159
|
+
}): Promise<GetSpritzPayParams_spritzPayParams>;
|
|
1116
1160
|
}
|
|
1117
1161
|
|
|
1118
1162
|
interface CreateUserResponse {
|
|
@@ -1120,14 +1164,14 @@ interface CreateUserResponse {
|
|
|
1120
1164
|
email: string;
|
|
1121
1165
|
apiKey: string;
|
|
1122
1166
|
}
|
|
1123
|
-
interface
|
|
1167
|
+
interface CreateUserParams {
|
|
1124
1168
|
email: string;
|
|
1125
1169
|
}
|
|
1126
1170
|
declare class UserService {
|
|
1127
1171
|
private client;
|
|
1128
|
-
constructor(client:
|
|
1129
|
-
createUser(args:
|
|
1130
|
-
create(args:
|
|
1172
|
+
constructor(client: SpritzClient);
|
|
1173
|
+
createUser(args: CreateUserParams): Promise<CreateUserResponse>;
|
|
1174
|
+
create(args: CreateUserParams): Promise<CreateUserResponse>;
|
|
1131
1175
|
getCurrentUser(): Promise<CurrentUser_me>;
|
|
1132
1176
|
getUserVerification(): Promise<UserVerification_verification | null>;
|
|
1133
1177
|
}
|
|
@@ -1179,7 +1223,7 @@ type CreateMutationMapping = {
|
|
|
1179
1223
|
};
|
|
1180
1224
|
declare class VirtualCardService {
|
|
1181
1225
|
private client;
|
|
1182
|
-
constructor(client:
|
|
1226
|
+
constructor(client: SpritzClient);
|
|
1183
1227
|
fetch(): Promise<UserVirtualDebitCard_virtualDebitCard | null>;
|
|
1184
1228
|
create<T extends VirtualCardType>(type: T, input: CreateInputMapping[T]): Promise<NonNullable<CreateMutationMapping[T]["query"][keyof CreateMutationMapping[T]["query"]]> | null>;
|
|
1185
1229
|
}
|
|
@@ -1194,25 +1238,44 @@ type IntegratorWebhook = {
|
|
|
1194
1238
|
url: string;
|
|
1195
1239
|
createdAt: string;
|
|
1196
1240
|
};
|
|
1197
|
-
type
|
|
1241
|
+
type CreateWebhookParams = {
|
|
1198
1242
|
url: string;
|
|
1199
1243
|
events: WebhookEvent[];
|
|
1200
1244
|
};
|
|
1201
1245
|
declare class WebhookService {
|
|
1202
1246
|
private client;
|
|
1203
|
-
constructor(client:
|
|
1204
|
-
create(args:
|
|
1247
|
+
constructor(client: SpritzClient);
|
|
1248
|
+
create(args: CreateWebhookParams): Promise<IntegratorWebhook>;
|
|
1205
1249
|
}
|
|
1206
1250
|
|
|
1207
|
-
type
|
|
1208
|
-
|
|
1251
|
+
type ClientOptions = {
|
|
1252
|
+
/**
|
|
1253
|
+
* Defaults to Environment.Staging.
|
|
1254
|
+
*/
|
|
1255
|
+
environment?: Environment;
|
|
1209
1256
|
apiKey?: string;
|
|
1210
1257
|
integrationKey?: string;
|
|
1258
|
+
/**
|
|
1259
|
+
* The client will wait up to a specified duration (in milliseconds)
|
|
1260
|
+
* for a response from the server before considering a single request as timed out.
|
|
1261
|
+
*
|
|
1262
|
+
* Please be aware that requests are automatically retried by default.
|
|
1263
|
+
* This means that in some situations, the actual wait time could exceed the set timeout
|
|
1264
|
+
* before the process is either completed or terminated.
|
|
1265
|
+
*/
|
|
1266
|
+
timeout?: number;
|
|
1267
|
+
/**
|
|
1268
|
+
* For security reasons, using this library on the client-side is not recommended
|
|
1269
|
+
* because it could potentially reveal your confidential Integrator Key.
|
|
1270
|
+
* Please enable this option to 'true' only if you're fully aware of the risks and
|
|
1271
|
+
* have implemented the necessary protective measures.
|
|
1272
|
+
*/
|
|
1273
|
+
dangerouslyAllowBrowser?: boolean;
|
|
1211
1274
|
};
|
|
1212
1275
|
declare class SpritzApiClient {
|
|
1276
|
+
private environment;
|
|
1213
1277
|
private apiKey;
|
|
1214
1278
|
private integrationKey;
|
|
1215
|
-
private environment;
|
|
1216
1279
|
private client;
|
|
1217
1280
|
user: UserService;
|
|
1218
1281
|
bankAccount: BankAccountService;
|
|
@@ -1222,8 +1285,8 @@ declare class SpritzApiClient {
|
|
|
1222
1285
|
bill: BillService;
|
|
1223
1286
|
institution: InstitutionService;
|
|
1224
1287
|
webhook: WebhookService;
|
|
1225
|
-
constructor(
|
|
1226
|
-
static initialize({ environment, apiKey, integrationKey }:
|
|
1288
|
+
constructor(environment: Environment, apiKey?: string, integrationKey?: string, dangerouslyAllowBrowser?: boolean);
|
|
1289
|
+
static initialize({ environment, apiKey, integrationKey, dangerouslyAllowBrowser, }: ClientOptions): SpritzApiClient;
|
|
1227
1290
|
private init;
|
|
1228
1291
|
setApiKey(_apiKey: string): this;
|
|
1229
1292
|
}
|