@tillhub/javascript-sdk 4.162.0 → 4.163.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [4.163.0](https://github.com/tillhub/tillhub-sdk-javascript/compare/v4.162.0...v4.163.0) (2024-11-06)
2
+
3
+
4
+ ### Features
5
+
6
+ * **invoices:** just to trigger new build ([#606](https://github.com/tillhub/tillhub-sdk-javascript/issues/606)) ([f7ffbd4](https://github.com/tillhub/tillhub-sdk-javascript/commit/f7ffbd457fadc1e7f714a19e77e946060144009a))
7
+
1
8
  # [4.162.0](https://github.com/tillhub/tillhub-sdk-javascript/compare/v4.161.0...v4.162.0) (2024-10-31)
2
9
 
3
10
 
@@ -2,9 +2,10 @@ import { Client } from '../client';
2
2
  import { BaseError } from '../errors';
3
3
  import { UriHelper } from '../uri-helper';
4
4
  import { ThBaseHandler } from '../base';
5
- declare type StatusTypes = 'Open' | 'Paid' | 'Dunning' | 'Encashment' | 'Cancellation' | 'Cancellation paid';
5
+ declare type StateTypes = 'Open' | 'Paid' | 'Dunning' | 'Encashment' | 'Cancellation' | 'Cancellation paid';
6
6
  declare type DocumentTypes = 'Standard' | 'Credit Note' | 'Partial Cancellation' | 'Full Cancellation';
7
7
  declare type OriginTypes = 'Ecom' | 'POS';
8
+ declare type InvoiceType = 'pdf' | 'csv';
8
9
  export interface UodInvoicesResponse {
9
10
  data: UodInvoicesEntity[];
10
11
  metadata: Record<string, unknown>;
@@ -22,29 +23,35 @@ export interface UodInvoicesQueryHandler {
22
23
  }
23
24
  export interface UodInvoicesQuery extends UodInvoicesEntity {
24
25
  active?: boolean;
25
- billingPeriodStart?: Date | string;
26
- billingPeriodEnd?: Date | string;
27
26
  }
28
27
  export interface UodInvoicesEntity {
29
- id?: string;
30
- documentNumber?: string;
31
- billingPeriod?: string | PeriodTimestamp;
32
- createdAt?: Date | string;
33
- status?: StatusTypes;
28
+ document: Document;
29
+ billingPeriodStart: Date | string;
30
+ billingPeriodEnd: Date | string;
31
+ origin?: OriginTypes;
32
+ state?: StateTypes;
34
33
  type?: DocumentTypes;
35
34
  csvUrl?: string;
36
35
  pdfUrl?: string;
37
- origin?: OriginTypes;
38
36
  }
39
- export interface PeriodTimestamp {
40
- billingPeriodStart: Date | string;
41
- billingPeriodEnd: Date | string;
37
+ export interface Document {
38
+ id?: string;
39
+ documentNumber?: string;
40
+ createdAt?: Date | string;
41
+ updatedAt?: Date | string;
42
42
  }
43
43
  export interface ErrorObject {
44
44
  id: string;
45
45
  label: string;
46
46
  errorDetails: Record<string, unknown>;
47
47
  }
48
+ export interface DocumentsDownloadResponse {
49
+ url?: string;
50
+ data?: string;
51
+ contentType?: string;
52
+ filename?: string;
53
+ correlationId?: string;
54
+ }
48
55
  export declare class UodInvoices extends ThBaseHandler {
49
56
  static baseEndpoint: string;
50
57
  endpoint: string;
@@ -53,10 +60,16 @@ export declare class UodInvoices extends ThBaseHandler {
53
60
  uriHelper: UriHelper;
54
61
  constructor(options: UodInvoicesOptions, http: Client);
55
62
  getAll(query?: UodInvoicesQueryHandler | undefined): Promise<UodInvoicesResponse>;
63
+ download(documentId: string, type: InvoiceType): Promise<DocumentsDownloadResponse>;
56
64
  }
57
65
  export declare class UodInvoicesFetchFailed extends BaseError {
58
66
  message: string;
59
67
  name: string;
60
68
  constructor(message?: string, properties?: Record<string, unknown>);
61
69
  }
70
+ export declare class DocumentsDownloadFailed extends BaseError {
71
+ message: string;
72
+ name: string;
73
+ constructor(message?: string, properties?: Record<string, unknown>);
74
+ }
62
75
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UodInvoicesFetchFailed = exports.UodInvoices = void 0;
3
+ exports.DocumentsDownloadFailed = exports.UodInvoicesFetchFailed = exports.UodInvoices = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var errors_1 = require("../errors");
6
6
  var uri_helper_1 = require("../uri-helper");
@@ -55,6 +55,42 @@ var UodInvoices = (function (_super) {
55
55
  });
56
56
  });
57
57
  };
58
+ UodInvoices.prototype.download = function (documentId, type) {
59
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
60
+ var uri, response, pdfObj, error_2;
61
+ return tslib_1.__generator(this, function (_a) {
62
+ switch (_a.label) {
63
+ case 0:
64
+ _a.trys.push([0, 2, , 3]);
65
+ uri = this.uriHelper.generateBaseUri("/download/" + documentId + "/type/" + type);
66
+ return [4, this.http.getClient().get(uri)];
67
+ case 1:
68
+ response = _a.sent();
69
+ pdfObj = response.data.results[0];
70
+ if ('correlationId' in pdfObj) {
71
+ return [2, {
72
+ correlationId: pdfObj.correlationId
73
+ }];
74
+ }
75
+ if ('url' in pdfObj) {
76
+ return [2, {
77
+ url: pdfObj.url,
78
+ filename: pdfObj.fileName
79
+ }];
80
+ }
81
+ return [2, {
82
+ data: pdfObj.base64Content,
83
+ contentType: pdfObj.contentType,
84
+ filename: pdfObj.fileName
85
+ }];
86
+ case 2:
87
+ error_2 = _a.sent();
88
+ throw new DocumentsDownloadFailed(error_2.message);
89
+ case 3: return [2];
90
+ }
91
+ });
92
+ });
93
+ };
58
94
  UodInvoices.baseEndpoint = '/api/v0/documents/unzer-one-invoices';
59
95
  return UodInvoices;
60
96
  }(base_1.ThBaseHandler));
