@hapl/api-queries 0.1.125 → 0.1.126

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,32 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Bill } from '../../../types';
3
+ declare type SuccessData = {
4
+ success: true;
5
+ data: Bill;
6
+ };
7
+ declare type ErrorData = {
8
+ success: false;
9
+ data: {
10
+ error: string;
11
+ };
12
+ };
13
+ declare type ResultData = SuccessData['data'];
14
+ declare type ResultError = ErrorData['data']['error'];
15
+ export declare type CreateBillHeaders = {
16
+ 'x-auth-hc': string;
17
+ };
18
+ export declare type CreateBillBody = {
19
+ payer: Required<Bill>['payer'];
20
+ services: Required<Bill>['services'];
21
+ dealId?: Required<Bill>['dealId'];
22
+ contractId?: Required<Bill>['contractId'];
23
+ };
24
+ export declare type CreateBillData = AxiosResponse<ResultData>;
25
+ export declare type CreateBillError = AxiosError<ResultError>;
26
+ export declare type CreateBillConfig = {
27
+ baseURL?: string;
28
+ headers: CreateBillHeaders;
29
+ body: CreateBillBody;
30
+ };
31
+ export declare function createBillRequest({ baseURL, body, headers }: CreateBillConfig): Promise<CreateBillData>;
32
+ export {};
@@ -0,0 +1,43 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Bill } from '../../../types';
3
+ declare type ResultData = {
4
+ ids: string[];
5
+ byId: Record<string, Bill & {
6
+ _id: string;
7
+ }>;
8
+ meta: {
9
+ total: number;
10
+ };
11
+ };
12
+ declare type ResultError = string;
13
+ export declare type FindBillsHeaders = {
14
+ 'x-auth-hc': string;
15
+ };
16
+ export declare type FindBillsParams = {
17
+ filter?: {
18
+ commonId?: string;
19
+ 'createdBy.id'?: string;
20
+ 'deal.contract.formalId'?: string;
21
+ 'deal.contract.id'?: string;
22
+ 'deal.contract.serviceRequest.id'?: string;
23
+ 'deal.id'?: string;
24
+ number?: string;
25
+ };
26
+ limits?: {
27
+ page?: number;
28
+ count: number | 'all';
29
+ };
30
+ sorting?: {
31
+ direction: 'asc' | 'desc';
32
+ type: 'id' | 'number' | 'createdAt' | 'deal.id' | 'deal.contract.id' | 'deal.contract.formalId' | 'deal.contract.serviceRequest.id' | 'createdById' | 'deal.lawyer.name';
33
+ };
34
+ };
35
+ export declare type FindBillsData = AxiosResponse<ResultData>;
36
+ export declare type FindBillsError = AxiosError<ResultError>;
37
+ export declare type FindBillsConfig = {
38
+ baseURL?: string;
39
+ headers: FindBillsHeaders;
40
+ params: FindBillsParams;
41
+ };
42
+ export declare function findBillsRequest({ baseURL, headers, params }: FindBillsConfig): Promise<FindBillsData>;
43
+ export {};
@@ -0,0 +1,35 @@
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
+ import { Contract } from '../../../types';
3
+ declare type ResultData = {
4
+ ids: number[];
5
+ byId: Record<string, Contract>;
6
+ meta: {
7
+ total: number;
8
+ };
9
+ };
10
+ declare type ResultError = string;
11
+ export declare type FindContractsHeaders = {
12
+ 'x-auth-hc': string;
13
+ };
14
+ export declare type FindContractsParams = {
15
+ filter?: {
16
+ id?: number | number[];
17
+ };
18
+ limits?: {
19
+ page?: number;
20
+ count: number | 'all';
21
+ };
22
+ sorting?: {
23
+ direction: 'asc' | 'desc';
24
+ type: 'id';
25
+ };
26
+ };
27
+ export declare type FindContractsData = AxiosResponse<ResultData>;
28
+ export declare type FindContractsError = AxiosError<ResultError>;
29
+ export declare type FindContractsConfig = {
30
+ baseURL?: string;
31
+ headers: FindContractsHeaders;
32
+ params: FindContractsParams;
33
+ };
34
+ export declare function findContractsRequest({ baseURL, headers, params }: FindContractsConfig): Promise<FindContractsData>;
35
+ export {};
@@ -5,6 +5,8 @@ export * from './availableFunds/createAvailableFunds';
5
5
  export * from './availableFunds/findAvailableFunds';
