Skip to content

Commit

Permalink
feat!: Unify include types
Browse files Browse the repository at this point in the history
This deduplicates types where includes are possible on API responses
with those that are the same resource but no includes come back.

Includes are optional on the type and thus can be used interchangeably

BREAKING CHANGE: Include types are renamed to replace their
non-include variant, see UPGRADING.md for migration details.
  • Loading branch information
mikeymike committed Jun 25, 2024
1 parent 6dbca56 commit 0c29fd2
Show file tree
Hide file tree
Showing 25 changed files with 1,226 additions and 1,664 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx
### Breaking changes

- 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`

### Added

Expand Down
12 changes: 11 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All breaking changes prior to v1 will be documented in this file to assist with

## v0.4.0

This version includes a breaking change to shared types between Transactions and Subscriptions resources which have now been split into their own respective types.
1. This version includes a breaking change to shared types between Transactions and Subscriptions resources which have now been split into their own respective types.

To upgrade to `0.4.0` from any earlier version you will need to refactor your use of these types as noted below depending on the resource:

Expand All @@ -13,4 +13,14 @@ To upgrade to `0.4.0` from any earlier version you will need to refactor your us
| `TransactionSubscriptionPriceCreateWithProduct` | `TransactionPriceCreateWithProduct` | `SubscriptionChargeCreateWithProduct` |
| `TransactionSubscriptionPriceCreateWithProductID` | `TransactionPriceCreateWithProductID` | `SubscriptionChargeCreateWithPrice` |

2. We have unified types that have includes with their non-include variant, e.g. `ProductWithIncludes` and `Product` are now just `Product`

To upgrade to `0.4.0` any references to the types below need to be refactored accordingly

| Previous Type | New Type |
|------------------------|---------------------|
| `ProductWithIncludes` | `Product` |
| `CustomerIncludes` | `Customer` |
| `TransactionIncludes` | `Transaction` |
| `SubscriptionIncludes` | `Subscription` |
| `PriceIncludes` | `Price` |
6 changes: 3 additions & 3 deletions customers.go

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

4 changes: 2 additions & 2 deletions example_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Example_list() {
res, err := client.ListTransactions(ctx, &paddle.ListTransactionsRequest{})

// Iterate the transactions.
err = res.Iter(ctx, func(v *paddle.TransactionIncludes) (bool, error) {
err = res.Iter(ctx, func(v *paddle.Transaction) (bool, error) {
fmt.Println(v.ID)
return true, nil
})
Expand Down Expand Up @@ -76,7 +76,7 @@ func Example_pagination() {
res, err := client.ListTransactions(ctx, &paddle.ListTransactionsRequest{})

// Iterate the transactions which will internally paginate to the next page.
err = res.Iter(ctx, func(v *paddle.TransactionIncludes) (bool, error) {
err = res.Iter(ctx, func(v *paddle.Transaction) (bool, error) {
fmt.Println(v.ID)
return true, nil
})
Expand Down

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

68 changes: 0 additions & 68 deletions pkg/paddlenotification/adjustment.go

This file was deleted.

180 changes: 180 additions & 0 deletions pkg/paddlenotification/adjustments.go

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

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

Loading

0 comments on commit 0c29fd2

Please sign in to comment.