@@ -72,4 +108,17 @@ var UodInvoicesFetchFailed = (function (_super) {
72
108
  return UodInvoicesFetchFailed;
73
109
  }(errors_1.BaseError));
74
110
  exports.UodInvoicesFetchFailed = UodInvoicesFetchFailed;
111
+ var DocumentsDownloadFailed = (function (_super) {
112
+ tslib_1.__extends(DocumentsDownloadFailed, _super);
113
+ function DocumentsDownloadFailed(message, properties) {
114
+ if (message === void 0) { message = 'Could not download file'; }
115
+ var _this = _super.call(this, message, properties) || this;
116
+ _this.message = message;
117
+ _this.name = 'DocumentsDownloadFailed';
118
+ Object.setPrototypeOf(_this, DocumentsDownloadFailed.prototype);
119
+ return _this;
120
+ }
121
+ return DocumentsDownloadFailed;
122
+ }(errors_1.BaseError));
123
+ exports.DocumentsDownloadFailed = DocumentsDownloadFailed;
75
124
  //# sourceMappingURL=invoices_uod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"invoices_uod.js","sourceRoot":"","sources":["../../src/v0/invoices_uod.ts"],"names":[],"mappings":";;;;AACA,oCAAqC;AACrC,4CAAyC;AACzC,gCAAuC;AAqDvC;IAAiC,uCAAa;IAO5C,qBAAa,OAA2B,EAAE,IAAY;;QAAtD,YACE,kBAAM,IAAI,EAAE;YACV,QAAQ,EAAE,WAAW,CAAC,YAAY;YAClC,IAAI,QAAE,OAAO,CAAC,IAAI,mCAAI,yBAAyB;SAChD,CAAC,SAOH;QANC,KAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,KAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAA;QACxC,KAAI,CAAC,OAAO,CAAC,IAAI,SAAG,KAAI,CAAC,OAAO,CAAC,IAAI,mCAAI,yBAAyB,CAAA;QAClE,KAAI,CAAC,SAAS,GAAG,IAAI,sBAAS,CAAC,KAAI,CAAC,QAAQ,EAAE,KAAI,CAAC,OAAO,CAAC,CAAA;;IAC7D,CAAC;IAEK,4BAAM,GAAZ,UAAc,KAA2C;;;;;;;;wBAEjD,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAA;wBACvC,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;;;;wBAGzC,WAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAA/C,aAAW,SAAoC;wBACrD,IAAI,UAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;4BAC3B,MAAM,IAAI,sBAAsB,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE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Q,aAAO,GAAP,OAAO,CAAqC;QAF9C,UAAI,GAAG,wBAAwB,CAAA;QAMpC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAA;;IAC/D,CAAC;IACH,6BAAC;AAAD,CAAC,AATD,CAA4C,kBAAS,GASpD;AATY,wDAAsB;AAWnC;IAA6C,mDAAS;IAEpD,iCACS,OAA2C,EAClD,UAAoC;QAD7B,wBAAA,EAAA,mCAA2C;QADpD,YAIE,kBAAM,OAAO,EAAE,UAAU,CAAC,SAE3B;QALQ,aAAO,GAAP,OAAO,CAAoC;QAF7C,UAAI,GAAG,yBAAyB,CAAA;QAMrC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAA;;IAChE,CAAC;IACH,8BAAC;AAAD,CAAC,AATD,CAA6C,kBAAS,GASrD;AATY,0DAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/javascript-sdk",
3
- "version": "4.162.0",
3
+ "version": "4.163.0",
4
4
  "description": "The JavaScript (Browser) SDK for the Tillhub API.",
5
5
  "keywords": [],
6
6
  "main": "dist/tillhub-js.js",