Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Install-Package CSharpAmazonSpAPI
| [Replenishment](https://developer-docs.amazon.com/sp-api/docs/replenishment-api-v2022-11-07-reference) | ✅ | `listOffers`, `listOfferMetrics`, `getSellingPartnerMetrics` |
| [External Fulfillment Shipments](https://developer-docs.amazon.com/sp-api/reference/externalfulfillmentshipments-api-v2024-09-11) | ✅ | `getShipments`, `getShipment`, `processShipment`, `createPackages`, `updatePackage`, `retrieveShippingOptions`, `generateShipLabels`, `generateInvoice`, `retrieveInvoice`, `updatePackageStatus` |
| [Data Kiosk (v2023-11-15)](https://developer-docs.amazon.com/sp-api/reference/datakiosk-api-v2023-11-15-reference) | ✅ | `getQueries`, `createQuery`, `getQuery`, `cancelQuery`, `getDocument` |
| [Support (v2025-02-01)](https://developer-docs.amazon/sp-api/reference/support-v2025-02-01) | ✅ | `listCases`, `getCase`, `listContacts` |

#### Vendor

Expand Down Expand Up @@ -1416,6 +1417,24 @@ if (query.ProcessingStatus == Query.ProcessingStatusEnum.DONE && !string.IsNullO
var list = amazonConnection.DataKiosk.GetQueries(new ParameterGetQueries { PageSize = 10 });
amazonConnection.DataKiosk.CancelQuery(created.QueryId);
```
### Support (v2025-02-01): Seller support cases and contact history
For more samples, please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/SupportSample.cs). Requires the Selling Partner Support (Restricted) role.
```CSharp
// 1. List cases: auto-pages through every result page and returns a flat list.
var cases = amazonConnection.Support.ListCases(new ParameterListCases
{
CaseFilters = new CaseFilters(
caseStatuses: new List<CaseFilters.CaseStatusesEnum> { CaseFilters.CaseStatusesEnum.PENDINGMERCHANTACTION },
createdDate: new DateFilter(after: DateTime.UtcNow.AddDays(-30))),
MaxResults = 50
});

// 2. Get a single case.
var supportCase = amazonConnection.Support.GetCase("CASE_ID");

// 3. List the case's email, chat and phone contacts (attachment download URLs expire after 15 minutes).
var contacts = amazonConnection.Support.ListContacts("CASE_ID", new ParameterListContacts { SortOrder = SupportSortOrder.ASC });
```
---
## Q & A

Expand Down
80 changes: 80 additions & 0 deletions Source/FikaAmazonAPI.SampleCode/SupportSample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using FikaAmazonAPI.AmazonSpApiSDK.Models.Support;
using FikaAmazonAPI.Parameter.Support;

namespace FikaAmazonAPI.SampleCode;

public class SupportSample
{
AmazonConnection amazonConnection;

public SupportSample(AmazonConnection amazonConnection)
{
this.amazonConnection = amazonConnection;
}

public void ListCases()
{
// Pages through every result page internally and returns a flat list.
// Set MaxNumberOfPages to stop after a given number of pages.
var cases = amazonConnection.Support.ListCases(new ParameterListCases
{
CaseFilters = new CaseFilters(
caseStatuses: new List<CaseFilters.CaseStatusesEnum> { CaseFilters.CaseStatusesEnum.PENDINGMERCHANTACTION },
createdDate: new DateFilter(after: DateTime.UtcNow.AddDays(-30))),
SortOrder = ListCasesRequest.SortOrderEnum.DESC,
MaxResults = 50
});
}

public void ListCasesOnePageWithNextToken()
{
// ONLY USE THIS SAMPLE IF YOU NEED TO GET ONE PAGE EACH TIME, otherwise remove parameter
// 'MaxNumberOfPages' and the library will fetch all cases for you
var parameter = new ParameterListCases
{
MaxResults = 10,
MaxNumberOfPages = 1
};

var cases = amazonConnection.Support.ListCases(parameter);

// ListCases leaves the token for the next unfetched page on the parameter object.
while (!string.IsNullOrEmpty(parameter.NextToken))
{
var moreCases = amazonConnection.Support.ListCasesByNextToken(parameter);
parameter.NextToken = moreCases.NextToken;
}
}

public void GetCase()
{
var supportCase = amazonConnection.Support.GetCase("CASE_ID");
}

public void ListContacts()
{
var contacts = amazonConnection.Support.ListContacts("CASE_ID", new ParameterListContacts
{
SortOrder = SupportSortOrder.ASC,
MaxResults = 50
});

foreach (var contact in contacts)
{
// Only the content matching the contact's channel is populated.
// Attachment download URLs expire after 15 minutes.
switch (contact.Channel)
{
case Contact.ChannelEnum.EMAIL:
var message = contact.EmailContent?.Message;
break;
case Contact.ChannelEnum.CHAT:
var transcript = contact.ChatContent?.Transcript;
break;
case Contact.ChannelEnum.PHONE:
var callNotes = contact.PhoneContent?.CallNotes;
break;
}
}
}
}
3 changes: 3 additions & 0 deletions Source/FikaAmazonAPI/AmazonConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class AmazonConnection
public MerchantShippingTemplateService MerchantShippingTemplate => this._MerchantShippingTemplate ?? throw _NoCredentials;
public ReplenishmentService Replenishment => this._Replenishment ?? throw _NoCredentials;
public ApplicationManagementService ApplicationManagement => this._ApplicationManagement ?? throw _NoCredentials;
public SupportService Support => this._Support ?? throw _NoCredentials;


private AppIntegrationsServiceV20240401 _AppIntegrationsServiceV20240401 { get; set; }
Expand Down Expand Up @@ -120,6 +121,7 @@ public class AmazonConnection
private MerchantShippingTemplateService _MerchantShippingTemplate { get; set; }
private ReplenishmentService _Replenishment { get; set; }
private ApplicationManagementService _ApplicationManagement { get; set; }
private SupportService _Support { get; set; }

private UnauthorizedAccessException _NoCredentials = new UnauthorizedAccessException($"Error, you cannot make calls to Amazon without credentials!");

Expand Down Expand Up @@ -196,6 +198,7 @@ private void Init(AmazonCredential Credentials)
this._MerchantShippingTemplate = new MerchantShippingTemplateService(this.Credentials, _loggerFactory);
this._Replenishment = new ReplenishmentService(this.Credentials, _loggerFactory);
this._ApplicationManagement = new ApplicationManagementService(this.Credentials, _loggerFactory);
this._Support = new SupportService(this.Credentials, _loggerFactory);

AmazonCredential.DebugMode = this.Credentials.IsDebugMode;
}
Expand Down
Loading