6
6
  export * from './availableFunds/updateAvailableFunds';
7
7
  export * from './availableFunds/deleteAvailableFunds';
8
+ export * from './bill/createBill';
9
+ export * from './bill/findBills';
8
10
  export * from './buyer/countBuyers';
9
11
  export * from './buyer/findBuyers';
10
12
  export * from './call/findCalls';
@@ -16,6 +18,7 @@ export * from './callCenter/startOperatorWork';
16
18
  export * from './callTask/createCallTask';
17
19
  export * from './contract/approveContract';
18
20
  export * from './contract/declineContract';
21
+ export * from './contract/findContracts';
19
22
  export * from './contract/terminateContract';
20
23
  export * from './deal/createDealCategorizedFile';
21
24
  export * from './deal/createDealInvestPrepayment';
@@ -0,0 +1,11 @@
1
+ import { BillServiceType, BillServiceUnit } from '../types';
2
+ export declare const BillDictionary: {
3
+ ServiceType: {
4
+ part_payment: string;
5
+ full_payment: string;
6
+ buy_service_payment: string;
7
+ };
8
+ ServiceUnit: {
9
+ piece: string;
10
+ };
11
+ };
@@ -1,5 +1,6 @@
1
1
  export * from './AddressBTIParams';
2
2
  export * from './AvailableFunds';
3
+ export * from './Bill';
3
4
  export * from './Buyer';
4
5
  export * from './Call';
5
6
  export * from './CallTask';
