-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3c3234
commit 885836e
Showing
3 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
Contains all information about a given CsvOrder | ||
|
||
# Fields | ||
|
||
| Name | Type | Description | | ||
| ---------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------- | | ||
| `id` | `string` | The ID of the coupon. | | ||
| `name` | `string` | The name of the coupon. | | ||
| `companyId` | `string` | The ID of the company the coupon belongs to. | | ||
| `stats` | `object` | An object containing the stats of the coupon. With keys 'total', 'used' and 'remaining' | | ||
|
||
# Methods | ||
|
||
## `.getTemplate()` | ||
|
||
Get the template the order is based on. Uses [`PrintOne.getTemplate()`](./PrintOne#gettemplateid). | ||
|
||
**Returns: [`Promise<Template>`](./Template)** | ||
|
||
**Example** | ||
|
||
```js | ||
const order = await client.getOrder("example-order-id"); | ||
const template = await order.getTemplate(); | ||
``` | ||
|
||
--- | ||
|
||
## `.refresh()` | ||
|
||
Refresh the Coupon data to get the latest information | ||
|
||
**Returns: `Promise<void>`** | ||
|
||
**Example** | ||
|
||
```js | ||
const coupon: Coupon; | ||
await coupon.refresh(); | ||
``` | ||
|
||
--- | ||
|
||
## `Coupon.getCodes()` | ||
|
||
Get all coupon codes within the coupon. | | ||
|
||
**Returns: [`Promise<PaginatedResponse<CouponCode>>`](./CouponCode)** | ||
|
||
**Example** | ||
|
||
```js | ||
const couponCodes = await coupon.getCodes(); | ||
``` | ||
|
||
--- | ||
|
||
## `Coupon.getCode(id)` | ||
|
||
Get all coupon codes by its ID. | ||
|
||
**Parameters** | ||
|
||
| Name | Type | Description | | ||
| ---- | -------- | --------------------------------- | | ||
| `id` | `string` | The ID of the coupon code to get. | | ||
|
||
**Returns: [`Promise<PaginatedResponse<CouponCode>>`](./CouponCode)** | ||
|
||
**Example** | ||
|
||
```js | ||
const couponCode = await coupon.getCode('example-coupon-code-id'); | ||
``` | ||
|
||
--- | ||
|
||
## `Coupon.addCodes(csv)` | ||
|
||
Add coupon codes to the coupon by uploading a CSV. | ||
|
||
**Parameters** | ||
|
||
| Name | Type | Description | | ||
| ---------- | ------------- | --------------------------------- | | ||
| `csv` | `ArrayBuffer` | The file to upload. Must be a CSV | | ||
|
||
**Returns: `Promise<void>` | ||
|
||
**Example** | ||
|
||
```js | ||
const data = fs.readFileSync("example.csv").buffer; | ||
const file = await coupon.addCodes(data); | ||
``` | ||
|
||
|
||
--- | ||
|
||
## `Coupon.delete()` | ||
|
||
Delete the coupon. | ||
|
||
**Returns: `Promise<void>` | ||
|
||
**Example** | ||
|
||
```js | ||
await coupon.delete(); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Contains all information about a given CsvOrder | ||
|
||
# Fields | ||
|
||
| Name | Type | Description | | ||
| ---------------------- | ------------------------------------ | --------------------------------------------------------------------------------- | | ||
| `id` | `string` | The ID of the coupon code. | | ||
| `couponId` | `string` | The ID of the parent coupon. | | ||
| `code` | `string` | The actual code saved for the coupon code`. | | ||
| `used` | `boolean` | Whether the coupon code has been used. | | ||
| `usedAt` | `Date` or `null` | The date at which the coupon code was used or `null` if not used yet. | | ||
| `orderId` | `string` or `null` | The order ID by which the coupon code was used or `null` if not used yet. | | ||
|
||
# Methods | ||
--- | ||
|
||
## `.refresh()` | ||
|
||
Refresh the CouponCode data to get the latest information | ||
|
||
**Returns: `Promise<void>`** | ||
|
||
**Example** | ||
|
||
```js | ||
const couponCode: CouponCOde; | ||
await couponCode.refresh(); | ||
``` | ||
|
||
--- | ||
|
||
## `.getOrder()` | ||
|
||
Get the order the coupon code was used by. You might need to do [`CouponCode.refresh`](#refresh) first when coupon was used after fetching. | ||
|
||
**Returns: [`Promise<Order|null>`](./Order)** | ||
|
||
**Example** | ||
|
||
```js | ||
const couponCode: CouponCode | ||
const order = await couponCode.getOrder();; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters