-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentSample.cs
More file actions
50 lines (42 loc) · 2.03 KB
/
DocumentSample.cs
File metadata and controls
50 lines (42 loc) · 2.03 KB
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
using CSharpAmazonBusinessAPI;
using CSharpAmazonBusinessAPI.Model.Document;
namespace CSharpAmazonBusinessAPI.SampleCode;
public class DocumentSample
{
private readonly AmazonBusinessConnection _connection;
public DocumentSample(AmazonBusinessConnection connection)
{
_connection = connection;
}
public async Task<GetReportsResponse> GetReportsAsync()
{
// The static sandbox does EXACT (not subset) parameter matching, so any extra
// query parameter — even a defaulted-from-credential marketplaceIds — breaks the
// match and returns 400 "Could not match input arguments". Pass an empty array
// explicitly to skip the wrapper's marketplaceIds-from-credential default.
// Documented sandbox pattern:
// https://developer-docs.amazon.com/amazon-business/docs/document-api-static-sandbox-guide
// Production: drop the explicit empty array and pass the real filters you want.
return await _connection.Documents.GetReportsAsync(
reportTypes: new[] { "FEE_DISCOUNTS_REPORT", "GET_AFN_INVENTORY_DATA" },
processingStatuses: new[] { Anonymous.IN_QUEUE, Anonymous.IN_PROGRESS },
marketplaceIds: Array.Empty<string>());
}
public async Task<string> CreateInvoiceReportAsync()
{
var spec = new CreateReportSpecification
{
ReportType = "GET_FLAT_FILE_VAT_INVOICE_DATA_REPORT",
DataStartTime = DateTime.UtcNow.AddDays(-30),
DataEndTime = DateTime.UtcNow,
};
var response = await _connection.Documents.CreateReportAsync(spec);
return response.ReportId;
}
public Task<Report> GetReportAsync(string reportId) =>
_connection.Documents.GetReportAsync(reportId);
public Task<ReportDocument> GetReportDocumentAsync(string reportDocumentId) =>
_connection.Documents.GetReportDocumentAsync(reportDocumentId);
public Task CancelReportAsync(string reportId) =>
_connection.Documents.CancelReportAsync(reportId);
}