@@ -9,6 +9,8 @@ export declare class Api {
9
9
  findAvailableFunds: (params: api.FindAvailableFundsParams, headers: api.FindAvailableFundsHeaders) => Promise<api.FindAvailableFundsData>;
10
10
  updateAvailableFunds: (urlParams: api.UpdateAvailableFundsUrlParams, body: api.UpdateAvailableFundsBody, headers: api.UpdateAvailableFundsHeaders) => Promise<api.UpdateAvailableFundsData>;
11
11
  deleteAvailableFunds: (urlParams: api.DeleteAvailableFundsUrlParams, headers: api.DeleteAvailableFundsHeaders) => Promise<api.DeleteAvailableFundsData>;
12
+ createBill: (body: api.CreateBillBody, headers: api.CreateBillHeaders) => Promise<api.CreateBillData>;
13
+ findBills: (params: api.FindBillsParams, headers: api.FindBillsHeaders) => Promise<api.FindBillsData>;
12
14
  countBuyers: (params: api.CountBuyersParams, headers: api.CountBuyersHeaders) => Promise<api.CountBuyersData>;
13
15
  findBuyers: (params: api.FindBuyersParams, headers: api.FindBuyersHeaders) => Promise<api.FindBuyersData>;
14
16
  findCalls: (params: api.FindCallsParams, headers: api.FindCallsHeaders) => Promise<api.FindCallsData>;
@@ -20,6 +22,7 @@ export declare class Api {
20
22
  createCallTask: (body: api.CreateCallTaskBody, headers: api.CreateCallTaskHeaders) => Promise<api.CreateCallTaskData>;
21
23
  approveContract: (urlParams: api.ApproveContractUrlParams, body: api.ApproveContractBody, headers: api.ApproveContractHeaders) => Promise<api.ApproveContractData>;
22
24
  declineContract: (urlParams: api.DeclineContractUrlParams, body: api.DeclineContractBody, headers: api.DeclineContractHeaders) => Promise<api.DeclineContractData>;
25
+ findContracts: (params: api.FindContractsParams, headers: api.FindContractsHeaders) => Promise<api.FindContractsData>;
23
26
  terminateContract: (urlParams: api.TerminateContractUrlParams, body: api.TerminateContractBody, headers: api.TerminateContractHeaders) => Promise<api.TerminateContractData>;
24
27
  createDealCategorizedFile: (urlParams: api.CreateDealCategorizedFileUrlParams, body: api.CreateDealCategorizedFileBody, headers: api.CreateDealCategorizedFileHeaders) => Promise<api.CreateDealCategorizedFileData>;
25
28
  createDealInvestPrepayment: (urlParams: api.CreateDealInvestPrepaymentUrlParams, body: api.CreateDealInvestPrepaymentBody, headers: api.CreateDealInvestPrepaymentHeaders) => Promise<api.CreateDealInvestPrepaymentData>;
@@ -0,0 +1,34 @@
1
+ export declare enum BillServiceType {
2
+ PartPayment = "part_payment",
3
+ FullPayment = "full_payment",
4
+ BuyServicePayment = "buy_service_payment"
5
+ }
6
+ export declare enum BillServiceUnit {
7
+ Piece = "piece"
8
+ }
9
+ export declare type Bill = {
10
+ contractId: number;
11
+ createdAt: string;
12
+ createdById: number;
13
+ number: string;
14
+ payer: string;
15
+ qrString: string;
16
+ requisites: {
17
+ bankName: string;
18
+ bic: string;
19
+ companyAddress: string;
20
+ companyName: string;
21
+ correspondingAccount: string;
22
+ inn: string;
23
+ kpp: string;
24
+ personalAccount: string;
25
+ };
26
+ services: Array<{
27
+ count: number;
28
+ price: number;
29
+ tax: number;
30
+ type: BillServiceType;
31
+ unit: BillServiceUnit;
32
+ }>;
33
+ dealId?: number;
34
+ };
@@ -2,6 +2,7 @@ export * from './Address';
2
2
  export * from './AddressBTIParams';
3
3
  export * from './AddressMetroDistance';
4
4
  export * from './AvailableFunds';
5
+ export * from './Bill';
5
6
  export * from './Buyer';
6
7
  export * from './Call';
7
8
  export * from './CallTask';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.125",
2
+ "version": "0.1.126",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -0,0 +1,40 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { Bill } from '../../../types';
3
+
4
+ type SuccessData = { success: true; data: Bill };
5
+ type ErrorData = { success: false; data: { error: string } };
6
+
7
+ type ResultData = SuccessData['data'];
8
+ type ResultError = ErrorData['data']['error'];
9
+
10
+ export type CreateBillHeaders = { 'x-auth-hc': string };
11
+ export type CreateBillBody = {
12
+ payer: Required<Bill>['payer'];
13
+ services: Required<Bill>['services'];
14
+ dealId?: Required<Bill>['dealId'];
15
+ contractId?: Required<Bill>['contractId'];
16
+ };
17
+
18
+ export type CreateBillData = AxiosResponse<ResultData>;
19
+ export type CreateBillError = AxiosError<ResultError>;
20
+ export type CreateBillConfig = {
21
+ baseURL?: string;
22
+ headers: CreateBillHeaders;
23
+ body: CreateBillBody;
24
+ };
25
+
26
+ export function createBillRequest({ baseURL = 'https://clients.homeapp.ru', body, headers }: CreateBillConfig) {
27
+ return axios
28
+ .post('/api/bill', body, {
29
+ baseURL,
30
+ headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...headers },
31
+ transformResponse: [
32
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
33
+ (data: SuccessData | ErrorData): ResultData | ResultError => (data.success ? data.data : data.data.error),
34
+ ],
35
+ })
36
+ .then((res: CreateBillData) => res)
37
+ .catch((err: CreateBillError) => {
38
+ throw err;
39
+ });
40
+ }
@@ -0,0 +1,75 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import { nanoid } from 'nanoid';
3
+ import qs from 'qs';
4
+ import { Bill } from '../../../types';
5
+
6
+ type SuccessData = { success: true; data: Bill[]; pageParams: { page: number; length: number } };
7
+ type ErrorData = { success: false; data: Record<'error' | 'message', string> };
8
+
9
+ type ResultData = { ids: string[]; byId: Record<string, Bill & { _id: string }>; meta: { total: number } };
10
+ type ResultError = string;
11
+
12
+ export type FindBillsHeaders = { 'x-auth-hc': string };
13
+ export type FindBillsParams = {
14
+ filter?: {
15
+ commonId?: string;
16
+ 'createdBy.id'?: string;
17
+ 'deal.contract.formalId'?: string;
18
+ 'deal.contract.id'?: string;
19
+ 'deal.contract.serviceRequest.id'?: string;
20
+ 'deal.id'?: string;
21
+ number?: string;
22
+ };
23
+ limits?: { page?: number; count: number | 'all' };
24
+ sorting?: {
25
+ direction: 'asc' | 'desc';
26
+ type:
27
+ | 'id'
28
+ | 'number'
29
+ | 'createdAt'
30
+ | 'deal.id'
31
+ | 'deal.contract.id'
32
+ | 'deal.contract.formalId'
33
+ | 'deal.contract.serviceRequest.id'
34
+ | 'createdById'
35
+ | 'deal.lawyer.name';
36
+ };
37
+ };
38
+ export type FindBillsData = AxiosResponse<ResultData>;
39
+ export type FindBillsError = AxiosError<ResultError>;
40
+ export type FindBillsConfig = {
41
+ baseURL?: string;
42
+ headers: FindBillsHeaders;
43
+ params: FindBillsParams;
44
+ };
45
+
46
+ export function findBillsRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindBillsConfig) {
47
+ return axios
48
+ .get('/api/bill/list', {
49
+ baseURL,
50
+ params,
51
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
52
+ headers: { Accept: 'application/json', ...headers },
53
+ transformResponse: [
54
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
55
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
56
+ if (!data.success) return data.data.error || data.data.message;
57
+
58
+ const ids: ResultData['ids'] = [];
59
+ const byId: ResultData['byId'] = {};
60
+
61
+ data.data.forEach(entity => {
62
+ const _id = nanoid();
63
+ byId[_id] = { ...entity, _id };
64
+ ids.push(_id);
65
+ });
66
+
67
+ return { ids, byId, meta: { total: data.pageParams.length } };
68
+ },
69
+ ],
70
+ })
71
+ .then((res: FindBillsData) => res)
72
+ .catch((err: FindBillsError) => {
73
+ throw err;
74
+ });
75
+ }
@@ -0,0 +1,53 @@
1
+ import axios, { AxiosResponse, AxiosError, AxiosTransformer } from 'axios';
2
+ import qs from 'qs';
3
+ import { Contract } from '../../../types';
4
+
5
+ type SuccessData = { success: true; data: Contract[]; pageParams: { page: number; length: number } };
6
+ type ErrorData = { success: false; data: Record<'error' | 'message', string> };
7
+
8
+ type ResultData = { ids: number[]; byId: Record<string, Contract>; meta: { total: number } };
9
+ type ResultError = string;
10
+
11
+ export type FindContractsHeaders = { 'x-auth-hc': string };
12
+ export type FindContractsParams = {
13
+ filter?: { id?: number | number[] };
14
+ limits?: { page?: number; count: number | 'all' };
15
+ sorting?: { direction: 'asc' | 'desc'; type: 'id' };
16
+ };
17
+ export type FindContractsData = AxiosResponse<ResultData>;
18
+ export type FindContractsError = AxiosError<ResultError>;
19
+ export type FindContractsConfig = {
20
+ baseURL?: string;
21
+ headers: FindContractsHeaders;
22
+ params: FindContractsParams;
23
+ };
24
+
25
+ export function findContractsRequest({ baseURL = 'https://clients.homeapp.ru', headers, params }: FindContractsConfig) {
26
+ return axios
27
+ .get('/api/contract', {
28
+ baseURL,
29
+ params,
30
+ paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
31
+ headers: { Accept: 'application/json', ...headers },
32
+ transformResponse: [
33
+ ...(axios.defaults.transformResponse as AxiosTransformer[]),
34
+ (data: SuccessData | ErrorData): ResultData | ResultError => {
35
+ if (!data.success) return data.data.error || data.data.message;
36
+
37
+ const ids: ResultData['ids'] = [];
38
+ const byId: ResultData['byId'] = {};
39
+
40
+ data.data.forEach(entity => {
41
+ byId[entity.id] = entity;
42
+ ids.push(entity.id);
43
+ });
44
+
45
+ return { ids, byId, meta: { total: data.pageParams.length } };
46
+ },
47
+ ],
48
+ })
49
+ .then((res: FindContractsData) => res)
50
+ .catch((err: FindContractsError) => {
51
+ throw err;
52
+ });
53
+ }
@@ -7,6 +7,9 @@ export * from './availableFunds/findAvailableFunds';
7
7
  export * from './availableFunds/updateAvailableFunds';
