@riocrypto/common-server 1.0.671 → 1.0.676

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,4 +1,4 @@
1
- import { BusinessUser, KapstarInvoiceResponse, User } from "@riocrypto/common";
1
+ import { KapstarInvoiceResponse, User } from "@riocrypto/common";
2
2
  import { Axios } from "axios";
3
3
  declare class KapstarClient {
4
4
  private userId;
@@ -6,7 +6,7 @@ declare class KapstarClient {
6
6
  axiosInstance: Axios;
7
7
  constructor(userId: string, apiKey: string);
8
8
  getBRLExchangeRateUSD(): Promise<number>;
9
- createInvoice(amount: number, orderId: string, user: User | BusinessUser): Promise<KapstarInvoiceResponse>;
9
+ createInvoice(amount: number, orderId: string, user: User): Promise<KapstarInvoiceResponse>;
10
10
  createPIXPayment(amount: number, pixKey: string): Promise<KapstarInvoiceResponse>;
11
11
  }
12
12
  export declare const buildKapstarClient: () => Promise<KapstarClient>;
@@ -1,12 +1,12 @@
1
- import { BusinessUser, Order, User } from "@riocrypto/common";
1
+ import { Order, User } from "@riocrypto/common";
2
2
  declare class KushkiClient {
3
3
  private privateMerchantId;
4
4
  private environment;
5
5
  private baseUrl;
6
6
  constructor(privateMerchantId: string, environment: "sandbox" | "production");
7
7
  createPaymentLink(order: Order, user: User, token: string): Promise<any>;
8
- createBankPaymentToken(order: Order, user: User | BusinessUser): Promise<any>;
9
- createBankPayment(order: Order, user: User | BusinessUser, token: string): Promise<any>;
8
+ createBankPaymentToken(order: Order, user: User): Promise<any>;
9
+ createBankPayment(order: Order, user: User, token: string): Promise<any>;
10
10
  }
11
11
  export declare const buildKushkiClient: () => Promise<KushkiClient>;
12
12
  export {};
@@ -1,14 +1,12 @@
1
- import { Admin, Auth, AuthUpdate, BankPayout, BusinessUser, BusinessUserInput, BusinessUserUpdate, CheckedAddress, Country, Fiat, Order, OrderInput, Partner, PaymentMethod, PayoutMethod, RioSettings, RioSettingsUpdate, SecurityQuestion, User, UserInput, UserUpdate } from "@riocrypto/common";
1
+ import { Admin, Auth, AuthUpdate, BankPayout, CheckedAddress, Country, Fiat, Order, OrderInput, Partner, PaymentMethod, PayoutMethod, RioSettings, RioSettingsUpdate, SecurityQuestion, User, UserInput, UserUpdate } from "@riocrypto/common";
2
2
  import { AxiosInstance, AxiosStatic } from "axios";
3
3
  export declare class RioClient {
4
4
  private axios;
5
5
  constructor(axios: AxiosStatic | AxiosInstance);
6
6
  getOrders(): Promise<Order[]>;
7
7
  getUsers(): Promise<User[]>;
8
- getBusinessUsers(): Promise<BusinessUser[]>;
9
8
  signin(email: string, password: string): Promise<any>;
10
9
  updateUser(update: UserUpdate, userId?: string): Promise<User>;
11
- updateBusinessUser(update: BusinessUserUpdate, businessUserId?: string): Promise<BusinessUser>;
12
10
  updateAdminUserPassword({ password, newPassword, }: {
13
11
  password: string;
14
12
  newPassword: string;
@@ -22,14 +20,12 @@ export declare class RioClient {
22
20
  updateRioSettings(update: RioSettingsUpdate): Promise<void>;
23
21
  confirmBankPayment(orderId: string): Promise<any>;
24
22
  getUser(): Promise<User>;
25
- getBusinessUser(): Promise<BusinessUser>;
26
23
  createUser(user: UserInput): Promise<void>;
27
- createBusinessUser(businessUser: BusinessUserInput): Promise<BusinessUser>;
28
- createBrokerCustomer(businessUser: BusinessUserInput): Promise<BusinessUser>;
24
+ createBrokerCustomer(userInput: UserInput): Promise<User>;
29
25
  sendPhoneAuthCode(phoneNumber: string): Promise<void>;
30
26
  authExists(phoneNumber: string): Promise<boolean>;
31
- uploadCOI(businessUserId: string, formData: FormData): Promise<BusinessUser>;
32
- uploadKYCReport(businessUserId: string, formData: FormData): Promise<BusinessUser>;
27
+ uploadCOI(businessUserId: string, formData: FormData): Promise<User>;
28
+ uploadKYCReport(businessUserId: string, formData: FormData): Promise<User>;
33
29
  getSecurityQuestion(): Promise<SecurityQuestion>;
34
30
  signout(): Promise<void>;
35
31
  verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
@@ -40,7 +36,6 @@ export declare class RioClient {
40
36
  getBankPayout(orderId: string): Promise<BankPayout>;
41
37
  checkAddress(address: string, crypto: Crypto): Promise<CheckedAddress>;
42
38
  getSupportedPaymentMethods(fiat: Fiat, country: Country): Promise<PaymentMethod[]>;
43
- getBrokerCustomers(): Promise<BusinessUser[]>;
44
39
  getSupportedPayoutMethods(fiat: Fiat, country: Country): Promise<PayoutMethod[]>;
45
40
  getPartnerLayout(partnerId: string): Promise<Partner>;
46
41
  createClipCardPayment(orderId: string): Promise<{
@@ -26,12 +26,6 @@ class RioClient {
26
26
  return data;
27
27
  });
28
28
  }
29
- getBusinessUsers() {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const { data } = yield this.axios.get(`/api/business/users`);
32
- return data;
33
- });
34
- }
35
29
  signin(email, password) {
36
30
  return __awaiter(this, void 0, void 0, function* () {
37
31
  const { data } = yield this.axios.post(`/api/admin/signin`, {
@@ -47,12 +41,6 @@ class RioClient {
47
41
  return data;
48
42
  });
49
43
  }
50
- updateBusinessUser(update, businessUserId) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const { data } = yield this.axios.patch(`/api/business/users/${businessUserId}`, update);
53
- return data;
54
- });
55
- }
56
44
  updateAdminUserPassword({ password, newPassword, }) {
57
45
  return __awaiter(this, void 0, void 0, function* () {
58
46
  const { data } = yield this.axios.patch(`/api/admin`, {
@@ -104,26 +92,14 @@ class RioClient {
104
92
  return data;
105
93
  });
106
94
  }
107
- getBusinessUser() {
108
- return __awaiter(this, void 0, void 0, function* () {
109
- const { data } = yield this.axios.get("/api/business/users/current");
110
- return data;
111
- });
112
- }
113
95
  createUser(user) {
114
96
  return __awaiter(this, void 0, void 0, function* () {
115
97
  yield this.axios.post("/api/users/current-auth", user);
116
98
  });
117
99
  }
118
- createBusinessUser(businessUser) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const response = yield this.axios.post("/api/business/users/current-auth", businessUser);
121
- return response.data;
122
- });
123
- }
124
- createBrokerCustomer(businessUser) {
100
+ createBrokerCustomer(userInput) {
125
101
  return __awaiter(this, void 0, void 0, function* () {
126
- const response = yield this.axios.post("/api/business/users/broker-customers/current-auth", businessUser);
102
+ const response = yield this.axios.post("/api/users/broker-customers/current-auth", userInput);
127
103
  return response.data;
128
104
  });
129
105
  }
@@ -222,12 +198,6 @@ class RioClient {
222
198
  return response.data;
223
199
  });
224
200
  }
225
- getBrokerCustomers() {
226
- return __awaiter(this, void 0, void 0, function* () {
227
- const response = yield this.axios.get(`/api/business/users/broker-customers`);
228
- return response.data;
229
- });
230
- }
231
201
  getSupportedPayoutMethods(fiat, country) {
232
202
  return __awaiter(this, void 0, void 0, function* () {
233
203
  const response = yield this.axios.get(`/api/payout-methods/supported?fiat=${fiat}&country=${country}`);
@@ -1,6 +1,6 @@
1
- import { BusinessUser, Country, Fiat, Processor, User } from "@riocrypto/common";
1
+ import { Country, Fiat, Processor, User } from "@riocrypto/common";
2
2
  import { Mongoose } from "mongoose";
3
- export declare const getPlatformAndPartnerFees: (mongoose: Mongoose, amountFiat: number, fiat: Fiat, processor: Processor, country: Country, partnerId?: string, brokerCustomerId?: string, user?: BusinessUser | User) => Promise<{
3
+ export declare const getPlatformAndPartnerFees: (mongoose: Mongoose, amountFiat: number, fiat: Fiat, processor: Processor, country: Country, partnerId?: string, brokerCustomerId?: string, user?: User) => Promise<{
4
4
  platformFeeFiat: number;
5
5
  platformFeeFiatTax: number;
6
6
  partnerFeeFiat: number;
@@ -15,7 +15,7 @@ const common_1 = require("@riocrypto/common");
15
15
  const kapstar_client_1 = require("../clients/kapstar-client");
16
16
  const currency_api_client_1 = require("../clients/currency-api-client");
17
17
  const partner_1 = require("../models/partner");
18
- const business_user_1 = require("../models/business-user");
18
+ const user_1 = require("../models/user");
19
19
  const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, country, partnerId, brokerCustomerId, user) => __awaiter(void 0, void 0, void 0, function* () {
20
20
  let platformFeeFiat;
21
21
  let platformFeeFiatTax = 0;
@@ -73,10 +73,10 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
73
73
  partnerFeeFiat = 0;
74
74
  }
75
75
  if (brokerCustomerId) {
76
- const BusinessUser = (0, business_user_1.buildBusinessUser)(mongoose);
77
- const brokerCustomer = yield BusinessUser.findById(brokerCustomerId);
76
+ const User = (0, user_1.buildUser)(mongoose);
77
+ const brokerCustomer = yield User.findById(brokerCustomerId);
78
78
  if (!brokerCustomer) {
79
- throw new Error("Business user not found");
79
+ throw new Error("Broker customer not found");
80
80
  }
81
81
  if (brokerCustomer === null || brokerCustomer === void 0 ? void 0 : brokerCustomer.platformFeeRanges) {
82
82
  for (const range of brokerCustomer.platformFeeRanges) {
@@ -1,3 +1,3 @@
1
1
  import { Mongoose } from "mongoose";
2
- import { BusinessUser as BusinessUserType } from "@riocrypto/common";
3
- export declare const getUserHelper: (id: string, mongoose: Mongoose) => Promise<BusinessUserType | null>;
2
+ import { User as UserType } from "@riocrypto/common";
3
+ export declare const getUserHelper: (id: string, mongoose: Mongoose) => Promise<UserType | null>;
@@ -10,26 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getUserHelper = void 0;
13
- const business_user_1 = require("../models/business-user");
14
13
  const user_1 = require("../models/user");
15
14
  const getUserHelper = (id, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
16
- let individualUser;
17
- let businessUser;
15
+ let user;
18
16
  const User = (0, user_1.buildUser)(mongoose);
19
- const BusinessUser = (0, business_user_1.buildBusinessUser)(mongoose);
20
17
  try {
21
- individualUser = yield User.findById(id);
18
+ user = yield User.findById(id);
22
19
  }
23
20
  catch (error) {
24
- individualUser = null;
21
+ user = null;
25
22
  }
26
- try {
27
- businessUser = yield BusinessUser.findById(id);
28
- }
29
- catch (error) {
30
- businessUser = null;
31
- }
32
- const user = individualUser || businessUser;
33
23
  return user;
34
24
  });
35
25
  exports.getUserHelper = getUserHelper;
package/build/index.d.ts CHANGED
@@ -16,7 +16,6 @@ export * from "./services/apiKey";
16
16
  export * from "./services/password";
17
17
  export * from "./models/admin-auth";
18
18
  export * from "./models/auth";
19
- export * from "./models/business-user";
20
19
  export * from "./models/bank-payout";
21
20
  export * from "./models/bank-payment";
22
21
  export * from "./models/order";
package/build/index.js CHANGED
@@ -32,7 +32,6 @@ __exportStar(require("./services/apiKey"), exports);
32
32
  __exportStar(require("./services/password"), exports);
33
33
  __exportStar(require("./models/admin-auth"), exports);
34
34
  __exportStar(require("./models/auth"), exports);
35
- __exportStar(require("./models/business-user"), exports);
36
35
  __exportStar(require("./models/bank-payout"), exports);
37
36
  __exportStar(require("./models/bank-payment"), exports);
38
37
  __exportStar(require("./models/order"), exports);
@@ -1,5 +1,4 @@
1
1
  import { Request, Response, NextFunction } from "express";
2
- import { BusinessUserDoc } from "../models/business-user";
3
2
  import { UserDoc } from "../models/user";
4
3
  import { Mongoose } from "mongoose";
5
4
  import { PartnerDoc } from "../models/partner";
@@ -23,7 +22,7 @@ declare global {
23
22
  currentAuth?: AuthPayload;
24
23
  currentAdminAuth?: AdminAuthPayload;
25
24
  currentPartnerAuth?: PartnerAuthPayload;
26
- user?: UserDoc | BusinessUserDoc;
25
+ user?: UserDoc;
27
26
  partner?: PartnerDoc;
28
27
  validAdminApiKey?: boolean;
29
28
  session?: any;
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.authorize = void 0;
16
- const business_user_1 = require("../models/business-user");
17
16
  const user_1 = require("../models/user");
18
17
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
19
18
  const partner_1 = require("../models/partner");
@@ -123,95 +122,65 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
123
122
  }
124
123
  }
125
124
  if (authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) {
126
- let individualUser;
127
- let businessUser;
125
+ let user;
128
126
  try {
129
127
  const User = yield (0, user_1.buildUser)(mongoose);
130
- individualUser = yield User.findOne({
128
+ user = yield User.findOne({
131
129
  authId: req.currentAuth.id,
132
130
  attributes: { $ne: common_1.UserAttribute.deleted },
133
131
  });
134
132
  }
135
133
  catch (err) {
136
- individualUser = null;
134
+ user = null;
137
135
  }
138
- try {
139
- const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
140
- businessUser = yield BusinessUser.findOne({
141
- authIds: { $in: [req.currentAuth.id] },
142
- attributes: { $ne: common_1.UserAttribute.deleted },
143
- });
144
- }
145
- catch (err) {
146
- businessUser = null;
147
- }
148
- const user = individualUser || businessUser;
149
136
  if (user) {
150
137
  req.user = user;
151
138
  }
152
139
  }
153
140
  if (authorizationTypes.includes(common_1.AuthorizationType.User) ||
154
141
  authorizationTypes.includes(common_1.AuthorizationType.UserOptional)) {
155
- let individualUser;
156
- let businessUser;
142
+ let user;
157
143
  try {
158
144
  const User = yield (0, user_1.buildUser)(mongoose);
159
- individualUser = yield User.findOne({
145
+ user = yield User.findOne({
160
146
  authId: req.currentAuth.id,
161
147
  attributes: { $ne: common_1.UserAttribute.deleted },
162
148
  });
163
- if (!individualUser) {
149
+ if (!user) {
164
150
  throw new Error();
165
151
  }
166
- if ((individualUser === null || individualUser === void 0 ? void 0 : individualUser.kycStatus) !== common_1.KYCStatus.Passed) {
152
+ if ((user === null || user === void 0 ? void 0 : user.kycStatus) !== common_1.KYCStatus.Passed) {
167
153
  missingKYC = true;
168
154
  throw new Error();
169
155
  }
170
156
  }
171
157
  catch (err) {
172
- individualUser = null;
158
+ user = null;
173
159
  }
174
- try {
175
- const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
176
- businessUser = yield BusinessUser.findOne({
177
- authIds: { $in: [req.currentAuth.id] },
178
- });
179
- if (!businessUser) {
180
- throw new Error();
181
- }
182
- if ((businessUser === null || businessUser === void 0 ? void 0 : businessUser.kycStatus) !== common_1.KYCStatus.businessApproved) {
183
- missingKYC = true;
184
- throw new Error();
185
- }
186
- }
187
- catch (err) {
188
- businessUser = null;
189
- }
190
- const user = individualUser || businessUser;
191
160
  if (user) {
192
161
  req.user = user;
193
162
  }
194
163
  }
195
164
  if (authorizationTypes.includes(common_1.AuthorizationType.Broker)) {
196
- let brokerBusinessUser;
165
+ let brokerUser;
197
166
  try {
198
- const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
199
- brokerBusinessUser = yield BusinessUser.findOne({
167
+ const User = yield (0, user_1.buildUser)(mongoose);
168
+ brokerUser = yield User.findOne({
200
169
  authIds: { $in: [req.currentAuth.id] },
201
170
  attributes: { $in: [common_1.UserAttribute.broker] },
202
171
  });
203
- if (!brokerBusinessUser) {
172
+ if (!brokerUser) {
204
173
  throw new Error();
205
174
  }
206
- if ((brokerBusinessUser === null || brokerBusinessUser === void 0 ? void 0 : brokerBusinessUser.kycStatus) !== common_1.KYCStatus.businessApproved) {
175
+ if ((brokerUser === null || brokerUser === void 0 ? void 0 : brokerUser.kycStatus) !== common_1.KYCStatus.businessApproved) {
207
176
  missingKYC = true;
208
177
  throw new Error();
209
178
  }
210
179
  }
211
180
  catch (err) {
212
- brokerBusinessUser = null;
181
+ brokerUser = null;
213
182
  }
214
- const user = brokerBusinessUser;
183
+ const user = brokerUser;
215
184
  if (user) {
216
185
  req.user = user;
217
186
  }
@@ -1,11 +1,10 @@
1
1
  import { Request, Response, NextFunction } from "express";
2
- import { BusinessUserDoc } from "../models/business-user";
3
2
  import { UserDoc } from "../models/user";
4
3
  import { Mongoose } from "mongoose";
5
4
  declare global {
6
5
  namespace Express {
7
6
  interface Request {
8
- user?: UserDoc | BusinessUserDoc;
7
+ user?: UserDoc;
9
8
  }
10
9
  }
11
10
  }
@@ -10,33 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getUser = void 0;
13
- const business_user_1 = require("../models/business-user");
14
13
  const user_1 = require("../models/user");
15
14
  const common_1 = require("@riocrypto/common");
16
15
  const getUser = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
17
- let individualUser;
18
- let businessUser;
16
+ let user;
19
17
  try {
20
18
  const User = yield (0, user_1.buildUser)(mongoose);
21
- individualUser = yield User.findOne({
19
+ user = yield User.findOne({
22
20
  phoneNumber: req.currentAuth.phoneNumber,
23
21
  attributes: { $ne: common_1.UserAttribute.deleted },
24
22
  });
25
23
  }
26
24
  catch (err) {
27
- individualUser = null;
25
+ user = null;
28
26
  }
29
- try {
30
- const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
31
- businessUser = yield BusinessUser.findOne({
32
- phoneNumber: req.currentAuth.phoneNumber,
33
- attributes: { $ne: common_1.UserAttribute.deleted },
34
- });
35
- }
36
- catch (err) {
37
- businessUser = null;
38
- }
39
- const user = individualUser || businessUser;
40
27
  if (user) {
41
28
  req.user = user;
42
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.671",
3
+ "version": "1.0.676",
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.609",
27
+ "@riocrypto/common": "^1.0.617",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",
@@ -1,53 +0,0 @@
1
- import { Country, KYCStatus, Language, PlatformFeeRange, USState, UserAttribute, UserType } from "@riocrypto/common";
2
- import { Mongoose, Model, Document } from "mongoose";
3
- interface BusinessUserAttrs {
4
- authIds?: string[];
5
- type: UserType;
6
- companyName: string;
7
- legalRepresentative: string;
8
- phoneNumber: string;
9
- email: string;
10
- street1: string;
11
- street2?: string;
12
- city: string;
13
- state: USState | string;
14
- postalCode: string;
15
- country: Country;
16
- kycStatus: KYCStatus;
17
- COIFile?: string;
18
- KYCReportFile?: string;
19
- cpf?: string;
20
- language?: Language;
21
- attributes?: UserAttribute[];
22
- brokerId?: string;
23
- platformFeeRanges?: PlatformFeeRange[];
24
- partnerId?: string;
25
- }
26
- interface BusinessUserModel extends Model<BusinessUserDoc> {
27
- build(attrs: BusinessUserAttrs): BusinessUserDoc;
28
- }
29
- interface BusinessUserDoc extends Document {
30
- authIds?: string[];
31
- type: UserType;
32
- companyName: string;
33
- legalRepresentative: string;
34
- phoneNumber: string;
35
- email: string;
36
- street1: string;
37
- street2?: string;
38
- city: string;
39
- state: USState | string;
40
- postalCode: string;
41
- country: Country;
42
- kycStatus: KYCStatus;
43
- COIFile?: string;
44
- KYCReportFile?: string;
45
- cpf?: string;
46
- language?: Language;
47
- attributes?: UserAttribute[];
48
- brokerId?: string;
49
- platformFeeRanges?: PlatformFeeRange[];
50
- partnerId?: string;
51
- }
52
- declare const buildBusinessUser: (mongoose: Mongoose) => BusinessUserModel;
53
- export { buildBusinessUser, BusinessUserDoc };
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildBusinessUser = void 0;
4
- const buildBusinessUser = (mongoose) => {
5
- // if model is already defined, return it
6
- if (mongoose.models.BusinessUser) {
7
- return mongoose.model("BusinessUser");
8
- }
9
- const BusinessUserSchema = new mongoose.Schema({
10
- authIds: [
11
- {
12
- type: String,
13
- },
14
- ],
15
- type: {
16
- type: String,
17
- required: true,
18
- },
19
- companyName: {
20
- type: String,
21
- required: true,
22
- },
23
- legalRepresentative: {
24
- type: String,
25
- required: true,
26
- },
27
- phoneNumber: {
28
- type: String,
29
- required: true,
30
- },
31
- email: {
32
- type: String,
33
- required: true,
34
- },
35
- street1: {
36
- type: String,
37
- required: true,
38
- },
39
- street2: {
40
- type: String,
41
- },
42
- city: {
43
- type: String,
44
- required: true,
45
- },
46
- state: {
47
- type: String,
48
- required: true,
49
- },
50
- postalCode: {
51
- type: String,
52
- required: true,
53
- },
54
- country: {
55
- type: String,
56
- required: true,
57
- },
58
- language: {
59
- type: String,
60
- },
61
- cpf: {
62
- type: String,
63
- },
64
- attributes: [
65
- {
66
- type: String,
67
- },
68
- ],
69
- kycStatus: {
70
- type: String,
71
- required: true,
72
- },
73
- COIFile: {
74
- type: String,
75
- },
76
- KYCReportFile: {
77
- type: String,
78
- },
79
- brokerId: {
80
- type: String,
81
- },
82
- partnerId: {
83
- type: String,
84
- },
85
- platformFeeRanges: [
86
- {
87
- min: {
88
- type: Number,
89
- required: true,
90
- },
91
- max: {
92
- type: Number,
93
- required: true,
94
- },
95
- fee: {
96
- type: Number,
97
- required: true,
98
- },
99
- },
100
- ],
101
- }, {
102
- toJSON: {
103
- transform(doc, ret) {
104
- ret.id = ret._id.valueOf();
105
- delete ret._id;
106
- delete ret.__v;
107
- },
108
- },
109
- });
110
- BusinessUserSchema.statics.build = (attrs) => {
111
- return new BusinessUser(attrs);
112
- };
113
- const BusinessUser = mongoose.model("BusinessUser", BusinessUserSchema);
114
- return BusinessUser;
115
- };
116
- exports.buildBusinessUser = buildBusinessUser;