orb-billing 1.19.2 → 1.19.5

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 (29) hide show
  1. package/dist/internal/utils/utils.js +1 -1
  2. package/dist/sdk/credit.d.ts +182 -0
  3. package/dist/sdk/credit.js +182 -0
  4. package/dist/sdk/models/shared/addamendmentcreditledgerentryrequestparams.d.ts +28 -0
  5. package/dist/sdk/models/shared/addamendmentcreditledgerentryrequestparams.js +81 -0
  6. package/dist/sdk/models/shared/adddecrementcreditledgerentryrequestparams.d.ts +1 -1
  7. package/dist/sdk/models/shared/addexpirationchangecreditledgerentryrequestparams.d.ts +1 -1
  8. package/dist/sdk/models/shared/addexpirationchangecreditledgerentryrequestparams.js +2 -0
  9. package/dist/sdk/models/shared/addincrementcreditledgerentryrequestparams.d.ts +1 -1
  10. package/dist/sdk/models/shared/addincrementcreditledgerentryrequestparams.js +2 -0
  11. package/dist/sdk/models/shared/addvoidcreditledgerentryrequestparams.d.ts +4 -0
  12. package/dist/sdk/models/shared/addvoidcreditledgerentryrequestparams.js +5 -0
  13. package/dist/sdk/models/shared/createinvoicelineitemparams.js +2 -0
  14. package/dist/sdk/models/shared/fixedfeequantitychange.js +1 -0
  15. package/dist/sdk/models/shared/index.d.ts +1 -0
  16. package/dist/sdk/models/shared/index.js +1 -0
  17. package/dist/sdk/models/shared/invoicelineitemparams.js +2 -0
  18. package/dist/sdk/models/shared/markaspaidrequestparams.js +1 -0
  19. package/dist/sdk/models/shared/triggersubscriptionphaseparams.js +1 -0
  20. package/dist/sdk/sdk.js +3 -3
  21. package/docs/models/shared/addamendmentcreditledgerentryrequestparams.md +12 -0
  22. package/docs/models/shared/addamendmentcreditledgerentryrequestparamsentrytype.md +8 -0
  23. package/docs/models/shared/addamendmentcreditledgerentryrequestparamsmetadata.md +9 -0
  24. package/docs/models/shared/adddecrementcreditledgerentryrequestparams.md +1 -1
  25. package/docs/models/shared/addexpirationchangecreditledgerentryrequestparams.md +1 -1
  26. package/docs/models/shared/addincrementcreditledgerentryrequestparams.md +1 -1
  27. package/docs/models/shared/addvoidcreditledgerentryrequestparams.md +1 -0
  28. package/docs/sdks/credit/README.md +189 -8
  29. package/package.json +1 -1
