feat: add SellerPerformanceReport support#926
Conversation
Implements GET_V2_SELLER_PERFORMANCE_REPORT via the ReportManager, parsing the JSON response into strongly-typed SellerPerformanceReport and SellerPerformanceMetrics classes covering account health, order defect rates (AFN/MFN), late shipment rate, pre-fulfilment cancellation rate, valid tracking rate, on-time delivery rate, invoice defect rate, and policy violations. Adds Stream constructor alongside the file path constructor for consistency with existing report classes. README updated with usage example.
|
There was a problem hiding this comment.
Pull request overview
Adds support for the SP-API Seller Performance V2 report by introducing a new report parser/model and exposing it via ReportManager, plus documenting usage in the README.
Changes:
- Added
SellerPerformanceReportto deserializeGET_V2_SELLER_PERFORMANCE_REPORTJSON into strongly-typed metric objects. - Exposed
GetSellerPerformance()/GetSellerPerformanceAsync()onReportManager. - Updated README with a usage example.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Source/FikaAmazonAPI/ReportGeneration/SellerPerformanceReport.cs | New JSON-based report parser + public metric models and internal deserialization DTOs. |
| Source/FikaAmazonAPI/ReportGeneration/ReportManager.cs | Adds sync/async entrypoints to request and download the seller performance report. |
| README.md | Documents how to call the new report method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// <summary> | ||
| /// Represents the collection of account status objects | ||
| /// for each marketplace identified in the Seller Performance report. | ||
| /// </summary> | ||
| public List<AccountStatus> AccountStatuses { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Collection of marketplace-specific performance data | ||
| /// </summary> | ||
| public List<SellerPerformanceMetrics> Metrics { get; set; } = new List<SellerPerformanceMetrics>(); | ||
|
|
There was a problem hiding this comment.
AccountStatuses is left uninitialized unless the JSON contains accountStatuses, so consumers may hit null-reference checks while other report classes typically expose empty lists (e.g., InventoryAgingReport.Data). Initialize AccountStatuses to an empty list by default and consider assigning an empty list when the JSON omits the field.
| if (stream == null) | ||
| return; | ||
|
|
||
| using (var reader = new StreamReader(stream)) |
There was a problem hiding this comment.
The Stream constructor disposes the provided stream because StreamReader is disposed without leaveOpen: true. Other report parsers deliberately leave streams open (see ReportParser.ParseCsvLines(... leaveOpen: true)) and callers may want to reuse the stream after constructing the report. Use a StreamReader with leaveOpen: true (and optionally reset stream.Position to 0 when seekable) to match the codebase’s stream-handling behavior.
| using (var reader = new StreamReader(stream)) | |
| using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8, true, 1024, true)) |
| MarketplaceId = metric.MarketplaceId, | ||
| RefNumber = refNumber, | ||
| SnapshotDate = DateTime.UtcNow, | ||
|
|
||
| // Account Health Rating | ||
| AccountHealthStatus = metric.AccountHealthRating?.AhrStatus, | ||
| AccountHealthScore = metric.AccountHealthRating?.AhrScore, |
There was a problem hiding this comment.
SnapshotDate is documented as “Date of the report”, but the parser sets it to DateTime.UtcNow, which can be unrelated to the report’s actual reporting period. Consider deriving it from the report payload (e.g., reportingDateRange) or rename the property/doc to clarify it’s the client parse time.
|
|
||
| #region Performance | ||
|
|
||
| /// <summary> |
There was a problem hiding this comment.
There is already a #region Performance earlier in this file (currently empty). Adding another #region Performance at the end creates duplicate regions and makes navigation confusing. Either move these methods into the existing region or remove the earlier empty region.



Summary
GET_V2_SELLER_PERFORMANCE_REPORTvia a newSellerPerformanceReportclass, parsing the JSON response into strongly-typedSellerPerformanceMetricsobjectsGetSellerPerformance()andGetSellerPerformanceAsync()onReportManager, with XML doc commentsStreamconstructor alongside the file path constructor for consistency with existing report classesinternalTest plan
GetSellerPerformance()returns a populatedSellerPerformanceReportagainst a live sandbox or real credentialsGetSellerPerformanceAsync()behaves correctly with cancellationStreamconstructor parses correctly when passed a stream directly