ozon-api 0.0.12 → 1.0.1

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as Foo } from './Foo';
2
2
  export { default as ProductClass } from './ozon/product';
3
3
  export { default as CategoryClass } from './ozon/category';
4
+ export { default as ActionClass } from './ozon/action';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as Foo } from "./Foo";
2
2
  export { default as ProductClass } from "./ozon/product";
3
- export { default as CategoryClass } from "./ozon/category";
3
+ export { default as CategoryClass } from "./ozon/category";
4
+ export { default as ActionClass } from "./ozon/action";
@@ -71,7 +71,7 @@ var requestApi = /*#__PURE__*/function () {
71
71
  var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
72
72
  console.log('ajax requestData then:', result);
73
73
  if (!result.code) {
74
- resolve(result);
74
+ resolve(result.result || result);
75
75
  } else {
76
76
  var error = new Error((result === null || result === void 0 ? void 0 : result.message) || '发生了一些问题,请稍后重试');
77
77
  error.name = result.code;
@@ -0,0 +1,9 @@
1
+ import { Action } from "../../types/Action";
2
+ declare class ActionClass {
3
+ private readonly apiKeyInfo;
4
+ constructor(apiId: string, apiKey: string);
5
+ list(): Promise<Action.List[]>;
6
+ activate(actionId: number, products: Action.ActivateQueryProducts[]): Promise<Action.ActivateResult>;
7
+ getCanActionGoodsList(actionId: number, limit: number, last_id: string): Promise<Action.GetCanActionGoodsListResult>;
8
+ }
9
+ export default ActionClass;
@@ -0,0 +1,190 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ import * as ActionController from "../../service/api/ActionController";
12
+ var ActionClass = /*#__PURE__*/function () {
13
+ function ActionClass(apiId, apiKey) {
14
+ _classCallCheck(this, ActionClass);
15
+ _defineProperty(this, "apiKeyInfo", {
16
+ apiId: '',
17
+ apiKey: ''
18
+ });
19
+ this.apiKeyInfo = {
20
+ apiId: apiId,
21
+ apiKey: apiKey
22
+ };
23
+ console.log('actionClass constructor:', this.apiKeyInfo);
24
+ }
25
+ // 列表 https://api-seller.ozon.ru/v1/actions
26
+ _createClass(ActionClass, [{
27
+ key: "list",
28
+ value: function () {
29
+ var _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
30
+ var _this = this;
31
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
32
+ while (1) switch (_context2.prev = _context2.next) {
33
+ case 0:
34
+ return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
35
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
36
+ var listResult;
37
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
38
+ while (1) switch (_context.prev = _context.next) {
39
+ case 0:
40
+ _context.next = 2;
41
+ return ActionController.list({}, {
42
+ apiKey: _this.apiKeyInfo.apiKey,
43
+ apiId: _this.apiKeyInfo.apiId
44
+ }).catch(function (err) {
45
+ reject(err);
46
+ });
47
+ case 2:
48
+ listResult = _context.sent;
49
+ if (listResult) {
50
+ _context.next = 5;
51
+ break;
52
+ }
53
+ return _context.abrupt("return");
54
+ case 5:
55
+ if (listResult) {
56
+ _context.next = 7;
57
+ break;
58
+ }
59
+ return _context.abrupt("return", reject(new Error('没结果')));
60
+ case 7:
61
+ return _context.abrupt("return", resolve(listResult));
62
+ case 8:
63
+ case "end":
64
+ return _context.stop();
65
+ }
66
+ }, _callee);
67
+ }));
68
+ return function (_x, _x2) {
69
+ return _ref.apply(this, arguments);
70
+ };
71
+ }()));
72
+ case 1:
73
+ case "end":
74
+ return _context2.stop();
75
+ }
76
+ }, _callee2);
77
+ }));
78
+ function list() {
79
+ return _list.apply(this, arguments);
80
+ }
81
+ return list;
82
+ }()
83
+ }, {
84
+ key: "activate",
85
+ value: function () {
86
+ var _activate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(actionId, products) {
87
+ var _this2 = this;
88
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
89
+ while (1) switch (_context4.prev = _context4.next) {
90
+ case 0:
91
+ return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
92
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve, reject) {
93
+ var listResult;
94
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
95
+ while (1) switch (_context3.prev = _context3.next) {
96
+ case 0:
97
+ if (!(products.length === 0)) {
98
+ _context3.next = 2;
99
+ break;
100
+ }
101
+ return _context3.abrupt("return", resolve({
102
+ product_ids: [],
103
+ rejected: []
104
+ }));
105
+ case 2:
106
+ _context3.next = 4;
107
+ return ActionController.activate({
108
+ action_id: actionId,
109
+ products: products
110
+ }, {
111
+ apiKey: _this2.apiKeyInfo.apiKey,
112
+ apiId: _this2.apiKeyInfo.apiId
113
+ }).catch(function (err) {
114
+ reject(err);
115
+ });
116
+ case 4:
117
+ listResult = _context3.sent;
118
+ if (listResult) {
119
+ _context3.next = 7;
120
+ break;
121
+ }
122
+ return _context3.abrupt("return");
123
+ case 7:
124
+ return _context3.abrupt("return", resolve(listResult));
125
+ case 8:
126
+ case "end":
127
+ return _context3.stop();
128
+ }
129
+ }, _callee3);
130
+ }));
131
+ return function (_x5, _x6) {
132
+ return _ref2.apply(this, arguments);
133
+ };
134
+ }()));
135
+ case 1:
136
+ case "end":
137
+ return _context4.stop();
138
+ }
139
+ }, _callee4);
140
+ }));
141
+ function activate(_x3, _x4) {
142
+ return _activate.apply(this, arguments);
143
+ }
144
+ return activate;
145
+ }()
146
+ }, {
147
+ key: "getCanActionGoodsList",
148
+ value: function getCanActionGoodsList(actionId, limit, last_id) {
149
+ var _this3 = this;
150
+ return new Promise( /*#__PURE__*/function () {
151
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(resolve, reject) {
152
+ var listResult;
153
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
154
+ while (1) switch (_context5.prev = _context5.next) {
155
+ case 0:
156
+ _context5.next = 2;
157
+ return ActionController.getCanActionGoodsList({
158
+ action_id: actionId,
159
+ limit: limit,
160
+ last_id: last_id || undefined
161
+ }, {
162
+ apiKey: _this3.apiKeyInfo.apiKey,
163
+ apiId: _this3.apiKeyInfo.apiId
164
+ }).catch(function (err) {
165
+ reject(err);
166
+ });
167
+ case 2:
168
+ listResult = _context5.sent;
169
+ if (listResult) {
170
+ _context5.next = 5;
171
+ break;
172
+ }
173
+ return _context5.abrupt("return");
174
+ case 5:
175
+ return _context5.abrupt("return", resolve(listResult));
176
+ case 6:
177
+ case "end":
178
+ return _context5.stop();
179
+ }
180
+ }, _callee5);
181
+ }));
182
+ return function (_x7, _x8) {
183
+ return _ref3.apply(this, arguments);
184
+ };
185
+ }());
186
+ }
187
+ }]);
188
+ return ActionClass;
189
+ }();
190
+ export default ActionClass;
@@ -77,14 +77,8 @@ var CategoryClass = /*#__PURE__*/function () {
77
77
  }
