Skip to content

Commit 9a562be

Browse files
author
Gonzalo Cuadrado
committed
Merge branch 'main' of https://github.com/gcuadrado/Amazon-SP-API-CSharp into main
2 parents 2d45ec2 + 5a1d446 commit 9a562be

36 files changed

+297
-249
lines changed

README.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Amazon Selling Partner API C# 🚀 [![.NET](https://github.com/abuzuhri/Amazon-SP-API-CSharp/actions/workflows/dotnet.yml/badge.svg)](https://github.com/abuzuhri/Amazon-SP-API-CSharp/actions/workflows/dotnet.yml) [![NuGet](https://img.shields.io/nuget/v/CSharpAmazonSpAPI.svg)](https://www.nuget.org/packages/CSharpAmazonSpAPI/) [![Gitter Chat](https://badges.gitter.im/bitwarden/Lobby.svg)](https://gitter.im/Amazon-SP-API-CSharp/community)
1+
# Amazon Selling Partner API C# 🚀 [![.NET](https://github.com/abuzuhri/Amazon-SP-API-CSharp/actions/workflows/dotnet.yml/badge.svg)](https://github.com/abuzuhri/Amazon-SP-API-CSharp/actions/workflows/dotnet.yml) [![NuGet](https://img.shields.io/nuget/v/CSharpAmazonSpAPI.svg)](https://www.nuget.org/packages/CSharpAmazonSpAPI/) [![Gitter Chat](https://badges.gitter.im/bitwarden/Lobby.svg)](https://gitter.im/Amazon-SP-API-CSharp/community)
22

33

