Skip to content

Commit

Permalink
[patch] Support for Orders Import API (#137)
Browse files Browse the repository at this point in the history
* Add support for orders import API

* Update README.md

* Add changeset

* Correct markdown javascript annotation

* Add link to documentation
  • Loading branch information
darekg11 authored Aug 12, 2022
1 parent 020ef96 commit ae6110b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-crabs-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@voucherify/sdk': patch
---

Added support for orders import API
6 changes: 6 additions & 0 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ Methods are provided within `client.orders.*` namespace.
- [Get Order](#get-order)
- [Update Order](#update-order)
- [List Orders](#list-orders)
- [Import Orders](#import-orders)

#### [Create Order](https://docs.voucherify.io/reference/create-order)

Expand Down Expand Up @@ -675,6 +676,11 @@ client.orders.list()
client.orders.list(params)
```

#### [Import Orders](https://docs.voucherify.io/reference/import-orders)
```javascript
client.orders.import(orders)
```

---

### Products
Expand Down
8 changes: 8 additions & 0 deletions packages/sdk/src/Orders.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as T from './types/Orders'
import * as AAT from './types/AsyncActions'

import { encode, omit } from './helpers'
import type { RequestController } from './RequestController'
Expand Down Expand Up @@ -32,4 +33,11 @@ export class Orders {
public list(params: T.OrdersListParams = {}) {
return this.client.get<T.OrdersListResponse>('/orders', params)
}

/**
* @see https://docs.voucherify.io/reference/import-orders
*/
public import(orders: T.OrdersCreate[]) {
return this.client.post<AAT.AsyncActionCreateResponse>('/orders/import', orders)
}
}
4 changes: 4 additions & 0 deletions packages/sdk/src/types/AsyncActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ export interface AsyncActionsListResponse {
async_actions: Omit<AsyncActionsResponse, 'result'>[]
}

export interface AsyncActionCreateResponse {
async_action_id: string
}

export type AsyncActionsGetResponse = AsyncActionsResponse

0 comments on commit ae6110b

Please sign in to comment.