This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
get-service-status.ts
61 lines (53 loc) · 1.7 KB
/
get-service-status.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable import/no-unresolved */
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* import from '@scaleleap/amazon-mws-api-sdk'
*/
import { amazonMarketplaces, HttpClient, MWS, Sellers } from '@scaleleap/amazon-mws-api-sdk'
/**
* Configure the HttpClient
*/
const mwsOptions = {
marketplace: amazonMarketplaces.US,
awsAccessKeyId: '',
mwsAuthToken: '',
sellerId: '',
secretKey: '',
}
/**
* Get service status of the Sellers API using sections directly
*/
const usingSections = async () => {
const http = new HttpClient(mwsOptions)
/**
* Configure which API you need
* Sellers, Orders, Fulfillment Inventory, Products, Reports, Subscriptions, Finances, Feeds
*/
const sellers = new Sellers(http)
/**
* Returns a tuple containing
* [0] Actual response data in JS object format
* [1] Metadata of the request
*/
const [serviceStatus, requestMeta] = await sellers.getServiceStatus()
if (serviceStatus.Status === 'GREEN') {
console.log(`Sellers API is up on ${serviceStatus.Timestamp}!`)
}
}
// Using MWS client
const usingMws = async () => {
const http = new HttpClient(mwsOptions)
const mws = new MWS(http)
const [serviceStatus] = await mws.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
* http://docs.developer.amazonservices.com/en_CA/dev_guide/index.html
* Under the folder API References
*/