44
This is an API Binding in .Net C# for the new Amazon Selling Partner API.
@@ -17,16 +17,13 @@ The purpose of this package is to have an easy way of getting started with the A
1717
- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations/)
1818
- [System.Reflection](https://www.nuget.org/packages/System.Reflection/)
1919

20+
2021
---
21-
### Useful links
22-
##### [Selling Partner API](https://developer-docs.amazon.com/sp-api)
23-
##### [Amazon MWS to SP-API Migration Guide](https://developer-docs.amazon.com/sp-api/docs/amazon-mws-to-sp-api-migration-guide#mapping-apis-from-amazon-mws-to-the-selling-partner-api)
24-
##### [SP-API models](https://developer-docs.amazon.com/sp-api/page/sp-api-models)
25-
##### [Using Postman for Selling Partner API models](https://developer-docs.amazon.com/sp-api/page/sp-api-models)
26-
##### [Test Project with pure C# code](https://github.com/abuzuhri/Amazon-SP-API-CSharp/tree/main/Others/PureCodeSampleForTest)
27-
##### [Sample Code](https://github.com/abuzuhri/Amazon-SP-API-CSharp/tree/main/Source/FikaAmazonAPI.SampleCode)
28-
##### [Creating And Configuring AWS](https://developer-docs.amazon.com/sp-api/docs/creating-and-configuring-iam-policies-and-entities)
22+
## Installation [![NuGet](https://img.shields.io/nuget/v/CSharpAmazonSpAPI.svg)](https://www.nuget.org/packages/CSharpAmazonSpAPI/)
2923

24+
```powershell
25+
Install-Package CSharpAmazonSpAPI
26+
```
3027

3128
---
3229
### Tasks
@@ -71,37 +68,24 @@ The purpose of this package is to have an easy way of getting started with the A
7168

7269

7370

74-
---
75-
## Installation [![NuGet](https://img.shields.io/nuget/v/CSharpAmazonSpAPI.svg)](https://www.nuget.org/packages/CSharpAmazonSpAPI/)
76-
77-
```powershell
78-
Install-Package CSharpAmazonSpAPI
79-
```
80-
81-
---
82-
## Contributing
83-
84-
1. Fork it (https://github.com/abuzuhri/Amazon-SP-API-CSharp/fork)
85-
2. Clone it (`git clone https://github.com/{YOUR_USERNAME}/Amazon-SP-API-CSharp`)
86-
3. Create your feature branch (`git checkout -b your_branch_name`)
87-
4. Commit your changes (`git commit -m 'Description of a commit'`)
88-
5. Push to the branch (`git push origin your_branch_name`)
89-
6. Create a new Pull Request
90-
9171
---
9272
## Keys
73+
To get all keys needed you need to follow this step [Creating and configuring IAM policies and entities](https://developer-docs.amazon.com/sp-api/docs/creating-and-configuring-iam-policies-and-entities) and then you need to [Registering your Application](https://developer-docs.amazon.com/sp-api/docs/registering-your-application) then [Authorizing Selling Partner API applications
74+
](https://developer-docs.amazon.com/sp-api/docs/authorizing-selling-partner-api-applications#step-1-request-a-login-with-amazon-access-token)
75+
> :warning: **Use role ARN created in step 5 when you register your application**: and dont use IAM user
76+
9377
| Name | Description |
9478
| --- | --- |
9579
| AccessKey | AWS USER ACCESS KEY |
9680
| SecretKey | AWS USER SECRET KEY |
9781
| RoleArn | AWS IAM Role ARN (needs permission to “Assume Role” STS) |
98-
| Region | Marketplace region |
82+
| Region | Marketplace region [List of Marketplaces](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids)|
9983
| ClientId | Your amazon app id |
10084
| ClientSecret | Your amazon app secret |
10185
| RefreshToken | Check how to get [RefreshToken](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#Self-authorization) |
10286

10387

104-
For more information about keys please check [Amazon Selling Partner API developer guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md) , If you are not registered as developer please [Register](https://developer.amazonservices.com/) to be able to create application.
88+
For more information about keys please check [New Amazon doc for create keys Developer ](https://developer-docs.amazon.com/sp-api/docs/creating-and-configuring-iam-policies-and-entities) , If you are not registered as developer please [Register](https://developer.amazonservices.com/) to be able to create application.
10589

10690
---
10791
## Usage
@@ -116,7 +100,7 @@ AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
116100
ClientId = "amzn1.application-XXX-client.XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
117101
ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
118102
RefreshToken= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
119-
MarketPlace = MarketPlace.UnitedArabEmirates, //MarketPlace.GetMarketPlaceByID("A2VIGQ35RCS4UG")
103+
MarketPlace = MarketPlace.UnitedArabEmirates, //MarketPlace.GetMarketPlaceByID("A2VIGQ35RCS4UG")
120104
});
121105

122106
```
@@ -411,6 +395,26 @@ If you have questions, please ask in GitHub discussions
411395

412396
- Improve documentation
413397

398+
---
399+
### Useful links
400+
##### [Selling Partner API](https://developer-docs.amazon.com/sp-api)
401+
##### [Amazon MWS to SP-API Migration Guide](https://developer-docs.amazon.com/sp-api/docs/amazon-mws-to-sp-api-migration-guide#mapping-apis-from-amazon-mws-to-the-selling-partner-api)
402+
##### [SP-API models](https://developer-docs.amazon.com/sp-api/page/sp-api-models)
403+
##### [Using Postman for Selling Partner API models](https://developer-docs.amazon.com/sp-api/page/sp-api-models)
404+
##### [Test Project with pure C# code](https://github.com/abuzuhri/Amazon-SP-API-CSharp/tree/main/Others/PureCodeSampleForTest)
405+
##### [Sample Code](https://github.com/abuzuhri/Amazon-SP-API-CSharp/tree/main/Source/FikaAmazonAPI.SampleCode)
406+
##### [Creating And Configuring AWS](https://developer-docs.amazon.com/sp-api/docs/creating-and-configuring-iam-policies-and-entities)
407+
408+
---
409+
## Contributing
410+
411+
1. Fork it (https://github.com/abuzuhri/Amazon-SP-API-CSharp/fork)
412+
2. Clone it (`git clone https://github.com/{YOUR_USERNAME}/Amazon-SP-API-CSharp`)
413+
3. Create your feature branch (`git checkout -b your_branch_name`)
414+
4. Commit your changes (`git commit -m 'Description of a commit'`)
415+
5. Push to the branch (`git push origin your_branch_name`)
416+
6. Create a new Pull Request
417+
414418
---
415419
## Notes
416420

Source/FikaAmazonAPI.SampleCode/Program.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static async Task Main(string[] args)
1919
.AddUserSecrets<Program>()
2020
.Build();
2121

22+
2223
AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
2324
{
2425
AccessKey = config.GetSection("FikaAmazonAPI:AccessKey").Value,
@@ -32,6 +33,21 @@ static async Task Main(string[] args)
3233
});
3334

3435

36+
37+
ReportManager reportManager2 = new ReportManager(amazonConnection);
38+
var products2 = await reportManager2.GetProductsAsync(); //GET_MERCHANT_LISTINGS_ALL_DATA
39+
40+
41+
ParameterOrderList serachOrderList = new ParameterOrderList();
42+
serachOrderList.CreatedAfter = DateTime.UtcNow.AddDays(-100);
43+
44+
serachOrderList.OrderStatuses = new List<OrderStatuses>();
45+
serachOrderList.OrderStatuses.Add(OrderStatuses.Shipped);
46+
47+
48+
var orders = await amazonConnection.Orders.GetOrdersAsync(serachOrderList);
49+
50+
3551
//var parameterOrderList = new ParameterOrderList
3652
//{
3753
// CreatedAfter = DateTime.UtcNow.AddHours(-24),
@@ -93,14 +109,7 @@ static async Task Main(string[] args)
93109

94110

95111

96-
ParameterOrderList serachOrderList = new ParameterOrderList();
97-
serachOrderList.CreatedAfter = DateTime.UtcNow.AddMinutes(-600000);
98-
99-
serachOrderList.OrderStatuses = new List<OrderStatuses>();
100-
serachOrderList.OrderStatuses.Add(OrderStatuses.Shipped);
101-
102112

103-
var orders = amazonConnection.Orders.GetOrders(serachOrderList);
104113

105114
var list3 = amazonConnection.Financial.ListFinancialEvents(new ParameterListFinancialEvents()
106115
{

Source/FikaAmazonAPI/AmazonConnection.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using FikaAmazonAPI.Services;
2-
using FikaAmazonAPI.Utils;
32
using System;
4-
using System.Collections.Generic;
53

64
namespace FikaAmazonAPI
75
{
@@ -40,7 +38,7 @@ public class AmazonConnection
4038
public VendorDirectFulfillmentOrderService VendorDirectFulfillmentOrders => this._VendorDirectFulfillmentOrders ?? throw _NoCredentials;
4139

4240

43-
41+
4442
private OrderService _Orders { get; set; }
4543
private ReportService _Reports { get; set; }
4644
private SolicitationService _Solicitations { get; set; }
@@ -75,7 +73,7 @@ public class AmazonConnection
7573
private UnauthorizedAccessException _NoCredentials = new UnauthorizedAccessException($"Error, you cannot make calls to Amazon without credentials!");
7674

7775
public string RefNumber { get; set; }
78-
public AmazonConnection(AmazonCredential Credentials,string RefNumber=null)
76+
public AmazonConnection(AmazonCredential Credentials, string RefNumber = null)
7977
{
8078
this.Authenticate(Credentials);
8179
this.RefNumber = RefNumber;
@@ -93,6 +91,7 @@ private void Init(AmazonCredential Credentials)
9391
{
9492
this.Credentials = Credentials;
9593

94+
this._Authorization = new AuthorizationService(this.Credentials);
9695
this._Orders = new OrderService(this.Credentials);
9796
this._Reports = new ReportService(this.Credentials);
9897
this._Solicitations = new SolicitationService(this.Credentials);
@@ -109,18 +108,18 @@ private void Init(AmazonCredential Credentials)
109108
this._Feed = new FeedService(this.Credentials);
110109
this._ListingsItem = new ListingsItemService(this.Credentials);
111110
this._MerchantFulfillment = new MerchantFulfillmentService(this.Credentials);
112-
this._Messaging= new MessagingService(this.Credentials);
113-
this._Notification= new NotificationService(this.Credentials);
114-
this._ProductFee= new ProductFeeService(this.Credentials);
115-
this._Sales= new SalesService(this.Credentials);
116-
this._Seller= new SellerService(this.Credentials);
117-
this._Services= new ServicesService(this.Credentials);
118-
this._ShipmentInvoicing= new ShipmentInvoicingService(this.Credentials);
119-
this._Shipping= new ShippingService(this.Credentials);
120-
this._Upload= new UploadService(this.Credentials);
121-
this._Tokens= new TokenService(this.Credentials);
122-
this._FulFillmentInbound= new FulFillmentInboundService(this.Credentials);
123-
this._FulFillmentOutbound= new FulFillmentOutboundService(this.Credentials);
111+
this._Messaging = new MessagingService(this.Credentials);
112+
this._Notification = new NotificationService(this.Credentials);
113+
this._ProductFee = new ProductFeeService(this.Credentials);
114+
this._Sales = new SalesService(this.Credentials);
115+
this._Seller = new SellerService(this.Credentials);
116+
this._Services = new ServicesService(this.Credentials);
117+
this._ShipmentInvoicing = new ShipmentInvoicingService(this.Credentials);
118+
this._Shipping = new ShippingService(this.Credentials);
119+
this._Upload = new UploadService(this.Credentials);
120+
this._Tokens = new TokenService(this.Credentials);
121+
this._FulFillmentInbound = new FulFillmentInboundService(this.Credentials);
122+
this._FulFillmentOutbound = new FulFillmentOutboundService(this.Credentials);
124123
this._VendorDirectFulfillmentOrders = new VendorDirectFulfillmentOrderService(this.Credentials);
125124
}
126125
}

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/Authorization/GetAuthorizationCodeResponse.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public partial class GetAuthorizationCodeResponse : IEquatable<GetAuthorizationC
2828
/// </summary>
2929
/// <param name="Payload">Payload.</param>
3030
/// <param name="Errors">Errors.</param>
31+
public GetAuthorizationCodeResponse()
32+
{
33+
this.Payload = default(AuthorizationCode);
34+
this.Errors = default(ErrorList);
35+
}
3136
public GetAuthorizationCodeResponse(AuthorizationCode Payload = default(AuthorizationCode), ErrorList Errors = default(ErrorList))
3237
{
3338
this.Payload = Payload;

Source/FikaAmazonAPI/AmazonSpApiSDK/Runtime/LWAClient.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ public LWAClient(LWAAuthorizationCredentials lwaAuthorizationCredentials)
2525
RestClient = new RestClient(LWAAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority));
2626
}
2727

28-
/// <summary>
29-
/// Retrieves access token from LWA
30-
/// </summary>
31-
/// <param name="lwaAccessTokenRequestMeta">LWA AccessTokenRequest metadata</param>
32-
/// <returns>LWA Access Token</returns>
33-
public virtual TokenResponse GetAccessToken()
34-
{
35-
return GetAccessTokenAsync().GetAwaiter().GetResult();
36-
}
3728

3829
/// <summary>
3930
/// Retrieves access token from LWA
@@ -51,7 +42,7 @@ public virtual async Task<TokenResponse> GetAccessTokenAsync()
5142

5243
try
5344
{
54-
var response = await RestClient.ExecuteAsync(accessTokenRequest);
45+
var response = await RestClient.ExecuteAsync(accessTokenRequest).ConfigureAwait(false);
5546

5647
if (!IsSuccessful(response))
5748
{

Source/FikaAmazonAPI/FikaAmazonAPI.csproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Product>CSharp Amazon Sp API</Product>
88
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
99
<LangVersion>8.0</LangVersion>
10-
<Version>1.1.5</Version>
11-
<AssemblyVersion>1.1.5</AssemblyVersion>
12-
<FileVersion>1.1.5</FileVersion>
10+
<Version>1.2.0</Version>
11+
<AssemblyVersion>1.2.0</AssemblyVersion>
12+
<FileVersion>1.2.0</FileVersion>
1313
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1414
<PackageProjectUrl>https://github.com/abuzuhri/Amazon-SP-API-CSharp</PackageProjectUrl>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -44,10 +44,6 @@
4444
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
4545
<PackageReference Include="System.Reflection" Version="4.3.0" />
4646
</ItemGroup>
47-
48-
<ItemGroup>
49-
<Folder Include="Parameter\Authorization\" />
50-
</ItemGroup>
5147
<ItemGroup>
5248
<None Include="..\..\Others\icon\icon.jpg">
5349
<Pack>True</Pack>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using FikaAmazonAPI.Search;
2+
3+
namespace FikaAmazonAPI.Parameter.Authorization
4+
{
5+
public class ParameterAuthorizationCode : ParameterBased
6+
{
7+
public string sellingPartnerId { get; set; }
8+
public string developerId { get; set; }
9+
public string mwsAuthToken { get; set; }
10+
11+
}
12+
}

0 commit comments

Comments
 (0)