8
8
  export * from './availableFunds/deleteAvailableFunds';
9
9
 
10
+ export * from './bill/createBill';
11
+ export * from './bill/findBills';
12
+
10
13
  export * from './buyer/countBuyers';
11
14
  export * from './buyer/findBuyers';
12
15
 
@@ -22,6 +25,7 @@ export * from './callTask/createCallTask';
22
25
 
23
26
  export * from './contract/approveContract';
24
27
  export * from './contract/declineContract';
28
+ export * from './contract/findContracts';
25
29
  export * from './contract/terminateContract';
26
30
 
27
31
  export * from './deal/createDealCategorizedFile';
@@ -0,0 +1,12 @@
1
+ import { BillServiceType, BillServiceUnit } from '../types';
2
+
3
+ export const BillDictionary = {
4
+ ServiceType: {
5
+ [BillServiceType.PartPayment]: 'Частичная оплата обеспечительного платежа',
6
+ [BillServiceType.FullPayment]: 'Окончательный расчет',
7
+ [BillServiceType.BuyServicePayment]: 'Оплата оказания услуг',
8
+ },
9
+ ServiceUnit: {
10
+ [BillServiceUnit.Piece]: 'шт',
11
+ },
12
+ };
@@ -1,5 +1,6 @@
1
1
  export * from './AddressBTIParams';