78
78
  return _context.abrupt("return");
79
79
  case 5:
80
- if (attributeResult.result) {
81
- _context.next = 7;
82
- break;
83
- }
84
- return _context.abrupt("return", reject(new Error(attributeResult === null || attributeResult === void 0 ? void 0 : attributeResult.message)));
85
- case 7:
86
- return _context.abrupt("return", resolve(attributeResult.result));
87
- case 8:
80
+ return _context.abrupt("return", resolve(attributeResult));
81
+ case 6:
88
82
  case "end":
89
83
  return _context.stop();
90
84
  }
@@ -156,14 +150,8 @@ var CategoryClass = /*#__PURE__*/function () {
156
150
  }
157
151
  return _context3.abrupt("return");
158
152
  case 5:
159
- if (attributeResult.result) {
160
- _context3.next = 7;
161
- break;
162
- }
163
- return _context3.abrupt("return", reject(new Error(attributeResult === null || attributeResult === void 0 ? void 0 : attributeResult.message)));
164
- case 7:
165
153
  return _context3.abrupt("return", resolve(attributeResult));
166
- case 8:
154
+ case 6:
167
155
  case "end":
168
156
  return _context3.stop();
169
157
  }
@@ -243,14 +231,8 @@ var CategoryClass = /*#__PURE__*/function () {
243
231
  }
