Skip to content

Commit

Permalink
Hard code the subscriptions block
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Aug 20, 2023
1 parent f4a4c42 commit 8d8f3cf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
1 change: 0 additions & 1 deletion subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type SubscriptionPause struct {

// SubscriptionUpdateParams are parameters for updating a subscription
type SubscriptionUpdateParams struct {
Type string `json:"type"`
ID string `json:"id"`
Attributes SubscriptionUpdateParamsAttributes `json:"attributes"`
}
Expand Down
6 changes: 1 addition & 5 deletions subscriptions_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ type SubscriptionsService service
//
// https://docs.lemonsqueezy.com/api/subscriptions#update-a-subscription
func (service *SubscriptionsService) Update(ctx context.Context, params *SubscriptionUpdateParams) (*ApiResponseSubscription, *Response, error) {
typeParam := "subscriptions"
if len(params.Type) > 0 {
typeParam = params.Type
}
payload := map[string]any{
"data": map[string]any{
"id": params.ID,
"type": typeParam,
"type": "subscriptions",
"attributes": params.Attributes,
},
}
Expand Down
3 changes: 1 addition & 2 deletions subscriptions_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ func TestSubscriptionsService_Update(t *testing.T) {

// Act
subscription, response, err := client.Subscriptions.Update(context.Background(), &SubscriptionUpdateParams{
Type: "subscriptions",
ID: "1",
ID: "1",
Attributes: SubscriptionUpdateParamsAttributes{
ProductID: 9,
VariantID: 11,
Expand Down

0 comments on commit 8d8f3cf

Please sign in to comment.