ozon-api 0.0.2
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/LICENSE +21 -0
- package/README.md +43 -0
- package/dist/Foo/index.d.ts +5 -0
- package/dist/Foo/index.js +8 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lib/Request.d.ts +3 -0
- package/dist/lib/Request.js +123 -0
- package/dist/lib/getTestApiKey.d.ts +3 -0
- package/dist/lib/getTestApiKey.js +19 -0
- package/dist/lib/store.d.ts +6 -0
- package/dist/lib/store.js +44 -0
- package/dist/lib/toast.d.ts +2 -0
- package/dist/lib/toast.js +8 -0
- package/dist/lib/toastError.d.ts +2 -0
- package/dist/lib/toastError.js +8 -0
- package/dist/ozon/category/index.d.ts +7 -0
- package/dist/ozon/category/index.js +188 -0
- package/dist/ozon/product/index.d.ts +10 -0
- package/dist/ozon/product/index.js +154 -0
- package/dist/service/api/CategoryController.d.ts +2 -0
- package/dist/service/api/CategoryController.js +56 -0
- package/dist/service/api/ProductController.d.ts +7 -0
- package/dist/service/api/ProductController.js +125 -0
- package/dist/types/Category.d.ts +49 -0
- package/dist/types/Category.js +0 -0
- package/dist/types/Product.d.ts +193 -0
- package/dist/types/Product.js +0 -0
- package/dist/types/typings.d.ts +32 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 13640661@qq.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# ozon-api
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/ozon-api)
|
|
4
|
+
[](https://npmjs.org/package/ozon-api)
|
|
5
|
+
|
|
6
|
+
A react library developed with dumi
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
TODO
|
|
11
|
+
|
|
12
|
+
## Options
|
|
13
|
+
|
|
14
|
+
TODO
|
|
15
|
+
|
|
16
|
+
## Development
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# install dependencies
|
|
20
|
+
$ pnpm install
|
|
21
|
+
|
|
22
|
+
# develop library by docs demo
|
|
23
|
+
$ pnpm start
|
|
24
|
+
|
|
25
|
+
# build library source code
|
|
26
|
+
$ pnpm run build
|
|
27
|
+
|
|
28
|
+
# build library source code in watch mode
|
|
29
|
+
$ pnpm run build:watch
|
|
30
|
+
|
|
31
|
+
# build docs
|
|
32
|
+
$ pnpm run docs:build
|
|
33
|
+
|
|
34
|
+
# Locally preview the production build.
|
|
35
|
+
$ pnpm run docs:preview
|
|
36
|
+
|
|
37
|
+
# check your project for potential problems
|
|
38
|
+
$ pnpm run doctor
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## LICENSE
|
|
42
|
+
|
|
43
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
// 二次封装 hooks request ;
|
|
11
|
+
// 参数详见:https://github.com/umijs/umi-request/blob/master/README_zh-CN.md
|
|
12
|
+
import request from 'umi-request';
|
|
13
|
+
import toastError from "./toastError";
|
|
14
|
+
import Config from "../config";
|
|
15
|
+
var requestApi = /*#__PURE__*/function () {
|
|
16
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17
|
+
var api,
|
|
18
|
+
options,
|
|
19
|
+
optionDomain,
|
|
20
|
+
url,
|
|
21
|
+
headers,
|
|
22
|
+
postUrl,
|
|
23
|
+
pageUrl,
|
|
24
|
+
_args = arguments;
|
|
25
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
api = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
|
|
29
|
+
options = _args.length > 1 ? _args[1] : undefined;
|
|
30
|
+
// 要请求的 url
|
|
31
|
+
if (!options) {
|
|
32
|
+
options = {
|
|
33
|
+
apiKey: '',
|
|
34
|
+
apiId: ''
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
optionDomain = options.domain || '';
|
|
38
|
+
optionDomain = optionDomain.match(/\/$/) ? optionDomain : optionDomain + '/';
|
|
39
|
+
url = optionDomain + api;
|
|
40
|
+
headers = options.headers || {};
|
|
41
|
+
if (!/^https?:/.test(url)) {
|
|
42
|
+
_context.next = 10;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
_context.next = 15;
|
|
46
|
+
break;
|
|
47
|
+
case 10:
|
|
48
|
+
url = Config.ozonApiDomain + url;
|
|
49
|
+
if (!(!options.apiId || !options.apiKey)) {
|
|
50
|
+
_context.next = 13;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return _context.abrupt("return", Promise.reject(new Error('缺少 ClientId/App Key')));
|
|
54
|
+
case 13:
|
|
55
|
+
headers['Client-Id'] = options.apiId;
|
|
56
|
+
headers['Api-Key'] = options.apiKey;
|
|
57
|
+
case 15:
|
|
58
|
+
console.log('makeAjax int 20 111 url:', url, options);
|
|
59
|
+
postUrl = url;
|
|
60
|
+
if (!options.disabledToken) {
|
|
61
|
+
// postUrl += (url.indexOf('?') === -1 ? '?' : '&')
|
|
62
|
+
}
|
|
63
|
+
pageUrl = document.location.href;
|
|
64
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
65
|
+
var requestData = request(postUrl, _objectSpread(_objectSpread({}, options), {}, {
|
|
66
|
+
headers: headers,
|
|
67
|
+
timeout: options.timeout || 120e3
|
|
68
|
+
}));
|
|
69
|
+
requestData.then(function () {
|
|
70
|
+
var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
71
|
+
console.log('ajax requestData then:', result);
|
|
72
|
+
if (!result.code) {
|
|
73
|
+
resolve(result);
|
|
74
|
+
} else {
|
|
75
|
+
var error = new Error((result === null || result === void 0 ? void 0 : result.message) || '发生了一些问题,请稍后重试');
|
|
76
|
+
error.name = result.code;
|
|
77
|
+
error.stack = result.data;
|
|
78
|
+
if (['staff-not-login', 'not-login'].includes(result === null || result === void 0 ? void 0 : result.code)) {
|
|
79
|
+
// 未登录,跳走;
|
|
80
|
+
reject(error);
|
|
81
|
+
} else {
|
|
82
|
+
var _options, _options2;
|
|
83
|
+
onError(pageUrl, url, error.message, JSON.stringify(error), (_options = options) === null || _options === void 0 ? void 0 : _options.silent);
|
|
84
|
+
reject(error);
|
|
85
|
+
if (!((_options2 = options) !== null && _options2 !== void 0 && _options2.silent)) {
|
|
86
|
+
toastError(result.message);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}).catch(function (err) {
|
|
91
|
+
var _err$data, _options3;
|
|
92
|
+
console.log('ajax error:', err);
|
|
93
|
+
console.log('ajax error 2:', JSON.stringify(err));
|
|
94
|
+
// if (['Failed to fetch', 'http error'].includes(err?.message)) {
|
|
95
|
+
// err.message = '发生了一些问题,请稍后重试.';
|
|
96
|
+
// }
|
|
97
|
+
var msg = (err === null || err === void 0 || (_err$data = err.data) === null || _err$data === void 0 ? void 0 : _err$data.message) || (err === null || err === void 0 ? void 0 : err.message) || '发生了一些问题,请稍后重试';
|
|
98
|
+
toastError(msg);
|
|
99
|
+
var error = new Error(msg);
|
|
100
|
+
onError(pageUrl, url, msg, JSON.stringify(err), (_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.silent);
|
|
101
|
+
reject(error);
|
|
102
|
+
});
|
|
103
|
+
}));
|
|
104
|
+
case 20:
|
|
105
|
+
case "end":
|
|
106
|
+
return _context.stop();
|
|
107
|
+
}
|
|
108
|
+
}, _callee);
|
|
109
|
+
}));
|
|
110
|
+
return function requestApi() {
|
|
111
|
+
return _ref.apply(this, arguments);
|
|
112
|
+
};
|
|
113
|
+
}();
|
|
114
|
+
var onError = function onError(pageUrl) {
|
|
115
|
+
var apiUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
116
|
+
var title = arguments.length > 2 ? arguments[2] : undefined;
|
|
117
|
+
var content = arguments.length > 3 ? arguments[3] : undefined;
|
|
118
|
+
var silent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
119
|
+
if (silent) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export default requestApi;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import store from "./store";
|
|
8
|
+
export var OzonApiTestStoreKeyName = 'ozon-api-test-apiKey';
|
|
9
|
+
var getTestApiKey = function getTestApiKey(apiKeyInfo) {
|
|
10
|
+
if (apiKeyInfo) {
|
|
11
|
+
store.set(OzonApiTestStoreKeyName, apiKeyInfo);
|
|
12
|
+
return apiKeyInfo;
|
|
13
|
+
}
|
|
14
|
+
return _objectSpread({
|
|
15
|
+
apiId: '',
|
|
16
|
+
apiKey: ''
|
|
17
|
+
}, store.get(OzonApiTestStoreKeyName));
|
|
18
|
+
};
|
|
19
|
+
export default getTestApiKey;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var store = {
|
|
2
|
+
key: function key() {
|
|
3
|
+
return ""; // _shipinlv_
|
|
4
|
+
},
|
|
5
|
+
get: function get(name) {
|
|
6
|
+
var getData;
|
|
7
|
+
if (typeof window === 'undefined') {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
if (!name) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
getData = window.localStorage.getItem(this.key() + name);
|
|
15
|
+
if (getData) {
|
|
16
|
+
getData = JSON.parse(getData);
|
|
17
|
+
}
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error('LocalStorage get Error:', e);
|
|
20
|
+
}
|
|
21
|
+
var out;
|
|
22
|
+
if (!getData) {
|
|
23
|
+
out = '';
|
|
24
|
+
} else {
|
|
25
|
+
out = getData.value;
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
},
|
|
29
|
+
set: function set(name, value) {
|
|
30
|
+
value = typeof value === 'undefined' ? '' : value;
|
|
31
|
+
if (typeof window === 'undefined') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var saveData = {
|
|
35
|
+
value: value
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
window.localStorage.setItem(this.key() + name, JSON.stringify(saveData));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error('LocalStorage set Error:', e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export default store;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
var toast = function toast() {
|
|
3
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
4
|
+
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
5
|
+
var onClose = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
6
|
+
return content && message.info(content, duration, onClose);
|
|
7
|
+
};
|
|
8
|
+
export default toast;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
var toastError = function toastError() {
|
|
3
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
4
|
+
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
5
|
+
var onClose = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
6
|
+
return content && message.error(content, duration, onClose);
|
|
7
|
+
};
|
|
8
|
+
export default toastError;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare class CategoryClass {
|
|
2
|
+
private apiKeyInfo;
|
|
3
|
+
constructor(apiKeyInfo: Global.ApiKeyInfo);
|
|
4
|
+
attribute(description_category_id: number, type_id: number, language?: Global.ApiLanguage): Promise<Category.Attribute[]>;
|
|
5
|
+
attributeValue(description_category_id: number, type_id: number, attribute_id: number, language?: Global.ApiLanguage): Promise<Category.AttributeValue[]>;
|
|
6
|
+
}
|
|
7
|
+
export default CategoryClass;
|
|
@@ -0,0 +1,188 @@
|
|
|
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 CategoryController from "../../service/api/CategoryController";
|
|
12
|
+
var CategoryClass = /*#__PURE__*/function () {
|
|
13
|
+
function CategoryClass(apiKeyInfo) {
|
|
14
|
+
_classCallCheck(this, CategoryClass);
|
|
15
|
+
_defineProperty(this, "apiKeyInfo", {
|
|
16
|
+
apiId: '',
|
|
17
|
+
apiKey: ''
|
|
18
|
+
});
|
|
19
|
+
this.apiKeyInfo = apiKeyInfo;
|
|
20
|
+
console.log('categoryClass constructor:', apiKeyInfo);
|
|
21
|
+
}
|
|
22
|
+
// 类别特征列表
|
|
23
|
+
// https://api-seller.ozon.ru/v1/description-category/attribute
|
|
24
|
+
_createClass(CategoryClass, [{
|
|
25
|
+
key: "attribute",
|
|
26
|
+
value: function () {
|
|
27
|
+
var _attribute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(description_category_id, type_id) {
|
|
28
|
+
var _this = this;
|
|
29
|
+
var language,
|
|
30
|
+
_args2 = arguments;
|
|
31
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
32
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
language = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : 'ZH_HANS';
|
|
35
|
+
if (description_category_id) {
|
|
36
|
+
_context2.next = 3;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return _context2.abrupt("return", Promise.reject(new Error('请输入 descriptionCategoryId')));
|
|
40
|
+
case 3:
|
|
41
|
+
if (type_id) {
|
|
42
|
+
_context2.next = 5;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return _context2.abrupt("return", Promise.reject(new Error('请输入 typeId')));
|
|
46
|
+
case 5:
|
|
47
|
+
return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
48
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
|
|
49
|
+
var attributeResult;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
_context.next = 2;
|
|
54
|
+
return CategoryController.attribute({
|
|
55
|
+
description_category_id: description_category_id,
|
|
56
|
+
type_id: type_id,
|
|
57
|
+
language: language
|
|
58
|
+
}, {
|
|
59
|
+
apiKey: _this.apiKeyInfo.apiKey,
|
|
60
|
+
apiId: _this.apiKeyInfo.apiId
|
|
61
|
+
}).catch(function (err) {
|
|
62
|
+
reject(err);
|
|
63
|
+
});
|
|
64
|
+
case 2:
|
|
65
|
+
attributeResult = _context.sent;
|
|
66
|
+
if (attributeResult) {
|
|
67
|
+
_context.next = 5;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context.abrupt("return");
|
|
71
|
+
case 5:
|
|
72
|
+
if (attributeResult.result) {
|
|
73
|
+
_context.next = 7;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return _context.abrupt("return", reject(new Error(attributeResult === null || attributeResult === void 0 ? void 0 : attributeResult.message)));
|
|
77
|
+
case 7:
|
|
78
|
+
return _context.abrupt("return", resolve(attributeResult.result));
|
|
79
|
+
case 8:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context.stop();
|
|
82
|
+
}
|
|
83
|
+
}, _callee);
|
|
84
|
+
}));
|
|
85
|
+
return function (_x3, _x4) {
|
|
86
|
+
return _ref.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}()));
|
|
89
|
+
case 6:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context2.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee2);
|
|
94
|
+
}));
|
|
95
|
+
function attribute(_x, _x2) {
|
|
96
|
+
return _attribute.apply(this, arguments);
|
|
97
|
+
}
|
|
98
|
+
return attribute;
|
|
99
|
+
}()
|
|
100
|
+
}, {
|
|
101
|
+
key: "attributeValue",
|
|
102
|
+
value: function () {
|
|
103
|
+
var _attributeValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(description_category_id, type_id, attribute_id) {
|
|
104
|
+
var _this2 = this;
|
|
105
|
+
var language,
|
|
106
|
+
_args4 = arguments;
|
|
107
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
108
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
language = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : 'ZH_HANS';
|
|
111
|
+
if (description_category_id) {
|
|
112
|
+
_context4.next = 3;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context4.abrupt("return", Promise.reject(new Error('请输入 descriptionCategoryId')));
|
|
116
|
+
case 3:
|
|
117
|
+
if (type_id) {
|
|
118
|
+
_context4.next = 5;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
return _context4.abrupt("return", Promise.reject(new Error('请输入 typeId')));
|
|
122
|
+
case 5:
|
|
123
|
+
if (type_id) {
|
|
124
|
+
_context4.next = 7;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return _context4.abrupt("return", Promise.reject(new Error('请输入 attribute_id')));
|
|
128
|
+
case 7:
|
|
129
|
+
return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
130
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve, reject) {
|
|
131
|
+
var attributeResult;
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
133
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
_context3.next = 2;
|
|
136
|
+
return CategoryController.attributeValue({
|
|
137
|
+
description_category_id: description_category_id,
|
|
138
|
+
type_id: type_id,
|
|
139
|
+
attribute_id: attribute_id,
|
|
140
|
+
language: language,
|
|
141
|
+
limit: 2000,
|
|
142
|
+
last_value_id: 0
|
|
143
|
+
}, {
|
|
144
|
+
apiKey: _this2.apiKeyInfo.apiKey,
|
|
145
|
+
apiId: _this2.apiKeyInfo.apiId
|
|
146
|
+
}).catch(function (err) {
|
|
147
|
+
reject(err);
|
|
148
|
+
});
|
|
149
|
+
case 2:
|
|
150
|
+
attributeResult = _context3.sent;
|
|
151
|
+
if (attributeResult) {
|
|
152
|
+
_context3.next = 5;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
return _context3.abrupt("return");
|
|
156
|
+
case 5:
|
|
157
|
+
if (attributeResult.result) {
|
|
158
|
+
_context3.next = 7;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
return _context3.abrupt("return", reject(new Error(attributeResult === null || attributeResult === void 0 ? void 0 : attributeResult.message)));
|
|
162
|
+
case 7:
|
|
163
|
+
return _context3.abrupt("return", resolve(attributeResult.result));
|
|
164
|
+
case 8:
|
|
165
|
+
case "end":
|
|
166
|
+
return _context3.stop();
|
|
167
|
+
}
|
|
168
|
+
}, _callee3);
|
|
169
|
+
}));
|
|
170
|
+
return function (_x8, _x9) {
|
|
171
|
+
return _ref2.apply(this, arguments);
|
|
172
|
+
};
|
|
173
|
+
}()));
|
|
174
|
+
case 8:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context4.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee4);
|
|
179
|
+
}));
|
|
180
|
+
function attributeValue(_x5, _x6, _x7) {
|
|
181
|
+
return _attributeValue.apply(this, arguments);
|
|
182
|
+
}
|
|
183
|
+
return attributeValue;
|
|
184
|
+
}()
|
|
185
|
+
}]);
|
|
186
|
+
return CategoryClass;
|
|
187
|
+
}();
|
|
188
|
+
export default CategoryClass;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare class ProductClass {
|
|
2
|
+
private apiKeyInfo;
|
|
3
|
+
constructor(apiKeyInfo: Global.ApiKeyInfo);
|
|
4
|
+
importBySku(query: Product.ImportBySkuQuery): Promise<Product.ImportBySkuResult>;
|
|
5
|
+
checkImportInfo(taskId: number): Promise<Product.CheckImportInfoResult>;
|
|
6
|
+
getListOfProducts(filter: Product.GetListOfProductsQueryFilter): Promise<Product.CheckImportInfoResult>;
|
|
7
|
+
getPlatformProductDetailList(query: Product.GetPlatformProductDetailListQuery): Promise<Product.GetPlatformProductDetailList>;
|
|
8
|
+
productImport(query: Product.ProductImportQuery): Promise<Product.ProductImportResult>;
|
|
9
|
+
}
|
|
10
|
+
export default ProductClass;
|