@spritz-finance/service-client 0.4.6 → 0.4.8

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.
@@ -1,7 +1,11 @@
1
- export * as BridgeClient from './bridgeServiceClient';
2
- import { ExternalPayment } from '../lib/graphClient/generated';
3
- import { BridgeUser } from '../onramp/types';
4
- import { BridgeExternalAccount, BridgeNetwork, BridgeTransfer, BridgeTransferOffRampPaymentRail, CreateBridgeAccountParams } from './types';
1
+ export * as BridgeClient from "./bridgeServiceClient";
2
+ import { ExternalPayment } from "../lib/graphClient/generated";
3
+ import { BridgeUser } from "../onramp/types";
4
+ import { BridgeExternalAccount, BridgeNetwork, BridgeTransfer, BridgeTransferOffRampPaymentRail, CreateBridgeAccountParams } from "./types";
5
+ export declare function getTransferHashes(externalPaymentIds: string[]): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<{
6
+ externalPaymentId: string;
7
+ hash: string | null;
8
+ }>>;
5
9
  export declare function createBridgeBankAccount(userId: string, accountId: string, input: CreateBridgeAccountParams): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeExternalAccount>>;
6
10
  export declare function getBridgeUser(userId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeUser>>;
7
11
  export declare function validateTransfer({ userId, transferId, amount, toAddress, }: {
@@ -23,10 +23,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getExternalPayments = exports.createBridgeTransfer = exports.validateTransfer = exports.getBridgeUser = exports.createBridgeBankAccount = exports.BridgeClient = void 0;
26
+ exports.getExternalPayments = exports.createBridgeTransfer = exports.validateTransfer = exports.getBridgeUser = exports.createBridgeBankAccount = exports.getTransferHashes = exports.BridgeClient = void 0;
27
27
  exports.BridgeClient = __importStar(require("./bridgeServiceClient"));
28
28
  const serviceClient_1 = require("../serviceClient");
29
- const ONRAMP_ENDPOINT = '/bridge';
29
+ const ONRAMP_ENDPOINT = "/bridge";
30
+ const ONRAMP_ROUTER_ENDPOINT = "/v2/bridge/api";
31
+ async function getTransferHashes(externalPaymentIds) {
32
+ return serviceClient_1.baseClient
33
+ .post(`${ONRAMP_ROUTER_ENDPOINT}/off-ramps/blockchain-transactions`, { externalPaymentIds })
34
+ .then((res) => res.data);
35
+ }
36
+ exports.getTransferHashes = getTransferHashes;
30
37
  async function createBridgeBankAccount(userId, accountId, input) {
31
38
  return serviceClient_1.baseClient
32
39
  .post(`${ONRAMP_ENDPOINT}/user/${userId}/bank-account/${accountId}`, input)
@@ -58,7 +65,7 @@ async function createBridgeTransfer(userId, input) {
58
65
  exports.createBridgeTransfer = createBridgeTransfer;
59
66
  async function getExternalPayments(paymentIds) {
60
67
  return serviceClient_1.baseClient
61
- .get(`${ONRAMP_ENDPOINT}/external-payments?paymentIds=${paymentIds.join(',')}`)
68
+ .get(`${ONRAMP_ENDPOINT}/external-payments?paymentIds=${paymentIds.join(",")}`)
62
69
  .then((res) => res.data);
63
70
  }
64
71
  exports.getExternalPayments = getExternalPayments;
@@ -1,6 +1,6 @@
1
- export * as PaymentsClient from './paymentsClient';
2
- import { DirectPayment, DirectPaymentStatus, PaymentDeliveryMethod, PaymentStatus } from '../lib/graphClient/generated';
3
- import { CreateDirectPaymentArgs, ExternalPaymentInput, GetUserRewardFeeAmountBody, GetUsersTransactionVolumeBody, Payment, PaymentQueryFilter, PaymentSource } from './types';
1
+ export * as PaymentsClient from "./paymentsClient";
2
+ import { DirectPayment, DirectPaymentStatus, PaymentDeliveryMethod } from "../lib/graphClient/generated";
3
+ import { CreateDirectPaymentArgs, ExternalPaymentInput, ExternalPaymentStatusInput, GetUserRewardFeeAmountBody, GetUsersTransactionVolumeBody, Payment, PaymentQueryFilter, PaymentSource } from "./types";
4
4
  export type DirectPaymentModel = {
5
5
  _id?: string;
6
6
  id: string;
@@ -45,7 +45,7 @@ export declare function getRewardTransactionVolume(args: GetUsersTransactionVolu
45
45
  export declare function getRewardFeeAmount(args: GetUserRewardFeeAmountBody): Promise<number>;
46
46
  export declare function initializeExternalPayment(args: ExternalPaymentInput): Promise<Payment>;
47
47
  export declare function scheduleExternalPayment(args: ExternalPaymentInput): Promise<Payment>;
48
- export declare function updateExternalPaymentStatus(paymentId: string, status: PaymentStatus): Promise<Payment>;
48
+ export declare function updateExternalPaymentStatus(paymentId: string, input: ExternalPaymentStatusInput): Promise<Payment>;
49
49
  export declare function getDirectPaymentToken(directPaymentId: string): Promise<string | null>;
50
50
  export declare function getDirectPaymentDetails(directPaymentId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<{
51
51
  tokenAddress: string;
@@ -26,7 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.queryUserPayments = exports.directPaymentsForRiskAnalysis = exports.getUserPaymentById = exports.getAllPaymentsForUser = exports.getDirectPaymentDetails = exports.getDirectPaymentToken = exports.updateExternalPaymentStatus = exports.scheduleExternalPayment = exports.initializeExternalPayment = exports.getRewardFeeAmount = exports.getRewardTransactionVolume = exports.getValidPaymentsForUser = exports.getValidPaymentsForAccount = exports.validateDirectPayment = exports.validatePaymentAmount = exports.createDirectPayment = exports.PaymentsClient = void 0;
27
27
  exports.PaymentsClient = __importStar(require("./paymentsClient"));
28
28
  const serviceClient_1 = require("../serviceClient");
29
- const PAYMENTS_ENDPOINT = '/liabilities';
29
+ const PAYMENTS_ENDPOINT = "/liabilities";
30
+ const PAYMENTS_ROUTER_ENDPOINT = "/v2/liabilities/api";
30
31
  async function createDirectPayment(args) {
31
32
  return serviceClient_1.baseClient
32
33
  .post(`${PAYMENTS_ENDPOINT}/direct-payments`, args)
@@ -74,19 +75,19 @@ async function getRewardFeeAmount(args) {
74
75
  exports.getRewardFeeAmount = getRewardFeeAmount;
75
76
  async function initializeExternalPayment(args) {
76
77
  return serviceClient_1.baseClient
77
- .post(`${PAYMENTS_ENDPOINT}/external-payment/initialize`, args)
78
+ .post(`${PAYMENTS_ROUTER_ENDPOINT}/external-payment/initialize`, args)
78
79
  .then((res) => res.data);
79
80
  }
80
81
  exports.initializeExternalPayment = initializeExternalPayment;
81
82
  async function scheduleExternalPayment(args) {
82
83
  return serviceClient_1.baseClient
83
- .post(`${PAYMENTS_ENDPOINT}/external-payment/schedule`, args)
84
+ .post(`${PAYMENTS_ROUTER_ENDPOINT}/external-payment/schedule`, args)
84
85
  .then((res) => res.data);
85
86
  }
86
87
  exports.scheduleExternalPayment = scheduleExternalPayment;
87
- async function updateExternalPaymentStatus(paymentId, status) {
88
+ async function updateExternalPaymentStatus(paymentId, input) {
88
89
  return serviceClient_1.baseClient
89
- .post(`${PAYMENTS_ENDPOINT}/external-payment/status/${paymentId}`, { status })
90
+ .post(`${PAYMENTS_ROUTER_ENDPOINT}/external-payment/status/${paymentId}`, input)
90
91
  .then((res) => res.data);
91
92
  }
92
93
  exports.updateExternalPaymentStatus = updateExternalPaymentStatus;
@@ -10,6 +10,15 @@ export type GetUserRewardFeeAmountBody = {
10
10
  excludeDaysSinceUserCreated?: number;
11
11
  paymentDateThreshold?: string;
12
12
  };
13
+ export type PaymentAsset = {
14
+ symbol: string;
15
+ quantity: number;
16
+ usdMarketRate: number;
17
+ usdQuotedRate: number;
18
+ usdValue: number;
19
+ usdValueQuoted: number;
20
+ spread: number;
21
+ };
13
22
  export type ExternalPaymentInput = {
14
23
  externalPaymentId: string;
15
24
  userId: string;
@@ -22,6 +31,17 @@ export type ExternalPaymentInput = {
22
31
  targetCurrencyRate: number;
23
32
  targetCurrencyFee: number;
24
33
  targetCurrencyAmount: number;
34
+ network: string;
35
+ partnerFeeUSD?: number;
36
+ paymentAsset?: PaymentAsset;
37
+ };
38
+ export type ExternalPaymentStatusInput = {
39
+ status: PaymentStatus;
40
+ error?: string;
41
+ targetCurrencyRate?: number;
42
+ targetCurrencyFee?: number;
43
+ targetCurrencyAmount?: number;
44
+ outputAsset?: PaymentAsset;
25
45
  };
26
46
  export interface CreateDirectPaymentArgs extends CreateDirectPaymentInput {
27
47
  userId: string;
@@ -1,6 +1,6 @@
1
- export * as RainClient from './rainServiceClient';
2
- import { VirtualCardStatus } from '../payableAccounts/types';
3
- import { ApplicationStatus, CardOrderStatus, CardType, CreateRainApplicationInput, OrderPhysicalCardInput, OrderPhysicalCardResponse, RainCard, RainContract, RainUser, ShippingDetails, WithdrawalSignature } from './types';
1
+ export * as RainClient from "./rainServiceClient";
2
+ import { VirtualCardStatus } from "../payableAccounts/types";
3
+ import { ApplicationStatus, CardDetailsResponse, CardOrderStatus, CardType, CreateRainApplicationInput, OrderPhysicalCardInput, OrderPhysicalCardResponse, RainCard, RainContract, RainUser, ShippingDetails, WithdrawalSignature } from "./types";
4
4
  export declare function createCardApplication(userId: string, input: CreateRainApplicationInput): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<RainUser>>;
5
5
  export declare function getUserDepositAddress({ userId, network, }: {
6
6
  userId: string;
@@ -33,6 +33,10 @@ export declare function getLiveBalance({ userId }: {
33
33
  }): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<{
34
34
  balance: number;
35
35
  }>>;
36
+ export declare function getCardDetails({ userId, cardId }: {
37
+ userId: string;
38
+ cardId: string;
39
+ }): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<CardDetailsResponse>>;
36
40
  export declare function requestWithdrawalSignature({ userId, network, amount, }: {
37
41
  userId: string;
38
42
  network: string;
@@ -23,10 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getCardUser = exports.getPendingCardOrder = exports.orderPhysicalCard = exports.adminGetUserInfo = exports.requestWithdrawalSignature = exports.getLiveBalance = exports.activatePhysicalCard = exports.updateCardStatus = exports.createRainCard = exports.validateContractAddress = exports.getUserDepositAddress = exports.createCardApplication = exports.RainClient = void 0;
26
+ exports.getCardUser = exports.getPendingCardOrder = exports.orderPhysicalCard = exports.adminGetUserInfo = exports.requestWithdrawalSignature = exports.getCardDetails = exports.getLiveBalance = exports.activatePhysicalCard = exports.updateCardStatus = exports.createRainCard = exports.validateContractAddress = exports.getUserDepositAddress = exports.createCardApplication = exports.RainClient = void 0;
27
27
  exports.RainClient = __importStar(require("./rainServiceClient"));
28
28
  const serviceClient_1 = require("../serviceClient");
29
- const RAIN_ENDPOINT = '/rain-v2';
29
+ const RAIN_ENDPOINT = "/rain-v2";
30
30
  async function createCardApplication(userId, input) {
31
31
  return serviceClient_1.baseClient
32
32
  .post(`${RAIN_ENDPOINT}/application?userId=${userId}`, input)
@@ -83,6 +83,14 @@ async function getLiveBalance({ userId }) {
83
83
  .then((res) => res.data);
84
84
  }
85
85
  exports.getLiveBalance = getLiveBalance;
86
+ async function getCardDetails({ userId, cardId }) {
87
+ return serviceClient_1.baseClient
88
+ .post(`${RAIN_ENDPOINT}/api/cards/${cardId}/details`, {
89
+ userId,
90
+ })
91
+ .then((res) => res.data);
92
+ }
93
+ exports.getCardDetails = getCardDetails;
86
94
  async function requestWithdrawalSignature({ userId, network, amount, }) {
87
95
  return serviceClient_1.baseClient
88
96
  .post(`${RAIN_ENDPOINT}/withdrawl-signature`, {
@@ -15,6 +15,12 @@ export type RainUser = {
15
15
  createdAt: string;
16
16
  updatedAt: string;
17
17
  };
18
+ export type CardDetailsResponse = {
19
+ number: string;
20
+ cvv: string;
21
+ expirationMonth: string;
22
+ expirationYear: string;
23
+ };
18
24
  export type RainContract = {
19
25
  id: string;
20
26
  externalId: string;
@@ -38,7 +44,7 @@ export declare const CardStatus: {
38
44
  readonly Locked: "locked";
39
45
  readonly Canceled: "canceled";
40
46
  };
41
- export type CardStatus = typeof CardStatus[keyof typeof CardStatus];
47
+ export type CardStatus = (typeof CardStatus)[keyof typeof CardStatus];
42
48
  export type ShippingDetails = {
43
49
  address: {
44
50
  street: string;
@@ -62,12 +68,12 @@ export declare const ApplicationStatus: {
62
68
  readonly Canceled: "canceled";
63
69
  readonly NotStarted: "notStarted";
64
70
  };
65
- export type ApplicationStatus = typeof ApplicationStatus[keyof typeof ApplicationStatus];
71
+ export type ApplicationStatus = (typeof ApplicationStatus)[keyof typeof ApplicationStatus];
66
72
  export declare const CardType: {
67
73
  readonly Physical: "physical";
68
74
  readonly Virtual: "virtual";
69
75
  };
70
- export type CardType = typeof CardType[keyof typeof CardType];
76
+ export type CardType = (typeof CardType)[keyof typeof CardType];
71
77
  export type RainCard = {
72
78
  id: string;
73
79
  externalId: string;
@@ -83,22 +89,7 @@ export type RainCard = {
83
89
  };
84
90
  export type WithdrawalSignature = {
85
91
  to: string;
86
- args: [
87
- string,
88
- string,
89
- string,
90
- string,
91
- number,
92
- number[],
93
- string,
94
- [
95
- string
96
- ],
97
- [
98
- string
99
- ],
100
- boolean
101
- ];
92
+ args: [string, string, string, string, number, number[], string, [string], [string], boolean];
102
93
  };
103
94
  export interface OrderPhysicalCardInput {
104
95
  userId: string;
package/lib/rain/types.js CHANGED
@@ -2,26 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CardOrderStatus = exports.CardType = exports.ApplicationStatus = exports.CardStatus = void 0;
4
4
  exports.CardStatus = {
5
- NotActivated: 'notActivated',
6
- Active: 'active',
7
- Locked: 'locked',
8
- Canceled: 'canceled',
5
+ NotActivated: "notActivated",
6
+ Active: "active",
7
+ Locked: "locked",
8
+ Canceled: "canceled",
9
9
  };
10
10
  exports.ApplicationStatus = {
11
- Approved: 'approved',
12
- Pending: 'pending',
13
- NeedsInformation: 'needsInformation',
14
- NeedsVerification: 'needsVerification',
15
- ManualReview: 'manualReview',
16
- Denied: 'denied',
17
- Locked: 'locked',
18
- Canceled: 'canceled',
11
+ Approved: "approved",
12
+ Pending: "pending",
13
+ NeedsInformation: "needsInformation",
14
+ NeedsVerification: "needsVerification",
15
+ ManualReview: "manualReview",
16
+ Denied: "denied",
17
+ Locked: "locked",
18
+ Canceled: "canceled",
19
19
  // internal status
20
- NotStarted: 'notStarted',
20
+ NotStarted: "notStarted",
21
21
  };
22
22
  exports.CardType = {
23
- Physical: 'physical',
24
- Virtual: 'virtual',
23
+ Physical: "physical",
24
+ Virtual: "virtual",
25
25
  };
26
26
  var CardOrderStatus;
27
27
  (function (CardOrderStatus) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/service-client",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "gitHead": "06f8e96b7b38c34df26a38da329331940675e4f8",
5
5
  "description": "Service client",
6
6
  "license": "ISC",