@riocrypto/common-server 1.0.1124 → 1.0.1126

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,5 +1,5 @@
1
1
  import { AxiosRequestConfig } from "axios";
2
- import { BankAccount, User } from "@riocrypto/common";
2
+ import { BankAccount, Crypto, User } from "@riocrypto/common";
3
3
  declare class BitsoClient {
4
4
  private apiKey;
5
5
  private apiSecret;
@@ -9,6 +9,20 @@ declare class BitsoClient {
9
9
  createClabe(): Promise<string>;
10
10
  createReceivingAccount(user: User, bankAccount: BankAccount, bitsoBankAccountCode: string): Promise<string>;
11
11
  createWithdraw(bitsoReceivingAccountId: string, amount: number, concept: string, rfc?: string): Promise<string>;
12
+ getOrderBook(crypto: Crypto): Promise<{
13
+ asks: {
14
+ book: string;
15
+ price: string;
16
+ amount: string;
17
+ }[];
18
+ bids: {
19
+ book: string;
20
+ price: string;
21
+ amount: string;
22
+ }[];
23
+ updated_at: string;
24
+ sequence: string;
25
+ }>;
12
26
  signRequest(requestConfig: AxiosRequestConfig): AxiosRequestConfig;
13
27
  }
14
28
  export declare const buildBistoClient: () => Promise<BitsoClient>;
@@ -102,6 +102,23 @@ class BitsoClient {
102
102
  return data.payload;
103
103
  });
104
104
  }
105
+ getOrderBook(crypto) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const requestConfig = {
108
+ method: "GET",
109
+ url: `${this.baseUrl}/api/v3/order_book/?book=${crypto.toLocaleLowerCase()}_mxn`,
110
+ headers: {
111
+ "Content-Type": "application/json",
112
+ },
113
+ };
114
+ const signedRequestConfig = this.signRequest(requestConfig);
115
+ const { data } = yield (0, axios_1.default)(signedRequestConfig);
116
+ if (!data.success) {
117
+ throw new Error("Error getting Bitso order book");
118
+ }
119
+ return data.payload;
120
+ });
121
+ }
105
122
  signRequest(requestConfig) {
106
123
  var _a;
107
124
  const url = new URL(requestConfig.url || "");
@@ -23,6 +23,9 @@ const getProcessorFees = (processor, amountFiat, conversionRateFromUSD) => __awa
23
23
  else if (processor === common_1.Processor.SWIFT) {
24
24
  return 25 * conversionRateFromUSD;
25
25
  }
26
+ else if (processor === common_1.Processor.SPID) {
27
+ return 4 * conversionRateFromUSD;
28
+ }
26
29
  else {
27
30
  return 0;
28
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1124",
3
+ "version": "1.0.1126",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "@aws-sdk/client-s3": "^3.297.0",
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
- "@riocrypto/common": "^1.0.972",
29
+ "@riocrypto/common": "^1.0.974",
30
30
  "@types/express": "^4.17.13",
31
31
  "axios": "^0.27.2",
32
32
  "ccxt": "^3.0.30",