diff --git a/customer_portal_sessions.go b/customer_portal_sessions.go new file mode 100644 index 0000000..037c177 --- /dev/null +++ b/customer_portal_sessions.go @@ -0,0 +1,80 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddle + +import "context" + +// CustomerPortalSessionGeneralURLs: Authenticated customer portal deep links that aren't associated with a specific entity. +type CustomerPortalSessionGeneralURLs struct { + // Overview: Link to the overview page in the customer portal. + Overview string `json:"overview,omitempty"` +} + +/* +CustomerPortalSessionSubscriptionURLs: List of generated authenticated customer portal deep links for the subscriptions passed in the `subscription_ids` array in the request. + +If subscriptions are paused or canceled, links open the overview page for a subscription. + +Empty if no subscriptions passed in the request. +*/ +type CustomerPortalSessionSubscriptionURLs struct { + // ID: Paddle ID of the subscription that the authenticated customer portal deep links are for. + ID string `json:"id,omitempty"` + // CancelSubscription: Link to the page for this subscription in the customer portal with the subscription cancellation form pre-opened. Use as part of cancel subscription workflows. + CancelSubscription string `json:"cancel_subscription,omitempty"` + /* + UpdateSubscriptionPaymentMethod: Link to the page for this subscription in the customer portal with the payment method update form pre-opened. Use as part of workflows to let customers update their payment details. + + If a manually-collected subscription, opens the overview page for this subscription. + */ + UpdateSubscriptionPaymentMethod string `json:"update_subscription_payment_method,omitempty"` +} + +// CustomerPortalSessionURLs: Authenticated customer portal deep links. For security, the `token` appended to each link is temporary. You shouldn't store these links. +type CustomerPortalSessionURLs struct { + // General: Authenticated customer portal deep links that aren't associated with a specific entity. + General CustomerPortalSessionGeneralURLs `json:"general,omitempty"` + /* + Subscriptions: List of generated authenticated customer portal deep links for the subscriptions passed in the `subscription_ids` array in the request. + + If subscriptions are paused or canceled, links open the overview page for a subscription. + + Empty if no subscriptions passed in the request. + */ + Subscriptions []CustomerPortalSessionSubscriptionURLs `json:"subscriptions,omitempty"` +} + +// CustomerPortalSession: Represents a customer portal session. +type CustomerPortalSession struct { + // ID: Unique Paddle ID for this customer portal session entity, prefixed with `cpls_`. + ID string `json:"id,omitempty"` + // CustomerID: Paddle ID of the customer that this customer portal sessions is for, prefixed with `ctm_`. + CustomerID string `json:"customer_id,omitempty"` + // URLs: Authenticated customer portal deep links. For security, the `token` appended to each link is temporary. You shouldn't store these links. + URLs CustomerPortalSessionURLs `json:"urls,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this customer portal session was created. + CreatedAt string `json:"created_at,omitempty"` +} + +// CustomerPortalSessionsClient is a client for the Customer portal sessions resource. +type CustomerPortalSessionsClient struct { + doer Doer +} + +// CreateCustomerPortalSessionRequest is given as an input to CreateCustomerPortalSession. +type CreateCustomerPortalSessionRequest struct { + // URL path parameters. + CustomerID string `in:"path=customer_id" json:"-"` + + // SubscriptionIDs: Paddle ID of a subscription related to this customer to create an authenticated customer portal deep link for. + SubscriptionIDs []string `json:"subscription_ids,omitempty"` +} + +// CreateCustomerPortalSession performs the POST operation on a Customer portal sessions resource. +func (c *CustomerPortalSessionsClient) CreateCustomerPortalSession(ctx context.Context, req *CreateCustomerPortalSessionRequest) (res *CustomerPortalSession, err error) { + if err := c.doer.Do(ctx, "POST", "/customers/{customer_id}/portal-sessions", req, &res); err != nil { + return nil, err + } + + return res, nil +} diff --git a/sdk.go b/sdk.go index bc9d2dd..84d8183 100644 --- a/sdk.go +++ b/sdk.go @@ -13,6 +13,7 @@ type SDK struct { *AddressesClient *BusinessesClient *PaymentMethodsClient + *CustomerPortalSessionsClient *NotificationSettingsClient *EventsTypesClient *EventsClient @@ -35,6 +36,7 @@ func newSDK(d Doer) *SDK { AddressesClient: &AddressesClient{doer: d}, AdjustmentsClient: &AdjustmentsClient{doer: d}, BusinessesClient: &BusinessesClient{doer: d}, + CustomerPortalSessionsClient: &CustomerPortalSessionsClient{doer: d}, CustomersClient: &CustomersClient{doer: d}, DiscountsClient: &DiscountsClient{doer: d}, EventsClient: &EventsClient{doer: d}, diff --git a/subscriptions.go b/subscriptions.go index 57a8304..5ab514b 100644 --- a/subscriptions.go +++ b/subscriptions.go @@ -427,11 +427,11 @@ type SubscriptionScheduledChange struct { ResumeAt *string `json:"resume_at,omitempty"` } -// SubscriptionManagementUrLs: Public URLs that customers can use to make changes to this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. +// SubscriptionManagementUrLs: Authenticated customer portal deep links for this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. type SubscriptionManagementUrLs struct { - // UpdatePaymentMethod: Public URL that lets customers update the payment method for this subscription. Creates or gets a transaction that can be used to update a payment method, then passes it to your default checkout page. + // UpdatePaymentMethod: Link to the page for this subscription in the customer portal with the payment method update form pre-opened. Use as part of workflows to let customers update their payment details. `null` for manually-collected subscriptions. UpdatePaymentMethod *string `json:"update_payment_method,omitempty"` - // Cancel: Public URL that lets customers cancel this subscription. Takes customers to a Paddle page that lets them cancel their subscription. + // Cancel: Link to the page for this subscription in the customer portal with the subscription cancellation form pre-opened. Use as part of cancel subscription workflows. Cancel string `json:"cancel,omitempty"` } @@ -573,7 +573,7 @@ type Subscription struct { BillingCycle Duration `json:"billing_cycle,omitempty"` // ScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. ScheduledChange *SubscriptionScheduledChange `json:"scheduled_change,omitempty"` - // ManagementURLs: Public URLs that customers can use to make changes to this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. + // ManagementURLs: Authenticated customer portal deep links for this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. ManagementURLs SubscriptionManagementUrLs `json:"management_urls,omitempty"` // Items: Represents a subscription item. Items []SubscriptionItem `json:"items,omitempty"` @@ -738,7 +738,7 @@ type SubscriptionPreview struct { BillingCycle Duration `json:"billing_cycle,omitempty"` // ScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. ScheduledChange *SubscriptionScheduledChange `json:"scheduled_change,omitempty"` - // ManagementURLs: Public URLs that customers can use to make changes to this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. + // ManagementURLs: Authenticated customer portal deep links for this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. ManagementURLs SubscriptionManagementUrLs `json:"management_urls,omitempty"` // Items: Represents a subscription item. Items []SubscriptionItem `json:"items,omitempty"`