Skip to content

Commit 27bc847

Browse files
authored
Merge pull request #3 from ifcore/sync-with-amazon-main
Sync with amazon main
2 parents 6810166 + 279d734 commit 27bc847

File tree

90 files changed

+47511
-16434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+47511
-16434
lines changed
Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,29 @@
1-
name: "Close stale issues"
1+
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2+
#
3+
# You can adjust the behavior by modifying this file.
4+
# For more information, see:
5+
# https://github.com/actions/stale
6+
name: Mark stale issues and pull requests
27

3-
# Controls when the action will run.
48
on:
59
schedule:
6-
# Controls when the action will run: Minute (0-59) | Hour (0-23) | Day of the month (1-31) | Month (1-12 or JAN-DEC) | Day of the week (0-6 or SUN-SAT)
7-
- cron: "30 18 * * *"
10+
- cron: '5 * * * *'
811

912
jobs:
10-
cleanup:
11-
name: Stale issue job
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: aws-actions/stale-issue-cleanup@v4
15-
with:
16-
17-
#Issue types to process ("issues", "pull_requests", or "issues,pull_requests")
18-
issue-types: 'issues'
19-
# Setting messages to an empty string will cause the automation to skip
20-
# that category
21-
# Implementing ancient issue closure only at the moment.
22-
stale-issue-message: 'This is a very old issue that is probably not getting as much
23-
attention as it deserves.
24-
We encourage you to check if this is still an issue after
25-
the latest release and if you find that this is still a problem, please feel free
26-
to open a new issue and make a reference to this one.'
27-
#ancient-issue-message: 'It looks like this issue has not been active for more than thirty days.
28-
#In the absence of more information, we will be closing this issue soon.
29-
#If you find that this is still a problem, please add a comment to prevent automatic closure, or
30-
#if the issue is already closed please feel free to reopen it.'
31-
32-
# These labels are required
33-
stale-issue-label: 'closing soon'
34-
exempt-issue-labels: 'no auto-closure'
35-
response-requested-label: 'answer required'
13+
stale:
3614

37-
# Don't set closed-for-staleness label to skip closing very old issues
38-
# regardless of label
39-
closed-for-staleness-label: 'closed for inactivity'
40-
41-
# Issue timing. Setting ancient issues to 6 months and stale to 1 month with no activity.
42-
# Issue will automatically close after 5 days of being marked as stale.
43-
days-before-stale: 180
44-
days-before-close: 5
45-
days-before-ancient: 180
46-
47-
# If you don't want to mark an issue as being ancient based on a
48-
# threshold of "upvotes", you can set this here. An "upvote" is
49-
# the total number of +1, heart, hooray, and rocket reactions
50-
# on an issue.
51-
# Current threshold based off the minimum expected for a possible bug.
52-
minimum-upvotes-to-exempt: 10
15+
runs-on: ubuntu-latest
16+
permissions:
17+
issues: write
18+
contents: write
5319

54-
repo-token: ${{ secrets.GITHUB_TOKEN }}
55-
loglevel: DEBUG
56-
# Set dry-run to true to not perform label or close actions.
57-
#dry-run: true
20+
steps:
21+
- uses: actions/stale@v9
22+
with:
23+
days-before-issue-stale: 30
24+
days-before-issue-close: 8
25+
close-issue-message: 'closed for inactivity'
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
27+
stale-issue-message: 'This issue is scheduled to close soon. If you are still encountering problems, please feel free to open a new issue and make a reference to this one.'
28+
stale-issue-label: 'closing soon'
29+
operations-per-run: 1000

