bexio 4.0.0 → 4.0.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/lib/index.mjs CHANGED
@@ -557,6 +557,64 @@ var TextPositions = class extends BaseCrud {
557
557
  }
558
558
  };
559
559
 
560
+ // src/resources/Positions.ts
561
+ var Positions = class _Positions extends BaseCrud {
562
+ static {
563
+ this.endpoints = {
564
+ KbPositionCustom: "kb_position_custom",
565
+ KbPositionArticle: "kb_position_article",
566
+ KbPositionText: "kb_position_text",
567
+ KbPositionSubtotal: "kb_position_subtotal",
568
+ KbPositionPagebreak: "kb_position_pagebreak",
569
+ KbPositionDiscount: "kb_position_discount",
570
+ KbPositionSubposition: "kb_position_subposition"
571
+ };
572
+ }
573
+ constructor(apiToken, documentType, documentId, positionType) {
574
+ super(
575
+ apiToken,
576
+ `/2.0/${documentType}/${documentId}/${_Positions.endpoint(positionType)}`
577
+ );
578
+ }
579
+ /**
580
+ * Endpoint segment of a position type
581
+ *
582
+ * @private
583
+ * @static
584
+ * @param {PositionsStatic.PositionType} positionType
585
+ * @returns {string}
586
+ * @memberof Positions
587
+ */
588
+ static endpoint(positionType) {
589
+ if (!Object.prototype.hasOwnProperty.call(_Positions.endpoints, positionType)) {
590
+ throw new Error(`Unknown position type "${positionType}"`);
591
+ }
592
+ return _Positions.endpoints[positionType];
593
+ }
594
+ /**
595
+ * Not implemented by Bexio yet
596
+ *
597
+ * @param {Array<BaseStatic.SearchParameter<{}>>} searchOptions
598
+ * @param {BaseStatic.BaseOptions} [options]
599
+ * @returns {Promise<Array<{}>>}
600
+ * @memberof Positions
601
+ */
602
+ async search(searchOptions, options) {
603
+ throw new Error("not implemented by Bexio yet");
604
+ }
605
+ /**
606
+ * Not implemented by Bexio yet
607
+ *
608
+ * @param {number} id
609
+ * @param {{}} ressource
610
+ * @returns {Promise<PositionStatic.Position>}
611
+ * @memberof Positions
612
+ */
613
+ async overwrite(id, ressource) {
614
+ throw new Error("not implemented by Bexio yet");
615
+ }
616
+ };
617
+
560
618
  // src/resources/Orders.ts
561
619
  var Orders = class extends BaseCrud {
562
620
  constructor(apiToken) {
@@ -601,6 +659,61 @@ var Orders = class extends BaseCrud {
601
659
  position
602
660
  );
603
661
  }
662
+ /**
663
+ * Delete a default position for an order
664
+ *
665
+ * @param {number} orderId
666
+ * @param {number} positionId
667
+ * @returns {Promise<boolean>}
668
+ * @memberof Orders
669
+ */
670
+ async deleteDefaultPosition(orderId, positionId) {
671
+ return new DefaultPositions(this.apiToken, "kb_order", orderId).delete(
672
+ positionId
673
+ );
674
+ }
675
+ /**
676
+ * Delete an item position for an order
677
+ *
678
+ * @param {number} orderId
679
+ * @param {number} positionId
680
+ * @returns {Promise<boolean>}
681
+ * @memberof Orders
682
+ */
683
+ async deleteItemPosition(orderId, positionId) {
684
+ return new ItemPositions(this.apiToken, "kb_order", orderId).delete(
685
+ positionId
686
+ );
687
+ }
688
+ /**
689
+ * Delete a text position for an order
690
+ *
691
+ * @param {number} orderId
692
+ * @param {number} positionId
693
+ * @returns {Promise<boolean>}
694
+ * @memberof Orders
695
+ */
696
+ async deleteTextPosition(orderId, positionId) {
697
+ return new TextPositions(this.apiToken, "kb_order", orderId).delete(
698
+ positionId
699
+ );
700
+ }
701
+ /**
702
+ * Delete a position for an order, whatever its type
703
+ *
704
+ * @param {number} orderId
705
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
706
+ * @returns {Promise<boolean>}
707
+ * @memberof Orders
708
+ */
709
+ async deletePosition(orderId, position) {
710
+ return new Positions(
711
+ this.apiToken,
712
+ "kb_order",
713
+ orderId,
714
+ position.type
715
+ ).delete(position.id);
716
+ }
604
717
  };
605
718
 
606
719
  // src/resources/Projects.ts
@@ -1013,6 +1126,61 @@ var Invoices = class extends BaseCrud {
1013
1126
  position
1014
1127
  );
1015
1128
  }
1129
+ /**
1130
+ * Delete a default position for an invoice
1131
+ *
1132
+ * @param {number} invoiceId
1133
+ * @param {number} positionId
1134
+ * @returns {Promise<boolean>}
1135
+ * @memberof Invoices
1136
+ */
1137
+ async deleteDefaultPosition(invoiceId, positionId) {
1138
+ return new DefaultPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1139
+ positionId
1140
+ );
1141
+ }
1142
+ /**
1143
+ * Delete an item position for an invoice
1144
+ *
1145
+ * @param {number} invoiceId
1146
+ * @param {number} positionId
1147
+ * @returns {Promise<boolean>}
1148
+ * @memberof Invoices
1149
+ */
1150
+ async deleteItemPosition(invoiceId, positionId) {
1151
+ return new ItemPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1152
+ positionId
1153
+ );
1154
+ }
1155
+ /**
1156
+ * Delete a text position for an invoice
1157
+ *
1158
+ * @param {number} invoiceId
1159
+ * @param {number} positionId
1160
+ * @returns {Promise<boolean>}
1161
+ * @memberof Invoices
1162
+ */
1163
+ async deleteTextPosition(invoiceId, positionId) {
1164
+ return new TextPositions(this.apiToken, "kb_invoice", invoiceId).delete(
1165
+ positionId
1166
+ );
1167
+ }
1168
+ /**
1169
+ * Delete a position for an invoice, whatever its type
1170
+ *
1171
+ * @param {number} invoiceId
1172
+ * @param {Pick<PositionStatic.Position, "id" | "type">} position
1173
+ * @returns {Promise<boolean>}
1174
+ * @memberof Invoices
1175
+ */
1176
+ async deletePosition(invoiceId, position) {
1177
+ return new Positions(
1178
+ this.apiToken,
1179
+ "kb_invoice",
1180
+ invoiceId,
1181
+ position.type
1182
+ ).delete(position.id);
1183
+ }
1016
1184
  };
1017
1185
 
1018
1186
  // src/resources/Currencies.ts