Skip to content

Commit

Permalink
feat!: API alignment (#29)
Browse files Browse the repository at this point in the history
- General documentation updates
- Support new errors
- Adjustment credit note PDF
- Support disposition query param on credit note and invoice
- Notification setting active query param
- CatalogType nullable in notifications
- PricePreview moved to PreviewPrices to match docs
- PaymentMethodID on Transaction payments is nullable
- Support non catalog items on Subscription updates
- Align non catalog item type names for consistency on all resources

- fix(lint): ignore G115 potential integer overflow err
- docs(release): 2.0.0 documentation
- docs(examples): Migrate examples for v2.0.0
- chore(version): Bump version to 2.0.0
  • Loading branch information
mikeymike authored Sep 18, 2024
1 parent 2056f24 commit 194c888
Show file tree
Hide file tree
Showing 18 changed files with 646 additions and 304 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ linters-settings:
allow-cuddle-with-calls: ["Lock", "RLock"]
allow-cuddle-with-rhs: ["Unlock", "RUnlock"]
error-variable-names: ["err"]
gosec:
excludes:
- G115 # Potential integer overflow when converting between integer types

linters:
disable-all: true
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ 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.

## 2.0.0 - 2024-09-18

### Changed

- `PricePreview` has moved to `PreviewPrices` to match API documentation
- Refactored non catalog item types for consistency through the SDK, see [UPGRADING](./UPGRADING.md) for details

### Added

- Support for new Paddle API errors
- Adjustment credit notes (`GetAdjustmentCreditNote`)
- `disposition` query parameter for `GetTransactionInvoice` and `GetAdjustmentCreditNote`
- `active` query parameter filter support for NotificationSettings
- Subscription update and preview update support non catalog items

### Fixed

- `Type` for Product and Price notifications are nullable `*CatalogType`
- `PaymentMethodID` on Transaction payments is nullable `*PaymentMethodID` for both notifications and API calls

## 1.0.0 - 2024-08-15

No documented changes.
Expand Down
65 changes: 64 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,69 @@
# Upgrading

All breaking changes prior to v1 will be documented in this file to assist with upgrading.
All breaking changes will be documented in this file to assist with upgrading.

## v2.0.0

This release brings 2 breaking changes and fixes that may require some changes in your code to upgrade.

1. `PricePreview` has moved to `PreviewPrices` to match API documentation

Any usage of the method `PricePreview` will need to me refactored to `PreviewPrices` which also includes the request type `PricePreviewRequest` to `PreviewPricesRequest`.

2. Refactored non catalog item types for consistency through the SDK

This release added support for non catalog items on Subscription updates and preview of Subscription updates. With this introduction naming conflicts occurred and were standardised throughout.

Subscription updates now accepts a `[]UpdateSubscriptionItems`instead of `[]SubscriptionUpdateCatalogItem` use `NewUpdateSubscriptionItemsSubscriptionUpdateItem*` functions to create this.

Preview subscription updates now accepts a `[]PreviewSubscriptionUpdateItems` instead of a `[]SubscriptionUpdateCatalogItem` use `NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItem*` functions to create this.

To support these changes you may have to refactor some of your type usage, see the below table for reference:

| Previous Type | New Type |
|-------------------------------------------------|-----------------------------------------|
| CatalogItem | TransactionItemFromCatalog |
| NonCatalogPriceForAnExistingProduct | TransactionItemCreateWithPrice |
| NonCatalogPriceAndProduct | TransactionItemCreateWithProduct |
| TransactionCatalogItem | TransactionPreviewItemFromCatalog |
| TransactionNonCatalogPriceForAnExistingProduct | TransactionPreviewItemCreateWithPrice |
| TransactionNonCatalogPriceAndProduct | TransactionPreviewItemCreateWithProduct |
| SubscriptionUpdateCatalogItem | SubscriptionUpdateItemFromCatalog |
| SubscriptionCatalogItem | SubscriptionChargeItemFromCatalog |
| SubscriptionNonCatalogPriceForAnExistingProduct | SubscriptionChargeItemCreateWithPrice |
| SubscriptionNonCatalogPriceAndProduct | SubscriptionChargeItemCreateWithProduct |

Functions names have also changed as part of this standardisation, see the following table and update your code accordingly:

| Previous Function | New Function |
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| NewCreateTransactionItemsCatalogItem | NewCreateTransactionItemsTransactionItemFromCatalog |
| NewCreateTransactionItemsNonCatalogPriceForAnExistingProduct | NewCreateTransactionItemsTransactionItemCreateWithPrice |
| NewCreateTransactionItemsNonCatalogPriceAndProduct | NewCreateTransactionItemsTransactionItemCreateWithProduct |
| NewUpdateTransactionItemsCatalogItem | NewUpdateTransactionItemsTransactionItemFromCatalog |
| NewUpdateTransactionItemsNonCatalogPriceForAnExistingProduct | NewUpdateTransactionItemsTransactionItemCreateWithPrice |
| NewUpdateTransactionItemsNonCatalogPriceAndProduct | NewUpdateTransactionItemsTransactionItemCreateWithProduct |
| NewTransactionPreviewByAddressItemsTransactionCatalogItem | NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog |
| NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceForAnExistingProduct | NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice |
| NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceAndProduct | NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct |
| NewTransactionPreviewByIPItemsTransactionCatalogItem | NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog |
| NewTransactionPreviewByIPItemsTransactionNonCatalogPriceForAnExistingProduct | NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice |
| NewTransactionPreviewByIPItemsTransactionNonCatalogPriceAndProduct | NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct |
| NewTransactionPreviewByCustomerItemsTransactionCatalogItem | NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog |
| NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceForAnExistingProduct | NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice |
| NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceAndProduct | NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct |

3. Some fields have been moved to pointers to correctly facilitate them being nullable.

- `Type` for Product and Price notifications are nullable `*CatalogType`
- `PaymentMethodID` on Transaction payments is nullable `*PaymentMethodID` for both notifications and API calls

Any usages of `Type` on `PriceNotification` or `ProductNotification` types will need to be changed to handle the `*CatalogType` type.
Any usages of `PaymentMethodID` on `TransactionPaymentAttempt` will need to be changed to handle a `*string` type.

## v1.0.0

- No documented change

## v0.7.0

Expand Down
31 changes: 30 additions & 1 deletion adjustments.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 38 additions & 14 deletions discounts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions example_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func Example_create() {
// Create a transaction.
res, err := client.CreateTransaction(ctx, &paddle.CreateTransactionRequest{
Items: []paddle.CreateTransactionItems{
*paddle.NewCreateTransactionItemsCatalogItem(&paddle.CatalogItem{
*paddle.NewCreateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{
Quantity: 20,
PriceID: "pri_01gsz91wy9k1yn7kx82aafwvea",
}),
*paddle.NewCreateTransactionItemsCatalogItem(&paddle.CatalogItem{
*paddle.NewCreateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{
Quantity: 1,
PriceID: "pri_01gsz96z29d88jrmsf2ztbfgjg",
}),
*paddle.NewCreateTransactionItemsCatalogItem(&paddle.CatalogItem{
*paddle.NewCreateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{
Quantity: 1,
PriceID: "pri_01gsz98e27ak2tyhexptwc58yk",
}),
Expand Down
6 changes: 3 additions & 3 deletions example_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func Example_update() {
res, err := client.UpdateTransaction(ctx, &paddle.UpdateTransactionRequest{
DiscountID: paddle.NewPtrPatchField("dsc_01gtgztp8fpchantd5g1wrksa3"),
Items: paddle.NewPatchField([]paddle.UpdateTransactionItems{
*paddle.NewUpdateTransactionItemsCatalogItem(&paddle.CatalogItem{
*paddle.NewUpdateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{
Quantity: 50,
PriceID: "pri_01gsz91wy9k1yn7kx82aafwvea",
}),
*paddle.NewUpdateTransactionItemsCatalogItem(&paddle.CatalogItem{
*paddle.NewUpdateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{
Quantity: 1,
PriceID: "pri_01gsz96z29d88jrmsf2ztbfgjg",
}),
*paddle.NewUpdateTransactionItemsCatalogItem(&paddle.CatalogItem{
*paddle.NewUpdateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{
Quantity: 1,
PriceID: "pri_01gsz98e27ak2tyhexptwc58yk",
}),
Expand Down
2 changes: 1 addition & 1 deletion internal/client/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
2.0.0
3 changes: 3 additions & 0 deletions notification_settings.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 194c888

Please sign in to comment.