@teemill/gtins 0.2.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/.openapi-generator/FILES +16 -0
- package/.openapi-generator/VERSION +1 -0
- package/.openapi-generator-ignore +23 -0
- package/README.md +46 -0
- package/dist/apis/GTINsApi.d.ts +77 -0
- package/dist/apis/GTINsApi.js +213 -0
- package/dist/apis/index.d.ts +1 -0
- package/dist/apis/index.js +19 -0
- package/dist/esm/apis/GTINsApi.d.ts +77 -0
- package/dist/esm/apis/GTINsApi.js +209 -0
- package/dist/esm/apis/index.d.ts +1 -0
- package/dist/esm/apis/index.js +3 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/models/ApiError.d.ts +37 -0
- package/dist/esm/models/ApiError.js +42 -0
- package/dist/esm/models/AssignGtinRequest.d.ts +31 -0
- package/dist/esm/models/AssignGtinRequest.js +40 -0
- package/dist/esm/models/GTIN.d.ts +37 -0
- package/dist/esm/models/GTIN.js +44 -0
- package/dist/esm/models/GTINsResponse.d.ts +38 -0
- package/dist/esm/models/GTINsResponse.js +41 -0
- package/dist/esm/models/ImportGtins202Response.d.ts +31 -0
- package/dist/esm/models/ImportGtins202Response.js +38 -0
- package/dist/esm/models/index.d.ts +5 -0
- package/dist/esm/models/index.js +7 -0
- package/dist/esm/runtime.d.ts +187 -0
- package/dist/esm/runtime.js +333 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +21 -0
- package/dist/models/ApiError.d.ts +37 -0
- package/dist/models/ApiError.js +49 -0
- package/dist/models/AssignGtinRequest.d.ts +31 -0
- package/dist/models/AssignGtinRequest.js +47 -0
- package/dist/models/GTIN.d.ts +37 -0
- package/dist/models/GTIN.js +51 -0
- package/dist/models/GTINsResponse.d.ts +38 -0
- package/dist/models/GTINsResponse.js +48 -0
- package/dist/models/ImportGtins202Response.d.ts +31 -0
- package/dist/models/ImportGtins202Response.js +45 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.js +23 -0
- package/dist/runtime.d.ts +187 -0
- package/dist/runtime.js +349 -0
- package/package.json +21 -0
- package/src/apis/GTINsApi.ts +311 -0
- package/src/apis/index.ts +3 -0
- package/src/index.ts +5 -0
- package/src/models/ApiError.ts +69 -0
- package/src/models/AssignGtinRequest.ts +61 -0
- package/src/models/GTIN.ts +70 -0
- package/src/models/GTINsResponse.ts +75 -0
- package/src/models/ImportGtins202Response.ts +60 -0
- package/src/models/index.ts +7 -0
- package/src/runtime.ts +441 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +20 -0
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* GTINs API
|
|
6
|
+
* Manage GTINs
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 0.2.1
|
|
9
|
+
* Contact: hello@teemill.com
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.canConsumeForm = exports.mapValues = exports.querystring = exports.exists = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.DefaultConfig = exports.Configuration = exports.BASE_PATH = void 0;
|
|
26
|
+
exports.BASE_PATH = "https://api.teemill.com".replace(/\/+$/, "");
|
|
27
|
+
class Configuration {
|
|
28
|
+
constructor(configuration = {}) {
|
|
29
|
+
this.configuration = configuration;
|
|
30
|
+
}
|
|
31
|
+
set config(configuration) {
|
|
32
|
+
this.configuration = configuration;
|
|
33
|
+
}
|
|
34
|
+
get basePath() {
|
|
35
|
+
return this.configuration.basePath != null ? this.configuration.basePath : exports.BASE_PATH;
|
|
36
|
+
}
|
|
37
|
+
get fetchApi() {
|
|
38
|
+
return this.configuration.fetchApi;
|
|
39
|
+
}
|
|
40
|
+
get middleware() {
|
|
41
|
+
return this.configuration.middleware || [];
|
|
42
|
+
}
|
|
43
|
+
get queryParamsStringify() {
|
|
44
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
45
|
+
}
|
|
46
|
+
get username() {
|
|
47
|
+
return this.configuration.username;
|
|
48
|
+
}
|
|
49
|
+
get password() {
|
|
50
|
+
return this.configuration.password;
|
|
51
|
+
}
|
|
52
|
+
get apiKey() {
|
|
53
|
+
const apiKey = this.configuration.apiKey;
|
|
54
|
+
if (apiKey) {
|
|
55
|
+
return typeof apiKey === 'function' ? apiKey : () => apiKey;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
get accessToken() {
|
|
60
|
+
const accessToken = this.configuration.accessToken;
|
|
61
|
+
if (accessToken) {
|
|
62
|
+
return typeof accessToken === 'function' ? accessToken : () => __awaiter(this, void 0, void 0, function* () { return accessToken; });
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
get headers() {
|
|
67
|
+
return this.configuration.headers;
|
|
68
|
+
}
|
|
69
|
+
get credentials() {
|
|
70
|
+
return this.configuration.credentials;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Configuration = Configuration;
|
|
74
|
+
exports.DefaultConfig = new Configuration();
|
|
75
|
+
/**
|
|
76
|
+
* This is the base class for all generated API classes.
|
|
77
|
+
*/
|
|
78
|
+
class BaseAPI {
|
|
79
|
+
constructor(configuration = exports.DefaultConfig) {
|
|
80
|
+
this.configuration = configuration;
|
|
81
|
+
this.fetchApi = (url, init) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
let fetchParams = { url, init };
|
|
83
|
+
for (const middleware of this.middleware) {
|
|
84
|
+
if (middleware.pre) {
|
|
85
|
+
fetchParams = (yield middleware.pre(Object.assign({ fetch: this.fetchApi }, fetchParams))) || fetchParams;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
let response = undefined;
|
|
89
|
+
try {
|
|
90
|
+
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
for (const middleware of this.middleware) {
|
|
94
|
+
if (middleware.onError) {
|
|
95
|
+
response = (yield middleware.onError({
|
|
96
|
+
fetch: this.fetchApi,
|
|
97
|
+
url: fetchParams.url,
|
|
98
|
+
init: fetchParams.init,
|
|
99
|
+
error: e,
|
|
100
|
+
response: response ? response.clone() : undefined,
|
|
101
|
+
})) || response;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (response === undefined) {
|
|
105
|
+
if (e instanceof Error) {
|
|
106
|
+
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const middleware of this.middleware) {
|
|
114
|
+
if (middleware.post) {
|
|
115
|
+
response = (yield middleware.post({
|
|
116
|
+
fetch: this.fetchApi,
|
|
117
|
+
url: fetchParams.url,
|
|
118
|
+
init: fetchParams.init,
|
|
119
|
+
response: response.clone(),
|
|
120
|
+
})) || response;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return response;
|
|
124
|
+
});
|
|
125
|
+
this.middleware = configuration.middleware;
|
|
126
|
+
}
|
|
127
|
+
isResponseError(error) {
|
|
128
|
+
return error instanceof Error && error.name === 'ResponseError';
|
|
129
|
+
}
|
|
130
|
+
withMiddleware(...middlewares) {
|
|
131
|
+
const next = this.clone();
|
|
132
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
133
|
+
return next;
|
|
134
|
+
}
|
|
135
|
+
withPreMiddleware(...preMiddlewares) {
|
|
136
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
137
|
+
return this.withMiddleware(...middlewares);
|
|
138
|
+
}
|
|
139
|
+
withPostMiddleware(...postMiddlewares) {
|
|
140
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
141
|
+
return this.withMiddleware(...middlewares);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if the given MIME is a JSON MIME.
|
|
145
|
+
* JSON MIME examples:
|
|
146
|
+
* application/json
|
|
147
|
+
* application/json; charset=UTF8
|
|
148
|
+
* APPLICATION/JSON
|
|
149
|
+
* application/vnd.company+json
|
|
150
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
151
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
152
|
+
*/
|
|
153
|
+
isJsonMime(mime) {
|
|
154
|
+
if (!mime) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return BaseAPI.jsonRegex.test(mime);
|
|
158
|
+
}
|
|
159
|
+
request(context, initOverrides) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const { url, init } = yield this.createFetchParams(context, initOverrides);
|
|
162
|
+
const response = yield this.fetchApi(url, init);
|
|
163
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
164
|
+
return response;
|
|
165
|
+
}
|
|
166
|
+
throw new ResponseError(response, 'Response returned an error code');
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
createFetchParams(context, initOverrides) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
let url = this.configuration.basePath + context.path;
|
|
172
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
173
|
+
// only add the querystring to the URL if there are query parameters.
|
|
174
|
+
// this is done to avoid urls ending with a "?" character which buggy webservers
|
|
175
|
+
// do not handle correctly sometimes.
|
|
176
|
+
url += '?' + this.configuration.queryParamsStringify(context.query);
|
|
177
|
+
}
|
|
178
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
179
|
+
Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
|
|
180
|
+
const initOverrideFn = typeof initOverrides === "function"
|
|
181
|
+
? initOverrides
|
|
182
|
+
: () => __awaiter(this, void 0, void 0, function* () { return initOverrides; });
|
|
183
|
+
const initParams = {
|
|
184
|
+
method: context.method,
|
|
185
|
+
headers,
|
|
186
|
+
body: context.body,
|
|
187
|
+
credentials: this.configuration.credentials,
|
|
188
|
+
};
|
|
189
|
+
const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({
|
|
190
|
+
init: initParams,
|
|
191
|
+
context,
|
|
192
|
+
})));
|
|
193
|
+
let body;
|
|
194
|
+
if (isFormData(overriddenInit.body)
|
|
195
|
+
|| (overriddenInit.body instanceof URLSearchParams)
|
|
196
|
+
|| isBlob(overriddenInit.body)) {
|
|
197
|
+
body = overriddenInit.body;
|
|
198
|
+
}
|
|
199
|
+
else if (this.isJsonMime(headers['Content-Type'])) {
|
|
200
|
+
body = JSON.stringify(overriddenInit.body);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
body = overriddenInit.body;
|
|
204
|
+
}
|
|
205
|
+
const init = Object.assign(Object.assign({}, overriddenInit), { body });
|
|
206
|
+
return { url, init };
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a shallow clone of `this` by constructing a new instance
|
|
211
|
+
* and then shallow cloning data members.
|
|
212
|
+
*/
|
|
213
|
+
clone() {
|
|
214
|
+
const constructor = this.constructor;
|
|
215
|
+
const next = new constructor(this.configuration);
|
|
216
|
+
next.middleware = this.middleware.slice();
|
|
217
|
+
return next;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.BaseAPI = BaseAPI;
|
|
221
|
+
BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
222
|
+
;
|
|
223
|
+
function isBlob(value) {
|
|
224
|
+
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
225
|
+
}
|
|
226
|
+
function isFormData(value) {
|
|
227
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
228
|
+
}
|
|
229
|
+
class ResponseError extends Error {
|
|
230
|
+
constructor(response, msg) {
|
|
231
|
+
super(msg);
|
|
232
|
+
this.response = response;
|
|
233
|
+
this.name = "ResponseError";
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.ResponseError = ResponseError;
|
|
237
|
+
class FetchError extends Error {
|
|
238
|
+
constructor(cause, msg) {
|
|
239
|
+
super(msg);
|
|
240
|
+
this.cause = cause;
|
|
241
|
+
this.name = "FetchError";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.FetchError = FetchError;
|
|
245
|
+
class RequiredError extends Error {
|
|
246
|
+
constructor(field, msg) {
|
|
247
|
+
super(msg);
|
|
248
|
+
this.field = field;
|
|
249
|
+
this.name = "RequiredError";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
exports.RequiredError = RequiredError;
|
|
253
|
+
exports.COLLECTION_FORMATS = {
|
|
254
|
+
csv: ",",
|
|
255
|
+
ssv: " ",
|
|
256
|
+
tsv: "\t",
|
|
257
|
+
pipes: "|",
|
|
258
|
+
};
|
|
259
|
+
function exists(json, key) {
|
|
260
|
+
const value = json[key];
|
|
261
|
+
return value !== null && value !== undefined;
|
|
262
|
+
}
|
|
263
|
+
exports.exists = exists;
|
|
264
|
+
function querystring(params, prefix = '') {
|
|
265
|
+
return Object.keys(params)
|
|
266
|
+
.map(key => querystringSingleKey(key, params[key], prefix))
|
|
267
|
+
.filter(part => part.length > 0)
|
|
268
|
+
.join('&');
|
|
269
|
+
}
|
|
270
|
+
exports.querystring = querystring;
|
|
271
|
+
function querystringSingleKey(key, value, keyPrefix = '') {
|
|
272
|
+
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
273
|
+
if (value instanceof Array) {
|
|
274
|
+
const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
|
|
275
|
+
.join(`&${encodeURIComponent(fullKey)}[]=`);
|
|
276
|
+
return `${encodeURIComponent(fullKey)}[]=${multiValue}`;
|
|
277
|
+
}
|
|
278
|
+
if (value instanceof Set) {
|
|
279
|
+
const valueAsArray = Array.from(value);
|
|
280
|
+
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
|
281
|
+
}
|
|
282
|
+
if (value instanceof Date) {
|
|
283
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
284
|
+
}
|
|
285
|
+
if (value instanceof Object) {
|
|
286
|
+
return querystring(value, fullKey);
|
|
287
|
+
}
|
|
288
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
289
|
+
}
|
|
290
|
+
function mapValues(data, fn) {
|
|
291
|
+
return Object.keys(data).reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: fn(data[key]) })), {});
|
|
292
|
+
}
|
|
293
|
+
exports.mapValues = mapValues;
|
|
294
|
+
function canConsumeForm(consumes) {
|
|
295
|
+
for (const consume of consumes) {
|
|
296
|
+
if ('multipart/form-data' === consume.contentType) {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
exports.canConsumeForm = canConsumeForm;
|
|
303
|
+
class JSONApiResponse {
|
|
304
|
+
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
305
|
+
this.raw = raw;
|
|
306
|
+
this.transformer = transformer;
|
|
307
|
+
}
|
|
308
|
+
value() {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
return this.transformer(yield this.raw.json());
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
exports.JSONApiResponse = JSONApiResponse;
|
|
315
|
+
class VoidApiResponse {
|
|
316
|
+
constructor(raw) {
|
|
317
|
+
this.raw = raw;
|
|
318
|
+
}
|
|
319
|
+
value() {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
321
|
+
return undefined;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.VoidApiResponse = VoidApiResponse;
|
|
326
|
+
class BlobApiResponse {
|
|
327
|
+
constructor(raw) {
|
|
328
|
+
this.raw = raw;
|
|
329
|
+
}
|
|
330
|
+
value() {
|
|
331
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
332
|
+
return yield this.raw.blob();
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
;
|
|
336
|
+
}
|
|
337
|
+
exports.BlobApiResponse = BlobApiResponse;
|
|
338
|
+
class TextApiResponse {
|
|
339
|
+
constructor(raw) {
|
|
340
|
+
this.raw = raw;
|
|
341
|
+
}
|
|
342
|
+
value() {
|
|
343
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
+
return yield this.raw.text();
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
;
|
|
348
|
+
}
|
|
349
|
+
exports.TextApiResponse = TextApiResponse;
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teemill/gtins",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "OpenAPI client for @teemill/gtins",
|
|
5
|
+
"author": "OpenAPI-Generator",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Teemill/public-api.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"typings": "./dist/index.d.ts",
|
|
12
|
+
"module": "./dist/esm/index.js",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc && tsc -p tsconfig.esm.json",
|
|
16
|
+
"prepare": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^4.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* GTINs API
|
|
5
|
+
* Manage GTINs
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 0.2.1
|
|
8
|
+
* Contact: hello@teemill.com
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import * as runtime from '../runtime';
|
|
17
|
+
import type {
|
|
18
|
+
ApiError,
|
|
19
|
+
AssignGtinRequest,
|
|
20
|
+
GTIN,
|
|
21
|
+
GTINsResponse,
|
|
22
|
+
ImportGtins202Response,
|
|
23
|
+
} from '../models/index';
|
|
24
|
+
import {
|
|
25
|
+
ApiErrorFromJSON,
|
|
26
|
+
ApiErrorToJSON,
|
|
27
|
+
AssignGtinRequestFromJSON,
|
|
28
|
+
AssignGtinRequestToJSON,
|
|
29
|
+
GTINFromJSON,
|
|
30
|
+
GTINToJSON,
|
|
31
|
+
GTINsResponseFromJSON,
|
|
32
|
+
GTINsResponseToJSON,
|
|
33
|
+
ImportGtins202ResponseFromJSON,
|
|
34
|
+
ImportGtins202ResponseToJSON,
|
|
35
|
+
} from '../models/index';
|
|
36
|
+
|
|
37
|
+
export interface AssignGtinOperationRequest {
|
|
38
|
+
project: string;
|
|
39
|
+
gtin: string;
|
|
40
|
+
assignGtinRequest?: AssignGtinRequest;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ImportGtinsRequest {
|
|
44
|
+
project: string;
|
|
45
|
+
body?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ListGtinsRequest {
|
|
49
|
+
project: string;
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
pageToken?: number;
|
|
52
|
+
search?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface UnassignGtinRequest {
|
|
56
|
+
project: string;
|
|
57
|
+
gtin: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
export class GTINsApi extends runtime.BaseAPI {
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Assign a GTIN to a variant
|
|
67
|
+
* Assign GTIN
|
|
68
|
+
*/
|
|
69
|
+
async assignGtinRaw(requestParameters: AssignGtinOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<GTIN>> {
|
|
70
|
+
if (requestParameters.project === null || requestParameters.project === undefined) {
|
|
71
|
+
throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling assignGtin.');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (requestParameters.gtin === null || requestParameters.gtin === undefined) {
|
|
75
|
+
throw new runtime.RequiredError('gtin','Required parameter requestParameters.gtin was null or undefined when calling assignGtin.');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const queryParameters: any = {};
|
|
79
|
+
|
|
80
|
+
if (requestParameters.project !== undefined) {
|
|
81
|
+
queryParameters['project'] = requestParameters.project;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
85
|
+
|
|
86
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
87
|
+
|
|
88
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
89
|
+
// oauth required
|
|
90
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("session-oauth", []);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
94
|
+
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // api-key authentication
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const response = await this.request({
|
|
98
|
+
path: `/v1/gtins/{gtin}/assign`.replace(`{${"gtin"}}`, encodeURIComponent(String(requestParameters.gtin))),
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers: headerParameters,
|
|
101
|
+
query: queryParameters,
|
|
102
|
+
body: AssignGtinRequestToJSON(requestParameters.assignGtinRequest),
|
|
103
|
+
}, initOverrides);
|
|
104
|
+
|
|
105
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => GTINFromJSON(jsonValue));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Assign a GTIN to a variant
|
|
110
|
+
* Assign GTIN
|
|
111
|
+
*/
|
|
112
|
+
async assignGtin(
|
|
113
|
+
project: string, gtin: string,
|
|
114
|
+
optionalParameters: runtime.OptionalOnly<AssignGtinOperationRequest> = {},
|
|
115
|
+
initOverrides?: RequestInit | runtime.InitOverrideFunction
|
|
116
|
+
): Promise<GTIN> {
|
|
117
|
+
const response = await this.assignGtinRaw(
|
|
118
|
+
{
|
|
119
|
+
project: project,gtin: gtin,
|
|
120
|
+
...optionalParameters,
|
|
121
|
+
},
|
|
122
|
+
initOverrides
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return await response.value();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Initiates a GTINs import from a CSV file. The result will be available as a notification in the dashboard.
|
|
130
|
+
* Import GTINs
|
|
131
|
+
*/
|
|
132
|
+
async importGtinsRaw(requestParameters: ImportGtinsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ImportGtins202Response>> {
|
|
133
|
+
if (requestParameters.project === null || requestParameters.project === undefined) {
|
|
134
|
+
throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling importGtins.');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const queryParameters: any = {};
|
|
138
|
+
|
|
139
|
+
if (requestParameters.project !== undefined) {
|
|
140
|
+
queryParameters['project'] = requestParameters.project;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
144
|
+
|
|
145
|
+
headerParameters['Content-Type'] = 'text/csv';
|
|
146
|
+
|
|
147
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
148
|
+
// oauth required
|
|
149
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("session-oauth", []);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
153
|
+
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // api-key authentication
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const response = await this.request({
|
|
157
|
+
path: `/v1/gtins/import`,
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: headerParameters,
|
|
160
|
+
query: queryParameters,
|
|
161
|
+
body: requestParameters.body as any,
|
|
162
|
+
}, initOverrides);
|
|
163
|
+
|
|
164
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => ImportGtins202ResponseFromJSON(jsonValue));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Initiates a GTINs import from a CSV file. The result will be available as a notification in the dashboard.
|
|
169
|
+
* Import GTINs
|
|
170
|
+
*/
|
|
171
|
+
async importGtins(
|
|
172
|
+
project: string,
|
|
173
|
+
optionalParameters: runtime.OptionalOnly<ImportGtinsRequest> = {},
|
|
174
|
+
initOverrides?: RequestInit | runtime.InitOverrideFunction
|
|
175
|
+
): Promise<ImportGtins202Response> {
|
|
176
|
+
const response = await this.importGtinsRaw(
|
|
177
|
+
{
|
|
178
|
+
project: project,
|
|
179
|
+
...optionalParameters,
|
|
180
|
+
},
|
|
181
|
+
initOverrides
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return await response.value();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* List GTINs
|
|
189
|
+
* List gtins
|
|
190
|
+
*/
|
|
191
|
+
async listGtinsRaw(requestParameters: ListGtinsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<GTINsResponse>> {
|
|
192
|
+
if (requestParameters.project === null || requestParameters.project === undefined) {
|
|
193
|
+
throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling listGtins.');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const queryParameters: any = {};
|
|
197
|
+
|
|
198
|
+
if (requestParameters.project !== undefined) {
|
|
199
|
+
queryParameters['project'] = requestParameters.project;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (requestParameters.pageSize !== undefined) {
|
|
203
|
+
queryParameters['pageSize'] = requestParameters.pageSize;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (requestParameters.pageToken !== undefined) {
|
|
207
|
+
queryParameters['pageToken'] = requestParameters.pageToken;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (requestParameters.search !== undefined) {
|
|
211
|
+
queryParameters['search'] = requestParameters.search;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
215
|
+
|
|
216
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
217
|
+
// oauth required
|
|
218
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("session-oauth", []);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
222
|
+
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // api-key authentication
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const response = await this.request({
|
|
226
|
+
path: `/v1/gtins`,
|
|
227
|
+
method: 'GET',
|
|
228
|
+
headers: headerParameters,
|
|
229
|
+
query: queryParameters,
|
|
230
|
+
}, initOverrides);
|
|
231
|
+
|
|
232
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => GTINsResponseFromJSON(jsonValue));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* List GTINs
|
|
237
|
+
* List gtins
|
|
238
|
+
*/
|
|
239
|
+
async listGtins(
|
|
240
|
+
project: string,
|
|
241
|
+
optionalParameters: runtime.OptionalOnly<ListGtinsRequest> = {},
|
|
242
|
+
initOverrides?: RequestInit | runtime.InitOverrideFunction
|
|
243
|
+
): Promise<GTINsResponse> {
|
|
244
|
+
const response = await this.listGtinsRaw(
|
|
245
|
+
{
|
|
246
|
+
project: project,
|
|
247
|
+
...optionalParameters,
|
|
248
|
+
},
|
|
249
|
+
initOverrides
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
return await response.value();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Unassign a GTIN from a variant
|
|
257
|
+
* Unassign GTIN
|
|
258
|
+
*/
|
|
259
|
+
async unassignGtinRaw(requestParameters: UnassignGtinRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
|
|
260
|
+
if (requestParameters.project === null || requestParameters.project === undefined) {
|
|
261
|
+
throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling unassignGtin.');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (requestParameters.gtin === null || requestParameters.gtin === undefined) {
|
|
265
|
+
throw new runtime.RequiredError('gtin','Required parameter requestParameters.gtin was null or undefined when calling unassignGtin.');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const queryParameters: any = {};
|
|
269
|
+
|
|
270
|
+
if (requestParameters.project !== undefined) {
|
|
271
|
+
queryParameters['project'] = requestParameters.project;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
275
|
+
|
|
276
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
277
|
+
// oauth required
|
|
278
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("session-oauth", []);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
282
|
+
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // api-key authentication
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const response = await this.request({
|
|
286
|
+
path: `/v1/gtins/{gtin}/unassign`.replace(`{${"gtin"}}`, encodeURIComponent(String(requestParameters.gtin))),
|
|
287
|
+
method: 'POST',
|
|
288
|
+
headers: headerParameters,
|
|
289
|
+
query: queryParameters,
|
|
290
|
+
}, initOverrides);
|
|
291
|
+
|
|
292
|
+
return new runtime.VoidApiResponse(response);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Unassign a GTIN from a variant
|
|
297
|
+
* Unassign GTIN
|
|
298
|
+
*/
|
|
299
|
+
async unassignGtin(
|
|
300
|
+
project: string, gtin: string,
|
|
301
|
+
initOverrides?: RequestInit | runtime.InitOverrideFunction
|
|
302
|
+
): Promise<void> {
|
|
303
|
+
await this.unassignGtinRaw(
|
|
304
|
+
{
|
|
305
|
+
project: project,gtin: gtin,
|
|
306
|
+
},
|
|
307
|
+
initOverrides
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
}
|