.github/workflows/rdme-openapi.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This GitHub Actions workflow was auto-generated by the `rdme` cli on 2024-11-06T18:56:19.723Z
2+
# You can view our full documentation here: https://docs.readme.com/docs/rdme
3+
name: ReadMe GitHub Action 🦉
4+
5+
on:
6+
push:
7+
branches:
8+
# This workflow will run every time you push code to the following branch: `main`
9+
# Check out GitHub's docs for more info on configuring this:
10+
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
11+
- main
12+
13+
jobs:
14+
rdme-openapi:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out repo 📚
18+
uses: actions/checkout@v3
19+
20+
- name: Run `openapi` command 🚀
21+
uses: readmeio/rdme@v8
22+
with:
23+
rdme: openapi catalog-items-api-model/catalogItems_2022-04-01.json --key=${{ secrets.README_API_KEY }} --id=672bbbc7847aca00335d8976
24+
- name: Run `openapi` command 🚀
25+
uses: readmeio/rdme@v8
26+
with:
27+
rdme: openapi fulfillment-inbound-api-model/fulfillmentInbound_2024-03-20.json --key=${{ secrets.README_API_KEY }} --id=672bbde35d2c6300178a79aa
28+
- name: Run `openapi` command 🚀
29+
uses: readmeio/rdme@v8
30+
with:
31+
rdme: openapi feeds-api-model/feeds_2021-06-30.json --key=${{ secrets.README_API_KEY }} --id=672bbc58bccd1cf23f81fdbf
32+
- name: Run `openapi` command 🚀
33+
uses: readmeio/rdme@v8
34+
with:
35+
rdme: openapi vendor-shipments-api-model/vendorShipments.json --key=${{ secrets.README_API_KEY }} --id=672bbe959736d800458d34a1
36+
- name: Run `openapi` command 🚀
37+
uses: readmeio/rdme@v8
38+
with:
39+
rdme: openapi vendor-invoices-api-model/vendorInvoices.json --key=${{ secrets.README_API_KEY }} --id=672bbe78195b89000fdd5a12
40+
- name: Run `openapi` command 🚀
41+
uses: readmeio/rdme@v8
42+
with:
43+
rdme: openapi reports-api-model/reports_2021-06-30.json --key=${{ secrets.README_API_KEY }} --id=672bbe4a70bc520012f0807f
44+
- name: Run `openapi` command 🚀
45+
uses: readmeio/rdme@v8
46+
with:
47+
rdme: openapi orders-api-model/ordersV0.json --key=${{ secrets.README_API_KEY }} --id=672bbe2b026480e27a6cd778
48+
- name: Run `openapi` command 🚀
49+
uses: readmeio/rdme@v8
50+
with:
51+
rdme: openapi listings-items-api-model/listingsItems_2021-08-01.json --key=${{ secrets.README_API_KEY }} --id=672bbe0cd03b2700626433b0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Send dispatch event to selling-partner-api-sdk
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'main'
8+
paths:
9+
- 'clients/**'
10+
- 'models/**'
11+
12+
jobs:
13+
trigger-event:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Trigger workflow
17+
run: |
18+
curl -X POST https://api.github.com/repos/amzn/selling-partner-api-sdk/dispatches \
19+
-H 'Accept: application/vnd.github.everest-preview+json' \
20+
-u ${{ secrets.MAFGE_PAT }} \
21+
--data '{"event_type": "trigger-build"}'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.idea
22
*.iml
3-
.DS_Store
3+
.DS_Store

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
# Modifications
1+
# `sellingpartnerapi-aa-java` Fork
2+
3+
## Modifications
4+
5+
All modifications apply to the `sellingpartnerapi-aa-java` client.
26

37
* Dependency updates (not okhttp and apache httpcomponents - sadly)
48
* Attach sources to jar
59
* Define ItemAttributes of Catalog API as hashmap containing arrays of jsonObjects
610
* bugfix for stackoverflow error caused by networkInterceptors in async methods
711

8-
# Update instructions
12+
## Update instructions
913

1014
to update this repository with changes by Amazon:
1115

1216
* add a git remote for the amazon repo: `git remote add amazon git@github.com:amzn/selling-partner-api-models.git`
1317
* create a new branch and perform a git merge: `git merge amazon/main`
1418

