Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat: initial pass at documentation. Sellers, Orders, Reports
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jun 25, 2020
1 parent 3996e0f commit dc86860
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 13 deletions.
57 changes: 45 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,61 @@
📦 @scaleleap/amazon-mws-api-sdk
===================================

A template for creating TypeScript applications.

---

This package does one, two and three.
A fully typed TypeScript SDK library for Amazon MWS API

## Download & Installation

```sh
$ npm i -s @scaleleap/amazon-mws-api-sdk
```

## Contributing
## Documentation (WIP)

This repository uses [Conventional Commit](https://www.conventionalcommits.org/) style commit messages.
[Click me!](docs)

Testing uses [global-agent](https://github.com/gajus/global-agent) to allow for request proxying/interception
for debugging.
## Example
---

1. Use [Charles.app](https://www.charlesproxy.com), or a similar MiM tool to proxy the requests.
2. Set the proxy server via `export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080`
3. Run tests `npm t` and you'll be able to inspect traffic going through.
```TypeScript
import {
amazonMarketplaces,
HttpClient,
MWSOptions,
Sellers,
Orders
} from 'amazon-mws-api-sdk'

const mwsOptions: MWSOptions = {
marketplace: amazonMarketplaces.US,
awsAccessKeyId: '',
mwsAuthToken: '',
sellerId: '',
secretKey: '',
}

const main = async () => {
const http = new HttpClient(mwsOptions)

// Get status for Sellers API
const sellers = new Sellers(http)
const [serviceStatus] = await sellers.getServiceStatus()
if (serviceStatus.Status === 'GREEN') {
console.log(`Sellers API is up on ${serviceStatus.Timestamp}!`)
}

// List Orders
const orders = new Orders(http)
const [ordersList, requestMeta] = await orders.listOrders({
MarketplaceId: [amazonMarketplaces.US.id],
CreatedAfter: new Date(Date.now() - 100 * 24 * 60 * 60 * 1000)
})

ordersList.Orders.forEach((order) => {
console.log(`Order ID is ${order.AmazonOrderId}`)
})
}
```
More examples in the `/examples` folder!

## Authors or Acknowledgments

Expand Down
133 changes: 133 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
## Table of Contents
* [Table of Contents](#table-of-contents)
* [Sellers](#sellers)
* [listMarketplaceParticipations](#listmarketplaceparticipations)
* [listMarketplaceParticipationsByNextToken](#listmarketplaceparticipationsbynexttoken)
* [getServiceStatus](#getservicestatus)
* [Orders](#orders)
* [listOrders](#listorders)
* [listOrdersByNextToken](#listordersbynexttoken)
* [getOrder](#getorder)
* [listOrderItems](#listorderitems)
* [listOrderItemsByNextToken](#listorderitemsbynexttoken)
* [getServiceStatus](#getservicestatus-1)
* [Reports](#reports)
* [requestReport](#requestreport)
* [getReportRequestList](#getreportrequestlist)
* [Subscriptions](#subscriptions)
* [FulfillmentInventory](#fulfillmentinventory)
* [Feeds](#feeds)
* [Products](#products)
* [Finances](#finances)

## Sellers

[Amazon MWS Sellers API official documentation](http://docs.developer.amazonservices.com/en_CA/sellers/Sellers_Overview.html)

### listMarketplaceParticipations
Parameters

| None |
|------|

### listMarketplaceParticipationsByNextToken

Parameters
| Name | Type | Example | Required |
|-----------|-----------|-----------------------------------------------------------------------|----------|
| NextToken | NextToken | new NextToken('action', 'nexttoken')<br>See examples for sample usage | Yes |
### getServiceStatus

Parameters

| None |
|------|

## Orders

### listOrders
Parameters

| Name | Type | Example | Required |
|--------------------|----------|----------------------------|-----------------------------------------|
| CreatedAfter | Date | new Date() | Yes if LastUpdatedAfter is not provided |
| CreatedBefore | Date | new Date() | No |
| LastUpdatedAfter | Date | new Date() | Yes if CreatedAfter is not provided |
| LastUpdatedBefore | Date | new Date() | No |
| OrderStatus | string | 'PendingAvailability' | No |
| MarketplaceId | string[] | ['A2EUQ1WTGCTBG2'] | No |
| FulfillmentChannel | string[] | ['AFN'] | No |
| PaymentMethod | string[] | ['COD'] | No |
| BuyerEmail | string | 'buyer@example.com' | No |
| SellerOrderId | string | 'STRINGID' | No |
| MaxResultsPerPage | number | 10 | No |
| EasyShipmentStatus | string[] | ['PendingPickUp'] | No |

* [Possible values for FulfillmentChannel, PaymentMethod and EasyShipmentStatus ](http://docs.developer.amazonservices.com/en_CA/orders-2013-09-01/Orders_ListOrders.html)

### listOrdersByNextToken
Parameters
| Name | Type | Example | Required |
|-----------|-----------|-----------------------------------------------------------------------|----------|
| NextToken | NextToken | new NextToken('action', 'nexttoken')<br>See examples for sample usage | Yes |

### getOrder
Parameters
| Name | Type | Example | Required |
|---------------|----------|-------------------------|----------|
| AmazonOrderId | string[] | ['902-3159896-1390916'] | Yes |

### listOrderItems
Parameters
| Name | Type | Example | Required |
|---------------|--------|-----------------------|----------|
| AmazonOrderId | string | '902-3159896-1390916' | Yes |
### listOrderItemsByNextToken
Parameters
| Name | Type | Example | Required |
|-----------|-----------|-----------------------------------------------------------------------|----------|
| NextToken | NextToken | new NextToken('action', 'nexttoken')<br>See examples for sample usage | Yes |
### getServiceStatus

Parameters

| None |
|------|

## Reports

### requestReport
Parameters
| Name | Type | Example | Required |
|------------------- |---------- |-------------------------------------- |---------- |
| ReportType | string | '_GET_FLAT_FILE_OPEN_LISTINGS_DATA_' | Yes |
| StartDate | Date | new Date() | No |
| EndDate | Date | new Date() | No |
| ReportOptions | string | 'Report Option' | No |
| MarketplaceIdList | string[] | ['A2EUQ1WTGCTBG2'] | No |

* [Possible values for ReportType](http://docs.developer.amazonservices.com/en_CA/reports/Reports_ReportType.html)

### getReportRequestList
Parameters


## Subscriptions

_coming soon_

## FulfillmentInventory

_in progress_

## Feeds

_in progress_

## Products

_in progress_

## Finances

_in progress_
4 changes: 4 additions & 0 deletions examples/get-service-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const main = async () => {
*/
const [serviceStatus, requestMeta] = await sellers.getServiceStatus()

if (serviceStatus.Status === 'GREEN') {
console.log(`Sellers API is up on ${serviceStatus.Timestamp}!`)
}

/**
* Check out Amazon's official docs for other available endpoints
* and definitions of possible request and response parameters
Expand Down
5 changes: 4 additions & 1 deletion examples/orders/list-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ const main = async () => {
// EasyShipShipmentStatus: easyShipmentStatus,
}

const [listOrders, requestMeta]: [ListOrders, RequestMeta] = await orders.listOrders(parameters)
const [ordersList, requestMeta]: [ListOrders, RequestMeta] = await orders.listOrders(parameters)
ordersList.Orders.forEach((order) => {
console.log(`Order ID is ${order.AmazonOrderId}`)
})

/**
* Check out Amazon's official docs for other available endpoints
Expand Down

0 comments on commit dc86860

Please sign in to comment.