@entegrasyonapp/lib 1.0.0

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.
Files changed (122) hide show
  1. package/README.md +19 -0
  2. package/dist/common/client.d.ts +12 -0
  3. package/dist/common/client.d.ts.map +1 -0
  4. package/dist/common/client.js +9 -0
  5. package/dist/common/client.js.map +1 -0
  6. package/dist/common/kv-handler.d.ts +17 -0
  7. package/dist/common/kv-handler.d.ts.map +1 -0
  8. package/dist/common/kv-handler.js +24 -0
  9. package/dist/common/kv-handler.js.map +1 -0
  10. package/dist/common/request.d.ts +21 -0
  11. package/dist/common/request.d.ts.map +1 -0
  12. package/dist/common/request.js +9 -0
  13. package/dist/common/request.js.map +1 -0
  14. package/dist/index.d.ts +15 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +42 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/integrations/boyner/v1/client.d.ts +30 -0
  19. package/dist/integrations/boyner/v1/client.d.ts.map +1 -0
  20. package/dist/integrations/boyner/v1/client.js +30 -0
  21. package/dist/integrations/boyner/v1/client.js.map +1 -0
  22. package/dist/integrations/boyner/v1/index.d.ts +2 -0
  23. package/dist/integrations/boyner/v1/index.d.ts.map +1 -0
  24. package/dist/integrations/boyner/v1/index.js +6 -0
  25. package/dist/integrations/boyner/v1/index.js.map +1 -0
  26. package/dist/integrations/boyner/v1/request.d.ts +20 -0
  27. package/dist/integrations/boyner/v1/request.d.ts.map +1 -0
  28. package/dist/integrations/boyner/v1/request.js +67 -0
  29. package/dist/integrations/boyner/v1/request.js.map +1 -0
  30. package/dist/integrations/ciceksepeti/v1/client.d.ts +33 -0
  31. package/dist/integrations/ciceksepeti/v1/client.d.ts.map +1 -0
  32. package/dist/integrations/ciceksepeti/v1/client.js +39 -0
  33. package/dist/integrations/ciceksepeti/v1/client.js.map +1 -0
  34. package/dist/integrations/ciceksepeti/v1/index.d.ts +2 -0
  35. package/dist/integrations/ciceksepeti/v1/index.d.ts.map +1 -0
  36. package/dist/integrations/ciceksepeti/v1/index.js +7 -0
  37. package/dist/integrations/ciceksepeti/v1/index.js.map +1 -0
  38. package/dist/integrations/ciceksepeti/v1/request.d.ts +20 -0
  39. package/dist/integrations/ciceksepeti/v1/request.d.ts.map +1 -0
  40. package/dist/integrations/ciceksepeti/v1/request.js +63 -0
  41. package/dist/integrations/ciceksepeti/v1/request.js.map +1 -0
  42. package/dist/integrations/hepsiburada/v1/client.d.ts +42 -0
  43. package/dist/integrations/hepsiburada/v1/client.d.ts.map +1 -0
  44. package/dist/integrations/hepsiburada/v1/client.js +48 -0
  45. package/dist/integrations/hepsiburada/v1/client.js.map +1 -0
  46. package/dist/integrations/hepsiburada/v1/index.d.ts +2 -0
  47. package/dist/integrations/hepsiburada/v1/index.d.ts.map +1 -0
  48. package/dist/integrations/hepsiburada/v1/index.js +8 -0
  49. package/dist/integrations/hepsiburada/v1/index.js.map +1 -0
  50. package/dist/integrations/hepsiburada/v1/request.d.ts +20 -0
  51. package/dist/integrations/hepsiburada/v1/request.d.ts.map +1 -0
  52. package/dist/integrations/hepsiburada/v1/request.js +67 -0
  53. package/dist/integrations/hepsiburada/v1/request.js.map +1 -0
  54. package/dist/integrations/lcw/v1/client.d.ts +42 -0
  55. package/dist/integrations/lcw/v1/client.d.ts.map +1 -0
  56. package/dist/integrations/lcw/v1/client.js +42 -0
  57. package/dist/integrations/lcw/v1/client.js.map +1 -0
  58. package/dist/integrations/lcw/v1/index.d.ts +2 -0
  59. package/dist/integrations/lcw/v1/index.d.ts.map +1 -0
  60. package/dist/integrations/lcw/v1/index.js +8 -0
  61. package/dist/integrations/lcw/v1/index.js.map +1 -0
  62. package/dist/integrations/lcw/v1/request.d.ts +21 -0
  63. package/dist/integrations/lcw/v1/request.d.ts.map +1 -0
  64. package/dist/integrations/lcw/v1/request.js +97 -0
  65. package/dist/integrations/lcw/v1/request.js.map +1 -0
  66. package/dist/integrations/n11/v2/client.d.ts +29 -0
  67. package/dist/integrations/n11/v2/client.d.ts.map +1 -0
  68. package/dist/integrations/n11/v2/client.js +30 -0
  69. package/dist/integrations/n11/v2/client.js.map +1 -0
  70. package/dist/integrations/n11/v2/index.d.ts +2 -0
  71. package/dist/integrations/n11/v2/index.d.ts.map +1 -0
  72. package/dist/integrations/n11/v2/index.js +6 -0
  73. package/dist/integrations/n11/v2/index.js.map +1 -0
  74. package/dist/integrations/n11/v2/request.d.ts +20 -0
  75. package/dist/integrations/n11/v2/request.d.ts.map +1 -0
  76. package/dist/integrations/n11/v2/request.js +65 -0
  77. package/dist/integrations/n11/v2/request.js.map +1 -0
  78. package/dist/integrations/ozon/v1/client.d.ts +36 -0
  79. package/dist/integrations/ozon/v1/client.d.ts.map +1 -0
  80. package/dist/integrations/ozon/v1/client.js +38 -0
  81. package/dist/integrations/ozon/v1/client.js.map +1 -0
  82. package/dist/integrations/ozon/v1/index.d.ts +2 -0
  83. package/dist/integrations/ozon/v1/index.d.ts.map +1 -0
  84. package/dist/integrations/ozon/v1/index.js +7 -0
  85. package/dist/integrations/ozon/v1/index.js.map +1 -0
  86. package/dist/integrations/ozon/v1/request.d.ts +20 -0
  87. package/dist/integrations/ozon/v1/request.d.ts.map +1 -0
  88. package/dist/integrations/ozon/v1/request.js +65 -0
  89. package/dist/integrations/ozon/v1/request.js.map +1 -0
  90. package/dist/integrations/pttavm/v1/client.d.ts +30 -0
  91. package/dist/integrations/pttavm/v1/client.d.ts.map +1 -0
  92. package/dist/integrations/pttavm/v1/client.js +30 -0
  93. package/dist/integrations/pttavm/v1/client.js.map +1 -0
  94. package/dist/integrations/pttavm/v1/index.d.ts +2 -0
  95. package/dist/integrations/pttavm/v1/index.d.ts.map +1 -0
  96. package/dist/integrations/pttavm/v1/index.js +6 -0
  97. package/dist/integrations/pttavm/v1/index.js.map +1 -0
  98. package/dist/integrations/pttavm/v1/request.d.ts +20 -0
  99. package/dist/integrations/pttavm/v1/request.d.ts.map +1 -0
  100. package/dist/integrations/pttavm/v1/request.js +66 -0
  101. package/dist/integrations/pttavm/v1/request.js.map +1 -0
  102. package/dist/integrations/trendyol/v1/client.d.ts +35 -0
  103. package/dist/integrations/trendyol/v1/client.d.ts.map +1 -0
  104. package/dist/integrations/trendyol/v1/client.js +39 -0
  105. package/dist/integrations/trendyol/v1/client.js.map +1 -0
  106. package/dist/integrations/trendyol/v1/index.d.ts +2 -0
  107. package/dist/integrations/trendyol/v1/index.d.ts.map +1 -0
  108. package/dist/integrations/trendyol/v1/index.js +7 -0
  109. package/dist/integrations/trendyol/v1/index.js.map +1 -0
  110. package/dist/integrations/trendyol/v1/request.d.ts +20 -0
  111. package/dist/integrations/trendyol/v1/request.d.ts.map +1 -0
  112. package/dist/integrations/trendyol/v1/request.js +67 -0
  113. package/dist/integrations/trendyol/v1/request.js.map +1 -0
  114. package/dist/utils/backoff-request.d.ts +33 -0
  115. package/dist/utils/backoff-request.d.ts.map +1 -0
  116. package/dist/utils/backoff-request.js +67 -0
  117. package/dist/utils/backoff-request.js.map +1 -0
  118. package/dist/utils/request-id.d.ts +17 -0
  119. package/dist/utils/request-id.d.ts.map +1 -0
  120. package/dist/utils/request-id.js +72 -0
  121. package/dist/utils/request-id.js.map +1 -0
  122. package/package.json +45 -0
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Request module for N11
4
+ * @package entegrasyonapp/lib
5
+ * @author Ekin Karadeniz
6
+ * @copyright 2023-2024
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Request = void 0;
13
+ const axios_1 = __importDefault(require("axios"));
14
+ const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
15
+ const request_id_1 = require("../../../utils/request-id");
16
+ class Request {
17
+ client;
18
+ request;
19
+ axiosConfig;
20
+ axiosMockCallback;
21
+ constructor(client, request) {
22
+ this.client = client;
23
+ this.request = request;
24
+ if (this.request.headers == undefined) {
25
+ this.request.headers = {};
26
+ }
27
+ this.request.headers['Accept'] = this.request.headers?.['Accept'] ?? 'application/json';
28
+ this.request.headers['User-Agent'] = this.request.headers?.['User-Agent'] ?? 'Entegrasyon.app/1.0';
29
+ this.request.headers['appkey'] = this.client.params.credentials.apiKey;
30
+ this.request.headers['appsecret'] = this.client.params.credentials.apiSecret;
31
+ if (this.request.body) {
32
+ this.request.headers['Content-Type'] = this.request.headers?.['Content-Type'] ?? 'application/json';
33
+ }
34
+ this.axiosConfig = {
35
+ baseURL: this.client.getBaseURL(),
36
+ timeout: this.client.params.options?.timeout,
37
+ proxy: this.client.params.options?.proxy,
38
+ method: this.request.method,
39
+ url: this.request.path,
40
+ params: this.request.params,
41
+ data: this.request.body,
42
+ headers: this.request.headers,
43
+ responseType: 'json',
44
+ validateStatus: (status) => {
45
+ return ![401, 403, 404].includes(status);
46
+ },
47
+ };
48
+ }
49
+ setAxiosMock(callback) {
50
+ this.axiosMockCallback = callback;
51
+ }
52
+ getRequestId() {
53
+ return (0, request_id_1.generateRequestId)(this.axiosConfig, 'n11-v1');
54
+ }
55
+ async send() {
56
+ // mocks will be used during the tests
57
+ if (this.axiosMockCallback != undefined) {
58
+ const mock = new axios_mock_adapter_1.default(axios_1.default);
59
+ this.axiosMockCallback(mock);
60
+ }
61
+ return (0, axios_1.default)(this.axiosConfig);
62
+ }
63
+ }
64
+ exports.Request = Request;
65
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/integrations/n11/v2/request.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,kDAAiE;AAEjE,4EAA6C;AAE7C,0DAA8D;AAE9D,MAAa,OAAO;IAII;IAAwB;IAHpC,WAAW,CAA8B;IACzC,iBAAiB,CAAY;IAErC,YAAoB,MAAc,EAAU,OAA+B;QAAvD,WAAM,GAAN,MAAM,CAAQ;QAAU,YAAO,GAAP,OAA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AC3B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,YAAY,EAAE,MAAM;YACpB,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE;gBAC/B,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC7C,CAAC;SACJ,CAAC;IACN,CAAC;IAED,YAAY,CAAC,QAAkB;QAC3B,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAC;IACtC,CAAC;IAED,YAAY;QACR,OAAO,IAAA,8BAAiB,EAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,IAAI;QAEN,sCAAsC;QACtC,IAAI,IAAI,CAAC,iBAAiB,IAAI,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,IAAI,4BAAW,CAAC,eAAK,CAAC,CAAC;YACpC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,IAAA,eAAK,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACJ;AAlDD,0BAkDC","sourcesContent":["/**\n * Request module for N11\n * @package entegrasyonapp/lib\n * @author Ekin Karadeniz\n * @copyright 2023-2024\n */\n\nimport axios, { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport { Client } from \"./client\";\nimport MockAdapter from \"axios-mock-adapter\";\nimport { IRequest, IRequestInput } from \"./../../../common/request\";\nimport { generateRequestId } from \"../../../utils/request-id\";\n\nexport class Request implements IRequest {\n private axiosConfig: Partial<AxiosRequestConfig>;\n private axiosMockCallback?: Function;\n\n constructor(private client: Client, private request: Partial<IRequestInput>) {\n if (this.request.headers == undefined) {\n this.request.headers = {};\n }\n this.request.headers['Accept'] = this.request.headers?.['Accept'] ?? 'application/json';\n this.request.headers['User-Agent'] = this.request.headers?.['User-Agent'] ?? 'Entegrasyon.app/1.0';\n this.request.headers['appkey'] = this.client.params.credentials.apiKey;\n this.request.headers['appsecret'] = this.client.params.credentials.apiSecret;\n if (this.request.body) {\n this.request.headers['Content-Type'] = this.request.headers?.['Content-Type'] ?? 'application/json';\n }\n\n this.axiosConfig = {\n baseURL: this.client.getBaseURL(),\n timeout: this.client.params.options?.timeout,\n proxy: this.client.params.options?.proxy,\n method: this.request.method,\n url: this.request.path,\n params: this.request.params,\n data: this.request.body,\n headers: this.request.headers,\n responseType: 'json',\n validateStatus: (status: number) => {\n return ![401, 403, 404].includes(status);\n },\n };\n }\n\n setAxiosMock(callback: Function) {\n this.axiosMockCallback = callback;\n }\n\n getRequestId(): string {\n return generateRequestId(this.axiosConfig, 'n11-v1');\n }\n\n async send(): Promise<AxiosResponse> {\n\n // mocks will be used during the tests\n if (this.axiosMockCallback != undefined) {\n const mock = new MockAdapter(axios);\n this.axiosMockCallback(mock);\n }\n\n return axios(this.axiosConfig);\n }\n}"]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Client module for Ozon
3
+ * @package entegrasyonapp/lib
4
+ * @author Ekin Karadeniz
5
+ * @copyright 2023-2024
6
+ */
7
+ import { Request } from "./request";
8
+ import { IClient } from "../../../common/client";
9
+ import { IRequestInput } from "../../../common/request";
10
+ export interface ICredentials {
11
+ clientId: string;
12
+ apiKey: string;
13
+ }
14
+ export interface IOptions {
15
+ debug: boolean;
16
+ timeout: number;
17
+ proxy: any;
18
+ }
19
+ export declare enum Language {
20
+ Default = "DEFAULT",
21
+ RU = "RU",
22
+ EN = "EN",
23
+ TR = "TR",
24
+ ZH_HANS = "ZH_HANS"
25
+ }
26
+ export interface IClientParams {
27
+ credentials: ICredentials;
28
+ options?: Partial<IOptions>;
29
+ }
30
+ export declare class Client implements IClient {
31
+ params: IClientParams;
32
+ constructor(params: IClientParams);
33
+ getBaseURL(): string;
34
+ request(request: Partial<IRequestInput>): Request;
35
+ }
36
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/integrations/ozon/v1/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;CACd;AAED,oBAAY,QAAQ;IAChB,OAAO,YAAY;IACnB,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,OAAO,YAAY;CACtB;AAED,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/B;AAED,qBAAa,MAAO,YAAW,OAAO;IACf,MAAM,EAAE,aAAa;gBAArB,MAAM,EAAE,aAAa;IASxC,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO;CAGpD"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Client module for Ozon
4
+ * @package entegrasyonapp/lib
5
+ * @author Ekin Karadeniz
6
+ * @copyright 2023-2024
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Client = exports.Language = void 0;
10
+ const request_1 = require("./request");
11
+ var Language;
12
+ (function (Language) {
13
+ Language["Default"] = "DEFAULT";
14
+ Language["RU"] = "RU";
15
+ Language["EN"] = "EN";
16
+ Language["TR"] = "TR";
17
+ Language["ZH_HANS"] = "ZH_HANS";
18
+ })(Language || (exports.Language = Language = {}));
19
+ class Client {
20
+ params;
21
+ constructor(params) {
22
+ this.params = params;
23
+ const defaultOptions = {
24
+ debug: false,
25
+ timeout: 0, // no timeout
26
+ proxy: undefined
27
+ };
28
+ this.params.options = { ...defaultOptions, ...this.params.options }; // {...{foo:'bar'}, ...undefined} == {foo:'bar'}
29
+ }
30
+ getBaseURL() {
31
+ return 'https://api-seller.ozon.ru';
32
+ }
33
+ request(request) {
34
+ return new request_1.Request(this, request);
35
+ }
36
+ }
37
+ exports.Client = Client;
38
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/integrations/ozon/v1/client.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAoC;AAepC,IAAY,QAMX;AAND,WAAY,QAAQ;IAChB,+BAAmB,CAAA;IACnB,qBAAS,CAAA;IACT,qBAAS,CAAA;IACT,qBAAS,CAAA;IACT,+BAAmB,CAAA;AACvB,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAOD,MAAa,MAAM;IACI;IAAnB,YAAmB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QACpC,MAAM,cAAc,GAAa;YAC7B,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,CAAC,EAAE,aAAa;YACzB,KAAK,EAAE,SAAS;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,gDAAgD;IACzH,CAAC;IAED,UAAU;QACN,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,OAA+B;QACnC,OAAO,IAAI,iBAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACJ;AAjBD,wBAiBC","sourcesContent":["/**\n * Client module for Ozon\n * @package entegrasyonapp/lib\n * @author Ekin Karadeniz\n * @copyright 2023-2024\n */\n\nimport { Request } from \"./request\";\nimport { IClient } from \"../../../common/client\";\nimport { IRequestInput } from \"../../../common/request\";\n\nexport interface ICredentials {\n clientId: string;\n apiKey: string;\n}\n\nexport interface IOptions {\n debug: boolean;\n timeout: number; // milliseconds\n proxy: any;\n}\n\nexport enum Language {\n Default = 'DEFAULT',\n RU = 'RU',\n EN = 'EN',\n TR = 'TR',\n ZH_HANS = 'ZH_HANS',\n}\n\nexport interface IClientParams {\n credentials: ICredentials;\n options?: Partial<IOptions>;\n}\n\nexport class Client implements IClient {\n constructor(public params: IClientParams) {\n const defaultOptions: IOptions = {\n debug: false,\n timeout: 0, // no timeout\n proxy: undefined\n };\n this.params.options = { ...defaultOptions, ...this.params.options }; // {...{foo:'bar'}, ...undefined} == {foo:'bar'}\n }\n\n getBaseURL(): string {\n return 'https://api-seller.ozon.ru';\n }\n\n request(request: Partial<IRequestInput>): Request {\n return new Request(this, request);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { Client, Language } from "./client";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/ozon/v1/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Language = exports.Client = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
6
+ Object.defineProperty(exports, "Language", { enumerable: true, get: function () { return client_1.Language; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integrations/ozon/v1/index.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA","sourcesContent":["export { Client, Language } from \"./client\";\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Request module for Ozon
3
+ * @package entegrasyonapp/lib
4
+ * @author Ekin Karadeniz
5
+ * @copyright 2023-2024
6
+ */
7
+ import { AxiosResponse } from "axios";
8
+ import { Client } from "./client";
9
+ import { IRequest, IRequestInput } from "../../../common/request";
10
+ export declare class Request implements IRequest {
11
+ private client;
12
+ private request;
13
+ private axiosConfig;
14
+ private axiosMockCallback?;
15
+ constructor(client: Client, request: Partial<IRequestInput>);
16
+ setAxiosMock(callback: Function): void;
17
+ getRequestId(): string;
18
+ send(): Promise<AxiosResponse>;
19
+ }
20
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/integrations/ozon/v1/request.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAsB,aAAa,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGlE,qBAAa,OAAQ,YAAW,QAAQ;IAIxB,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;IAHnD,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,iBAAiB,CAAC,CAAW;gBAEjB,MAAM,EAAE,MAAM,EAAU,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC;IA4B3E,YAAY,CAAC,QAAQ,EAAE,QAAQ;IAI/B,YAAY,IAAI,MAAM;IAIhB,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;CAUvC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Request module for Ozon
4
+ * @package entegrasyonapp/lib
5
+ * @author Ekin Karadeniz
6
+ * @copyright 2023-2024
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Request = void 0;
13
+ const axios_1 = __importDefault(require("axios"));
14
+ const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
15
+ const request_id_1 = require("../../../utils/request-id");
16
+ class Request {
17
+ client;
18
+ request;
19
+ axiosConfig;
20
+ axiosMockCallback;
21
+ constructor(client, request) {
22
+ this.client = client;
23
+ this.request = request;
24
+ if (this.request.headers == undefined) {
25
+ this.request.headers = {};
26
+ }
27
+ this.request.headers['Accept'] = this.request.headers?.['Accept'] ?? 'application/json';
28
+ this.request.headers['User-Agent'] = this.request.headers?.['User-Agent'] ?? 'Entegrasyon.app/1.0';
29
+ this.request.headers['Client-Id'] = this.client.params.credentials.clientId;
30
+ this.request.headers['Api-Key'] = this.client.params.credentials.apiKey;
31
+ if (this.request.body) {
32
+ this.request.headers['Content-Type'] = this.request.headers?.['Content-Type'] ?? 'application/json';
33
+ }
34
+ this.axiosConfig = {
35
+ baseURL: this.client.getBaseURL(),
36
+ timeout: this.client.params.options?.timeout,
37
+ proxy: this.client.params.options?.proxy,
38
+ method: this.request.method,
39
+ url: this.request.path,
40
+ params: this.request.params,
41
+ data: this.request.body,
42
+ headers: this.request.headers,
43
+ responseType: 'json',
44
+ validateStatus: (status) => {
45
+ return ![401, 403, 404, 500].includes(status);
46
+ },
47
+ };
48
+ }
49
+ setAxiosMock(callback) {
50
+ this.axiosMockCallback = callback;
51
+ }
52
+ getRequestId() {
53
+ return (0, request_id_1.generateRequestId)(this.axiosConfig, 'ozon-v1');
54
+ }
55
+ async send() {
56
+ // mocks will be used during the tests
57
+ if (this.axiosMockCallback != undefined) {
58
+ const mock = new axios_mock_adapter_1.default(axios_1.default);
59
+ this.axiosMockCallback(mock);
60
+ }
61
+ return (0, axios_1.default)(this.axiosConfig);
62
+ }
63
+ }
64
+ exports.Request = Request;
65
+ //# source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AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport { Client } from \"./client\";\nimport MockAdapter from \"axios-mock-adapter\";\nimport { IRequest, IRequestInput } from \"../../../common/request\";\nimport { generateRequestId } from \"../../../utils/request-id\";\n\nexport class Request implements IRequest {\n private axiosConfig: Partial<AxiosRequestConfig>;\n private axiosMockCallback?: Function;\n\n constructor(private client: Client, private request: Partial<IRequestInput>) {\n if (this.request.headers == undefined) {\n this.request.headers = {};\n }\n this.request.headers['Accept'] = this.request.headers?.['Accept'] ?? 'application/json';\n this.request.headers['User-Agent'] = this.request.headers?.['User-Agent'] ?? 'Entegrasyon.app/1.0';\n this.request.headers['Client-Id'] = this.client.params.credentials.clientId;\n this.request.headers['Api-Key'] = this.client.params.credentials.apiKey;\n if (this.request.body) {\n this.request.headers['Content-Type'] = this.request.headers?.['Content-Type'] ?? 'application/json';\n }\n\n this.axiosConfig = {\n baseURL: this.client.getBaseURL(),\n timeout: this.client.params.options?.timeout,\n proxy: this.client.params.options?.proxy,\n method: this.request.method,\n url: this.request.path,\n params: this.request.params,\n data: this.request.body,\n headers: this.request.headers,\n responseType: 'json',\n validateStatus: (status: number) => {\n return ![401, 403, 404, 500].includes(status);\n },\n };\n }\n\n setAxiosMock(callback: Function) {\n this.axiosMockCallback = callback;\n }\n\n getRequestId(): string {\n return generateRequestId(this.axiosConfig, 'ozon-v1');\n }\n\n async send(): Promise<AxiosResponse> {\n\n // mocks will be used during the tests\n if (this.axiosMockCallback != undefined) {\n const mock = new MockAdapter(axios);\n this.axiosMockCallback(mock);\n }\n\n return axios(this.axiosConfig);\n }\n}"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Client module for PttAvm
3
+ * @package entegrasyonapp/lib
4
+ * @author Ekin Karadeniz
5
+ * @copyright 2023-2024
6
+ */
7
+ import { Request } from "./request";
8
+ import { IClient } from "./../../../common/client";
9
+ import { IRequestInput } from "./../../../common/request";
10
+ export interface ICredentials {
11
+ supplierId: string;
12
+ username: string;
13
+ password: string;
14
+ }
15
+ export interface IOptions {
16
+ debug: boolean;
17
+ timeout: number;
18
+ proxy: any;
19
+ }
20
+ export interface IClientParams {
21
+ credentials: ICredentials;
22
+ options?: Partial<IOptions>;
23
+ }
24
+ export declare class Client implements IClient {
25
+ params: IClientParams;
26
+ constructor(params: IClientParams);
27
+ getBaseURL(): string;
28
+ request(request: Partial<IRequestInput>): Request;
29
+ }
30
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/integrations/pttavm/v1/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/B;AAED,qBAAa,MAAO,YAAW,OAAO;IACf,MAAM,EAAE,aAAa;gBAArB,MAAM,EAAE,aAAa;IASxC,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO;CAGpD"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Client module for PttAvm
4
+ * @package entegrasyonapp/lib
5
+ * @author Ekin Karadeniz
6
+ * @copyright 2023-2024
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Client = void 0;
10
+ const request_1 = require("./request");
11
+ class Client {
12
+ params;
13
+ constructor(params) {
14
+ this.params = params;
15
+ const defaultOptions = {
16
+ debug: false,
17
+ timeout: 0, // no timeout
18
+ proxy: undefined
19
+ };
20
+ this.params.options = { ...defaultOptions, ...this.params.options }; // {...{foo:'bar'}, ...undefined} == {foo:'bar'}
21
+ }
22
+ getBaseURL() {
23
+ return `https://ws.pttavm.com:93/service.svc`;
24
+ }
25
+ request(request) {
26
+ return new request_1.Request(this, request);
27
+ }
28
+ }
29
+ exports.Client = Client;
30
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/integrations/pttavm/v1/client.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAoC;AAqBpC,MAAa,MAAM;IACI;IAAnB,YAAmB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QACpC,MAAM,cAAc,GAAa;YAC7B,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,CAAC,EAAE,aAAa;YACzB,KAAK,EAAE,SAAS;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,gDAAgD;IACzH,CAAC;IAED,UAAU;QACN,OAAO,sCAAsC,CAAC;IAClD,CAAC;IAED,OAAO,CAAC,OAA+B;QACnC,OAAO,IAAI,iBAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACJ;AAjBD,wBAiBC","sourcesContent":["/**\n * Client module for PttAvm\n * @package entegrasyonapp/lib\n * @author Ekin Karadeniz\n * @copyright 2023-2024\n */\n\nimport { Request } from \"./request\";\nimport { IClient } from \"./../../../common/client\";\nimport { IRequestInput } from \"./../../../common/request\";\n\nexport interface ICredentials {\n supplierId: string;\n username: string;\n password: string;\n}\n\nexport interface IOptions {\n debug: boolean;\n timeout: number; // milliseconds\n proxy: any;\n}\n\nexport interface IClientParams {\n credentials: ICredentials;\n options?: Partial<IOptions>;\n}\n\nexport class Client implements IClient {\n constructor(public params: IClientParams) {\n const defaultOptions: IOptions = {\n debug: false,\n timeout: 0, // no timeout\n proxy: undefined\n };\n this.params.options = { ...defaultOptions, ...this.params.options }; // {...{foo:'bar'}, ...undefined} == {foo:'bar'}\n }\n\n getBaseURL(): string {\n return `https://ws.pttavm.com:93/service.svc`;\n }\n\n request(request: Partial<IRequestInput>): Request {\n return new Request(this, request);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { Client } from "./client";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/pttavm/v1/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integrations/pttavm/v1/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA","sourcesContent":["export { Client } from \"./client\";\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Request module for PttAvm
3
+ * @package entegrasyonapp/lib
4
+ * @author Ekin Karadeniz
5
+ * @copyright 2023-2024
6
+ */
7
+ import { AxiosResponse } from "axios";
8
+ import { Client } from "./client";
9
+ import { IRequest, IRequestInput } from "./../../../common/request";
10
+ export declare class Request implements IRequest {
11
+ private client;
12
+ private request;
13
+ private axiosConfig;
14
+ private axiosMockCallback?;
15
+ constructor(client: Client, request: Partial<IRequestInput>);
16
+ setAxiosMock(callback: Function): void;
17
+ getRequestId(): string;
18
+ send(): Promise<AxiosResponse>;
19
+ }
20
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/integrations/pttavm/v1/request.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAsB,aAAa,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGpE,qBAAa,OAAQ,YAAW,QAAQ;IAIxB,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;IAHnD,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,iBAAiB,CAAC,CAAW;gBAEjB,MAAM,EAAE,MAAM,EAAU,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC;IA8B3E,YAAY,CAAC,QAAQ,EAAE,QAAQ;IAI/B,YAAY,IAAI,MAAM;IAIhB,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;CAUvC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * Request module for PttAvm
4
+ * @package entegrasyonapp/lib
5
+ * @author Ekin Karadeniz
6
+ * @copyright 2023-2024
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Request = void 0;
13
+ const axios_1 = __importDefault(require("axios"));
14
+ const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
15
+ const request_id_1 = require("../../../utils/request-id");
16
+ class Request {
17
+ client;
18
+ request;
19
+ axiosConfig;
20
+ axiosMockCallback;
21
+ constructor(client, request) {
22
+ this.client = client;
23
+ this.request = request;
24
+ if (this.request.headers == undefined) {
25
+ this.request.headers = {};
26
+ }
27
+ this.request.headers['Accept'] = this.request.headers?.['Accept'] ?? 'text/xml';
28
+ this.request.headers['Content-Type'] = this.request.headers?.['Content-Type'] ?? 'text/xml;charset=utf-8';
29
+ this.request.headers['User-Agent'] = this.request.headers?.['User-Agent'] ?? 'Entegrasyon.app/1.0';
30
+ this.request.headers['SOAPAction'] = `http://tempuri.org/IService/${this.request.soapAction}`;
31
+ // PttAvm uses POST as a default method.
32
+ if (!this.request.method) {
33
+ this.request.method = 'post';
34
+ }
35
+ this.axiosConfig = {
36
+ baseURL: this.client.getBaseURL(),
37
+ timeout: this.client.params.options?.timeout,
38
+ proxy: this.client.params.options?.proxy,
39
+ method: this.request.method,
40
+ url: this.request.path,
41
+ params: this.request.params,
42
+ data: this.request.body,
43
+ headers: this.request.headers,
44
+ responseType: 'text',
45
+ validateStatus: (status) => {
46
+ return ![401, 403, 404, 415].includes(status);
47
+ },
48
+ };
49
+ }
50
+ setAxiosMock(callback) {
51
+ this.axiosMockCallback = callback;
52
+ }
53
+ getRequestId() {
54
+ return (0, request_id_1.generateRequestId)(this.axiosConfig, 'pttavm-v1');
55
+ }
56
+ async send() {
57
+ // mocks will be used during the tests
58
+ if (this.axiosMockCallback != undefined) {
59
+ const mock = new axios_mock_adapter_1.default(axios_1.default);
60
+ this.axiosMockCallback(mock);
61
+ }
62
+ return (0, axios_1.default)(this.axiosConfig);
63
+ }
64
+ }
65
+ exports.Request = Request;
66
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/integrations/pttavm/v1/request.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,kDAAiE;AAEjE,4EAA6C;AAE7C,0DAA8D;AAE9D,MAAa,OAAO;IAII;IAAwB;IAHpC,WAAW,CAA8B;IACzC,iBAAiB,CAAY;IAErC,YAAoB,MAAc,EAAU,OAA+B;QAAvD,WAAM,GAAN,MAAM,CAAQ;QA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AC,IAAI;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,YAAY,EAAE,MAAM;YACpB,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE;gBAC/B,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClD,CAAC;SACJ,CAAC;IACN,CAAC;IAED,YAAY,CAAC,QAAkB;QAC3B,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAC;IACtC,CAAC;IAED,YAAY;QACR,OAAO,IAAA,8BAAiB,EAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,IAAI;QAEN,sCAAsC;QACtC,IAAI,IAAI,CAAC,iBAAiB,IAAI,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,IAAI,4BAAW,CAAC,eAAK,CAAC,CAAC;YACpC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,IAAA,eAAK,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACJ;AApDD,0BAoDC","sourcesContent":["/**\n * Request module for PttAvm\n * @package entegrasyonapp/lib\n * @author Ekin Karadeniz\n * @copyright 2023-2024\n */\n\nimport axios, { AxiosRequestConfig, AxiosResponse } from \"axios\";\nimport { Client } from \"./client\";\nimport MockAdapter from \"axios-mock-adapter\";\nimport { IRequest, IRequestInput } from \"./../../../common/request\";\nimport { generateRequestId } from \"../../../utils/request-id\";\n\nexport class Request implements IRequest {\n private axiosConfig: Partial<AxiosRequestConfig>;\n private axiosMockCallback?: Function;\n\n constructor(private client: Client, private request: Partial<IRequestInput>) {\n if (this.request.headers == undefined) {\n this.request.headers = {};\n }\n this.request.headers['Accept'] = this.request.headers?.['Accept'] ?? 'text/xml';\n this.request.headers['Content-Type'] = this.request.headers?.['Content-Type'] ?? 'text/xml;charset=utf-8';\n this.request.headers['User-Agent'] = this.request.headers?.['User-Agent'] ?? 'Entegrasyon.app/1.0';\n this.request.headers['SOAPAction'] = `http://tempuri.org/IService/${this.request.soapAction}`;\n\n // PttAvm uses POST as a default method.\n if (!this.request.method) {\n this.request.method = 'post';\n }\n\n this.axiosConfig = {\n baseURL: this.client.getBaseURL(),\n timeout: this.client.params.options?.timeout,\n proxy: this.client.params.options?.proxy,\n method: this.request.method,\n url: this.request.path,\n params: this.request.params,\n data: this.request.body,\n headers: this.request.headers,\n responseType: 'text',\n validateStatus: (status: number) => {\n return ![401, 403, 404, 415].includes(status);\n },\n };\n }\n\n setAxiosMock(callback: Function) {\n this.axiosMockCallback = callback;\n }\n\n getRequestId(): string {\n return generateRequestId(this.axiosConfig, 'pttavm-v1');\n }\n\n async send(): Promise<AxiosResponse> {\n\n // mocks will be used during the tests\n if (this.axiosMockCallback != undefined) {\n const mock = new MockAdapter(axios);\n this.axiosMockCallback(mock);\n }\n\n return axios(this.axiosConfig);\n }\n}"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Client module for Trendyol
3
+ * @package entegrasyonapp/lib
4
+ * @author Ekin Karadeniz
5
+ * @copyright 2023-2024
6
+ */
7
+ import { Request } from "./request";
8
+ import { IClient } from "./../../../common/client";
9
+ import { IRequestInput } from "./../../../common/request";
10
+ export interface ICredentials {
11
+ supplierId: string;
12
+ apiKey: string;
13
+ apiSecret: string;
14
+ }
15
+ export interface IOptions {
16
+ env: Environment;
17
+ debug: boolean;
18
+ timeout: number;
19
+ proxy: any;
20
+ }
21
+ export declare enum Environment {
22
+ PRODUCTION = 0,
23
+ STAGE = 1
24
+ }
25
+ export interface IClientParams {
26
+ credentials: ICredentials;
27
+ options?: Partial<IOptions>;
28
+ }
29
+ export declare class Client implements IClient {
30
+ params: IClientParams;
31
+ constructor(params: IClientParams);
32
+ getBaseURL(): string;
33
+ request(request: Partial<IRequestInput>): Request;
34
+ }
35
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/integrations/trendyol/v1/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACrB,GAAG,EAAE,WAAW,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;CACd;AAED,oBAAY,WAAW;IACnB,UAAU,IAAA;IACV,KAAK,IAAA;CACR;AAED,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/B;AAED,qBAAa,MAAO,YAAW,OAAO;IACf,MAAM,EAAE,aAAa;gBAArB,MAAM,EAAE,aAAa;IAUxC,UAAU,IAAI,MAAM;IAOpB,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO;CAGpD"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Client module for Trendyol
4
+ * @package entegrasyonapp/lib
5
+ * @author Ekin Karadeniz
6
+ * @copyright 2023-2024
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Client = exports.Environment = void 0;
10
+ const request_1 = require("./request");
11
+ var Environment;
12
+ (function (Environment) {
13
+ Environment[Environment["PRODUCTION"] = 0] = "PRODUCTION";
14
+ Environment[Environment["STAGE"] = 1] = "STAGE";
15
+ })(Environment || (exports.Environment = Environment = {}));
16
+ class Client {
17
+ params;
18
+ constructor(params) {
19
+ this.params = params;
20
+ const defaultOptions = {
21
+ env: Environment.PRODUCTION,
22
+ debug: false,
23
+ timeout: 0, // no timeout
24
+ proxy: undefined
25
+ };
26
+ this.params.options = { ...defaultOptions, ...this.params.options }; // {...{foo:'bar'}, ...undefined} == {foo:'bar'}
27
+ }
28
+ getBaseURL() {
29
+ if (this.params.options?.env == Environment.STAGE) {
30
+ return 'https://stageapi.trendyol.com/stagesapigw/';
31
+ }
32
+ return 'https://api.trendyol.com/sapigw/';
33
+ }
34
+ request(request) {
35
+ return new request_1.Request(this, request);
36
+ }
37
+ }
38
+ exports.Client = Client;
39
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/integrations/trendyol/v1/client.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAoC;AAiBpC,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,yDAAU,CAAA;IACV,+CAAK,CAAA;AACT,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAOD,MAAa,MAAM;IACI;IAAnB,YAAmB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QACpC,MAAM,cAAc,GAAa;YAC7B,GAAG,EAAE,WAAW,CAAC,UAAU;YAC3B,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,CAAC,EAAE,aAAa;YACzB,KAAK,EAAE,SAAS;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,gDAAgD;IACzH,CAAC;IAED,UAAU;QACN,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,4CAA4C,CAAC;QACxD,CAAC;QACD,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IAED,OAAO,CAAC,OAA+B;QACnC,OAAO,IAAI,iBAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACJ;AArBD,wBAqBC","sourcesContent":["/**\n * Client module for Trendyol\n * @package entegrasyonapp/lib\n * @author Ekin Karadeniz\n * @copyright 2023-2024\n */\n\nimport { Request } from \"./request\";\nimport { IClient } from \"./../../../common/client\";\nimport { IRequestInput } from \"./../../../common/request\";\n\nexport interface ICredentials {\n supplierId: string;\n apiKey: string;\n apiSecret: string;\n}\n\nexport interface IOptions {\n env: Environment;\n debug: boolean;\n timeout: number; // milliseconds\n proxy: any;\n}\n\nexport enum Environment {\n PRODUCTION,\n STAGE\n}\n\nexport interface IClientParams {\n credentials: ICredentials;\n options?: Partial<IOptions>;\n}\n\nexport class Client implements IClient {\n constructor(public params: IClientParams) {\n const defaultOptions: IOptions = {\n env: Environment.PRODUCTION,\n debug: false,\n timeout: 0, // no timeout\n proxy: undefined\n };\n this.params.options = { ...defaultOptions, ...this.params.options }; // {...{foo:'bar'}, ...undefined} == {foo:'bar'}\n }\n\n getBaseURL(): string {\n if (this.params.options?.env == Environment.STAGE) {\n return 'https://stageapi.trendyol.com/stagesapigw/';\n }\n return 'https://api.trendyol.com/sapigw/';\n }\n\n request(request: Partial<IRequestInput>): Request {\n return new Request(this, request);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { Client, Environment } from "./client";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/trendyol/v1/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Environment = exports.Client = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
6
+ Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return client_1.Environment; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integrations/trendyol/v1/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAAtC,gGAAA,MAAM,OAAA;AAAE,qGAAA,WAAW,OAAA","sourcesContent":["export { Client, Environment } from \"./client\";\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Request module for Trendyol
3
+ * @package entegrasyonapp/lib
4
+ * @author Ekin Karadeniz
5
+ * @copyright 2023-2024
6
+ */
7
+ import { AxiosResponse } from "axios";
8
+ import { Client } from "./client";
9
+ import { IRequest, IRequestInput } from "./../../../common/request";
10
+ export declare class Request implements IRequest {
11
+ private client;
12
+ private request;
13
+ private axiosConfig;
14
+ private axiosMockCallback?;
15
+ constructor(client: Client, request: Partial<IRequestInput>);
16
+ setAxiosMock(callback: Function): void;
17
+ getRequestId(): string;
18
+ send(): Promise<AxiosResponse>;
19
+ }
20
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/integrations/trendyol/v1/request.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAsB,aAAa,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGpE,qBAAa,OAAQ,YAAW,QAAQ;IAIxB,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;IAHnD,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,iBAAiB,CAAC,CAAW;gBAEjB,MAAM,EAAE,MAAM,EAAU,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC;IA+B3E,YAAY,CAAC,QAAQ,EAAE,QAAQ;IAI/B,YAAY,IAAI,MAAM;IAIhB,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;CAUvC"}