19+
# Amazon README
20+
1521
## Selling Partner API Models
16-
This repository contains Swagger models for developers to use to create software to call Selling Partner APIs. Developers can use [swagger codegen](https://github.com/swagger-api/swagger-codegen) to generate client libraries from these models. Please refer to [selling-partner-api-docs](https://github.com/amzn/selling-partner-api-docs) for additional documentation and read the [Selling Partner API Developer Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md) for instructions to get started.
22+
This repository contains Swagger models for developers to use to create software that calls Selling Partner APIs. Developers can use [swagger codegen](https://github.com/swagger-api/swagger-codegen) to generate client libraries from these models. Please refer to [selling-partner-api-docs](https://github.com/amzn/selling-partner-api-docs) for additional documentation and read the [Selling Partner API Developer Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md) for instructions to get started.
1723

1824
The [models directory](https://github.com/amzn/selling-partner-api-models/tree/main/models) contains all of the currently available Selling Partner API models.
1925

2026
The [clients directory](https://github.com/amzn/selling-partner-api-models/tree/main/clients) contains a [Java library](https://github.com/amzn/selling-partner-api-models/tree/main/clients/sellingpartner-api-aa-java) and a [C# library](https://github.com/amzn/selling-partner-api-models/tree/main/clients/sellingpartner-api-aa-csharp) with mustache templates for use with [swagger-codegen](https://swagger.io/tools/swagger-codegen/) to generate client libraries with authentication and authorization functionality included. The templates are located in *resources/swagger-codegen*.
2127

2228
The [schemas directory](https://github.com/amzn/selling-partner-api-models/tree/main/schemas) contains all of the currently available Selling Partner Api schemas.
2329

30+
**Note:** For any issues related to SP API like bugs or troubleshooting, please reach out to [Developer Support](https://developer.amazonservices.com/support) so that the right team can help / channel your inputs (in case of bugs / feature requests) to the development team.
31+
2432
## Security
2533

2634
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

clients/sellingpartner-api-aa-java/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.amazon.sellingpartnerapi</groupId>
77
<artifactId>sellingpartnerapi-aa-java</artifactId>
88
<packaging>jar</packaging>
9-
<version>2.0.0-IFCv1</version>
9+
<version>2.0.0-IFCv2</version>
1010
<build>
1111
<plugins>
1212
<plugin>
@@ -110,7 +110,7 @@
110110
<dependency>
111111
<groupId>com.amazonaws</groupId>
112112
<artifactId>aws-java-sdk-signer</artifactId>
113-
<version>1.12.271</version>
113+
<version>1.12.778</version>
114114
</dependency>
115115
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
116116
<dependency>
@@ -123,7 +123,7 @@
123123
<dependency>
124124
<groupId>com.google.code.gson</groupId>
125125
<artifactId>gson</artifactId>
126-
<version>2.9.0</version>
126+
<version>2.10.1</version>
127127
</dependency>
128128
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp -->
129129
<dependency>
@@ -182,7 +182,7 @@
182182
<dependency>
183183
<groupId>com.google.guava</groupId>
184184
<artifactId>guava</artifactId>
185-
<version>30.1.1-jre</version>
185+
<version>33.3.1-jre</version>
186186
</dependency>
187187
</dependencies>
188188
</project>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Selling Partner API JavaScript client library for Node.js (v18 or later)
2+
3+
## About this library
4+
This library is to help SP-API developers to create an app in JavaScript on Node.js easier than calling HTTP endpoints directly. This library comes with the following features.
5+
1. Login with Amazon (LWA) helper that does OAuth token refresh flow.
6+
2. This library takes care of HTTP communication with SP-API endpoints with a help of [superagent](https://www.npmjs.com/package/superagent), so you can call SP-API by just calling a right method of library that corresponds to SP-API operation.
7+
3. Calling SP-API requires non-standard `x-amz-access-token` HTTP request header in request. The SDK generated by this library supports to include this header with token value you specify.
8+
4. SP-API operaitons to handle restricted data are categorized as ["Restricted Operations"](https://developer-docs.amazon.com/sp-api/lang-ja_JP/docs/tokens-api-use-case-guide#restricted-operations), which requires ["Restricted Data Token" (RDT)](https://developer-docs.amazon.com/sp-api/lang-ja_JP/docs/authorization-with-the-restricted-data-token) instead of access token for tighter security. Calling restricted operation involves two seprate steps, one of wihch is calling Tokens API to retrieve RDT and the other of which is calling protected operation with RDT. This library helps to compbine these two steps into single library call.
9+
10+
## Installation and Generating SDK
11+
Please note this library doesn't include SDK. You need to generate SDK with the template and script files included in this library.
12+
### Prerequisites for SDK Generation
13+
* Java version 7 or higher
14+
* swagger-codegen-cli (swagger-codegen-cli-2.4.29) is recommended.
15+
* Download swagger-codegen-cli JAR file and store it. You will need its path later when generating SDK.
16+
* Node.js v18 or higher.
17+
18+
__CAUTION__: Please be aware that there are two major known issues with the latest JavaScript client library.
19+
1. If you use swagger-codegen-cli newer than 2.4.29 (such as 2.4.30 or 3.x), there is a known compatibility issue with SP-API models that makes generating SDK fail. We recommend that you use swagger-codegen-cli-2.4.29 specifically.
20+
2. Swagger codegen tool fails to generate SDK for "Merchant Fulfillment V0 API." For workaround, you need to modify a part of the API model file "merchantFulfillmentV0.json"
21+
22+
### Download swagger-codegen-cli JAR file
23+
We use `swagger-codegen-cli` executable JAR file. You can download it by the following command.
24+
```bash
25+
$ wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.29/swagger-codegen-cli-2.4.29.jar
26+
```
27+
### Installing dependencies
28+
Change the directory to `<package root>/src`. Run the following command to install dependencies in Node.js environment.
29+
```bash
30+
$ npm install
31+
```
32+
33+
### Download API models and Generate SDK
34+
Go to `<package root>/src` directory which is under the package root. In this directory you should be able to find `generate-js-sdk.sh` shell script file.
35+
Run this script as the command line below.
36+
```bash
37+
$ ./generate-js-sdk.sh -j <your path to swagger-codegen-cli-2.4.X.jar>
38+
```
39+
40+
You will find `models` directory and `sdk` directory under the package root.<br>
41+
* `models`: directory contains API models cloned from SP-API GitHub.
42+
* `sdk`: directory contains generated JavaScript SDK.
43+
44+
### Modify Merchant Fulfillment API model file to avoid error during SDK generation
45+
If you want to call Merchant Fulfillment API with the generated SDK, you need to follow this instruction. There is an fatal known issue in generating Merchant Fulfillment API library. If downloading API models is successful, you should be able to find `merchantFulfillmentV0.json` file In `<package root>/models/merchant-fulfillment-api-model` directory. Open this file with an editor and find the following part.
46+
```
47+
"AvailableFormatOptionsForLabel": {
48+
"$ref": "#/definitions/AvailableFormatOptionsForLabelList"
49+
},
50+
```
51+
Since this part causes a fatal error in SDK generation for JavaScript, please replace this part with the following snipet.
52+
```
53+
"AvailableFormatOptionsForLabel": {
54+
"type": "array",
55+
"description": "The available label formats.",
56+
"items": {
57+
"$ref": "#/definitions/LabelFormatOption"
58+
}
59+
},
60+
```
61+
After modification, please run the shell script (`generate-js-sdk.sh`) again but you should type 'n' to the prompt that asks whether to download models again.
62+
```bash
63+
$ ./generate-js-sdk.sh -j ~/devbin/swagger-codegen-cli-2.4.29.jar
64+
Found <package root>/models already exists. Would you like to delete all the files under '<package root>/models' and clone again? [y/n]: n # answer 'n' otherwise modification will be overwritten.
65+
66+
```
67+
With the correct modification in `merchantFulfillmentV0.json`, you should be able to find generated SDK for Merchant Fulfillment API.
68+
69+
### How to run tests
70+
This library contains a sample programs in `sample_node_app` directory under the packagte root.<br>In order to run the program, you need to have LWA credential information saved in the file and name it `app.config.mjs` and put it `<package root>/src` directory. Because __client secret__ and __refresh token__ shouldn't be exposed, you must make sure that you don't commit this file to the repository.
71+
```javascript
72+
export const AppConfig = {
73+
lwaClientId: "< LWA client ID >",
74+
lwaClientSecret: "< LWA client secret >",
75+
lwaRefreshToken: "< LWA refresh token >",
76+
endpoint: "https://sandbox.sellingpartnerapi-na.amazon.com",
77+
}
78+
```
79+
After you save `app.config.mjs` file, you can run the sample program`.
80+
```bash
81+
$ npm run test
82+
```
83+
---
84+
## How to use SDK
85+
### Calling SP-API operation with LWA credentials
86+
```javascript
87+
import { SellersApi, ApiClient as SellersApiClient } from '../../sdk/src/sellers/index.js';
88+
89+
const sellerApiClient = new SellersApiClient("https://sellingpartnerapi-na.amazon.com");
90+
const sellerApi = new SellersApi(sellerApiClient);
91+
sellerApiClient.enableAutoRetrievalAccessToken("<client ID>", "<client secret>", "<refresh token>");
92+
const participations = await sellerApi.getMarketplaceParticipations();
93+
```
94+
### Calling RDT-required SP-API operation with LWA credentials
95+
```javascript
96+
import { OrdersV0Api, ApiClient as OrdersApiClient } from '../../sdk/src/ordersV0/index.js';
97+
98+
const ordersApiClient = new OrdersApiClient("https://sellingpartnerapi-fe.amazon.com");
99+
ordersApiClient.enableAutoRetrievalRestrictedDataToken("<client ID>",
100+
"<client secret>", "<refresh token>", ["buyerInfo", "shippingAddress"]);
101+
const ordersApi = new OrdersV0Api(ordersApiClient);
102+
const order = await ordersApi.getOrder("<order ID to retrieve>");
103+
```
104+
### Calling SP-API with access token
105+
In case you manage LWA token refresh flow, you can explicitly use the access token you got yourself for your SP-API call as follows.
106+
```javascript
107+
import { SellersApi, ApiClient as SellersApiClient } from '../../sdk/src/sellers/index.js';
108+
109+
const sellerApiClient = new SellersApiClient("https://sellingpartnerapi-fe.amazon.com");
110+
const sellerApi = new SellersApi(sellerApiClient);
111+
sellerApiClient.applyXAmzAccessTokenToRequest("<access token you retrieve yourself>");
112+
const participations = await sellerApi.getMarketplaceParticipations();
113+
```
114+
### LWA Token refresh helper
115+
The following code shows how to use `LwaAuthClient` to execute token refresh flow.
116+
```javascript
117+
import { LwaAuthClient } from "<path to helper/LwaAuthClient.mjs>";
118+
119+
const lwaClient = new LwaAuthClient("<client ID>", "<client secret>", "<refresh token>");
120+
const accessToken = await lwaClient.getAccessToken();
121+
```

0 commit comments

Comments
 (0)