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

Commit

Permalink
feat: add list orders example
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado authored and moltar committed Jun 28, 2020
1 parent 59f0aae commit f28e97a
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/get-service-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* import from 'amazon-mws-api-sdk'
*/
import { amazonMarketplaces, HttpClient, MWSOptions, Sellers } from '../src'
import { ServiceStatus } from '../src/parsing'

/**
* Configure the HttpClient
Expand Down Expand Up @@ -38,6 +39,7 @@ const main = async () => {

/**
* Check out Amazon's official docs for other available endpoints
* and definitions of possible request and response parameters
* http://docs.developer.amazonservices.com/en_CA/dev_guide/index.html
* Under the folder API References
*/
Expand Down
81 changes: 81 additions & 0 deletions examples/orders/list-orders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unused-vars */

/**
* import from 'amazon-mws-api-sdk'
*/
import {
amazonMarketplaces,
EasyShipShipmentStatus,
FulfillmentChannel,
HttpClient,
ListOrderParameters,
ListOrders,
MWSOptions,
Orders,
OrderStatus,
PaymentMethod,
RequestMeta,
} from '../../src'
/**
* Configure the HttpClient
*/

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

const http = new HttpClient(mwsOptions)
/**
* Configure which API you need
* Sellers, Orders, Fulfillment Inventory, Products, Reports, Subscriptions, Finances, Feeds
*/
const orders = new Orders(http)

const main = async () => {
const easyShipmentStatus: EasyShipShipmentStatus = ['PendingPickUp']
const paymentMethod: PaymentMethod = ['COD']
const fulfillmentChannel: FulfillmentChannel = ['AFN']
const orderStatus: OrderStatus = ['PendingAvailability']

const afterDate = new Date(Date.now() - 150 * 24 * 60 * 60 * 1000) // Date from 150 days ago
const beforeDate = new Date(Date.now() - 100 * 24 * 60 * 60 * 1000) // Date from 100 days ago

const parameters: ListOrderParameters = {
/**
* REQUIRED
*/
MarketplaceId: [amazonMarketplaces.US.id],
/**
* Either `CreatedAfter` or `LastUpdatedAfter` not both
*/
CreatedAfter: afterDate,
// LastUpdatedAfter: afterDate,

/**
* OPTIONAL
*/
// CreatedBefore: beforeDate,
// LastUpdatedBefore: beforeDate,
// OrderStatus: orderStatus,
// FulfillmentChannel: fulfillmentChannel,
// PaymentMethod: paymentMethod,
// BuyerEmail: 'email@example.com',
// SellerOrderId: '123',
// MaxResultsPerPage: 10,
// EasyShipShipmentStatus: easyShipmentStatus,
}

const [listOrders, requestMeta]: [ListOrders, RequestMeta] = await orders.listOrders(parameters)

/**
* Check out Amazon's official docs for other available endpoints
* and definitions of possible request and response parameters
* http://docs.developer.amazonservices.com/en_CA/dev_guide/index.html
* Under the folder API References
*/
}

0 comments on commit f28e97a

Please sign in to comment.