generated from NdoleStudio/go-http-client
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from webtaken/update-subscriptions-object
Updated subscriptions object
- Loading branch information
Showing
5 changed files
with
248 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ func SubscriptionGetResponse() []byte { | |
"id": "1", | ||
"attributes": { | ||
"store_id": 1, | ||
"customer_id": 1, | ||
"order_id": 1, | ||
"order_item_id": 1, | ||
"product_id": 1, | ||
|
@@ -25,10 +26,20 @@ func SubscriptionGetResponse() []byte { | |
"user_email": "[email protected]", | ||
"status": "active", | ||
"status_formatted": "Active", | ||
"card_brand": "visa", | ||
"card_last_four": "42424", | ||
"pause": null, | ||
"cancelled": false, | ||
"trial_ends_at": null, | ||
"billing_anchor": 12, | ||
"first_subscription_item": { | ||
"id": 1, | ||
"subscription_id": 1, | ||
"price_id": 1, | ||
"quantity": 5, | ||
"created_at": "2021-08-11T13:47:28.000000Z", | ||
"updated_at": "2021-08-11T13:47:28.000000Z" | ||
}, | ||
"urls": { | ||
"update_payment_method": "https://app.lemonsqueezy.com/my-orders/2ba92a4e-a00a-45d2-a128-16856ffa8cdf/subscription/8/update-payment-method?expires=1666869343&signature=9985e3bf9007840aeb3951412be475abc17439c449c1af3e56e08e45e1345413" | ||
}, | ||
|
@@ -45,6 +56,12 @@ func SubscriptionGetResponse() []byte { | |
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/store" | ||
} | ||
}, | ||
"customer": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/customer", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/customer" | ||
} | ||
}, | ||
"order": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/order", | ||
|
@@ -68,6 +85,18 @@ func SubscriptionGetResponse() []byte { | |
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/variant", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/variant" | ||
} | ||
}, | ||
"subscription-items": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-items", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-items" | ||
} | ||
}, | ||
"subscription-invoices": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-invoices", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-invoices" | ||
} | ||
} | ||
}, | ||
"links": { | ||
|
@@ -93,6 +122,7 @@ func SubscriptionUpdateResponse() []byte { | |
"id": "1", | ||
"attributes": { | ||
"store_id": 1, | ||
"customer_id": 1, | ||
"order_id": 1, | ||
"order_item_id": 1, | ||
"product_id": 9, | ||
|
@@ -107,6 +137,14 @@ func SubscriptionUpdateResponse() []byte { | |
"cancelled": false, | ||
"trial_ends_at": null, | ||
"billing_anchor": 29, | ||
"first_subscription_item": { | ||
"id": 1, | ||
"subscription_id": 1, | ||
"price_id": 1, | ||
"quantity": 5, | ||
"created_at": "2021-08-11T13:47:28.000000Z", | ||
"updated_at": "2021-08-11T13:47:28.000000Z" | ||
}, | ||
"urls": { | ||
"update_payment_method": "https://app.lemonsqueezy.com/my-orders/2ba92a4e-a00a-45d2-a128-16856ffa8cdf/subscription/8/update-payment-method?expires=1666869343&signature=9985e3bf9007840aeb3951412be475abc17439c449c1af3e56e08e45e1345413" | ||
}, | ||
|
@@ -148,6 +186,7 @@ func SubscriptionsListResponse() []byte { | |
"id":"1", | ||
"attributes":{ | ||
"store_id":1, | ||
"customer_id": 1, | ||
"order_id":1, | ||
"order_item_id":1, | ||
"product_id":1, | ||
|
@@ -162,6 +201,14 @@ func SubscriptionsListResponse() []byte { | |
"cancelled":false, | ||
"trial_ends_at":null, | ||
"billing_anchor":12, | ||
"first_subscription_item": { | ||
"id": 1, | ||
"subscription_id": 1, | ||
"price_id": 1, | ||
"quantity": 5, | ||
"created_at": "2021-08-11T13:47:28.000000Z", | ||
"updated_at": "2021-08-11T13:47:28.000000Z" | ||
}, | ||
"urls":{ | ||
"update_payment_method":"https://app.lemonsqueezy.com/my-orders/2ba92a4e-a00a-45d2-a128-16856ffa8cdf/subscription/8/update-payment-method?expires=1666869343&signature=9985e3bf9007840aeb3951412be475abc17439c449c1af3e56e08e45e1345413" | ||
}, | ||
|
@@ -178,6 +225,12 @@ func SubscriptionsListResponse() []byte { | |
"self":"https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/store" | ||
} | ||
}, | ||
"customer": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/customer", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/customer" | ||
} | ||
}, | ||
"order":{ | ||
"links":{ | ||
"related":"https://api.lemonsqueezy.com/v1/subscriptions/1/order", | ||
|
@@ -201,6 +254,18 @@ func SubscriptionsListResponse() []byte { | |
"related":"https://api.lemonsqueezy.com/v1/subscriptions/1/variant", | ||
"self":"https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/variant" | ||
} | ||
}, | ||
"subscription-items": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-items", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-items" | ||
} | ||
}, | ||
"subscription-invoices": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-invoices", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-invoices" | ||
} | ||
} | ||
}, | ||
"links":{ | ||
|
@@ -212,6 +277,7 @@ func SubscriptionsListResponse() []byte { | |
"id":"2", | ||
"attributes":{ | ||
"store_id":2, | ||
"customer_id": 2, | ||
"order_id":2, | ||
"order_item_id":2, | ||
"product_id":2, | ||
|
@@ -226,6 +292,14 @@ func SubscriptionsListResponse() []byte { | |
"cancelled":false, | ||
"trial_ends_at":null, | ||
"billing_anchor":13, | ||
"first_subscription_item": { | ||
"id": 2, | ||
"subscription_id": 2, | ||
"price_id": 2, | ||
"quantity": 5, | ||
"created_at": "2021-08-11T13:47:28.000000Z", | ||
"updated_at": "2021-08-11T13:47:28.000000Z" | ||
}, | ||
"urls":{ | ||
"update_payment_method":"https://app.lemonsqueezy.com/my-orders/2ba92a4e-a00a-45d2-a128-16856ffa8cdf/subscription/8/update-payment-method?expires=1666869343&signature=9985e3bf9007840aeb3951412be475abc17439c449c1af3e56e08e45e1345413" | ||
}, | ||
|
@@ -242,6 +316,12 @@ func SubscriptionsListResponse() []byte { | |
"self":"https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/store" | ||
} | ||
}, | ||
"customer": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/customer", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/customer" | ||
} | ||
}, | ||
"order":{ | ||
"links":{ | ||
"related":"https://api.lemonsqueezy.com/v1/subscriptions/1/order", | ||
|
@@ -265,6 +345,18 @@ func SubscriptionsListResponse() []byte { | |
"related":"https://api.lemonsqueezy.com/v1/subscriptions/1/variant", | ||
"self":"https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/variant" | ||
} | ||
}, | ||
"subscription-items": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-items", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-items" | ||
} | ||
}, | ||
"subscription-invoices": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-invoices", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-invoices" | ||
} | ||
} | ||
}, | ||
"links":{ | ||
|
@@ -291,6 +383,7 @@ func SubscriptionCancelResponse() []byte { | |
"id": "1", | ||
"attributes": { | ||
"store_id": 1, | ||
"customer_id": 1, | ||
"order_id": 1, | ||
"order_item_id": 1, | ||
"product_id": 1, | ||
|
@@ -305,6 +398,14 @@ func SubscriptionCancelResponse() []byte { | |
"cancelled": true, | ||
"trial_ends_at": null, | ||
"billing_anchor": 12, | ||
"first_subscription_item": { | ||
"id": 1, | ||
"subscription_id": 1, | ||
"price_id": 1, | ||
"quantity": 5, | ||
"created_at": "2021-08-11T13:47:28.000000Z", | ||
"updated_at": "2021-08-11T13:47:28.000000Z" | ||
}, | ||
"urls": { | ||
"update_payment_method": "https://app.lemonsqueezy.com/my-orders/2ba92a4e-a00a-45d2-a128-16856ffa8cdf/subscription/8/update-payment-method?expires=1666869343&signature=9985e3bf9007840aeb3951412be475abc17439c449c1af3e56e08e45e1345413" | ||
}, | ||
|
@@ -321,6 +422,12 @@ func SubscriptionCancelResponse() []byte { | |
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/store" | ||
} | ||
}, | ||
"customer": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/customer", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/customer" | ||
} | ||
}, | ||
"order": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/order", | ||
|
@@ -344,6 +451,18 @@ func SubscriptionCancelResponse() []byte { | |
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/variant", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/variant" | ||
} | ||
}, | ||
"subscription-items": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-items", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-items" | ||
} | ||
}, | ||
"subscription-invoices": { | ||
"links": { | ||
"related": "https://api.lemonsqueezy.com/v1/subscriptions/1/subscription-invoices", | ||
"self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/subscription-invoices" | ||
} | ||
} | ||
}, | ||
"links": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package lemonsqueezy | ||
|
||
import "time" | ||
|
||
// In Lemon Squeezy A subscription item is an object that links a price to a subscription and also contains quantity information. | ||
// https://docs.lemonsqueezy.com/api/subscription-items#the-subscription-item-object | ||
type SubscriptionItem struct { | ||
ID int `json:"id"` | ||
SubscriptionID int `json:"subscription_id"` | ||
PriceID int `json:"price_id"` | ||
Quantity int `json:"quantity"` | ||
IsUsageBased bool `json:"is_usage_based"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
} | ||
|
||
// SubscriptionUpdateParams are parameters for updating a subscription | ||
type SubscriptionItemUpdateParams struct { | ||
ID string `json:"id"` | ||
Attributes SubscriptionItemUpdateParamsAttributes `json:"attributes"` | ||
} | ||
|
||
// SubscriptionUpdateParamsAttributes are subscription update attributes | ||
type SubscriptionItemUpdateParamsAttributes struct { | ||
Quantity int `json:"quantity,omitempty"` | ||
} | ||
|
||
// ApiResponseRelationshipsSubscription relationships of a subscription object | ||
type ApiResponseRelationshipsSubscriptionItem struct { | ||
Subscription ApiResponseLinks `json:"subscription"` | ||
Price ApiResponseLinks `json:"price"` | ||
UsageRecords ApiResponseLinks `json:"usage-records"` | ||
} | ||
|
||
// SubscriptionItemApiResponse represents a subscription item api response | ||
type SubscriptionItemApiResponse = ApiResponse[SubscriptionItem, ApiResponseRelationshipsSubscriptionItem] | ||
|
||
// SubscriptionItemsApiResponse represents a list of subscription items api responses | ||
type SubscriptionItemsApiResponse = ApiResponseList[SubscriptionItem, ApiResponseRelationshipsSubscriptionItem] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.