@@ -104,7 +104,7 @@ var SpeakeasyBase = /** @class */ (function () {
104
104
  var prop = props_1_1.value;
105
105
  if (payload && payload.hasOwnProperty(prop.key)) {
106
106
  var value = payload[prop.key];
107
- if (isSpeakeasyBase(prop.type)) {
107
+ if (isSpeakeasyBase(prop.type) && value != null) {
108
108
  this[prop.key] = new prop.type(value);
109
109
  }
110
110
  else if (prop.type.name == "Array" &&
@@ -9,10 +9,192 @@ export declare class Credit {
9
9
  constructor(sdkConfig: SDKConfiguration);
10
10
  /**
11
11
  * Create ledger entry by external ID
12
+ *
13
+ * @remarks
14
+ * This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to
15
+ * increment balance, deduct credits, and change the expiry date of existing credits.
16
+ *
17
+ * ## Effects of adding a ledger entry
18
+ * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that
19
+ * represents the changes (i.e. balance changes or transfers).
20
+ * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the
21
+ * [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In
22
+ * the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans
23
+ * credit blocks.
24
+ * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on
25
+ * `amount` and `per_unit_cost_basis`).
26
+ *
27
+ * ## Adding credits
28
+ * Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of
29
+ * credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description
30
+ * to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate
31
+ * how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
32
+ *
33
+ * The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
34
+ *
35
+ * ```json
36
+ * {
37
+ * "entry_type": "increment",
38
+ * "amount": 100,
39
+ * "expiry_date": "2022-12-28",
40
+ * "per_unit_cost_basis": "0.20",
41
+ * "description": "Purchased 100 credits"
42
+ * }
43
+ * ```
44
+ *
45
+ * Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the
46
+ * remaining amount to the desired credit block.
47
+ *
48
+ * ### Invoicing for credits
49
+ * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass
50
+ * `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the
51
+ * credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the
52
+ * invoice are calculated by multiplying the cost basis with the number of credit units added.
53
+ *
54
+ * ## Deducting Credits
55
+ * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the
56
+ * algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the
57
+ * deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also
58
+ * optionally allows specifying a description to assist with auditing.
59
+ *
60
+ * The following snippet illustrates a sample request body to decrement credits.
61
+ *
62
+ * ```json
63
+ * {
64
+ * "entry_type": "decrement",
65
+ * "amount": 20,
66
+ * "description": "Removing excess credits"
67
+ * }
68
+ * ```
69
+ *
70
+ * ## Changing credits expiry
71
+ * If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`.
72
+ * For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter
73
+ * `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created
74
+ * with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
75
+ *
76
+ * Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer
77
+ * amount determined by the `amount` parameter.
78
+ *
79
+ * The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
80
+ *
81
+ * ```json
82
+ * {
83
+ * "entry_type": "expiration_change",
84
+ * "amount": 10,
85
+ * "expiry_date": "2022-12-28",
86
+ * "block_id": "UiUhFWeLHPrBY4Ad",
87
+ * "target_expiry_date": "2023-12-28",
88
+ * "description": "Extending credit validity"
89
+ * }
90
+ * ```
91
+ *
92
+ * ## Voiding credits
93
+ *
94
+ * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, `block_id` is required
95
+ * to identify the block, and `amount` indicates how many credits to void, up to the block's initial balance. Pass
96
+ * in a `void_reason` of `refund` if the void is due to a refund.
97
+ *
98
+ * ## Amendment
99
+ *
100
+ * If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. For this entry, `block_id`
101
+ * is required to identify the block that was originally decremented from, and `amount` indicates how many credits to return
102
+ * to the customer, up to the block's initial balance.
12
103
  */
13
104
  addByExternalId(req: operations.CreateLedgerEntryExternalIdRequest, config?: AxiosRequestConfig): Promise<operations.CreateLedgerEntryExternalIdResponse>;
14
105
  /**
15
106
  * Create ledger entry
107
+ *
108
+ * @remarks
109
+ * This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to
110
+ * increment balance, deduct credits, and change the expiry date of existing credits.
111
+ *
112
+ * ## Effects of adding a ledger entry
113
+ * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that
114
+ * represents the changes (i.e. balance changes or transfers).
115
+ * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the
116
+ * [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In
117
+ * the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans
118
+ * credit blocks.
119
+ * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on
120
+ * `amount` and `per_unit_cost_basis`).
121
+ *
122
+ * ## Adding credits
123
+ * Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of
124
+ * credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description
125
+ * to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate
126
+ * how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
127
+ *
128
+ * The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
129
+ *
130
+ * ```json
131
+ * {
132
+ * "entry_type": "increment",
133
+ * "amount": 100,
134
+ * "expiry_date": "2022-12-28",
135
+ * "per_unit_cost_basis": "0.20",
136
+ * "description": "Purchased 100 credits"
137
+ * }
138
+ * ```
139
+ *
140
+ * Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the
141
+ * remaining amount to the desired credit block.
142
+ *
143
+ * ### Invoicing for credits
144
+ * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass
145
+ * `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the
146
+ * credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the
147
+ * invoice are calculated by multiplying the cost basis with the number of credit units added.
148
+ *
149
+ * ## Deducting Credits
150
+ * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the
151
+ * algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the
152
+ * deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also
153
+ * optionally allows specifying a description to assist with auditing.
154
+ *
155
+ * The following snippet illustrates a sample request body to decrement credits.
156
+ *
157
+ * ```json
158
+ * {
159
+ * "entry_type": "decrement",
160
+ * "amount": 20,
161
+ * "description": "Removing excess credits"
162
+ * }
163
+ * ```
164
+ *
165
+ * ## Changing credits expiry
166
+ * If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`.
167
+ * For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter
168
+ * `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created
169
+ * with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
170
+ *
171
+ * Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer
172
+ * amount determined by the `amount` parameter.
173
+ *
174
+ * The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
175
+ *
176
+ * ```json
177
+ * {
178
+ * "entry_type": "expiration_change",
179
+ * "amount": 10,
180
+ * "expiry_date": "2022-12-28",
181
+ * "block_id": "UiUhFWeLHPrBY4Ad",
182
+ * "target_expiry_date": "2023-12-28",
183
+ * "description": "Extending credit validity"
184
+ * }
185
+ * ```
186
+ *
187
+ * ## Voiding credits
188
+ *
189
+ * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, `block_id` is required
190
+ * to identify the block, and `amount` indicates how many credits to void, up to the block's initial balance. Pass
191
+ * in a `void_reason` of `refund` if the void is due to a refund.
192
+ *
193
+ * ## Amendment
194
+ *
195
+ * If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. For this entry, `block_id`
196
+ * is required to identify the block that was originally decremented from, and `amount` indicates how many credits to return
197
+ * to the customer, up to the block's initial balance.
16
198
  */
17
199
  create(req: operations.CreateLedgerEntryRequest, config?: AxiosRequestConfig): Promise<operations.CreateLedgerEntryResponse>;
18
200
  /**
@@ -103,6 +103,97 @@ var Credit = /** @class */ (function () {
103
103
  }
104
104
  /**
105
105
  * Create ledger entry by external ID
106
+ *
107
+ * @remarks
108
+ * This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to
109
+ * increment balance, deduct credits, and change the expiry date of existing credits.
110
+ *
111
+ * ## Effects of adding a ledger entry
112
+ * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that
113
+ * represents the changes (i.e. balance changes or transfers).
114
+ * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the
115
+ * [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In
116
+ * the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans
117
+ * credit blocks.
118
+ * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on
119
+ * `amount` and `per_unit_cost_basis`).
120
+ *
121
+ * ## Adding credits
122
+ * Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of
123
+ * credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description
124
+ * to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate
125
+ * how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
126
+ *
127
+ * The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
128
+ *
129
+ * ```json
130
+ * {
131
+ * "entry_type": "increment",
132
+ * "amount": 100,
133
+ * "expiry_date": "2022-12-28",
134
+ * "per_unit_cost_basis": "0.20",
135
+ * "description": "Purchased 100 credits"
136
+ * }
137
+ * ```
138
+ *
139
+ * Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the
140
+ * remaining amount to the desired credit block.
141
+ *
142
+ * ### Invoicing for credits
143
+ * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass
144
+ * `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the
145
+ * credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the
146
+ * invoice are calculated by multiplying the cost basis with the number of credit units added.
147
+ *
148
+ * ## Deducting Credits
149
+ * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the
150
+ * algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the
151
+ * deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also
152
+ * optionally allows specifying a description to assist with auditing.
153
+ *
154
+ * The following snippet illustrates a sample request body to decrement credits.
155
+ *
156
+ * ```json
157
+ * {
158
+ * "entry_type": "decrement",
159
+ * "amount": 20,
160
+ * "description": "Removing excess credits"
161
+ * }
162
+ * ```
163
+ *
164
+ * ## Changing credits expiry
165
+ * If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`.
166
+ * For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter
167
+ * `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created
168
+ * with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
169
+ *
170
+ * Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer
171
+ * amount determined by the `amount` parameter.
172
+ *
173
+ * The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
174
+ *
175
+ * ```json
176
+ * {
177
+ * "entry_type": "expiration_change",
178
+ * "amount": 10,
179
+ * "expiry_date": "2022-12-28",
180
+ * "block_id": "UiUhFWeLHPrBY4Ad",
181
+ * "target_expiry_date": "2023-12-28",
182
+ * "description": "Extending credit validity"
183
+ * }
184
+ * ```
185
+ *
186
+ * ## Voiding credits
187
+ *
188
+ * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, `block_id` is required
189
+ * to identify the block, and `amount` indicates how many credits to void, up to the block's initial balance. Pass
190
+ * in a `void_reason` of `refund` if the void is due to a refund.
191
+ *
192
+ * ## Amendment
193
+ *
194
+ * If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. For this entry, `block_id`
195
+ * is required to identify the block that was originally decremented from, and `amount` indicates how many credits to return
196
+ * to the customer, up to the block's initial balance.
106
197
  */
107
198
  Credit.prototype.addByExternalId = function (req, config) {
108
199
  var _a, _b;
@@ -227,6 +318,97 @@ var Credit = /** @class */ (function () {
227
318
  };
228
319
  /**
229
320
  * Create ledger entry
321
+ *
322
+ * @remarks
323
+ * This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to
324
+ * increment balance, deduct credits, and change the expiry date of existing credits.
325
+ *
326
+ * ## Effects of adding a ledger entry
327
+ * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that
328
+ * represents the changes (i.e. balance changes or transfers).
329
+ * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the
330
+ * [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In
331
+ * the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans
332
+ * credit blocks.
333
+ * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on
334
+ * `amount` and `per_unit_cost_basis`).
335
+ *
336
+ * ## Adding credits
337
+ * Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of
338
+ * credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description
339
+ * to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate
340
+ * how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
341
+ *
342
+ * The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
343
+ *
344
+ * ```json
345
+ * {
346
+ * "entry_type": "increment",
347
+ * "amount": 100,
348
+ * "expiry_date": "2022-12-28",
349
+ * "per_unit_cost_basis": "0.20",
350
+ * "description": "Purchased 100 credits"
351
+ * }
352
+ * ```
353
+ *
354
+ * Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the
355
+ * remaining amount to the desired credit block.
356
+ *
357
+ * ### Invoicing for credits
358
+ * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass
359
+ * `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the
360
+ * credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the
361
+ * invoice are calculated by multiplying the cost basis with the number of credit units added.
362
+ *
363
+ * ## Deducting Credits
364
+ * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the
365
+ * algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the
366
+ * deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also
367
+ * optionally allows specifying a description to assist with auditing.
368
+ *
369
+ * The following snippet illustrates a sample request body to decrement credits.
370
+ *
371
+ * ```json
372
+ * {
373
+ * "entry_type": "decrement",
374
+ * "amount": 20,
375
+ * "description": "Removing excess credits"
376
+ * }
377
+ * ```
378
+ *
379
+ * ## Changing credits expiry
380
+ * If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`.
381
+ * For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter
382
+ * `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created
383
+ * with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
384
+ *
385
+ * Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer
386
+ * amount determined by the `amount` parameter.
387
+ *
388
+ * The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
389
+ *
390
+ * ```json
391
+ * {
392
+ * "entry_type": "expiration_change",
393
+ * "amount": 10,
394
+ * "expiry_date": "2022-12-28",
395
+ * "block_id": "UiUhFWeLHPrBY4Ad",
396
+ * "target_expiry_date": "2023-12-28",
397
+ * "description": "Extending credit validity"
398
+ * }
399
+ * ```
400
+ *
401
+ * ## Voiding credits
402
+ *
403
+ * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, `block_id` is required
404
+ * to identify the block, and `amount` indicates how many credits to void, up to the block's initial balance. Pass
405
+ * in a `void_reason` of `refund` if the void is due to a refund.
406
+ *
407
+ * ## Amendment
408
+ *
409
+ * If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. For this entry, `block_id`
410
+ * is required to identify the block that was originally decremented from, and `amount` indicates how many credits to return
411
+ * to the customer, up to the block's initial balance.
230
412
  */
231
413
  Credit.prototype.create = function (req, config) {
232
414
  var _a, _b;
@@ -0,0 +1,28 @@
1
+ import { SpeakeasyBase } from "../../../internal/utils";
2
+ export declare enum AddAmendmentCreditLedgerEntryRequestParamsEntryType {
3
+ Amendment = "amendment"
4
+ }
5
+ /**
6
+ * User-specified key/value pairs for the ledger entry resource.
7
+ */
8
+ export declare class AddAmendmentCreditLedgerEntryRequestParamsMetadata extends SpeakeasyBase {
9
+ }
10
+ export declare class AddAmendmentCreditLedgerEntryRequestParams extends SpeakeasyBase {
11
+ /**
12
+ * The number of credits to effect. Note that this is required for increment, decrement or void operations.
13
+ */
14
+ amount: any;
15
+ /**
16
+ * The ID of the block to reverse a decrement from.
17
+ */
18
+ blockId: string;
19
+ /**
20
+ * Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc.
21
+ */
22
+ description?: string;
23
+ entryType: AddAmendmentCreditLedgerEntryRequestParamsEntryType;
24
+ /**
25
+ * User-specified key/value pairs for the ledger entry resource.
26
+ */
27
+ metadata?: AddAmendmentCreditLedgerEntryRequestParamsMetadata;
28
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __extends = (this && this.__extends) || (function () {
6
+ var extendStatics = function (d, b) {
7
+ extendStatics = Object.setPrototypeOf ||
8
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
10
+ return extendStatics(d, b);
11
+ };
12
+ return function (d, b) {
13
+ if (typeof b !== "function" && b !== null)
14
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
15
+ extendStatics(d, b);
16
+ function __() { this.constructor = d; }
17
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
+ };
19
+ })();
20
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
21
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
22
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
23
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
25
+ };
26
+ var __metadata = (this && this.__metadata) || function (k, v) {
27
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.AddAmendmentCreditLedgerEntryRequestParams = exports.AddAmendmentCreditLedgerEntryRequestParamsMetadata = exports.AddAmendmentCreditLedgerEntryRequestParamsEntryType = void 0;
31
+ var utils_1 = require("../../../internal/utils");
32
+ var class_transformer_1 = require("class-transformer");
33
+ var AddAmendmentCreditLedgerEntryRequestParamsEntryType;
34
+ (function (AddAmendmentCreditLedgerEntryRequestParamsEntryType) {
35
+ AddAmendmentCreditLedgerEntryRequestParamsEntryType["Amendment"] = "amendment";
36
+ })(AddAmendmentCreditLedgerEntryRequestParamsEntryType = exports.AddAmendmentCreditLedgerEntryRequestParamsEntryType || (exports.AddAmendmentCreditLedgerEntryRequestParamsEntryType = {}));
37
+ /**
38
+ * User-specified key/value pairs for the ledger entry resource.
39
+ */
40
+ var AddAmendmentCreditLedgerEntryRequestParamsMetadata = /** @class */ (function (_super) {
41
+ __extends(AddAmendmentCreditLedgerEntryRequestParamsMetadata, _super);
42
+ function AddAmendmentCreditLedgerEntryRequestParamsMetadata() {
43
+ return _super !== null && _super.apply(this, arguments) || this;
44
+ }
45
+ return AddAmendmentCreditLedgerEntryRequestParamsMetadata;
46
+ }(utils_1.SpeakeasyBase));
47
+ exports.AddAmendmentCreditLedgerEntryRequestParamsMetadata = AddAmendmentCreditLedgerEntryRequestParamsMetadata;
48
+ var AddAmendmentCreditLedgerEntryRequestParams = /** @class */ (function (_super) {
49
+ __extends(AddAmendmentCreditLedgerEntryRequestParams, _super);
50
+ function AddAmendmentCreditLedgerEntryRequestParams() {
51
+ return _super !== null && _super.apply(this, arguments) || this;
52
+ }
53
+ __decorate([
54
+ (0, utils_1.SpeakeasyMetadata)(),
55
+ (0, class_transformer_1.Expose)({ name: "amount" }),
56
+ __metadata("design:type", Object)
57
+ ], AddAmendmentCreditLedgerEntryRequestParams.prototype, "amount", void 0);
58
+ __decorate([
59
+ (0, utils_1.SpeakeasyMetadata)(),
60
+ (0, class_transformer_1.Expose)({ name: "block_id" }),
61
+ __metadata("design:type", String)
62
+ ], AddAmendmentCreditLedgerEntryRequestParams.prototype, "blockId", void 0);
63
+ __decorate([
64
+ (0, utils_1.SpeakeasyMetadata)(),
65
+ (0, class_transformer_1.Expose)({ name: "description" }),
66
+ __metadata("design:type", String)
67
+ ], AddAmendmentCreditLedgerEntryRequestParams.prototype, "description", void 0);
68
+ __decorate([
69
+ (0, utils_1.SpeakeasyMetadata)(),
70
+ (0, class_transformer_1.Expose)({ name: "entry_type" }),
71
+ __metadata("design:type", String)
72
+ ], AddAmendmentCreditLedgerEntryRequestParams.prototype, "entryType", void 0);
73
+ __decorate([
74
+ (0, utils_1.SpeakeasyMetadata)(),
75
+ (0, class_transformer_1.Expose)({ name: "metadata" }),
76
+ (0, class_transformer_1.Type)(function () { return AddAmendmentCreditLedgerEntryRequestParamsMetadata; }),
77
+ __metadata("design:type", AddAmendmentCreditLedgerEntryRequestParamsMetadata)
78
+ ], AddAmendmentCreditLedgerEntryRequestParams.prototype, "metadata", void 0);
79
+ return AddAmendmentCreditLedgerEntryRequestParams;
80
+ }(utils_1.SpeakeasyBase));
81
+ exports.AddAmendmentCreditLedgerEntryRequestParams = AddAmendmentCreditLedgerEntryRequestParams;
@@ -9,7 +9,7 @@ export declare class AddDecrementCreditLedgerEntryRequestParamsMetadata extends
9
9
  }
10
10
  export declare class AddDecrementCreditLedgerEntryRequestParams extends SpeakeasyBase {
11
11
  /**
12
- * The number of credits to effect. Note that this is required for increment, decrement or void operations.
12
+ * The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations.
13
13
  */
14
14
  amount: any;
15
15
  /**
@@ -10,7 +10,7 @@ export declare class AddExpirationChangeCreditLedgerEntryRequestParamsMetadata e
10
10
  }
11
11
  export declare class AddExpirationChangeCreditLedgerEntryRequestParams extends SpeakeasyBase {
12
12
  /**
13
- * The number of credits to effect. Note that this is required for increment, decrement or void operations.
13
+ * The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations.
14
14
  */
15
15
  amount?: any;
16
16
  /**
@@ -74,6 +74,7 @@ var AddExpirationChangeCreditLedgerEntryRequestParams = /** @class */ (function
74
74
  __decorate([
75
75
  (0, utils_1.SpeakeasyMetadata)(),
76
76
  (0, class_transformer_1.Expose)({ name: "expiry_date" }),
77
+ (0, class_transformer_1.Type)(function () { return String; }),
77
78
  (0, class_transformer_1.Transform)(function (_a) {
78
79
  var value = _a.value;
79
80
  return new types_1.RFCDate(value);
@@ -89,6 +90,7 @@ var AddExpirationChangeCreditLedgerEntryRequestParams = /** @class */ (function
89
90
  __decorate([
90
91
  (0, utils_1.SpeakeasyMetadata)(),
91
92
  (0, class_transformer_1.Expose)({ name: "target_expiry_date" }),
93
+ (0, class_transformer_1.Type)(function () { return String; }),
92
94
  (0, class_transformer_1.Transform)(function (_a) {
93
95
  var value = _a.value;
94
96
  return new types_1.RFCDate(value);
@@ -11,7 +11,7 @@ export declare class AddIncrementCreditLedgerEntryRequestParamsMetadata extends
11
11
  }
12
12
  export declare class AddIncrementCreditLedgerEntryRequestParams extends SpeakeasyBase {
13
13
  /**
14
- * The number of credits to effect. Note that this is required for increment, decrement or void operations.
14
+ * The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations.
15
15
  */
16
16
  amount: any;
17
17
  /**
@@ -65,6 +65,7 @@ var AddIncrementCreditLedgerEntryRequestParams = /** @class */ (function (_super
65
65
  __decorate([
66
66
  (0, utils_1.SpeakeasyMetadata)(),
67
67
  (0, class_transformer_1.Expose)({ name: "effective_date" }),
68
+ (0, class_transformer_1.Type)(function () { return String; }),
68
69
  (0, class_transformer_1.Transform)(function (_a) {
69
70
  var value = _a.value;
70
71
  return new types_1.RFCDate(value);
@@ -79,6 +80,7 @@ var AddIncrementCreditLedgerEntryRequestParams = /** @class */ (function (_super
79
80
  __decorate([
80
81
  (0, utils_1.SpeakeasyMetadata)(),
81
82
  (0, class_transformer_1.Expose)({ name: "expiry_date" }),
83
+ (0, class_transformer_1.Type)(function () { return String; }),
82
84
  (0, class_transformer_1.Transform)(function (_a) {
83
85
  var value = _a.value;
84
86
  return new types_1.RFCDate(value);
@@ -14,6 +14,10 @@ export declare enum AddVoidCreditLedgerEntryRequestParamsVoidReason {
14
14
  Refund = "refund"
15
15
  }
16
16
  export declare class AddVoidCreditLedgerEntryRequestParams extends SpeakeasyBase {
17
+ /**
18
+ * The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations.
19
+ */
20
+ amount: any;
17
21
  /**
18
22
  * The ID of the block to void.
19
23
  */
@@ -57,6 +57,11 @@ var AddVoidCreditLedgerEntryRequestParams = /** @class */ (function (_super) {
57
57
  function AddVoidCreditLedgerEntryRequestParams() {
58
58
  return _super !== null && _super.apply(this, arguments) || this;
59
59
  }
60
+ __decorate([
61
+ (0, utils_1.SpeakeasyMetadata)(),
62
+ (0, class_transformer_1.Expose)({ name: "amount" }),
63
+ __metadata("design:type", Object)
64
+ ], AddVoidCreditLedgerEntryRequestParams.prototype, "amount", void 0);
60
65
  __decorate([
61
66
  (0, utils_1.SpeakeasyMetadata)(),
62
67
  (0, class_transformer_1.Expose)({ name: "block_id" }),
@@ -44,6 +44,7 @@ var CreateInvoiceLineItemParams = /** @class */ (function (_super) {
44
44
  __decorate([
45
45
  (0, utils_1.SpeakeasyMetadata)(),
46
46
  (0, class_transformer_1.Expose)({ name: "end_date" }),
47
+ (0, class_transformer_1.Type)(function () { return String; }),
47
48
  (0, class_transformer_1.Transform)(function (_a) {
48
49
  var value = _a.value;
49
50
  return new types_1.RFCDate(value);
@@ -68,6 +69,7 @@ var CreateInvoiceLineItemParams = /** @class */ (function (_super) {
68
69
  __decorate([
69
70
  (0, utils_1.SpeakeasyMetadata)(),
70
71
  (0, class_transformer_1.Expose)({ name: "start_date" }),
72
+ (0, class_transformer_1.Type)(function () { return String; }),
71
73
  (0, class_transformer_1.Transform)(function (_a) {
72
74
  var value = _a.value;
73
75
  return new types_1.RFCDate(value);
@@ -53,6 +53,7 @@ var FixedFeeQuantityChange = /** @class */ (function (_super) {
53
53
  __decorate([
54
54
  (0, utils_1.SpeakeasyMetadata)(),
55
55
  (0, class_transformer_1.Expose)({ name: "effective_date" }),
56
+ (0, class_transformer_1.Type)(function () { return String; }),
56
57
  (0, class_transformer_1.Transform)(function (_a) {
57
58
  var value = _a.value;
58
59
  return new types_1.RFCDate(value);
@@ -1,6 +1,7 @@
1
1
  export * from "./accountingprovider";
2
2
  export * from "./accountingproviderconfig";
3
3
  export * from "./accountingsyncconfiguration";
4
+ export * from "./addamendmentcreditledgerentryrequestparams";
4
5
  export * from "./adddecrementcreditledgerentryrequestparams";
5
6
  export * from "./addeditpriceintervalparams";
6
7
  export * from "./addexpirationchangecreditledgerentryrequestparams";
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./accountingprovider"), exports);
21
21
  __exportStar(require("./accountingproviderconfig"), exports);
22
22
  __exportStar(require("./accountingsyncconfiguration"), exports);
23
+ __exportStar(require("./addamendmentcreditledgerentryrequestparams"), exports);
23
24
  __exportStar(require("./adddecrementcreditledgerentryrequestparams"), exports);
24
25
  __exportStar(require("./addeditpriceintervalparams"), exports);
25
26
  __exportStar(require("./addexpirationchangecreditledgerentryrequestparams"), exports);
@@ -44,6 +44,7 @@ var InvoiceLineItemParams = /** @class */ (function (_super) {
44
44
  __decorate([
45
45
  (0, utils_1.SpeakeasyMetadata)(),
46
46
  (0, class_transformer_1.Expose)({ name: "end_date" }),
47
+ (0, class_transformer_1.Type)(function () { return String; }),
47
48
  (0, class_transformer_1.Transform)(function (_a) {
48
49
  var value = _a.value;
49
50
  return new types_1.RFCDate(value);
@@ -73,6 +74,7 @@ var InvoiceLineItemParams = /** @class */ (function (_super) {
73
74
  __decorate([
74
75
  (0, utils_1.SpeakeasyMetadata)(),
75
76
  (0, class_transformer_1.Expose)({ name: "start_date" }),
77
+ (0, class_transformer_1.Type)(function () { return String; }),
76
78
  (0, class_transformer_1.Transform)(function (_a) {
77
79
  var value = _a.value;
78
80
  return new types_1.RFCDate(value);
@@ -49,6 +49,7 @@ var MarkAsPaidRequestParams = /** @class */ (function (_super) {
49
49
  __decorate([
50
50
  (0, utils_1.SpeakeasyMetadata)(),
51
51
  (0, class_transformer_1.Expose)({ name: "payment_received_date" }),
52
+ (0, class_transformer_1.Type)(function () { return String; }),
52
53
  (0, class_transformer_1.Transform)(function (_a) {
53
54
  var value = _a.value;
54
55
  return new types_1.RFCDate(value);
@@ -39,6 +39,7 @@ var TriggerSubscriptionPhaseParams = /** @class */ (function (_super) {
39
39
  __decorate([
40
40
  (0, utils_1.SpeakeasyMetadata)(),
41
41
  (0, class_transformer_1.Expose)({ name: "effective_date" }),
42
+ (0, class_transformer_1.Type)(function () { return String; }),
42
43
  (0, class_transformer_1.Transform)(function (_a) {
43
44
  var value = _a.value;
44
45
  return new types_1.RFCDate(value);
package/dist/sdk/sdk.js CHANGED
@@ -34,9 +34,9 @@ var SDKConfiguration = /** @class */ (function () {
34
34
  function SDKConfiguration(init) {
35
35
  this.language = "typescript";
36
36
  this.openapiDocVersion = "1.0";
37
- this.sdkVersion = "1.19.2";
38
- this.genVersion = "2.143.2";
39
- this.userAgent = "speakeasy-sdk/typescript 1.19.2 2.143.2 1.0 orb-billing";
37
+ this.sdkVersion = "1.19.5";
38
+ this.genVersion = "2.147.0";
39
+ this.userAgent = "speakeasy-sdk/typescript 1.19.5 2.147.0 1.0 orb-billing";
40
40
  Object.assign(this, init);
41
41
  }
42
42
  return SDKConfiguration;
@@ -0,0 +1,12 @@
1
+ # AddAmendmentCreditLedgerEntryRequestParams
2
+
3
+
4
+ ## Fields
5
+
6
+ | Field | Type | Required | Description |
7
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
+ | `amount` | *any* | :heavy_check_mark: | The number of credits to effect. Note that this is required for increment, decrement or void operations. |
9
+ | `blockId` | *string* | :heavy_check_mark: | The ID of the block to reverse a decrement from. |
10
+ | `description` | *string* | :heavy_minus_sign: | Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc. |
11
+ | `entryType` | [AddAmendmentCreditLedgerEntryRequestParamsEntryType](../../models/shared/addamendmentcreditledgerentryrequestparamsentrytype.md) | :heavy_check_mark: | N/A |
12
+ | `metadata` | [AddAmendmentCreditLedgerEntryRequestParamsMetadata](../../models/shared/addamendmentcreditledgerentryrequestparamsmetadata.md) | :heavy_minus_sign: | User-specified key/value pairs for the ledger entry resource. |
@@ -0,0 +1,8 @@
1
+ # AddAmendmentCreditLedgerEntryRequestParamsEntryType
2
+
3
+
4
+ ## Values
5
+
6
+ | Name | Value |
7
+ | ----------- | ----------- |
8
+ | `Amendment` | amendment |
@@ -0,0 +1,9 @@
1
+ # AddAmendmentCreditLedgerEntryRequestParamsMetadata
2
+
3
+ User-specified key/value pairs for the ledger entry resource.
4
+
5
+
6
+ ## Fields
7
+
8
+ | Field | Type | Required | Description |
9
+ | ----------- | ----------- | ----------- | ----------- |
@@ -5,7 +5,7 @@
5
5
 
6
6
  | Field | Type | Required | Description |
7
7
  | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
- | `amount` | *any* | :heavy_check_mark: | The number of credits to effect. Note that this is required for increment, decrement or void operations. |
8
+ | `amount` | *any* | :heavy_check_mark: | The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations. |
9
9
  | `description` | *string* | :heavy_minus_sign: | Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc. |
10
10
  | `entryType` | [AddDecrementCreditLedgerEntryRequestParamsEntryType](../../models/shared/adddecrementcreditledgerentryrequestparamsentrytype.md) | :heavy_check_mark: | N/A |
11
11
  | `metadata` | [AddDecrementCreditLedgerEntryRequestParamsMetadata](../../models/shared/adddecrementcreditledgerentryrequestparamsmetadata.md) | :heavy_minus_sign: | User-specified key/value pairs for the ledger entry resource. |
@@ -5,7 +5,7 @@
5
5
 
6
6
  | Field | Type | Required | Description |
7
7
  | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
- | `amount` | *any* | :heavy_minus_sign: | The number of credits to effect. Note that this is required for increment, decrement or void operations. |
8
+ | `amount` | *any* | :heavy_minus_sign: | The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations. |
9
9
  | `blockId` | *string* | :heavy_minus_sign: | The ID of the block affected by an expiration_change, used to differentiate between multiple blocks with the same `expiry_date`. |
10
10
  | `description` | *string* | :heavy_minus_sign: | Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc. |
11
11
  | `entryType` | [AddExpirationChangeCreditLedgerEntryRequestParamsEntryType](../../models/shared/addexpirationchangecreditledgerentryrequestparamsentrytype.md) | :heavy_check_mark: | N/A |
@@ -5,7 +5,7 @@
5
5
 
6
6
  | Field | Type | Required | Description |
7
7
  | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
- | `amount` | *any* | :heavy_check_mark: | The number of credits to effect. Note that this is required for increment, decrement or void operations. |
8
+ | `amount` | *any* | :heavy_check_mark: | The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations. |
9
9
  | `description` | *string* | :heavy_minus_sign: | Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc. |
10
10
  | `effectiveDate` | [RFCDate](../../types/rfcdate.md) | :heavy_minus_sign: | A future date (specified in YYYY-MM-DD format) that denotes when this credit balance should become available for use. |
11
11
  | `entryType` | [AddIncrementCreditLedgerEntryRequestParamsEntryType](../../models/shared/addincrementcreditledgerentryrequestparamsentrytype.md) | :heavy_check_mark: | N/A |
@@ -5,6 +5,7 @@
5
5
 
6
6
  | Field | Type | Required | Description |
7
7
  | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
+ | `amount` | *any* | :heavy_check_mark: | The number of credits to effect. Note that this is required for increment, decrement, void, or undo operations. |
8
9
  | `blockId` | *string* | :heavy_check_mark: | The ID of the block to void. |
9
10
  | `description` | *string* | :heavy_minus_sign: | Optional metadata that can be specified when adding ledger results via the API. For example, this can be used to note an increment refers to trial credits, or for noting corrections as a result of an incident, etc. |
10
11
  | `entryType` | [AddVoidCreditLedgerEntryRequestParamsEntryType](../../models/shared/addvoidcreditledgerentryrequestparamsentrytype.md) | :heavy_check_mark: | N/A |
@@ -16,7 +16,95 @@ The [Credit Ledger Entry resource](/guides/product-catalog/prepurchase) models p
16
16
 
17
17
  ## addByExternalId
18
18
 
19
- Create ledger entry by external ID
19
+ This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to
20
+ increment balance, deduct credits, and change the expiry date of existing credits.
21
+
22
+ ## Effects of adding a ledger entry
23
+ 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that
24
+ represents the changes (i.e. balance changes or transfers).
25
+ 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the
26
+ [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In
27
+ the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans
28
+ credit blocks.
29
+ 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on
30
+ `amount` and `per_unit_cost_basis`).
31
+
32
+ ## Adding credits
33
+ Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of
34
+ credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description
35
+ to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate
36
+ how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
37
+
38
+ The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
39
+
40
+ ```json
41
+ {
42
+ "entry_type": "increment",
43
+ "amount": 100,
44
+ "expiry_date": "2022-12-28",
45
+ "per_unit_cost_basis": "0.20",
46
+ "description": "Purchased 100 credits"
47
+ }
48
+ ```
49
+
50
+ Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the
51
+ remaining amount to the desired credit block.
52
+
53
+ ### Invoicing for credits
54
+ By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass
55
+ `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the
56
+ credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the
57
+ invoice are calculated by multiplying the cost basis with the number of credit units added.
58
+
59
+ ## Deducting Credits
60
+ Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the
61
+ algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the
62
+ deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also
63
+ optionally allows specifying a description to assist with auditing.
64
+
65
+ The following snippet illustrates a sample request body to decrement credits.
66
+
67
+ ```json
68
+ {
69
+ "entry_type": "decrement",
70
+ "amount": 20,
71
+ "description": "Removing excess credits"
72
+ }
73
+ ```
74
+
75
+ ## Changing credits expiry
76
+ If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`.
77
+ For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter
78
+ `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created
79
+ with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
80
+
81
+ Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer
82
+ amount determined by the `amount` parameter.
83
+
84
+ The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
85
+
86
+ ```json
87
+ {
88
+ "entry_type": "expiration_change",
89
+ "amount": 10,
90
+ "expiry_date": "2022-12-28",
91
+ "block_id": "UiUhFWeLHPrBY4Ad",
92
+ "target_expiry_date": "2023-12-28",
93
+ "description": "Extending credit validity"
94
+ }
95
+ ```
96
+
97
+ ## Voiding credits
98
+
99
+ If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, `block_id` is required
100
+ to identify the block, and `amount` indicates how many credits to void, up to the block's initial balance. Pass
101
+ in a `void_reason` of `refund` if the void is due to a refund.
102
+
103
+ ## Amendment
104
+
105
+ If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. For this entry, `block_id`
106
+ is required to identify the block that was originally decremented from, and `amount` indicates how many credits to return
107
+ to the customer, up to the block's initial balance.
20
108
 
21
109
  ### Example Usage
22
110
 
@@ -24,6 +112,7 @@ Create ledger entry by external ID
24
112
  import { Orb } from "orb-billing";
25
113
  import { CreateLedgerEntryExternalIdResponse } from "orb-billing/dist/sdk/models/operations";
26
114
  import {
115
+ AddAmendmentCreditLedgerEntryRequestParamsEntryType,
27
116
  AddDecrementCreditLedgerEntryRequestParamsEntryType,
28
117
  AddExpirationChangeCreditLedgerEntryRequestParamsEntryType,
29
118
  AddIncrementCreditLedgerEntryRequestParamsEntryType,
@@ -40,11 +129,11 @@ const sdk = new Orb({
40
129
 
41
130
  sdk.credit.addByExternalId({
42
131
  requestBody: {
43
- blockId: "navigate Southwest Silver",
132
+ amount: "543.93",
133
+ blockId: "Southwest Silver",
44
134
  description: "Fully-configurable object-oriented projection",
45
- entryType: AddVoidCreditLedgerEntryRequestParamsEntryType.Void,
135
+ entryType: AddAmendmentCreditLedgerEntryRequestParamsEntryType.Amendment,
46
136
  metadata: {},
47
- voidReason: AddVoidCreditLedgerEntryRequestParamsVoidReason.Refund,
48
137
  },
49
138
  externalCustomerId: "misspend Rubidium",
50
139
  }).then((res: CreateLedgerEntryExternalIdResponse) => {
@@ -69,7 +158,95 @@ sdk.credit.addByExternalId({
69
158
 
70
159
  ## create
71
160
 
72
- Create ledger entry
161
+ This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to
162
+ increment balance, deduct credits, and change the expiry date of existing credits.
163
+
164
+ ## Effects of adding a ledger entry
165
+ 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that
166
+ represents the changes (i.e. balance changes or transfers).
167
+ 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the
168
+ [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In
169
+ the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans
170
+ credit blocks.
171
+ 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on
172
+ `amount` and `per_unit_cost_basis`).
173
+
174
+ ## Adding credits
175
+ Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of
176
+ credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description
177
+ to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate
178
+ how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
179
+
180
+ The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
181
+
182
+ ```json
183
+ {
184
+ "entry_type": "increment",
185
+ "amount": 100,
186
+ "expiry_date": "2022-12-28",
187
+ "per_unit_cost_basis": "0.20",
188
+ "description": "Purchased 100 credits"
189
+ }
190
+ ```
191
+
192
+ Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the
193
+ remaining amount to the desired credit block.
194
+
195
+ ### Invoicing for credits
196
+ By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass
197
+ `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the
198
+ credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the
199
+ invoice are calculated by multiplying the cost basis with the number of credit units added.
200
+
201
+ ## Deducting Credits
202
+ Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the
203
+ algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the
204
+ deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also
205
+ optionally allows specifying a description to assist with auditing.
206
+
207
+ The following snippet illustrates a sample request body to decrement credits.
208
+
209
+ ```json
210
+ {
211
+ "entry_type": "decrement",
212
+ "amount": 20,
213
+ "description": "Removing excess credits"
214
+ }
215
+ ```
216
+
217
+ ## Changing credits expiry
218
+ If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`.
219
+ For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter
220
+ `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created
221
+ with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
222
+
223
+ Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer
224
+ amount determined by the `amount` parameter.
225
+
226
+ The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
227
+
228
+ ```json
229
+ {
230
+ "entry_type": "expiration_change",
231
+ "amount": 10,
232
+ "expiry_date": "2022-12-28",
233
+ "block_id": "UiUhFWeLHPrBY4Ad",
234
+ "target_expiry_date": "2023-12-28",
235
+ "description": "Extending credit validity"
236
+ }
237
+ ```
238
+
239
+ ## Voiding credits
240
+
241
+ If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, `block_id` is required
242
+ to identify the block, and `amount` indicates how many credits to void, up to the block's initial balance. Pass
243
+ in a `void_reason` of `refund` if the void is due to a refund.
244
+
245
+ ## Amendment
246
+
247
+ If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. For this entry, `block_id`
248
+ is required to identify the block that was originally decremented from, and `amount` indicates how many credits to return
249
+ to the customer, up to the block's initial balance.
73
250
 
74
251
  ### Example Usage
75
252
 
@@ -77,6 +254,7 @@ Create ledger entry
77
254
  import { Orb } from "orb-billing";
78
255
  import { CreateLedgerEntryResponse } from "orb-billing/dist/sdk/models/operations";
79
256
  import {
257
+ AddAmendmentCreditLedgerEntryRequestParamsEntryType,
80
258
  AddDecrementCreditLedgerEntryRequestParamsEntryType,
81
259
  AddExpirationChangeCreditLedgerEntryRequestParamsEntryType,
82
260
  AddIncrementCreditLedgerEntryRequestParamsEntryType,
@@ -94,11 +272,14 @@ const sdk = new Orb({
94
272
  sdk.credit.create({
95
273
  requestBody: {
96
274
  amount: 6384.24,
97
- description: "Synchronised full-range emulation",
98
- entryType: AddDecrementCreditLedgerEntryRequestParamsEntryType.Decrement,
275
+ blockId: "Money blue shred",
276
+ description: "Implemented web-enabled success",
277
+ entryType: AddExpirationChangeCreditLedgerEntryRequestParamsEntryType.ExpirationChange,
278
+ expiryDate: new RFCDate("2021-01-01"),
99
279
  metadata: {},
280
+ targetExpiryDate: new RFCDate("2022-05-14"),
100
281
  },
101
- customerId: "blue",
282
+ customerId: "evolve",
102
283
  }).then((res: CreateLedgerEntryResponse) => {
103
284
  if (res.statusCode == 200) {
104
285
  // handle response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orb-billing",
3
- "version": "1.19.2",
3
+ "version": "1.19.5",
4
4
  "author": "orbcorp",
5
5
  "scripts": {
6
6
  "prepare": "tsc --build"