@riocrypto/common-server 1.0.1641 → 1.0.1644

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.
@@ -0,0 +1,14 @@
1
+ declare class BrexClient {
2
+ private apiKey;
3
+ private baseUrl;
4
+ constructor(apiKey: string);
5
+ getTransfer(brexTransferId: string): Promise<{
6
+ processDate: Date;
7
+ status: "PROCESSED";
8
+ amount: number;
9
+ paymentType: "INTERNATIONAL_WIRE" | "DOMESTIC_WIRE";
10
+ accountNumber: string;
11
+ }>;
12
+ }
13
+ export declare const buildBrexClient: () => Promise<BrexClient>;
14
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.buildBrexClient = void 0;
16
+ const secret_manager_client_1 = require("./secret-manager-client");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ const common_1 = require("@riocrypto/common");
19
+ class BrexClient {
20
+ constructor(apiKey) {
21
+ this.apiKey = apiKey;
22
+ if ([common_1.RioEnv.Development, common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
23
+ this.baseUrl = "https://platform.brexapis.com";
24
+ }
25
+ else {
26
+ throw new common_1.GenericInputError("Brex client cannot be initialized in this environment");
27
+ }
28
+ }
29
+ getTransfer(brexTransferId) {
30
+ var _a;
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { data } = yield axios_1.default.get(`${this.baseUrl}/v1/transfers/${brexTransferId}`, {
33
+ headers: {
34
+ Authorization: `Bearer ${this.apiKey}`,
35
+ },
36
+ });
37
+ return {
38
+ processDate: new Date(data.process_date),
39
+ status: data.status,
40
+ amount: Math.abs(data.amount.amount),
41
+ paymentType: data.payment_type,
42
+ accountNumber: (_a = data.counterparty) === null || _a === void 0 ? void 0 : _a.account_number,
43
+ };
44
+ });
45
+ }
46
+ }
47
+ const buildBrexClient = () => __awaiter(void 0, void 0, void 0, function* () {
48
+ // Retrieve secrets asynchronously
49
+ const BREX_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("BREX_API_KEY");
50
+ if (!BREX_API_KEY) {
51
+ throw new common_1.SecretManagerError();
52
+ }
53
+ // Create GuenoClient instance and return
54
+ return new BrexClient(BREX_API_KEY);
55
+ });
56
+ exports.buildBrexClient = buildBrexClient;
@@ -20,7 +20,7 @@ class CoincoverClient {
20
20
  constructor(apiKey) {
21
21
  this.apiKey = apiKey;
22
22
  if ([common_1.RioEnv.Development, common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
23
- this.baseUrl = "https://api.txm.coincover.com ";
23
+ this.baseUrl = "https://api.txm.coincover.com";
24
24
  }
25
25
  else {
26
26
  this.baseUrl = "https://api.txm-uat.coincover.com";
package/build/index.d.ts CHANGED
@@ -81,6 +81,7 @@ export * from "./clients/polygon-client";
81
81
  export * from "./clients/coincover-client";
82
82
  export * from "./clients/coinbase-client";
83
83
  export * from "./clients/fogbender-client";
84
+ export * from "./clients/brex-client";
84
85
  export * from "./helpers/get-user-helper";
85
86
  export * from "./helpers/get-processor-fees";
86
87
  export * from "./helpers/get-network-fees";
package/build/index.js CHANGED
@@ -97,6 +97,7 @@ __exportStar(require("./clients/polygon-client"), exports);
97
97
  __exportStar(require("./clients/coincover-client"), exports);
98
98
  __exportStar(require("./clients/coinbase-client"), exports);
99
99
  __exportStar(require("./clients/fogbender-client"), exports);
100
+ __exportStar(require("./clients/brex-client"), exports);
100
101
  __exportStar(require("./helpers/get-user-helper"), exports);
101
102
  __exportStar(require("./helpers/get-processor-fees"), exports);
102
103
  __exportStar(require("./helpers/get-network-fees"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1641",
3
+ "version": "1.0.1644",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",