bexio 4.0.0 → 4.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/lib/index.js CHANGED
@@ -616,6 +616,64 @@ var TextPositions = class extends BaseCrud {
616
616
  }
617
617
  };
618
618
 
619
+ // src/resources/Positions.ts
620
+ var Positions = class _Positions extends BaseCrud {
621
+ static {
622
+ this.endpoints = {
623
+ KbPositionCustom: "kb_position_custom",
624
+ KbPositionArticle: "kb_position_article",
625
+ KbPositionText: "kb_position_text",
626
+ KbPositionSubtotal: "kb_position_subtotal",
627
+ KbPositionPagebreak: "kb_position_pagebreak",
628
+ KbPositionDiscount: "kb_position_discount",
629
+ KbPositionSubposition: "kb_position_subposition"
630
+ };
631
+ }
632
+ constructor(apiToken, documentType, documentId, positionType) {
633
+ super(
634
+ apiToken,
635
+ `/2.0/${documentType}/${documentId}/${_Positions.endpoint(positionType)}`
636
+ );
637
+ }
638
+ /**
639
+ * Endpoint segment of a position type
640
+ *
641
+ * @private
642
+ * @static
643
+ * @param {PositionsStatic.PositionType} positionType
644
+ * @returns {string}
645
+ * @memberof Positions
646
+ */
647
+ static endpoint(positionType) {
648
+ if (!Object.prototype.hasOwnProperty.call(_Positions.endpoints, positionType)) {
649
+ throw new Error(`Unknown position type "${positionType}"`);
650
+ }
651
+ return _Positions.endpoints[positionType];
652
+ }
653
+ /**
654
+ * Not implemented by Bexio yet
655
+ *
656
+ * @param {Array<BaseStatic.SearchParameter<{}>>} searchOptions
657
+ * @param {BaseStatic.BaseOptions} [options]
658
+ * @returns {Promise<Array<{}>>}
659
+ * @memberof Positions
660
+ */
661
+ async search(searchOptions, options) {
662
+ throw new Error("not implemented by Bexio yet");
663
+ }
664
+ /**
665
+ * Not implemented by Bexio yet
666
+ *
667
+ * @param {number} id
668
+ * @param {{}} ressource
669
+ * @returns {Promise<PositionStatic.Position>}
670
+ * @memberof Positions
671
+ */
672
+ async overwrite(id, ressource) {
673
+ throw new Error("not implemented by Bexio yet");
674
+ }
675
+ };
676
+
619
677
  // src/resources/Orders.ts
620
678
  var Orders = class extends BaseCrud {
621
679
  constructor(apiToken) {
@@ -660,6 +718,61 @@ var Orders = class extends BaseCrud {
660
718
  position
661
719
  );
662
720
  }
721
+ /**
722
+ * Delete a default position for an order
723
+ *
724
+ * @param {number} orderId
725
+ * @param {number} positionId
726
+ * @returns {Promise<boolean>}
727
+ * @memberof Orders
728
+ */
729
+ async deleteDefaultPosition(orderId, positionId) {
730
+ return new DefaultPositions(this.apiToken, "kb_order", orderId).delete(
731
+ positionId
732
+ );
733
+ }
734
+ /**
735
+ * Delete an item position for an order
736
+ *
737
+ * @param {number} orderId
738
+ * @param {number} positionId
739
+ * @returns {Promise<boolean>}
740
+ * @memberof Orders
741
+ */
742
+ async deleteItemPosition(orderId, positionId) {
743
+ return new ItemPositions(this.apiToken, "kb_order", orderId).delete(
744
+ positionId
745
+ );
746
+ }
747
+ /**
748
+ * Delete a text position for an order
749
+ *
750
+ * @param {number} orderId
751
+ * @param {number} positionId
752
+ * @returns {Promise<boolean>}
753
+ * @memberof Orders
754
+ */
755
+ async deleteTextPosition(orderId, positionId) {
756
+ return new TextPositions(this.apiToken, "kb_order", orderId).delete(
757
+ positionId
758
+ );
759
+ }
760
+ /**
761
+ * Delete a position for an order, whatever its type
762
+ *
763
+ * @param {number} orderId
764
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
765
+ * @returns {Promise<boolean>}
766
+ * @memberof Orders
767
+ */
768
+ async deletePosition(orderId, position) {
769
+ return new Positions(
770
+ this.apiToken,
771
+ "kb_order",
772
+ orderId,
773
+ position.type
774
+ ).delete(position.id);
775
+ }
663
776
  };
664
777
 
665
778
  // src/resources/Projects.ts
@@ -1072,6 +1185,61 @@ var Invoices = class extends BaseCrud {
1072
1185
  position
1073
1186
  );
1074
1187
  }
1188
+ /**
1189
+ * Delete a default position for an invoice
1190
+ *
1191
+ * @param {number} invoiceId
1192
+ * @param {number} positionId
1193
+ * @returns {Promise<boolean>}
1194
+ * @memberof Invoices
1195
+ */
1196
+ async deleteDefaultPosition(invoiceId, positionId) {
1197
+ return new DefaultPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1198
+ positionId
1199
+ );
1200
+ }
1201
+ /**
1202
+ * Delete an item position for an invoice
1203
+ *
1204
+ * @param {number} invoiceId
1205
+ * @param {number} positionId
1206
+ * @returns {Promise<boolean>}
1207
+ * @memberof Invoices
1208
+ */
1209
+ async deleteItemPosition(invoiceId, positionId) {
1210
+ return new ItemPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1211
+ positionId
1212
+ );
1213
+ }
1214
+ /**
1215
+ * Delete a text position for an invoice
1216
+ *
1217
+ * @param {number} invoiceId
1218
+ * @param {number} positionId
1219
+ * @returns {Promise<boolean>}
1220
+ * @memberof Invoices
1221
+ */
1222
+ async deleteTextPosition(invoiceId, positionId) {
1223
+ return new TextPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1224
+ positionId
1225
+ );
1226
+ }
1227
+ /**
1228
+ * Delete a position for an invoice, whatever its type
1229
+ *
1230
+ * @param {number} invoiceId
1231
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1232
+ * @returns {Promise<boolean>}
1233
+ * @memberof Invoices
1234
+ */
1235
+ async deletePosition(invoiceId, position) {
1236
+ return new Positions(
1237
+ this.apiToken,
1238
+ "kb_invoice",
1239
+ invoiceId,
1240
+ position.type
1241
+ ).delete(position.id);
1242
+ }
1075
1243
  };
1076
1244
 
1077
1245
  // src/resources/Currencies.ts