ozon-api 0.0.6 → 0.0.8

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,7 +1,9 @@
1
+ import { Category } from "../../types/Category";
1
2
  declare class CategoryClass {
2
3
  private readonly apiKeyInfo;
3
4
  constructor(apiId: string, apiKey: string);
4
5
  attribute(description_category_id: number, type_id: number, language?: Global.ApiLanguage): Promise<Category.Attribute[]>;
5
6
  attributeValue(description_category_id: number, type_id: number, attribute_id: number, language?: Global.ApiLanguage): Promise<Category.AttributeValue[]>;
7
+ attributeValueSearch(description_category_id: number, type_id: number, attribute_id: number, value: string): Promise<Category.AttributeValue[]>;
6
8
  }
7
9
  export default CategoryClass;
@@ -185,6 +185,93 @@ var CategoryClass = /*#__PURE__*/function () {
185
185
  }
186
186
  return attributeValue;
187
187
  }()
188
+ }, {
189
+ key: "attributeValueSearch",
190
+ value: function () {
191
+ var _attributeValueSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(description_category_id, type_id, attribute_id, value) {
192
+ var _this3 = this;
193
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
194
+ while (1) switch (_context6.prev = _context6.next) {
195
+ case 0:
196
+ if (description_category_id) {
197
+ _context6.next = 2;
198
+ break;
199
+ }
200
+ return _context6.abrupt("return", Promise.reject(new Error('请输入 descriptionCategoryId')));
201
+ case 2:
202
+ if (type_id) {
203
+ _context6.next = 4;
204
+ break;
205
+ }
206
+ return _context6.abrupt("return", Promise.reject(new Error('请输入 typeId')));
207
+ case 4:
208
+ if (attribute_id) {
209
+ _context6.next = 6;
210
+ break;
211
+ }
212
+ return _context6.abrupt("return", Promise.reject(new Error('请输入 attribute_id')));
213
+ case 6:
214
+ if (!((value === null || value === void 0 ? void 0 : value.length) < 2)) {
215
+ _context6.next = 8;
216
+ break;
217
+ }
218
+ return _context6.abrupt("return", Promise.reject(new Error('搜索内容至少 2 个字符')));
219
+ case 8:
220
+ return _context6.abrupt("return", new Promise( /*#__PURE__*/function () {
221
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(resolve, reject) {
222
+ var attributeResult;
223
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
224
+ while (1) switch (_context5.prev = _context5.next) {
225
+ case 0:
226
+ _context5.next = 2;
227
+ return CategoryController.attributeValueSearch({
228
+ description_category_id: description_category_id,
229
+ type_id: type_id,
230
+ attribute_id: attribute_id,
231
+ limit: 100,
232
+ value: value
233
+ }, {
234
+ apiKey: _this3.apiKeyInfo.apiKey,
235
+ apiId: _this3.apiKeyInfo.apiId
236
+ }).catch(function (err) {
237
+ reject(err);
238
+ });
239
+ case 2:
240
+ attributeResult = _context5.sent;
241
+ if (attributeResult) {
242
+ _context5.next = 5;
243
+ break;
244
+ }
245
+ return _context5.abrupt("return");
246
+ case 5:
247
+ if (attributeResult.result) {
248
+ _context5.next = 7;
249
+ break;
250
+ }
251
+ return _context5.abrupt("return", reject(new Error(attributeResult === null || attributeResult === void 0 ? void 0 : attributeResult.message)));
252
+ case 7:
253
+ return _context5.abrupt("return", resolve(attributeResult.result));
254
+ case 8:
255
+ case "end":
256
+ return _context5.stop();
257
+ }
258
+ }, _callee5);
259
+ }));
260
+ return function (_x14, _x15) {
261
+ return _ref3.apply(this, arguments);
262
+ };
263
+ }()));
264
+ case 9:
265
+ case "end":
266
+ return _context6.stop();
267
+ }
268
+ }, _callee6);
269
+ }));
270
+ function attributeValueSearch(_x10, _x11, _x12, _x13) {
271
+ return _attributeValueSearch.apply(this, arguments);
272
+ }
273
+ return attributeValueSearch;
274
+ }()
188
275
  }]);
189
276
  return CategoryClass;
190
277
  }();
@@ -1,5 +1,6 @@
1
+ import { Product } from "../../types/Product";
1
2
  declare class ProductClass {
2
- private apiKeyInfo;
3
+ private readonly apiKeyInfo;
3
4
  constructor(apiId: string, apiKey: string);
4
5
  importBySku(query: Product.ImportBySkuQuery): Promise<Product.ImportBySkuResult>;
5
6
  checkImportInfo(taskId: number): Promise<Product.CheckImportInfoResult>;
@@ -1,2 +1,4 @@
1
+ import { Category } from "../../types/Category";
1
2
  export declare function attribute(body: Category.AttributeQuery, options?: Global.RequestOptions): Promise<Category.AttributeApi>;
2
3
  export declare function attributeValue(body: Category.AttributeValueQuery, options?: Global.RequestOptions): Promise<Category.AttributeValueApi>;
4
+ export declare function attributeValueSearch(body: Category.AttributeValueSearchQuery, options?: Global.RequestOptions): Promise<Category.AttributeValueSearchApi>;
@@ -53,4 +53,27 @@ function _attributeValue() {
53
53
  }, _callee2);
54
54
  }));
55
55
  return _attributeValue.apply(this, arguments);
56
+ }
57
+ export function attributeValueSearch(_x5, _x6) {
58
+ return _attributeValueSearch.apply(this, arguments);
59
+ }
60
+ function _attributeValueSearch() {
61
+ _attributeValueSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(body, options) {
62
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
63
+ while (1) switch (_context3.prev = _context3.next) {
64
+ case 0:
65
+ return _context3.abrupt("return", request("/v1/description-category/attribute/values/search", _objectSpread({
66
+ method: 'POST',
67
+ headers: {
68
+ 'Content-Type': 'application/json'
69
+ },
70
+ data: _objectSpread({}, body)
71
+ }, options || {})));
72
+ case 1:
73
+ case "end":
74
+ return _context3.stop();
75
+ }
76
+ }, _callee3);
77
+ }));
78
+ return _attributeValueSearch.apply(this, arguments);
56
79
  }
@@ -1,3 +1,4 @@
1
+ import { Product } from "../../types/Product";
1
2
  export declare function importBySku(body: Product.ImportBySkuQuery, options?: Global.RequestOptions): Promise<Product.ImportBySkuResult>;
2
3
  export declare function checkImportInfo(body: {
3
4
  task_id: number;
@@ -1,4 +1,4 @@
1
- declare namespace Category {
1
+ export declare namespace Category {
2
2
  interface AttributeQuery {
3
3
  description_category_id: number;
4
4
  type_id: number;
@@ -46,4 +46,22 @@ declare namespace Category {
46
46
  "picture": string;
47
47
  "value": string;
48
48
  }
49
+ interface AttributeValueSearchQuery {
50
+ description_category_id: number;
51
+ type_id: number;
52
+ attribute_id: number;
53
+ limit: number;
54
+ value: string;
55
+ }
56
+ interface AttributeValueSearchApi {
57
+ result: AttributeValueSearch[];
58
+ success?: boolean;
59
+ message?: string;
60
+ }
61
+ interface AttributeValueSearch {
62
+ id: number;
63
+ info: string;
64
+ picture: string;
65
+ value: string;
66
+ }
49
67
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- declare namespace Product {
1
+ export declare namespace Product {
2
2
  interface ImportBySkuQuery {
3
3
  items: ImportBySkuQueryItems[];
4
4
  }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ozon-api",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "OZON API",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",