2
2
  export * from './AvailableFunds';
3
+ export * from './Bill';
3
4
  export * from './Buyer';
4
5
  export * from './Call';
5
6
  export * from './CallTask';
@@ -39,6 +39,16 @@ export class Api {
39
39
  return api.deleteAvailableFundsRequest({ urlParams, headers, baseURL: this.baseURL });
40
40
  };
41
41
 
42
+ // bill
43
+
44
+ createBill = (body: api.CreateBillBody, headers: api.CreateBillHeaders) => {
45
+ return api.createBillRequest({ body, headers, baseURL: this.baseURL });
46
+ };
47
+
48
+ findBills = (params: api.FindBillsParams, headers: api.FindBillsHeaders) => {
49
+ return api.findBillsRequest({ params, headers, baseURL: this.baseURL });
50
+ };
51
+
42
52
  // buyer
43
53
 
44
54
  countBuyers = (params: api.CountBuyersParams, headers: api.CountBuyersHeaders) => {
@@ -104,6 +114,10 @@ export class Api {
104
114
  return api.declineContractRequest({ urlParams, body, headers, baseURL: this.baseURL });
105
115
  };
106
116
 
117
+ findContracts = (params: api.FindContractsParams, headers: api.FindContractsHeaders) => {
118
+ return api.findContractsRequest({ params, headers, baseURL: this.baseURL });
119
+ };
120
+
107
121
  terminateContract = (
108
122
  urlParams: api.TerminateContractUrlParams,
109
123
  body: api.TerminateContractBody,
@@ -0,0 +1,37 @@
1
+ export enum BillServiceType {
2
+ PartPayment = 'part_payment',
3
+ FullPayment = 'full_payment',
4
+ BuyServicePayment = 'buy_service_payment',
5
+ }
6
+
7
+ export enum BillServiceUnit {
8
+ Piece = 'piece',
9
+ }
10
+
11
+ export type Bill = {
12
+ contractId: number;
13
+ createdAt: string;
14
+ createdById: number;
15
+ number: string;
16
+ payer: string;
17
+ qrString: string;
18
+ requisites: {
19
+ bankName: string;
20
+ bic: string;
21
+ companyAddress: string;
22
+ companyName: string;
23
+ correspondingAccount: string;
24
+ inn: string;
25
+ kpp: string;
26
+ personalAccount: string;
27
+ };
28
+ services: Array<{
29
+ count: number;
30
+ price: number;
31
+ tax: number;
32
+ type: BillServiceType;
33
+ unit: BillServiceUnit;
34
+ }>;
35
+
36
+ dealId?: number;
37
+ };
@@ -2,6 +2,7 @@ export * from './Address';
2
2
  export * from './AddressBTIParams';
3
3
  export * from './AddressMetroDistance';
4
4
  export * from './AvailableFunds';
5
+ export * from './Bill';
5
6
  export * from './Buyer';
6
7
  export * from './Call';
7
8
  export * from './CallTask';