From 8ceeeb9b98c850b8919e7146a0c5f689c2621982 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Thu, 8 Aug 2024 10:10:47 +0100 Subject: [PATCH] fix(reports)!: Regenerates Reports with oneOf design (#26) --- CHANGELOG.md | 16 ++- UPGRADING.md | 26 ++++ internal/client/version.txt | 2 +- pkg/paddlenotification/reports.go | 86 ++++++------ reports.go | 225 +++++++++++++++++++----------- 5 files changed, 227 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38bf6c6..4248ec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-go-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools. +## 0.6.0 - 2024-08-07 + +### Changed + +- Reports architecture has changed to a oneOf design + +### Fixed + +- Report filter values incorrectly typed as a `string` when it requires either `string` or `[]string` depending on the filter name. + ## 0.5.0 - 2024-07-26 -### Breaking changes +### Changed - Paddle API enum types are now correctly enforced where applicable - Notifications and Events `EventType` property now use `EventTypeName` instead of `string` type @@ -33,7 +43,7 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx ## 0.4.0 - 2024-06-26 -### Breaking changes +### Changed - Shared types `TransactionSubscriptionPriceCreateWithProduct` and `TransactionSubscriptionPriceCreateWithProductID` have diverged into 2 new types for Transactions and Subscriptions - Include entity types are unified with their non-include variant, e.g. `ProductWithIncludes` and `Product` are now just `Product` @@ -49,7 +59,7 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx ## 0.3.0 - 2024-05-27 -### Breaking changes +### Changed - `Event` and `NotificationsEvent` are now an interfaces. - `NotificationsEvent` has moved package to `paddlenotification`. diff --git a/UPGRADING.md b/UPGRADING.md index aa67d03..a36352d 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -2,6 +2,32 @@ All breaking changes prior to v1 will be documented in this file to assist with upgrading. +## v0.6.0 + +1. This update makes a significant change to the way the SDK works with the [Reports API](https://developer.paddle.com/api-reference/reports/overview) + +When updating to this version if you're integrating with Reports you will need to refactor the code accordingly as it now closely matches the oneOf design of the API. + +An example generating a product/price report: + +```go +res, err := client.CreateReport(ctx, + paddle.NewCreateReportRequestProductsAndPricesReport(&paddle.ProductsAndPricesReport{ + Type: paddle.ReportTypeProductsPricesProductsPrices, + Filters: []paddle.ReportFiltersProductPrices{ + paddle.ReportFiltersProductPrices{ + Name: paddle.FilterNameProductPricesPriceStatus, + Value: []string{"archived"}, + }, + paddle.ReportFiltersProductPrices{ + Name: paddle.FilterNameProductPricesProductStatus, + Value: []string{"archived"}, + }, + }, + }), +) +``` + ## v0.5.0 1. This update fixes correctly resolves generated enum types. Prior to this enum types in our spec were using there respective basic type `string` diff --git a/internal/client/version.txt b/internal/client/version.txt index fb7a04c..60f6343 100644 --- a/internal/client/version.txt +++ b/internal/client/version.txt @@ -1 +1 @@ -v0.4.0 +v0.6.0 diff --git a/pkg/paddlenotification/reports.go b/pkg/paddlenotification/reports.go index 570ccc9..b8c47f6 100644 --- a/pkg/paddlenotification/reports.go +++ b/pkg/paddlenotification/reports.go @@ -17,66 +17,66 @@ type ReportUpdated struct { } /* -ReportStatus: Status of this report. Set automatically by Paddle. +ReportsStatus: Status of this report. Set automatically by Paddle. Reports are created as `pending` initially, then move to `ready` when they're available to download.. */ -type ReportStatus string +type ReportsStatus string const ( - ReportStatusPending ReportStatus = "pending" - ReportStatusReady ReportStatus = "ready" - ReportStatusFailed ReportStatus = "failed" - ReportStatusExpired ReportStatus = "expired" + ReportsStatusPending ReportsStatus = "pending" + ReportsStatusReady ReportsStatus = "ready" + ReportsStatusFailed ReportsStatus = "failed" + ReportsStatusExpired ReportsStatus = "expired" ) -// ReportTypeTransactions: Type of report.. -type ReportTypeTransactions string +// ReportsType: Type of report to create.. +type ReportsType string const ( - ReportTypeTransactionsAdjustments ReportTypeTransactions = "adjustments" - ReportTypeTransactionsAdjustmentLineItems ReportTypeTransactions = "adjustment_line_items" - ReportTypeTransactionsTransactions ReportTypeTransactions = "transactions" - ReportTypeTransactionsTransactionLineItems ReportTypeTransactions = "transaction_line_items" - ReportTypeTransactionsProductsPrices ReportTypeTransactions = "products_prices" - ReportTypeTransactionsDiscounts ReportTypeTransactions = "discounts" + ReportsTypeAdjustments ReportsType = "adjustments" + ReportsTypeAdjustmentLineItems ReportsType = "adjustment_line_items" + ReportsTypeTransactions ReportsType = "transactions" + ReportsTypeTransactionLineItems ReportsType = "transaction_line_items" + ReportsTypeProductsPrices ReportsType = "products_prices" + ReportsTypeDiscounts ReportsType = "discounts" ) -// Name: Field name to filter by.. -type ReportsName string +// ReportsFiltersName: Field name to filter by.. +type ReportsFiltersName string const ( - ReportsNameAction ReportsName = "action" - ReportsNameCurrencyCode ReportsName = "currency_code" - ReportsNameStatus ReportsName = "status" - ReportsNameUpdatedAt ReportsName = "updated_at" - ReportsNameCollectionMode ReportsName = "collection_mode" - ReportsNameOrigin ReportsName = "origin" - ReportsNameProductStatus ReportsName = "product_status" - ReportsNamePriceStatus ReportsName = "price_status" - ReportsNameProductType ReportsName = "product_type" - ReportsNamePriceType ReportsName = "price_type" - ReportsNameProductUpdatedAt ReportsName = "product_updated_at" - ReportsNamePriceUpdatedAt ReportsName = "price_updated_at" - ReportsNameType ReportsName = "type" + ReportsFiltersNameAction ReportsFiltersName = "action" + ReportsFiltersNameCurrencyCode ReportsFiltersName = "currency_code" + ReportsFiltersNameStatus ReportsFiltersName = "status" + ReportsFiltersNameUpdatedAt ReportsFiltersName = "updated_at" + ReportsFiltersNameCollectionMode ReportsFiltersName = "collection_mode" + ReportsFiltersNameOrigin ReportsFiltersName = "origin" + ReportsFiltersNameProductStatus ReportsFiltersName = "product_status" + ReportsFiltersNamePriceStatus ReportsFiltersName = "price_status" + ReportsFiltersNameProductType ReportsFiltersName = "product_type" + ReportsFiltersNamePriceType ReportsFiltersName = "price_type" + ReportsFiltersNameProductUpdatedAt ReportsFiltersName = "product_updated_at" + ReportsFiltersNamePriceUpdatedAt ReportsFiltersName = "price_updated_at" + ReportsFiltersNameType ReportsFiltersName = "type" ) -// Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. -type ReportsOperator string +// ReportsFiltersOperator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. +type ReportsFiltersOperator string const ( - ReportsOperatorLt ReportsOperator = "lt" - ReportsOperatorGte ReportsOperator = "gte" + ReportsFiltersOperatorLt ReportsFiltersOperator = "lt" + ReportsFiltersOperatorGte ReportsFiltersOperator = "gte" ) -// ReportFilters: List of filters applied to this report. -type ReportFilters struct { +// ReportsFilters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. +type ReportsFilters struct { // Name: Field name to filter by. - Name ReportsName `json:"name,omitempty"` + Name ReportsFiltersName `json:"name,omitempty"` // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *ReportsOperator `json:"operator,omitempty"` + Operator *ReportsFiltersOperator `json:"operator,omitempty"` // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } // ReportNotification: New or changed entity. @@ -88,17 +88,17 @@ type ReportNotification struct { Reports are created as `pending` initially, then move to `ready` when they're available to download. */ - Status ReportStatus `json:"status,omitempty"` + Status ReportsStatus `json:"status,omitempty"` // Rows: Number of records in this report. `null` if the report is `pending`. Rows *int `json:"rows,omitempty"` - // Type: Type of report. - Type ReportTypeTransactions `json:"type,omitempty"` - // Filters: List of filters applied to this report. - Filters []ReportFilters `json:"filters,omitempty"` // ExpiresAt: RFC 3339 datetime string of when this report expires. The report is no longer available to download after this date. ExpiresAt *string `json:"expires_at,omitempty"` // UpdatedAt: RFC 3339 datetime string of when this report was last updated. UpdatedAt string `json:"updated_at,omitempty"` // CreatedAt: RFC 3339 datetime string of when this report was created. CreatedAt string `json:"created_at,omitempty"` + // Type: Type of report to create. + Type ReportsType `json:"type,omitempty"` + // Filters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. + Filters []ReportsFilters `json:"filters,omitempty"` } diff --git a/reports.go b/reports.go index 63bdaf8..56bcb46 100644 --- a/reports.go +++ b/reports.go @@ -38,66 +38,66 @@ var ErrReportFailed = &paddleerr.Error{ } /* -ReportStatus: Status of this report. Set automatically by Paddle. +ReportsStatus: Status of this report. Set automatically by Paddle. Reports are created as `pending` initially, then move to `ready` when they're available to download.. */ -type ReportStatus string +type ReportsStatus string const ( - ReportStatusPending ReportStatus = "pending" - ReportStatusReady ReportStatus = "ready" - ReportStatusFailed ReportStatus = "failed" - ReportStatusExpired ReportStatus = "expired" + ReportsStatusPending ReportsStatus = "pending" + ReportsStatusReady ReportsStatus = "ready" + ReportsStatusFailed ReportsStatus = "failed" + ReportsStatusExpired ReportsStatus = "expired" ) -// ReportTypeTransactions: Type of report.. -type ReportTypeTransactions string +// ReportsType: Type of report to create.. +type ReportsType string const ( - ReportTypeTransactionsAdjustments ReportTypeTransactions = "adjustments" - ReportTypeTransactionsAdjustmentLineItems ReportTypeTransactions = "adjustment_line_items" - ReportTypeTransactionsTransactions ReportTypeTransactions = "transactions" - ReportTypeTransactionsTransactionLineItems ReportTypeTransactions = "transaction_line_items" - ReportTypeTransactionsProductsPrices ReportTypeTransactions = "products_prices" - ReportTypeTransactionsDiscounts ReportTypeTransactions = "discounts" + ReportsTypeAdjustments ReportsType = "adjustments" + ReportsTypeAdjustmentLineItems ReportsType = "adjustment_line_items" + ReportsTypeTransactions ReportsType = "transactions" + ReportsTypeTransactionLineItems ReportsType = "transaction_line_items" + ReportsTypeProductsPrices ReportsType = "products_prices" + ReportsTypeDiscounts ReportsType = "discounts" ) -// Name: Field name to filter by.. -type ReportsName string +// ReportsFiltersName: Field name to filter by.. +type ReportsFiltersName string const ( - ReportsNameAction ReportsName = "action" - ReportsNameCurrencyCode ReportsName = "currency_code" - ReportsNameStatus ReportsName = "status" - ReportsNameUpdatedAt ReportsName = "updated_at" - ReportsNameCollectionMode ReportsName = "collection_mode" - ReportsNameOrigin ReportsName = "origin" - ReportsNameProductStatus ReportsName = "product_status" - ReportsNamePriceStatus ReportsName = "price_status" - ReportsNameProductType ReportsName = "product_type" - ReportsNamePriceType ReportsName = "price_type" - ReportsNameProductUpdatedAt ReportsName = "product_updated_at" - ReportsNamePriceUpdatedAt ReportsName = "price_updated_at" - ReportsNameType ReportsName = "type" + ReportsFiltersNameAction ReportsFiltersName = "action" + ReportsFiltersNameCurrencyCode ReportsFiltersName = "currency_code" + ReportsFiltersNameStatus ReportsFiltersName = "status" + ReportsFiltersNameUpdatedAt ReportsFiltersName = "updated_at" + ReportsFiltersNameCollectionMode ReportsFiltersName = "collection_mode" + ReportsFiltersNameOrigin ReportsFiltersName = "origin" + ReportsFiltersNameProductStatus ReportsFiltersName = "product_status" + ReportsFiltersNamePriceStatus ReportsFiltersName = "price_status" + ReportsFiltersNameProductType ReportsFiltersName = "product_type" + ReportsFiltersNamePriceType ReportsFiltersName = "price_type" + ReportsFiltersNameProductUpdatedAt ReportsFiltersName = "product_updated_at" + ReportsFiltersNamePriceUpdatedAt ReportsFiltersName = "price_updated_at" + ReportsFiltersNameType ReportsFiltersName = "type" ) -// Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. -type ReportsOperator string +// ReportsFiltersOperator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. +type ReportsFiltersOperator string const ( - ReportsOperatorLt ReportsOperator = "lt" - ReportsOperatorGte ReportsOperator = "gte" + ReportsFiltersOperatorLt ReportsFiltersOperator = "lt" + ReportsFiltersOperatorGte ReportsFiltersOperator = "gte" ) -// ReportFilters: List of filters applied to this report. -type ReportFilters struct { +// ReportsFilters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. +type ReportsFilters struct { // Name: Field name to filter by. - Name ReportsName `json:"name,omitempty"` + Name ReportsFiltersName `json:"name,omitempty"` // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *ReportsOperator `json:"operator,omitempty"` + Operator *ReportsFiltersOperator `json:"operator,omitempty"` // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } // Report: Represents a report entity. @@ -109,19 +109,19 @@ type Report struct { Reports are created as `pending` initially, then move to `ready` when they're available to download. */ - Status ReportStatus `json:"status,omitempty"` + Status ReportsStatus `json:"status,omitempty"` // Rows: Number of records in this report. `null` if the report is `pending`. Rows *int `json:"rows,omitempty"` - // Type: Type of report. - Type ReportTypeTransactions `json:"type,omitempty"` - // Filters: List of filters applied to this report. - Filters []ReportFilters `json:"filters,omitempty"` // ExpiresAt: RFC 3339 datetime string of when this report expires. The report is no longer available to download after this date. ExpiresAt *string `json:"expires_at,omitempty"` // UpdatedAt: RFC 3339 datetime string of when this report was last updated. UpdatedAt string `json:"updated_at,omitempty"` // CreatedAt: RFC 3339 datetime string of when this report was created. CreatedAt string `json:"created_at,omitempty"` + // Type: Type of report to create. + Type ReportsType `json:"type,omitempty"` + // Filters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. + Filters []ReportsFilters `json:"filters,omitempty"` } // ReportTypeAdjustments: Type of report to create.. @@ -132,81 +132,144 @@ const ( ReportTypeAdjustmentsAdjustmentLineItems ReportTypeAdjustments = "adjustment_line_items" ) -// ReportsReportFilters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. -type ReportsReportFilters struct { +// FilterNameAdjustments: Field name to filter by.. +type FilterNameAdjustments string + +const ( + FilterNameAdjustmentsAction FilterNameAdjustments = "action" + FilterNameAdjustmentsCurrencyCode FilterNameAdjustments = "currency_code" + FilterNameAdjustmentsStatus FilterNameAdjustments = "status" + FilterNameAdjustmentsUpdatedAt FilterNameAdjustments = "updated_at" +) + +// FilterOperator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. +type FilterOperator string + +const ( + FilterOperatorLt FilterOperator = "lt" + FilterOperatorGte FilterOperator = "gte" +) + +// ReportFiltersAdjustments: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. +type ReportFiltersAdjustments struct { // Name: Field name to filter by. - Name ReportsName `json:"name,omitempty"` + Name FilterNameAdjustments `json:"name,omitempty"` // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *ReportsOperator `json:"operator,omitempty"` + Operator *FilterOperator `json:"operator,omitempty"` // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } -// AdjustmentsReports: Request body when creating reports for adjustments or adjustment line items. +// AdjustmentsReports: Entity when working with reports for adjustments or adjustment line items. type AdjustmentsReports struct { // Type: Type of report to create. Type ReportTypeAdjustments `json:"type,omitempty"` - // Filters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. - Filters []ReportsReportFilters `json:"filters,omitempty"` + // Filters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. + Filters []ReportFiltersAdjustments `json:"filters,omitempty"` } -// ReportsReportsReportFilters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. -type ReportsReportsReportFilters struct { +// ReportTypeTransactions: Type of report to create.. +type ReportTypeTransactions string + +const ( + ReportTypeTransactionsTransactions ReportTypeTransactions = "transactions" + ReportTypeTransactionsTransactionLineItems ReportTypeTransactions = "transaction_line_items" +) + +// FilterNameTransactions: Field name to filter by.. +type FilterNameTransactions string + +const ( + FilterNameTransactionsCollectionMode FilterNameTransactions = "collection_mode" + FilterNameTransactionsCurrencyCode FilterNameTransactions = "currency_code" + FilterNameTransactionsOrigin FilterNameTransactions = "origin" + FilterNameTransactionsStatus FilterNameTransactions = "status" + FilterNameTransactionsUpdatedAt FilterNameTransactions = "updated_at" +) + +// ReportFiltersTransactions: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. +type ReportFiltersTransactions struct { // Name: Field name to filter by. - Name ReportsName `json:"name,omitempty"` + Name FilterNameTransactions `json:"name,omitempty"` // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *ReportsOperator `json:"operator,omitempty"` + Operator *FilterOperator `json:"operator,omitempty"` // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } -// TransactionsReports: Request body when creating reports for transaction or transaction line items. +// TransactionsReports: Entity when working with reports for transaction or transaction line items. type TransactionsReports struct { // Type: Type of report to create. Type ReportTypeTransactions `json:"type,omitempty"` - // Filters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. - Filters []ReportsReportsReportFilters `json:"filters,omitempty"` + // Filters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. + Filters []ReportFiltersTransactions `json:"filters,omitempty"` } -// Type: Type of report to create.. -type Type string +// ReportTypeProductsPrices: Type of report to create.. +type ReportTypeProductsPrices string + +const ReportTypeProductsPricesProductsPrices ReportTypeProductsPrices = "products_prices" -const TypeProductsPrices Type = "products_prices" +// FilterNameProductPrices: Field name to filter by.. +type FilterNameProductPrices string -// ReportsReportsReportsReportFilters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `product_updated_at` and `price_updated_at` are greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. -type ReportsReportsReportsReportFilters struct { +const ( + FilterNameProductPricesProductStatus FilterNameProductPrices = "product_status" + FilterNameProductPricesPriceStatus FilterNameProductPrices = "price_status" + FilterNameProductPricesProductType FilterNameProductPrices = "product_type" + FilterNameProductPricesPriceType FilterNameProductPrices = "price_type" + FilterNameProductPricesProductUpdatedAt FilterNameProductPrices = "product_updated_at" + FilterNameProductPricesPriceUpdatedAt FilterNameProductPrices = "price_updated_at" +) + +// ReportFiltersProductPrices: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `product_updated_at` and `price_updated_at` are greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. +type ReportFiltersProductPrices struct { // Name: Field name to filter by. - Name ReportsName `json:"name,omitempty"` - // Operator: Operator to use when filtering. Valid when filtering by `product_updated_at` or `price_updated_at`, `null` otherwise. - Operator *ReportsOperator `json:"operator,omitempty"` + Name FilterNameProductPrices `json:"name,omitempty"` + // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. + Operator *FilterOperator `json:"operator,omitempty"` // Value: Value to filter by. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } -// ProductsAndPricesReport: Request body when creating a products and prices report. +// ProductsAndPricesReport: Entity when working with a products and prices report. type ProductsAndPricesReport struct { // Type: Type of report to create. - Type Type `json:"type,omitempty"` - // Filters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `product_updated_at` and `price_updated_at` are greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. - Filters []ReportsReportsReportsReportFilters `json:"filters,omitempty"` + Type ReportTypeProductsPrices `json:"type,omitempty"` + // Filters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `product_updated_at` and `price_updated_at` are greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. + Filters []ReportFiltersProductPrices `json:"filters,omitempty"` } -// ReportsReportsReportsReportsReportFilters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. -type ReportsReportsReportsReportsReportFilters struct { +// ReportTypeDiscounts: Type of report to create.. +type ReportTypeDiscounts string + +const ReportTypeDiscountsDiscounts ReportTypeDiscounts = "discounts" + +// FilterNameDiscounts: Field name to filter by.. +type FilterNameDiscounts string + +const ( + FilterNameDiscountsType FilterNameDiscounts = "type" + FilterNameDiscountsStatus FilterNameDiscounts = "status" + FilterNameDiscountsUpdatedAt FilterNameDiscounts = "updated_at" +) + +// ReportFiltersDiscounts: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. +type ReportFiltersDiscounts struct { // Name: Field name to filter by. - Name ReportsName `json:"name,omitempty"` + Name FilterNameDiscounts `json:"name,omitempty"` // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *ReportsOperator `json:"operator,omitempty"` + Operator *FilterOperator `json:"operator,omitempty"` // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } -// DiscountsReport: Request body when creating a discounts report. +// DiscountsReport: Entity when working with a discounts report. type DiscountsReport struct { // Type: Type of report to create. - Type Type `json:"type,omitempty"` - // Filters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. - Filters []ReportsReportsReportsReportsReportFilters `json:"filters,omitempty"` + Type ReportTypeDiscounts `json:"type,omitempty"` + // Filters: Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. + Filters []ReportFiltersDiscounts `json:"filters,omitempty"` } type ReportCSV struct {