244
232
  return _context5.abrupt("return");
245
233
  case 5:
246
- if (attributeResult.result) {
247
- _context5.next = 7;
248
- break;
249
- }
250
- return _context5.abrupt("return", reject(new Error(attributeResult === null || attributeResult === void 0 ? void 0 : attributeResult.message)));
251
- case 7:
252
- return _context5.abrupt("return", resolve(attributeResult.result));
253
- case 8:
234
+ return _context5.abrupt("return", resolve(attributeResult));
235
+ case 6:
254
236
  case "end":
255
237
  return _context5.stop();
256
238
  }
@@ -0,0 +1,4 @@
1
+ import { Action } from "../../types/Action";
2
+ export declare function list(body?: {}, options?: Global.RequestOptions): Promise<Action.List[]>;
3
+ export declare function activate(body: Action.ActivateQuery, options?: Global.RequestOptions): Promise<Action.ActivateResult>;
4
+ export declare function getCanActionGoodsList(body: Action.GetCanActionGoodsListQuery, options?: Global.RequestOptions): Promise<Action.GetCanActionGoodsListResult>;
@@ -0,0 +1,83 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ import request from "../../lib/Request";
11
+ export function list(_x, _x2) {
12
+ return _list.apply(this, arguments);
13
+ }
14
+
15
+ // 在促销活动中增加一个商品
16
+ function _list() {
17
+ _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body, options) {
18
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
19
+ while (1) switch (_context.prev = _context.next) {
20
+ case 0:
21
+ return _context.abrupt("return", request("/v1/actions", _objectSpread({
22
+ method: 'GET',
23
+ headers: {
24
+ 'Content-Type': 'application/json'
25
+ },
26
+ data: _objectSpread({}, body)
27
+ }, options || {})));
28
+ case 1:
29
+ case "end":
30
+ return _context.stop();
31
+ }
32
+ }, _callee);
33
+ }));
34
+ return _list.apply(this, arguments);
35
+ }
36
+ export function activate(_x3, _x4) {
37
+ return _activate.apply(this, arguments);
38
+ }
39
+
40
+ // 在促销活动中增加一个商品
41
+ function _activate() {
42
+ _activate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body, options) {
43
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
44
+ while (1) switch (_context2.prev = _context2.next) {
45
+ case 0:
46
+ return _context2.abrupt("return", request("/v1/actions/products/activate", _objectSpread({
47
+ method: 'POST',
48
+ headers: {
49
+ 'Content-Type': 'application/json'
50
+ },
51
+ data: _objectSpread({}, body)
52
+ }, options || {})));
53
+ case 1:
54
+ case "end":
55
+ return _context2.stop();
56
+ }
57
+ }, _callee2);
58
+ }));
59
+ return _activate.apply(this, arguments);
60
+ }
61
+ export function getCanActionGoodsList(_x5, _x6) {
62
+ return _getCanActionGoodsList.apply(this, arguments);
63
+ }
64
+ function _getCanActionGoodsList() {
65
+ _getCanActionGoodsList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(body, options) {
66
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
67
+ while (1) switch (_context3.prev = _context3.next) {
68
+ case 0:
69
+ return _context3.abrupt("return", request("/v1/actions/candidates", _objectSpread({
70
+ method: 'POST',
71
+ headers: {
72
+ 'Content-Type': 'application/json'
73
+ },
74
+ data: _objectSpread({}, body)
75
+ }, options || {})));
76
+ case 1:
77
+ case "end":
78
+ return _context3.stop();
79
+ }
80
+ }, _callee3);
81
+ }));
82
+ return _getCanActionGoodsList.apply(this, arguments);
83
+ }
@@ -1,4 +1,4 @@
1
1
  import { Category } from "../../types/Category";
