@riocrypto/common-server 1.0.853 → 1.0.855

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,10 +1,10 @@
1
- import { BridgeCustomer } from "@riocrypto/common";
1
+ import { BridgeCustomer, BridgeCustomerInput } from "@riocrypto/common";
2
2
  declare class BridgeClient {
3
3
  private apiKey;
4
4
  private baseUrl;
5
5
  constructor(apiKey: string);
6
6
  getTermsOfServiceUrl(): Promise<string>;
7
- createCustomer(): Promise<BridgeCustomer>;
7
+ createCustomer(userInput: BridgeCustomerInput): Promise<BridgeCustomer>;
8
8
  }
9
9
  export declare const buildBridgeClient: () => Promise<BridgeClient>;
10
10
  export {};
@@ -29,7 +29,7 @@ class BridgeClient {
29
29
  }
30
30
  getTermsOfServiceUrl() {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/tos_links`, {
32
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/tos_links`, undefined, {
33
33
  headers: {
34
34
  "Api-Key": this.apiKey,
35
35
  "Idempotency-Key": (0, uuid_1.v4)(),
@@ -38,9 +38,9 @@ class BridgeClient {
38
38
  return data.url;
39
39
  });
40
40
  }
41
- createCustomer() {
41
+ createCustomer(userInput) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers`, {
43
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers`, userInput, {
44
44
  headers: {
45
45
  "Api-Key": this.apiKey,
46
46
  "Idempotency-Key": (0, uuid_1.v4)(),
@@ -0,0 +1,27 @@
1
+ import { Mongoose, Model, Document } from "mongoose";
2
+ interface BridgeCustomerAttrs {
3
+ bridgeId: string;
4
+ type: "individual" | "business";
5
+ first_name: string;
6
+ last_name: string;
7
+ email: string;
8
+ phone: string;
9
+ requirements_due?: string[];
10
+ future_requirements_due?: string[];
11
+ }
12
+ interface BridgeCustomerModel extends Model<BridgeCustomerDoc> {
13
+ build(attrs: BridgeCustomerAttrs): BridgeCustomerDoc;
14
+ }
15
+ interface BridgeCustomerDoc extends Document {
16
+ _id: string;
17
+ bridgeId: string;
18
+ type: "individual" | "business";
19
+ first_name: string;
20
+ last_name: string;
21
+ email: string;
22
+ phone: string;
23
+ requirements_due?: string[];
24
+ future_requirements_due?: string[];
25
+ }
26
+ declare const buildBridgeCustomer: (mongoose: Mongoose) => BridgeCustomerModel;
27
+ export { buildBridgeCustomer, BridgeCustomerDoc };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBridgeCustomer = void 0;
4
+ const buildBridgeCustomer = (mongoose) => {
5
+ // if model is already defined, return it
6
+ if (mongoose.models.BridgeCustomer) {
7
+ return mongoose.model("BridgeCustomer");
8
+ }
9
+ const bridgeCustomerSchema = new mongoose.Schema({
10
+ bridgeId: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ type: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ first_name: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ last_name: {
23
+ type: String,
24
+ required: true,
25
+ },
26
+ phone: {
27
+ type: String,
28
+ required: true,
29
+ },
30
+ }, {
31
+ toJSON: {
32
+ transform(doc, ret) {
33
+ ret.id = ret._id.valueOf();
34
+ delete ret._id;
35
+ delete ret.__v;
36
+ },
37
+ },
38
+ });
39
+ bridgeCustomerSchema.statics.build = (attrs) => {
40
+ return new BridgeCustomer(attrs);
41
+ };
42
+ const BridgeCustomer = mongoose.model("BridgeCustomer", bridgeCustomerSchema);
43
+ return BridgeCustomer;
44
+ };
45
+ exports.buildBridgeCustomer = buildBridgeCustomer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.853",
3
+ "version": "1.0.855",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
25
  "@everapi/currencyapi-js": "^1.0.6",
26
26
  "@google-cloud/storage": "^6.9.5",
27
- "@riocrypto/common": "^1.0.738",
27
+ "@riocrypto/common": "^1.0.740",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",