@zauru-sdk/services 1.0.49 → 1.0.52
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.
- package/dist/cjs/common.js +235 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/sessions/sessions.js +18 -0
- package/dist/cjs/sessions/upstash.js +59 -0
- package/dist/cjs/zauru/httpGraphQL.js +42 -0
- package/dist/cjs/zauru/httpOauth.js +42 -0
- package/dist/cjs/zauru/httpZauru.js +42 -0
- package/dist/cjs/zauru/zauru-agencies.js +27 -0
- package/dist/cjs/zauru/zauru-automatic-numbers.js +28 -0
- package/dist/cjs/zauru/zauru-bookings.js +90 -0
- package/dist/cjs/zauru/zauru-bundles.js +104 -0
- package/dist/cjs/zauru/zauru-cases.js +30 -0
- package/dist/cjs/zauru/zauru-consolidated.js +81 -0
- package/dist/cjs/zauru/zauru-currencies.js +27 -0
- package/dist/cjs/zauru/zauru-deliveries.js +53 -0
- package/dist/cjs/zauru/zauru-discharges.js +55 -0
- package/dist/cjs/zauru/zauru-employees.js +30 -0
- package/dist/cjs/zauru/zauru-forms.js +363 -0
- package/dist/cjs/zauru/zauru-invoices.js +104 -0
- package/dist/cjs/zauru/zauru-items.js +293 -0
- package/dist/cjs/zauru/zauru-lote-record.js +33 -0
- package/dist/cjs/zauru/zauru-lotes.js +312 -0
- package/dist/cjs/zauru/zauru-motivos-rechazo.js +57 -0
- package/dist/cjs/zauru/zauru-payees.js +247 -0
- package/dist/cjs/zauru/zauru-payment-terms.js +75 -0
- package/dist/cjs/zauru/zauru-price-lists.js +49 -0
- package/dist/cjs/zauru/zauru-profiles.js +80 -0
- package/dist/cjs/zauru/zauru-purchase-orders.js +438 -0
- package/dist/cjs/zauru/zauru-receptions.js +104 -0
- package/dist/cjs/zauru/zauru-shipments.js +62 -0
- package/dist/cjs/zauru/zauru-suggested-prices.js +94 -0
- package/dist/cjs/zauru/zauru-tags.js +20 -0
- package/dist/cjs/zauru/zauru-templates.js +22 -0
- package/dist/cjs/zauru/zauru-variables.js +56 -0
- package/dist/cjs/zauru/zauru-web-app-tables.js +167 -0
- package/package.json +12 -9
- package/CHANGELOG.md +0 -232
- package/src/common.ts +0 -343
- package/src/index.ts +0 -37
- package/src/sessions/sessions.ts +0 -17
- package/src/sessions/upstash.ts +0 -55
- package/src/zauru/httpGraphQL.ts +0 -55
- package/src/zauru/httpOauth.ts +0 -55
- package/src/zauru/httpZauru.ts +0 -56
- package/src/zauru/zauru-agencies.ts +0 -32
- package/src/zauru/zauru-automatic-numbers.ts +0 -35
- package/src/zauru/zauru-bookings.ts +0 -134
- package/src/zauru/zauru-bundles.ts +0 -157
- package/src/zauru/zauru-cases.ts +0 -44
- package/src/zauru/zauru-consolidated.ts +0 -129
- package/src/zauru/zauru-currencies.ts +0 -39
- package/src/zauru/zauru-deliveries.ts +0 -70
- package/src/zauru/zauru-discharges.ts +0 -90
- package/src/zauru/zauru-employees.ts +0 -43
- package/src/zauru/zauru-forms.ts +0 -618
- package/src/zauru/zauru-invoices.ts +0 -142
- package/src/zauru/zauru-items.ts +0 -481
- package/src/zauru/zauru-lote-record.ts +0 -77
- package/src/zauru/zauru-lotes.ts +0 -484
- package/src/zauru/zauru-motivos-rechazo.ts +0 -121
- package/src/zauru/zauru-payees.ts +0 -402
- package/src/zauru/zauru-payment-terms.ts +0 -126
- package/src/zauru/zauru-price-lists.ts +0 -68
- package/src/zauru/zauru-profiles.ts +0 -106
- package/src/zauru/zauru-purchase-orders.ts +0 -701
- package/src/zauru/zauru-receptions.ts +0 -148
- package/src/zauru/zauru-shipments.ts +0 -88
- package/src/zauru/zauru-suggested-prices.ts +0 -137
- package/src/zauru/zauru-tags.ts +0 -22
- package/src/zauru/zauru-templates.ts +0 -24
- package/src/zauru/zauru-variables.ts +0 -67
- package/src/zauru/zauru-web-app-tables.ts +0 -256
- package/tsconfig.json +0 -24
- /package/dist/{common.js → esm/common.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{sessions → esm/sessions}/sessions.js +0 -0
- /package/dist/{sessions → esm/sessions}/upstash.js +0 -0
- /package/dist/{zauru → esm/zauru}/httpGraphQL.js +0 -0
- /package/dist/{zauru → esm/zauru}/httpOauth.js +0 -0
- /package/dist/{zauru → esm/zauru}/httpZauru.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-agencies.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-automatic-numbers.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-bookings.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-bundles.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-cases.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-consolidated.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-currencies.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-deliveries.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-discharges.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-employees.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-forms.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-invoices.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-items.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-lote-record.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-lotes.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-motivos-rechazo.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-payees.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-payment-terms.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-price-lists.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-profiles.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-purchase-orders.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-receptions.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-shipments.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-suggested-prices.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-tags.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-templates.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-variables.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-web-app-tables.js +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deletePayeeCategory = exports.updatePayeeCategory = exports.createPayeeCategory = exports.updatePayee = exports.deletePayee = exports.createPayee = exports.getClientCategories = exports.getProviderCategories = exports.getPayeeCategories = exports.getPayeeCategoriesByNotesMatch = exports.getPayeesByCategoryId = exports.getPayee = exports.getProviders = exports.getPayees = void 0;
|
|
7
|
+
const common_1 = require("@zauru-sdk/common");
|
|
8
|
+
const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
|
|
9
|
+
const common_js_1 = require("../common.js");
|
|
10
|
+
const graphql_1 = require("@zauru-sdk/graphql");
|
|
11
|
+
const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
|
|
12
|
+
/**
|
|
13
|
+
* getPayees
|
|
14
|
+
* @param headers
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
async function getPayees(session) {
|
|
18
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
19
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
20
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
21
|
+
query: graphql_1.getPayeesStringQuery,
|
|
22
|
+
}, {
|
|
23
|
+
headers,
|
|
24
|
+
});
|
|
25
|
+
return response.data?.data.payees;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.getPayees = getPayees;
|
|
29
|
+
/**
|
|
30
|
+
* getProviders
|
|
31
|
+
* @param headers
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
async function getProviders(session) {
|
|
35
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
36
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
37
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
38
|
+
query: graphql_1.getProvidersStringQuery,
|
|
39
|
+
}, {
|
|
40
|
+
headers,
|
|
41
|
+
});
|
|
42
|
+
return response.data?.data.payees;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.getProviders = getProviders;
|
|
46
|
+
/**
|
|
47
|
+
* getPayee
|
|
48
|
+
* @param session
|
|
49
|
+
* @param id
|
|
50
|
+
*/
|
|
51
|
+
async function getPayee(session, id) {
|
|
52
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
53
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
54
|
+
const responsePayee = await httpGraphQL_js_1.default.post("", {
|
|
55
|
+
query: graphql_1.getPayeeByIdStringQuery,
|
|
56
|
+
variables: {
|
|
57
|
+
id,
|
|
58
|
+
},
|
|
59
|
+
}, { headers });
|
|
60
|
+
if (!responsePayee?.data?.data?.payees[0]) {
|
|
61
|
+
throw new Error("No se encontró el beneficiario indicado");
|
|
62
|
+
}
|
|
63
|
+
return responsePayee?.data?.data?.payees[0];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.getPayee = getPayee;
|
|
67
|
+
/**
|
|
68
|
+
* getPayeesByCategoryId
|
|
69
|
+
* @param session
|
|
70
|
+
* @param categoryId
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
async function getPayeesByCategoryId(session, id) {
|
|
74
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
75
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
76
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
77
|
+
query: graphql_1.getPayeeCategoryByIdStringQuery,
|
|
78
|
+
variables: { id },
|
|
79
|
+
}, { headers });
|
|
80
|
+
if (response.data.errors) {
|
|
81
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
82
|
+
}
|
|
83
|
+
if (!response?.data?.data?.payee_categories[0]) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
return response.data?.data?.payee_categories[0]?.payees;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.getPayeesByCategoryId = getPayeesByCategoryId;
|
|
90
|
+
/**
|
|
91
|
+
* getPayeeCategoriesByNotesMatch
|
|
92
|
+
* @param session
|
|
93
|
+
* @param match
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
async function getPayeeCategoriesByNotesMatch(session, match) {
|
|
97
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
98
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
99
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
100
|
+
query: (0, graphql_1.getPayeeCategoriesByNotesMatchStringQuery)(match),
|
|
101
|
+
}, { headers });
|
|
102
|
+
if (response.data.errors) {
|
|
103
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
104
|
+
}
|
|
105
|
+
return response.data?.data?.payee_categories;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.getPayeeCategoriesByNotesMatch = getPayeeCategoriesByNotesMatch;
|
|
109
|
+
/**
|
|
110
|
+
* getPayeeCategories
|
|
111
|
+
* @param session
|
|
112
|
+
* @param match
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
async function getPayeeCategories(session) {
|
|
116
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
117
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
118
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
119
|
+
query: graphql_1.getPayeeCategoriesStringQuery,
|
|
120
|
+
}, { headers });
|
|
121
|
+
if (response.data.errors) {
|
|
122
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
123
|
+
}
|
|
124
|
+
return response.data?.data?.payee_categories;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
exports.getPayeeCategories = getPayeeCategories;
|
|
128
|
+
/**
|
|
129
|
+
* getProviderCategories
|
|
130
|
+
* @param session
|
|
131
|
+
* @param match
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
async function getProviderCategories(session) {
|
|
135
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
136
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
137
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
138
|
+
query: graphql_1.getProviderCategoriesStringQuery,
|
|
139
|
+
}, { headers });
|
|
140
|
+
if (response.data.errors) {
|
|
141
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
142
|
+
}
|
|
143
|
+
return response.data?.data?.payee_categories;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
exports.getProviderCategories = getProviderCategories;
|
|
147
|
+
/**
|
|
148
|
+
* getProviderCategories
|
|
149
|
+
* @param session
|
|
150
|
+
* @param match
|
|
151
|
+
* @returns
|
|
152
|
+
*/
|
|
153
|
+
async function getClientCategories(session) {
|
|
154
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
155
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
156
|
+
const response = await httpGraphQL_js_1.default.post(``, {
|
|
157
|
+
query: graphql_1.getClientCategoriesStringQuery,
|
|
158
|
+
}, { headers });
|
|
159
|
+
if (response.data.errors) {
|
|
160
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
161
|
+
}
|
|
162
|
+
return response.data?.data?.payee_categories;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
exports.getClientCategories = getClientCategories;
|
|
166
|
+
/**
|
|
167
|
+
* createPayee
|
|
168
|
+
* @param session
|
|
169
|
+
* @param headers
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
async function createPayee(headers, body) {
|
|
173
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
174
|
+
await httpZauru_js_1.default.post("/settings/payees", { payee: body }, { headers });
|
|
175
|
+
return true;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.createPayee = createPayee;
|
|
179
|
+
/**
|
|
180
|
+
* deletePayee
|
|
181
|
+
* @param headers
|
|
182
|
+
* @param id
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
async function deletePayee(headers, id) {
|
|
186
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
187
|
+
await httpZauru_js_1.default.delete(`/settings/payees/${id}?destroy=true`, {
|
|
188
|
+
headers,
|
|
189
|
+
});
|
|
190
|
+
return true;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
exports.deletePayee = deletePayee;
|
|
194
|
+
/**
|
|
195
|
+
* updatePayee
|
|
196
|
+
* @param session
|
|
197
|
+
* @param headers
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
async function updatePayee(headers, body) {
|
|
201
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
202
|
+
await httpZauru_js_1.default.patch(`/settings/payees/${body.id}`, { payee: body }, { headers });
|
|
203
|
+
return true;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
exports.updatePayee = updatePayee;
|
|
207
|
+
/**
|
|
208
|
+
* createPayeeCategory
|
|
209
|
+
* @param session
|
|
210
|
+
* @param headers
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
async function createPayeeCategory(headers, body) {
|
|
214
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
215
|
+
const response = await httpZauru_js_1.default.post("/settings/payees/payee_categories", { payee_category: body }, { headers });
|
|
216
|
+
return response.data;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
exports.createPayeeCategory = createPayeeCategory;
|
|
220
|
+
/**
|
|
221
|
+
* updatePayeeCategory
|
|
222
|
+
* @param session
|
|
223
|
+
* @param headers
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
async function updatePayeeCategory(headers, body) {
|
|
227
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
228
|
+
await httpZauru_js_1.default.patch(`/settings/payees/payee_categories/${body.id}`, { payee_category: body }, { headers });
|
|
229
|
+
return true;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
exports.updatePayeeCategory = updatePayeeCategory;
|
|
233
|
+
/**
|
|
234
|
+
* deletePayeeCategory
|
|
235
|
+
* @param headers
|
|
236
|
+
* @param id
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
239
|
+
async function deletePayeeCategory(headers, id) {
|
|
240
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
241
|
+
await httpZauru_js_1.default.delete(`/settings/payees/payee_categories/${id}?destroy=true`, {
|
|
242
|
+
headers,
|
|
243
|
+
});
|
|
244
|
+
return true;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
exports.deletePayeeCategory = deletePayeeCategory;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updatePaymentTerm = exports.createPaymentTerm = exports.getPaymentTermById = exports.getPaymentTerms = void 0;
|
|
7
|
+
const common_1 = require("@zauru-sdk/common");
|
|
8
|
+
const common_js_1 = require("../common.js");
|
|
9
|
+
const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
|
|
10
|
+
const graphql_1 = require("@zauru-sdk/graphql");
|
|
11
|
+
const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
|
|
12
|
+
/**
|
|
13
|
+
* getPaymentTerms
|
|
14
|
+
*/
|
|
15
|
+
async function getPaymentTerms(session) {
|
|
16
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
17
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
18
|
+
const response = await httpGraphQL_js_1.default.post("", {
|
|
19
|
+
query: graphql_1.getPaymentTermsStringQuery,
|
|
20
|
+
}, { headers });
|
|
21
|
+
if (response.data.errors) {
|
|
22
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
23
|
+
}
|
|
24
|
+
const registers = response?.data?.data?.payment_terms;
|
|
25
|
+
return registers;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.getPaymentTerms = getPaymentTerms;
|
|
29
|
+
/**
|
|
30
|
+
* getPaymentTermById
|
|
31
|
+
*/
|
|
32
|
+
async function getPaymentTermById(session, id) {
|
|
33
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
34
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
35
|
+
const response = await httpGraphQL_js_1.default.post("", {
|
|
36
|
+
query: graphql_1.getPaymentTermByIdStringQuery,
|
|
37
|
+
variables: { id },
|
|
38
|
+
}, { headers });
|
|
39
|
+
if (response.data.errors) {
|
|
40
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
41
|
+
}
|
|
42
|
+
if (!response?.data?.data?.payment_terms[0]) {
|
|
43
|
+
throw new Error("No se encontró ningún método de pago con este id: " + id);
|
|
44
|
+
}
|
|
45
|
+
const registers = response?.data?.data?.payment_terms[0] ?? [];
|
|
46
|
+
return registers;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.getPaymentTermById = getPaymentTermById;
|
|
50
|
+
/**
|
|
51
|
+
* createPaymentTerm
|
|
52
|
+
* @param headers
|
|
53
|
+
*/
|
|
54
|
+
async function createPaymentTerm(headers, payment_term) {
|
|
55
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
56
|
+
const response = await httpZauru_js_1.default.patch(`/sales/settings/payment_terms.json`, {
|
|
57
|
+
payment_term,
|
|
58
|
+
}, { headers });
|
|
59
|
+
return response.data;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.createPaymentTerm = createPaymentTerm;
|
|
63
|
+
/**
|
|
64
|
+
* updatePaymentTerm
|
|
65
|
+
* @param headers
|
|
66
|
+
*/
|
|
67
|
+
async function updatePaymentTerm(headers, payment_term) {
|
|
68
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
69
|
+
const response = await httpZauru_js_1.default.patch(`/sales/settings/payment_terms/${payment_term.id}.json`, {
|
|
70
|
+
payment_term,
|
|
71
|
+
}, { headers });
|
|
72
|
+
return response.data;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.updatePaymentTerm = updatePaymentTerm;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updatePriceList = exports.deletePriceList = exports.createPriceList = void 0;
|
|
7
|
+
const common_1 = require("@zauru-sdk/common");
|
|
8
|
+
const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
|
|
9
|
+
/**
|
|
10
|
+
* createPriceList
|
|
11
|
+
* @param session
|
|
12
|
+
* @param headers
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
async function createPriceList(headers, body) {
|
|
16
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
17
|
+
const response = await httpZauru_js_1.default.post("/sales/settings/price_lists", { price_list: body }, { headers });
|
|
18
|
+
return response.data;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.createPriceList = createPriceList;
|
|
22
|
+
/**
|
|
23
|
+
* deletePriceList
|
|
24
|
+
* @param headers
|
|
25
|
+
* @param id
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
async function deletePriceList(headers, id) {
|
|
29
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
30
|
+
await httpZauru_js_1.default.delete(`/sales/settings/price_lists/${id}?destroy=true`, {
|
|
31
|
+
headers,
|
|
32
|
+
});
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.deletePriceList = deletePriceList;
|
|
37
|
+
/**
|
|
38
|
+
* updatePriceList
|
|
39
|
+
* @param session
|
|
40
|
+
* @param headers
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
async function updatePriceList(headers, body) {
|
|
44
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
45
|
+
await httpZauru_js_1.default.patch(`/sales/settings/price_lists/${body.id}`, { price_list: body }, { headers });
|
|
46
|
+
return true;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.updatePriceList = updatePriceList;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAgencyInfo = exports.changeEntity = exports.getProfileInformation = exports.getEmployeeInfo = exports.getOauthUserInfo = void 0;
|
|
7
|
+
const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
|
|
8
|
+
const httpOauth_js_1 = __importDefault(require("./httpOauth.js"));
|
|
9
|
+
const common_1 = require("@zauru-sdk/common");
|
|
10
|
+
const config_1 = require("@zauru-sdk/config");
|
|
11
|
+
/**
|
|
12
|
+
* getOauthUserInfo
|
|
13
|
+
* @param codeValue
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
const getOauthUserInfo = async (codeValue) => {
|
|
17
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
18
|
+
const response = await httpOauth_js_1.default.get(`/api/userinfo`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${codeValue}`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
return response.data;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.getOauthUserInfo = getOauthUserInfo;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param employeeId
|
|
30
|
+
* @param headers
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
const getEmployeeInfo = async (id, headers) => {
|
|
34
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
35
|
+
const employeeInfo = await httpZauru_js_1.default.get(`/settings/employees/${id}.json`, { headers });
|
|
36
|
+
return employeeInfo.data;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.getEmployeeInfo = getEmployeeInfo;
|
|
40
|
+
/**
|
|
41
|
+
* getProfileInformation
|
|
42
|
+
* @param headers
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
const getProfileInformation = async (headers) => {
|
|
46
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
47
|
+
const response = await httpZauru_js_1.default.get(`/profile.json`, {
|
|
48
|
+
headers,
|
|
49
|
+
});
|
|
50
|
+
return response.data;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.getProfileInformation = getProfileInformation;
|
|
54
|
+
const changeEntity = async (headers, entityId) => {
|
|
55
|
+
const changeEntityFetch = await httpZauru_js_1.default.patch(`${config_1.config.zauruBaseURL}/company.json`, JSON.stringify({
|
|
56
|
+
selected_entity_id: entityId,
|
|
57
|
+
}), {
|
|
58
|
+
headers,
|
|
59
|
+
});
|
|
60
|
+
return changeEntityFetch.data;
|
|
61
|
+
};
|
|
62
|
+
exports.changeEntity = changeEntity;
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param headers
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
const getAgencyInfo = async (headers, session) => {
|
|
69
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
70
|
+
const agency_id = session.get("agency_id");
|
|
71
|
+
if (!agency_id) {
|
|
72
|
+
throw new Error("No hay una agencia asignada para este usuario... Contacte con su administrador.");
|
|
73
|
+
}
|
|
74
|
+
const response = await httpZauru_js_1.default.get(`/settings/agencies/${agency_id}.json`, {
|
|
75
|
+
headers,
|
|
76
|
+
});
|
|
77
|
+
return response?.data;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.getAgencyInfo = getAgencyInfo;
|