2
- export declare function attribute(body: Category.AttributeQuery, options?: Global.RequestOptions): Promise<Category.AttributeApi>;
2
+ export declare function attribute(body: Category.AttributeQuery, options?: Global.RequestOptions): Promise<Category.Attribute[]>;
3
3
  export declare function attributeValue(body: Category.AttributeValueApiQuery, options?: Global.RequestOptions): Promise<Category.AttributeValueApi>;
4
- export declare function attributeValueSearch(body: Category.AttributeValueSearchQuery, options?: Global.RequestOptions): Promise<Category.AttributeValueSearchApi>;
4
+ export declare function attributeValueSearch(body: Category.AttributeValueSearchQuery, options?: Global.RequestOptions): Promise<Category.AttributeValueSearch[]>;
@@ -0,0 +1,65 @@
1
+ export declare namespace Action {
2
+ interface List {
3
+ "id": number;
4
+ "title": string;
5
+ "date_start": string;
6
+ "date_end": string;
7
+ "potential_products_count": number;
8
+ "is_participating": boolean;
9
+ "participating_products_count": number;
10
+ "description": string;
11
+ "action_type": string;
12
+ "banned_products_count": number;
13
+ "with_targeting": boolean;
14
+ "discount_type": string;
15
+ "discount_value": number;
16
+ "order_amount": number;
17
+ "freeze_date": string;
18
+ "is_voucher_action": boolean;
19
+ }
20
+ interface ListResult {
21
+ result: List[];
22
+ }
23
+ interface ActivateQuery {
24
+ "action_id": number;
25
+ "products": ActivateQueryProducts[];
26
+ }
27
+ interface ActivateQueryProducts {
28
+ "action_price": number;
29
+ "product_id": number;
30
+ "stock"?: number;
31
+ }
32
+ interface ActivateResult {
33
+ product_ids: number[];
34
+ rejected: {
35
+ product_id: number;
36
+ reason: string;
37
+ }[];
38
+ }
39
+ interface GetCanActionGoodsListQuery {
40
+ "action_id": number;
41
+ "limit": number;
42
+ "last_id"?: string;
43
+ }
44
+ interface GetCanActionGoodsListResult {
45
+ total: number;
46
+ last_id: string;
47
+ products: GetCanActionGoodsListResultProducts[];
48
+ }
49
+ interface GetCanActionGoodsListResultProducts {
50
+ "id": number;
51
+ "price": number;
52
+ "action_price": number;
53
+ "alert_max_action_price_failed": true;
54
+ "alert_max_action_price": number;
55
+ "max_action_price": number;
56
+ "add_mode": "NOT_SET";
57
+ "stock": number;
58
+ "min_stock": number;
59
+ "current_boost": number;
60
+ "price_min_elastic": number;
61
+ "price_max_elastic": number;
62
+ "min_boost": number;
63
+ "max_boost": number;
64
+ }
65
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "ozon-api",
3
- "version": "0.0.12",
4
- "description": "OZON API",
3
+ "version": "1.0.1",
4
+ "description": "OZON Seller API",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "authors": [
8
- "13640661@qq.com"
8
+ "wang-wen-ru@foxmail.com"
9
9
  ],
10
10
  "license": "MIT",
11
11
  "files": [