From 1ff4cec7af8ea9c9eaa7a4507d0929d5fb55dd63 Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Fri, 29 Nov 2024 16:35:19 -0500 Subject: [PATCH] Update generated code --- adminapi/flows_test.go | 34 +++--- adminapi/invoices_test.go | 66 ++++++------ adminapi/organizations.go | 40 ++++++- adminapi/organizations_test.go | 104 +++++++++++++----- adminapi/subscriptions_test.go | 35 +++--- adminapi/users.go | 47 +++++++- adminapi/users_test.go | 109 ++++++++++++++----- adminv1/account_connection.go | 20 +++- adminv1/account_connection_input.go | 37 +++++++ adminv1/amazon_cognito_connection.go | 20 ++++ adminv1/auth0_connection.go | 5 + adminv1/connection.go | 2 + adminv1/oidc_config.go | 13 +++ adminv1/organization.go | 2 +- adminv1/organization_input.go | 2 +- adminv1/plan_group.go | 2 +- adminv1/plan_group_revision_plan.go | 2 +- adminv1/price_tiered_price.go | 2 +- adminv1/price_tiered_price_tier.go | 13 +++ adminv1/purge_organization_response.go | 7 ++ adminv1/purge_user_response.go | 7 ++ adminv1/user.go | 2 +- adminv1/user_input.go | 2 +- apiv1/status.go | 2 + apiv1/status_details.go | 2 + internal/constants.go | 4 +- userapi/flows_test.go | 50 ++++----- userapi/invoices_test.go | 44 ++++---- userapi/session.go | 125 +++++++++++++++++++++- userapi/session_test.go | 43 ++++++++ userv1/billing_account.go | 18 +++- userv1/billing_account_checkout.go | 9 ++ userv1/billing_account_input.go | 27 +++++ userv1/checkout.go | 67 ++++++++++++ userv1/checkout_complete_payment_step.go | 9 ++ userv1/checkout_discount.go | 11 ++ userv1/checkout_input.go | 17 +++ userv1/checkout_item.go | 45 ++++++++ userv1/checkout_plan.go | 53 +++++++++ userv1/checkout_plan_group.go | 19 ++++ userv1/checkout_plan_revision.go | 19 ++++ userv1/checkout_plan_savings.go | 11 ++ userv1/checkout_plan_trial.go | 9 ++ userv1/checkout_step.go | 13 +++ userv1/create_portal_session_response.go | 10 ++ userv1/exchange_session_token_response.go | 19 ++++ userv1/flow.go | 8 +- userv1/price_tiered_price.go | 2 +- userv1/price_tiered_price_tier.go | 13 +++ userv1/stripe_payment_method_intent.go | 2 + 50 files changed, 1039 insertions(+), 185 deletions(-) create mode 100644 adminv1/account_connection_input.go create mode 100644 adminv1/amazon_cognito_connection.go create mode 100644 adminv1/oidc_config.go create mode 100644 adminv1/price_tiered_price_tier.go create mode 100644 adminv1/purge_organization_response.go create mode 100644 adminv1/purge_user_response.go create mode 100644 userv1/billing_account_checkout.go create mode 100644 userv1/billing_account_input.go create mode 100644 userv1/checkout.go create mode 100644 userv1/checkout_complete_payment_step.go create mode 100644 userv1/checkout_discount.go create mode 100644 userv1/checkout_input.go create mode 100644 userv1/checkout_item.go create mode 100644 userv1/checkout_plan.go create mode 100644 userv1/checkout_plan_group.go create mode 100644 userv1/checkout_plan_revision.go create mode 100644 userv1/checkout_plan_savings.go create mode 100644 userv1/checkout_plan_trial.go create mode 100644 userv1/checkout_step.go create mode 100644 userv1/create_portal_session_response.go create mode 100644 userv1/exchange_session_token_response.go create mode 100644 userv1/price_tiered_price_tier.go diff --git a/adminapi/flows_test.go b/adminapi/flows_test.go index 8436eb1..f23a25d 100644 --- a/adminapi/flows_test.go +++ b/adminapi/flows_test.go @@ -20,7 +20,7 @@ func TestFlows_List(t *testing.T) { { "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "startTime": "2024-02-05T23:07:46.483Z", "expireTime": "2024-02-05T23:07:46.483Z", @@ -54,12 +54,12 @@ func TestFlows_CreateJoinOrganization(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -93,7 +93,7 @@ func TestFlows_CreateJoinOrganization(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -127,7 +127,7 @@ func TestFlows_CreateJoinOrganization(t *testing.T) { "creator": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -207,12 +207,12 @@ func TestFlows_CreateSignup(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -246,7 +246,7 @@ func TestFlows_CreateSignup(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -280,7 +280,7 @@ func TestFlows_CreateSignup(t *testing.T) { "creator": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -360,12 +360,12 @@ func TestFlows_Get(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -399,7 +399,7 @@ func TestFlows_Get(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -433,7 +433,7 @@ func TestFlows_Get(t *testing.T) { "creator": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -513,12 +513,12 @@ func TestFlows_Cancel(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -552,7 +552,7 @@ func TestFlows_Cancel(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -586,7 +586,7 @@ func TestFlows_Cancel(t *testing.T) { "creator": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", diff --git a/adminapi/invoices_test.go b/adminapi/invoices_test.go index 49430b7..a7214e8 100644 --- a/adminapi/invoices_test.go +++ b/adminapi/invoices_test.go @@ -20,21 +20,21 @@ func TestInvoices_List(t *testing.T) { { "id": "string", "state": "DRAFT", - "stateReason": "DELETED", + "stateReason": "UPDATING", "stateTime": "2024-02-05T23:07:46.483Z", "externalId": "string", "number": "string", "currencyCode": "USD", "description": "string", "effectiveTime": "2024-02-05T23:07:46.483Z", - "subtotalAmount": "string", - "discountAmount": "string", - "taxAmount": "string", - "totalAmount": "string", - "dueAmount": "string", - "remainingDueAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", + "taxAmount": "0", + "totalAmount": "10", + "dueAmount": "10", + "remainingDueAmount": "0", "dueTime": "2024-02-05T23:07:46.483Z", - "paidAmount": "string", + "paidAmount": "10", "paymentState": "PAYMENT_METHOD_REQUIRED", "pullTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -65,26 +65,32 @@ func TestInvoices_Get(t *testing.T) { tr.Body = `{ "id": "string", "state": "DRAFT", - "stateReason": "DELETED", + "stateReason": "UPDATING", "stateTime": "2024-02-05T23:07:46.483Z", "connection": { "id": "string", "uniqueId": "test", "displayName": "Test", - "state": "PENDING_SETUP", - "stateReason": "DELETED", - "type": "string", + "state": "ACTIVE", + "stateReason": "UPDATING", + "type": "AMAZON_COGNITO", "delegate": { "id": "string", "uniqueId": "test", "displayName": "Test", - "state": "PENDING_SETUP", - "stateReason": "DELETED", - "type": "string" + "state": "ACTIVE", + "stateReason": "UPDATING", + "type": "AMAZON_COGNITO" }, "providers": [], "createTime": "2024-02-05T23:07:46.483Z", "updateTime": "2024-02-05T23:07:46.483Z", + "amazonCognito": { + "userPoolId": "string", + "region": "string", + "accessKeyId": "string", + "accessKeySecret": "string" + }, "auth0": { "domain": "string", "clientId": "string", @@ -116,7 +122,7 @@ func TestInvoices_Get(t *testing.T) { "currencyCode": "USD", "description": "string", "account": { - "fullName": "Test", + "fullName": "Jane Doe", "email": "test@example.com", "phoneNumber": "+12125550123", "address": { @@ -132,19 +138,19 @@ func TestInvoices_Get(t *testing.T) { "startTime": "2024-02-05T23:07:46.483Z", "endTime": "2024-02-05T23:07:46.483Z" }, - "subtotalAmount": "string", - "discountAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", "balance": { - "startAmount": "string", - "endAmount": "string", - "appliedAmount": "string" + "startAmount": "10", + "endAmount": "10", + "appliedAmount": "10" }, - "taxAmount": "string", - "totalAmount": "string", - "dueAmount": "string", - "remainingDueAmount": "string", + "taxAmount": "0", + "totalAmount": "10", + "dueAmount": "10", + "remainingDueAmount": "0", "dueTime": "2024-02-05T23:07:46.483Z", - "paidAmount": "string", + "paidAmount": "10", "paymentState": "PAYMENT_METHOD_REQUIRED", "paymentIntent": { "stripe": { @@ -157,8 +163,8 @@ func TestInvoices_Get(t *testing.T) { { "id": "string", "quantity": 1, - "subtotalAmount": "string", - "discountAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", "description": "string", "externalId": "string", "proration": true @@ -168,8 +174,8 @@ func TestInvoices_Get(t *testing.T) { { "time": "2024-02-05T23:07:46.483Z", "description": "string", - "subtotalAmount": "string", - "discountAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", "startQuantity": 1, "endQuantity": 1, "startItemIds": [], diff --git a/adminapi/organizations.go b/adminapi/organizations.go index e679ebb..dedfb90 100644 --- a/adminapi/organizations.go +++ b/adminapi/organizations.go @@ -28,6 +28,10 @@ type Organizations interface { Delete(ctx context.Context, organizationId string, input *OrganizationDeleteInput) (*adminv1.Organization, error) // Un-marks specified organization for deletion. Undelete(ctx context.Context, organizationId string, input *OrganizationUndeleteInput) (*adminv1.Organization, error) + // Hard delete the specified organization. + // + // The organization must be marked for deletion before it can be purged. + Purge(ctx context.Context, organizationId string, input *OrganizationPurgeInput) (*adminv1.PurgeOrganizationResponse, error) // Connect specified organization to external account. Connect(ctx context.Context, organizationId string, input *OrganizationConnectInput) (*adminv1.Organization, error) // Disconnect specified organization from external account. @@ -187,7 +191,7 @@ type OrganizationCreateInput struct { RegionCode string // The IANA time zone for the organization (e.g. `America/New_York`). TimeZone string - // The billing address for the organization. + // The default address for the organization. Address *commonv1.Address // The sign-up time for the organization. SignupTime time.Time @@ -331,7 +335,7 @@ type OrganizationUpdateInput struct { RegionCode types.Optional[string] // The IANA time zone for the organization (e.g. `America/New_York`). TimeZone types.Optional[string] - // The billing address for the organization. + // The default address for the organization. Address types.Optional[*commonv1.Address] // The sign-up time for the organization. SignupTime types.Optional[time.Time] @@ -483,6 +487,38 @@ func (n *organizationsImpl) Undelete(ctx context.Context, organizationId string, return model, nil } +// OrganizationPurgeInput is the input param for the Purge method. +type OrganizationPurgeInput struct { +} + +func (n *organizationsImpl) Purge(ctx context.Context, organizationId string, input *OrganizationPurgeInput) (*adminv1.PurgeOrganizationResponse, error) { + req := internal.NewRequest( + "admin.organizations.purge", + "POST", + fmt.Sprintf("/admin/v1/organizations/%s:purge", + url.PathEscape(organizationId), + ), + ) + + body := map[string]any{} + + req.SetBody(body) + + res, err := n.transport.Execute(ctx, req) + if err != nil { + return nil, err + } + + model := &adminv1.PurgeOrganizationResponse{} + + err = res.DecodeBody(&model) + if err != nil { + return nil, err + } + + return model, nil +} + // OrganizationConnectInput is the input param for the Connect method. type OrganizationConnectInput struct { // The identifier of the connection. diff --git a/adminapi/organizations_test.go b/adminapi/organizations_test.go index 48c7364..b096153 100644 --- a/adminapi/organizations_test.go +++ b/adminapi/organizations_test.go @@ -20,7 +20,7 @@ func TestOrganizations_List(t *testing.T) { { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -63,7 +63,7 @@ func TestOrganizations_Create(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -89,9 +89,14 @@ func TestOrganizations_Create(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -134,7 +139,7 @@ func TestOrganizations_Get(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -160,9 +165,14 @@ func TestOrganizations_Get(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -205,7 +215,7 @@ func TestOrganizations_Update(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -231,9 +241,14 @@ func TestOrganizations_Update(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -276,7 +291,7 @@ func TestOrganizations_Delete(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -302,9 +317,14 @@ func TestOrganizations_Delete(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -347,7 +367,7 @@ func TestOrganizations_Undelete(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -373,9 +393,14 @@ func TestOrganizations_Undelete(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -411,6 +436,25 @@ func TestOrganizations_Undelete(t *testing.T) { require.NotNil(t, res) } +func TestOrganizations_Purge(t *testing.T) { + t.Parallel() + + tr := &internal.TestTransport{} + tr.Body = `{}` + + n := &organizationsImpl{transport: tr} + + res, err := n.Purge(context.Background(), "organizationId", nil) + require.NoError(t, err) + require.NotNil(t, res) + require.Equal(t, `POST`, tr.Request.Method()) + require.Equal(t, `/admin/v1/organizations/organizationId:purge`, tr.Request.Path()) + + res, err = n.Purge(context.Background(), "organizationId", &OrganizationPurgeInput{}) + require.NoError(t, err) + require.NotNil(t, res) +} + func TestOrganizations_Connect(t *testing.T) { t.Parallel() @@ -418,7 +462,7 @@ func TestOrganizations_Connect(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -444,9 +488,14 @@ func TestOrganizations_Connect(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -489,7 +538,7 @@ func TestOrganizations_Disconnect(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -515,9 +564,14 @@ func TestOrganizations_Disconnect(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -591,7 +645,7 @@ func TestOrganizations_AddMember(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -669,7 +723,7 @@ func TestOrganizations_GetMember(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -747,7 +801,7 @@ func TestOrganizations_UpdateMember(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", diff --git a/adminapi/subscriptions_test.go b/adminapi/subscriptions_test.go index d910cc7..f252c7c 100644 --- a/adminapi/subscriptions_test.go +++ b/adminapi/subscriptions_test.go @@ -20,7 +20,7 @@ func TestSubscriptions_List(t *testing.T) { { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "externalId": "string", "currencyCode": "USD", "cancelPeriodEnd": true, @@ -58,25 +58,31 @@ func TestSubscriptions_Get(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "connection": { "id": "string", "uniqueId": "test", "displayName": "Test", - "state": "PENDING_SETUP", - "stateReason": "DELETED", - "type": "string", + "state": "ACTIVE", + "stateReason": "UPDATING", + "type": "AMAZON_COGNITO", "delegate": { "id": "string", "uniqueId": "test", "displayName": "Test", - "state": "PENDING_SETUP", - "stateReason": "DELETED", - "type": "string" + "state": "ACTIVE", + "stateReason": "UPDATING", + "type": "AMAZON_COGNITO" }, "providers": [], "createTime": "2024-02-05T23:07:46.483Z", "updateTime": "2024-02-05T23:07:46.483Z", + "amazonCognito": { + "userPoolId": "string", + "region": "string", + "accessKeyId": "string", + "accessKeySecret": "string" + }, "auth0": { "domain": "string", "clientId": "string", @@ -138,10 +144,10 @@ func TestSubscriptions_Get(t *testing.T) { "id": "string", "externalId": "string", "state": "ACTIVE", - "stateReason": "DELETED", - "type": "string", + "stateReason": "UPDATING", + "type": "CARD", "displayName": "Test", - "fullName": "Test", + "fullName": "Jane Doe", "address": { "lines": [], "city": "Brooklyn", @@ -155,7 +161,8 @@ func TestSubscriptions_Get(t *testing.T) { "message": "string", "reason": "string", "param": "string", - "metadata": {} + "metadata": {}, + "localeMessage": "string" }, "pullTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -185,7 +192,7 @@ func TestSubscriptions_Get(t *testing.T) { "organization": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -219,7 +226,7 @@ func TestSubscriptions_Get(t *testing.T) { "user": { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", diff --git a/adminapi/users.go b/adminapi/users.go index ccefbca..5493049 100644 --- a/adminapi/users.go +++ b/adminapi/users.go @@ -27,6 +27,10 @@ type Users interface { Delete(ctx context.Context, userId string, input *UserDeleteInput) (*adminv1.User, error) // Un-marks specified user for deletion. Undelete(ctx context.Context, userId string, input *UserUndeleteInput) (*adminv1.User, error) + // Hard delete the specified user. + // + // The user must be marked for deletion before it can be purged. + Purge(ctx context.Context, userId string, input *UserPurgeInput) (*adminv1.PurgeUserResponse, error) // Connect specified user to external account. Connect(ctx context.Context, userId string, input *UserConnectInput) (*adminv1.User, error) // Disconnect specified user from external account. @@ -185,7 +189,7 @@ type UserCreateInput struct { RegionCode string // The IANA time zone for the user (e.g. `America/New_York`). TimeZone string - // The billing address for the user. + // The default address for the user. Address *commonv1.Address // The sign-up time for the user. SignupTime time.Time @@ -329,7 +333,7 @@ type UserUpdateInput struct { RegionCode types.Optional[string] // The IANA time zone for the user (e.g. `America/New_York`). TimeZone types.Optional[string] - // The billing address for the user. + // The default address for the user. Address types.Optional[*commonv1.Address] // The sign-up time for the user. SignupTime types.Optional[time.Time] @@ -479,6 +483,38 @@ func (n *usersImpl) Undelete(ctx context.Context, userId string, input *UserUnde return model, nil } +// UserPurgeInput is the input param for the Purge method. +type UserPurgeInput struct { +} + +func (n *usersImpl) Purge(ctx context.Context, userId string, input *UserPurgeInput) (*adminv1.PurgeUserResponse, error) { + req := internal.NewRequest( + "admin.users.purge", + "POST", + fmt.Sprintf("/admin/v1/users/%s:purge", + url.PathEscape(userId), + ), + ) + + body := map[string]any{} + + req.SetBody(body) + + res, err := n.transport.Execute(ctx, req) + if err != nil { + return nil, err + } + + model := &adminv1.PurgeUserResponse{} + + err = res.DecodeBody(&model) + if err != nil { + return nil, err + } + + return model, nil +} + // UserConnectInput is the input param for the Connect method. type UserConnectInput struct { // The identifier of the connection. @@ -641,7 +677,7 @@ func (n *usersImpl) CreateApiSession(ctx context.Context, userId string, input * // UserCreatePortalSessionInput is the input param for the CreatePortalSession method. type UserCreatePortalSessionInput struct { - // The portal URL, this is the target URL on the portal site. + // The Portal URL, this is the target URL on the portal site. // // If not defined the root URL for the portal will be used. // @@ -655,8 +691,9 @@ type UserCreatePortalSessionInput struct { // // Examples: // * `/{accountId}` - the billing dashboard - // * `/{accountId}/plans` - select a plan to checkout - // * `/{accountId}/checkout/` - checkout specified plan + // * `/{accountId}/checkout` - start a checkout + // * `/{accountId}/checkout/` - start a checkout with a specified plan + // * `/{accountId}/cancel` - cancel current plan // * `/{accountId}/members` - manage organization members // * `/{accountId}/invite` - invite a user to an organization PortalUrl string diff --git a/adminapi/users_test.go b/adminapi/users_test.go index 779682d..2ca8d70 100644 --- a/adminapi/users_test.go +++ b/adminapi/users_test.go @@ -20,7 +20,7 @@ func TestUsers_List(t *testing.T) { { "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -62,7 +62,7 @@ func TestUsers_Create(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -88,9 +88,14 @@ func TestUsers_Create(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -138,7 +143,7 @@ func TestUsers_Get(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -164,9 +169,14 @@ func TestUsers_Get(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -214,7 +224,7 @@ func TestUsers_Update(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -240,9 +250,14 @@ func TestUsers_Update(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -290,7 +305,7 @@ func TestUsers_Delete(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -316,9 +331,14 @@ func TestUsers_Delete(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -366,7 +386,7 @@ func TestUsers_Undelete(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -392,9 +412,14 @@ func TestUsers_Undelete(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -435,6 +460,25 @@ func TestUsers_Undelete(t *testing.T) { require.NotNil(t, res) } +func TestUsers_Purge(t *testing.T) { + t.Parallel() + + tr := &internal.TestTransport{} + tr.Body = `{}` + + n := &usersImpl{transport: tr} + + res, err := n.Purge(context.Background(), "userId", nil) + require.NoError(t, err) + require.NotNil(t, res) + require.Equal(t, `POST`, tr.Request.Method()) + require.Equal(t, `/admin/v1/users/userId:purge`, tr.Request.Path()) + + res, err = n.Purge(context.Background(), "userId", &UserPurgeInput{}) + require.NoError(t, err) + require.NotNil(t, res) +} + func TestUsers_Connect(t *testing.T) { t.Parallel() @@ -442,7 +486,7 @@ func TestUsers_Connect(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -468,9 +512,14 @@ func TestUsers_Connect(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -518,7 +567,7 @@ func TestUsers_Disconnect(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -544,9 +593,14 @@ func TestUsers_Disconnect(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", @@ -594,7 +648,7 @@ func TestUsers_ImportAccount(t *testing.T) { tr.Body = `{ "id": "string", "state": "ACTIVE", - "stateReason": "DELETED", + "stateReason": "UPDATING", "uniqueId": "test", "displayName": "Test", "email": "test@example.com", @@ -620,9 +674,14 @@ func TestUsers_ImportAccount(t *testing.T) { "externalId": "string", "adminUrl": "https://example.com", "state": "ACTIVE", - "stateReason": "DELETED", - "balanceAmount": "string", + "stateReason": "UPDATING", + "displayName": "Test", + "email": "test@example.com", + "emailVerified": true, + "phoneNumber": "+12125550123", + "phoneNumberVerified": true, "currencyCode": "USD", + "balanceAmount": "10", "pullTime": "2024-02-05T23:07:46.483Z", "pushTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z", diff --git a/adminv1/account_connection.go b/adminv1/account_connection.go index 7dc4330..6a5d8c8 100644 --- a/adminv1/account_connection.go +++ b/adminv1/account_connection.go @@ -4,9 +4,11 @@ package adminv1 import ( "time" + + "github.com/userhubdev/go-sdk/commonv1" ) -// A link between a account and an external account. +// A link between an organization/user and an external account. type AccountConnection struct { // The tenant connection. Connection *Connection `json:"connection"` @@ -18,6 +20,20 @@ type AccountConnection struct { State string `json:"state"` // The code that best describes the reason for the state. StateReason string `json:"stateReason"` + // The human-readable display name of the external account. + DisplayName string `json:"displayName"` + // The email address of the external account. + Email string `json:"email"` + // Whether the external account's email address has been verified. + EmailVerified bool `json:"emailVerified"` + // The E164 phone number for the external account (e.g. `+12125550123`). + PhoneNumber string `json:"phoneNumber"` + // Whether the external account's phone number has been verified. + PhoneNumberVerified bool `json:"phoneNumberVerified"` + // The billing address for the external account. + Address *commonv1.Address `json:"address"` + // The currency code for the account. + CurrencyCode string `json:"currencyCode"` // The balance amount for the account. // // A negative value indicates an amount which will be subtracted from the next @@ -26,8 +42,6 @@ type AccountConnection struct { // A positive value indicates an amount which will be added to the next // invoice (debt). BalanceAmount string `json:"balanceAmount"` - // The currency code for the account. - CurrencyCode string `json:"currencyCode"` // The payment methods for connections that support it. PaymentMethods []*PaymentMethod `json:"paymentMethods"` // The last time the account was pulled from the connection. diff --git a/adminv1/account_connection_input.go b/adminv1/account_connection_input.go new file mode 100644 index 0000000..7b40592 --- /dev/null +++ b/adminv1/account_connection_input.go @@ -0,0 +1,37 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +import ( + "github.com/userhubdev/go-sdk/commonv1" +) + +// AccountConnection input parameters. +type AccountConnectionInput struct { + // The system-assigned identifier for the connection of the external account. + ConnectionId string `json:"connectionId"` + // The human-readable display name of the external account. + // + // The maximum length is 200 characters. + // + // This might be further restricted by the external provider. + DisplayName *string `json:"displayName"` + // The email address of the external account. + // + // The maximum length is 320 characters. + // + // This might be further restricted by the external provider. + Email *string `json:"email"` + // Whether the external account's email address has been verified. + EmailVerified *bool `json:"emailVerified"` + // The E164 phone number for the external account (e.g. `+12125550123`). + PhoneNumber *string `json:"phoneNumber"` + // Whether the external account's phone number has been verified. + PhoneNumberVerified *bool `json:"phoneNumberVerified"` + // The default ISO-4217 currency code for the external account (e.g. `USD`). + CurrencyCode *string `json:"currencyCode"` + // The billing address for the external account. + Address *commonv1.Address `json:"address"` + // Whether the external account is disabled. + Disabled *bool `json:"disabled"` +} diff --git a/adminv1/amazon_cognito_connection.go b/adminv1/amazon_cognito_connection.go new file mode 100644 index 0000000..9dd0e90 --- /dev/null +++ b/adminv1/amazon_cognito_connection.go @@ -0,0 +1,20 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +// The Amazon Cognito connection data. +type AmazonCognitoConnection struct { + // The Amazon Cognito user pool ID. + UserPoolId string `json:"userPoolId"` + // The Amazon region. + Region string `json:"region"` + // The Amazon access key ID. + AccessKeyId string `json:"accessKeyId"` + // The Amazon access key secret. + AccessKeySecret string `json:"accessKeySecret"` + // OpenID Connect (OIDC) configuration. + // + // If configured, this can be used instead of implementing a + // Portal callback. + Oidc *OidcConfig `json:"oidc"` +} diff --git a/adminv1/auth0_connection.go b/adminv1/auth0_connection.go index 29c70b5..1d66ab1 100644 --- a/adminv1/auth0_connection.go +++ b/adminv1/auth0_connection.go @@ -10,4 +10,9 @@ type Auth0Connection struct { ClientId string `json:"clientId"` // The Auth0 client secret. ClientSecret string `json:"clientSecret"` + // OpenID Connect (OIDC) configuration. + // + // If configured, this can be used instead of implementing a + // Portal callback. + Oidc *OidcConfig `json:"oidc"` } diff --git a/adminv1/connection.go b/adminv1/connection.go index c77d463..5eddbdc 100644 --- a/adminv1/connection.go +++ b/adminv1/connection.go @@ -36,6 +36,8 @@ type Connection struct { CreateTime time.Time `json:"createTime"` // The last update time of the connection. UpdateTime time.Time `json:"updateTime"` + // The Amazon Cognito connection data. + AmazonCognito *AmazonCognitoConnection `json:"amazonCognito"` // The Auth0 connection data. Auth0 *Auth0Connection `json:"auth0"` // The builtin email configuration data. diff --git a/adminv1/oidc_config.go b/adminv1/oidc_config.go new file mode 100644 index 0000000..012aeb8 --- /dev/null +++ b/adminv1/oidc_config.go @@ -0,0 +1,13 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +// OpenID Connect (OIDC) configuration. +type OidcConfig struct { + // The issuer URL. + IssuerUrl string `json:"issuerUrl"` + // The client ID. + ClientId string `json:"clientId"` + // The client secret. + ClientSecret string `json:"clientSecret"` +} diff --git a/adminv1/organization.go b/adminv1/organization.go index 9e00a54..8ca58f9 100644 --- a/adminv1/organization.go +++ b/adminv1/organization.go @@ -38,7 +38,7 @@ type Organization struct { RegionCode string `json:"regionCode"` // The IANA time zone for the organization (e.g. `America/New_York`). TimeZone string `json:"timeZone"` - // The address for the organization. + // The default address for the organization. Address *commonv1.Address `json:"address"` // The connected accounts. AccountConnections []*AccountConnection `json:"accountConnections"` diff --git a/adminv1/organization_input.go b/adminv1/organization_input.go index ca8a580..e4847d3 100644 --- a/adminv1/organization_input.go +++ b/adminv1/organization_input.go @@ -46,7 +46,7 @@ type OrganizationInput struct { RegionCode *string `json:"regionCode"` // The IANA time zone for the organization (e.g. `America/New_York`). TimeZone *string `json:"timeZone"` - // The billing address for the organization. + // The default address for the organization. Address *commonv1.Address `json:"address"` // The sign-up time for the organization. SignupTime *time.Time `json:"signupTime"` diff --git a/adminv1/plan_group.go b/adminv1/plan_group.go index c972bc1..89ba431 100644 --- a/adminv1/plan_group.go +++ b/adminv1/plan_group.go @@ -27,7 +27,7 @@ type PlanGroup struct { // // The maximum length is 200 characters. DisplayName string `json:"displayName"` - // The admin facing description of the plan group. + // The admin-facing description of the plan group. // // The maximum length is 1000 characters. Description string `json:"description"` diff --git a/adminv1/plan_group_revision_plan.go b/adminv1/plan_group_revision_plan.go index 2014c38..8dcc357 100644 --- a/adminv1/plan_group_revision_plan.go +++ b/adminv1/plan_group_revision_plan.go @@ -17,7 +17,7 @@ type PlanGroupRevisionPlan struct { Interval *commonv1.Interval `json:"interval"` // The customer facing human-readable display name for the plan. DisplayName string `json:"displayName"` - // The admin facing description of the plan. + // The admin-facing description of the plan. // // The maximum length is 1000 characters. Description string `json:"description"` diff --git a/adminv1/price_tiered_price.go b/adminv1/price_tiered_price.go index 3dc5019..eaf3a12 100644 --- a/adminv1/price_tiered_price.go +++ b/adminv1/price_tiered_price.go @@ -8,5 +8,5 @@ type PriceTieredPrice struct { // The strategy for evaluating the tiers. Mode string `json:"mode"` // The tiers for the price. - Tiers []*TieredPriceTier `json:"tiers"` + Tiers []*PriceTieredPriceTier `json:"tiers"` } diff --git a/adminv1/price_tiered_price_tier.go b/adminv1/price_tiered_price_tier.go new file mode 100644 index 0000000..b64a279 --- /dev/null +++ b/adminv1/price_tiered_price_tier.go @@ -0,0 +1,13 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +// A quantity range within the tiered price. +type PriceTieredPriceTier struct { + // The upper quantity for tier (inclusive). + Upper int32 `json:"upper"` + // The per quantity amount for the tier. + UnitAmount string `json:"unitAmount"` + // The flat amount for the tier. + FlatAmount string `json:"flatAmount"` +} diff --git a/adminv1/purge_organization_response.go b/adminv1/purge_organization_response.go new file mode 100644 index 0000000..b040f5d --- /dev/null +++ b/adminv1/purge_organization_response.go @@ -0,0 +1,7 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +// Response message for PurgeOrganization. +type PurgeOrganizationResponse struct { +} diff --git a/adminv1/purge_user_response.go b/adminv1/purge_user_response.go new file mode 100644 index 0000000..2a368bc --- /dev/null +++ b/adminv1/purge_user_response.go @@ -0,0 +1,7 @@ +// Code generated. DO NOT EDIT. + +package adminv1 + +// Response message for PurgeUser. +type PurgeUserResponse struct { +} diff --git a/adminv1/user.go b/adminv1/user.go index bc27f20..67c7abe 100644 --- a/adminv1/user.go +++ b/adminv1/user.go @@ -38,7 +38,7 @@ type User struct { RegionCode string `json:"regionCode"` // The IANA time zone for the user (e.g. `America/New_York`). TimeZone string `json:"timeZone"` - // The billing address for the user. + // The default address for the user. Address *commonv1.Address `json:"address"` // The connected accounts. AccountConnections []*AccountConnection `json:"accountConnections"` diff --git a/adminv1/user_input.go b/adminv1/user_input.go index 1fc495a..1ccc366 100644 --- a/adminv1/user_input.go +++ b/adminv1/user_input.go @@ -46,7 +46,7 @@ type UserInput struct { RegionCode *string `json:"regionCode"` // The IANA time zone for the user (e.g. `America/New_York`). TimeZone *string `json:"timeZone"` - // The billing address for the user. + // The default address for the user. Address *commonv1.Address `json:"address"` // The sign-up time for the user. SignupTime *time.Time `json:"signupTime"` diff --git a/apiv1/status.go b/apiv1/status.go index 454ad5f..c589b18 100644 --- a/apiv1/status.go +++ b/apiv1/status.go @@ -14,4 +14,6 @@ type Status struct { Param string `json:"param"` // Additional metadata related to the error. Metadata map[string]string `json:"metadata"` + // A user-facing error message. + LocaleMessage string `json:"localeMessage"` } diff --git a/apiv1/status_details.go b/apiv1/status_details.go index d21cb92..996e7c5 100644 --- a/apiv1/status_details.go +++ b/apiv1/status_details.go @@ -11,4 +11,6 @@ type StatusDetails struct { Param string `json:"param"` // Additional metadata related to the error. Metadata map[string]string `json:"metadata"` + // A user-facing error message. + LocaleMessage string `json:"localeMessage"` } diff --git a/internal/constants.go b/internal/constants.go index e007814..b0383e9 100644 --- a/internal/constants.go +++ b/internal/constants.go @@ -8,8 +8,8 @@ import ( const ( ApiBaseUrl = "https://api.userhub.com" - UserAgent = "UserHub-Go/0.6.4" - Version = "0.6.4" + UserAgent = "UserHub-Go/0.7.0" + Version = "0.7.0" AuthHeader = "Authorization" ApiKeyHeader = "UserHub-Api-Key" diff --git a/userapi/flows_test.go b/userapi/flows_test.go index 6780c1a..793de75 100644 --- a/userapi/flows_test.go +++ b/userapi/flows_test.go @@ -20,7 +20,7 @@ func TestFlows_List(t *testing.T) { { "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "expireTime": "2024-02-05T23:07:46.483Z", "createTime": "2024-02-05T23:07:46.483Z" @@ -50,7 +50,7 @@ func TestFlows_CreateJoinOrganization(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", @@ -80,8 +80,6 @@ func TestFlows_CreateJoinOrganization(t *testing.T) { "imageUrl": "https://example.com/test.png", "disabled": true }, - "expireTime": "2024-02-05T23:07:46.483Z", - "createTime": "2024-02-05T23:07:46.483Z", "joinOrganization": { "displayName": "Test", "email": "test@example.com", @@ -99,7 +97,9 @@ func TestFlows_CreateJoinOrganization(t *testing.T) { "email": "test@example.com", "displayName": "Test", "createOrganization": true - } + }, + "expireTime": "2024-02-05T23:07:46.483Z", + "createTime": "2024-02-05T23:07:46.483Z" }` n := &flowsImpl{transport: tr} @@ -122,7 +122,7 @@ func TestFlows_CreateSignup(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", @@ -152,8 +152,6 @@ func TestFlows_CreateSignup(t *testing.T) { "imageUrl": "https://example.com/test.png", "disabled": true }, - "expireTime": "2024-02-05T23:07:46.483Z", - "createTime": "2024-02-05T23:07:46.483Z", "joinOrganization": { "displayName": "Test", "email": "test@example.com", @@ -171,7 +169,9 @@ func TestFlows_CreateSignup(t *testing.T) { "email": "test@example.com", "displayName": "Test", "createOrganization": true - } + }, + "expireTime": "2024-02-05T23:07:46.483Z", + "createTime": "2024-02-05T23:07:46.483Z" }` n := &flowsImpl{transport: tr} @@ -194,7 +194,7 @@ func TestFlows_Get(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", @@ -224,8 +224,6 @@ func TestFlows_Get(t *testing.T) { "imageUrl": "https://example.com/test.png", "disabled": true }, - "expireTime": "2024-02-05T23:07:46.483Z", - "createTime": "2024-02-05T23:07:46.483Z", "joinOrganization": { "displayName": "Test", "email": "test@example.com", @@ -243,7 +241,9 @@ func TestFlows_Get(t *testing.T) { "email": "test@example.com", "displayName": "Test", "createOrganization": true - } + }, + "expireTime": "2024-02-05T23:07:46.483Z", + "createTime": "2024-02-05T23:07:46.483Z" }` n := &flowsImpl{transport: tr} @@ -266,7 +266,7 @@ func TestFlows_Approve(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", @@ -296,8 +296,6 @@ func TestFlows_Approve(t *testing.T) { "imageUrl": "https://example.com/test.png", "disabled": true }, - "expireTime": "2024-02-05T23:07:46.483Z", - "createTime": "2024-02-05T23:07:46.483Z", "joinOrganization": { "displayName": "Test", "email": "test@example.com", @@ -315,7 +313,9 @@ func TestFlows_Approve(t *testing.T) { "email": "test@example.com", "displayName": "Test", "createOrganization": true - } + }, + "expireTime": "2024-02-05T23:07:46.483Z", + "createTime": "2024-02-05T23:07:46.483Z" }` n := &flowsImpl{transport: tr} @@ -338,7 +338,7 @@ func TestFlows_Consume(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", @@ -368,8 +368,6 @@ func TestFlows_Consume(t *testing.T) { "imageUrl": "https://example.com/test.png", "disabled": true }, - "expireTime": "2024-02-05T23:07:46.483Z", - "createTime": "2024-02-05T23:07:46.483Z", "joinOrganization": { "displayName": "Test", "email": "test@example.com", @@ -387,7 +385,9 @@ func TestFlows_Consume(t *testing.T) { "email": "test@example.com", "displayName": "Test", "createOrganization": true - } + }, + "expireTime": "2024-02-05T23:07:46.483Z", + "createTime": "2024-02-05T23:07:46.483Z" }` n := &flowsImpl{transport: tr} @@ -410,7 +410,7 @@ func TestFlows_Cancel(t *testing.T) { tr.Body = `{ "id": "string", "state": "START_PENDING", - "stateReason": "DELETED", + "stateReason": "UPDATING", "type": "JOIN_ORGANIZATION", "organization": { "id": "string", @@ -440,8 +440,6 @@ func TestFlows_Cancel(t *testing.T) { "imageUrl": "https://example.com/test.png", "disabled": true }, - "expireTime": "2024-02-05T23:07:46.483Z", - "createTime": "2024-02-05T23:07:46.483Z", "joinOrganization": { "displayName": "Test", "email": "test@example.com", @@ -459,7 +457,9 @@ func TestFlows_Cancel(t *testing.T) { "email": "test@example.com", "displayName": "Test", "createOrganization": true - } + }, + "expireTime": "2024-02-05T23:07:46.483Z", + "createTime": "2024-02-05T23:07:46.483Z" }` n := &flowsImpl{transport: tr} diff --git a/userapi/invoices_test.go b/userapi/invoices_test.go index 402b761..5f5204d 100644 --- a/userapi/invoices_test.go +++ b/userapi/invoices_test.go @@ -25,14 +25,14 @@ func TestInvoices_List(t *testing.T) { "currencyCode": "USD", "description": "string", "effectiveTime": "2024-02-05T23:07:46.483Z", - "subtotalAmount": "string", - "discountAmount": "string", - "taxAmount": "string", - "totalAmount": "string", - "dueAmount": "string", - "remainingDueAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", + "taxAmount": "0", + "totalAmount": "10", + "dueAmount": "10", + "remainingDueAmount": "0", "dueTime": "2024-02-05T23:07:46.483Z", - "paidAmount": "string", + "paidAmount": "10", "paymentState": "PAYMENT_METHOD_REQUIRED", "createTime": "2024-02-05T23:07:46.483Z", "updateTime": "2024-02-05T23:07:46.483Z" @@ -67,7 +67,7 @@ func TestInvoices_Get(t *testing.T) { "currencyCode": "USD", "description": "string", "account": { - "fullName": "Test", + "fullName": "Jane Doe", "email": "test@example.com", "phoneNumber": "+12125550123", "address": { @@ -83,19 +83,19 @@ func TestInvoices_Get(t *testing.T) { "startTime": "2024-02-05T23:07:46.483Z", "endTime": "2024-02-05T23:07:46.483Z" }, - "subtotalAmount": "string", - "discountAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", "balance": { - "startAmount": "string", - "endAmount": "string", - "appliedAmount": "string" + "startAmount": "10", + "endAmount": "10", + "appliedAmount": "10" }, - "taxAmount": "string", - "totalAmount": "string", - "dueAmount": "string", - "remainingDueAmount": "string", + "taxAmount": "0", + "totalAmount": "10", + "dueAmount": "10", + "remainingDueAmount": "0", "dueTime": "2024-02-05T23:07:46.483Z", - "paidAmount": "string", + "paidAmount": "10", "paymentState": "PAYMENT_METHOD_REQUIRED", "paymentIntent": { "stripe": { @@ -108,8 +108,8 @@ func TestInvoices_Get(t *testing.T) { { "id": "string", "quantity": 1, - "subtotalAmount": "string", - "discountAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", "description": "string", "proration": true } @@ -118,8 +118,8 @@ func TestInvoices_Get(t *testing.T) { { "time": "2024-02-05T23:07:46.483Z", "description": "string", - "subtotalAmount": "string", - "discountAmount": "string", + "subtotalAmount": "10", + "discountAmount": "0", "startQuantity": 1, "endQuantity": 1, "startItemIds": [], diff --git a/userapi/session.go b/userapi/session.go index 32caedd..3f38ade 100644 --- a/userapi/session.go +++ b/userapi/session.go @@ -10,8 +10,12 @@ import ( ) type Session interface { - // Get current session details. + // Get the current session details. Get(ctx context.Context, input *SessionGetInput) (*userv1.Session, error) + // Exchange an ID token from your IdP for an access token. + ExchangeToken(ctx context.Context, input *SessionExchangeTokenInput) (*userv1.ExchangeSessionTokenResponse, error) + // Create Portal session. + CreatePortal(ctx context.Context, input *SessionCreatePortalInput) (*userv1.CreatePortalSessionResponse, error) } type sessionImpl struct { @@ -44,3 +48,122 @@ func (n *sessionImpl) Get(ctx context.Context, input *SessionGetInput) (*userv1. return model, nil } + +// SessionExchangeTokenInput is the input param for the ExchangeToken method. +type SessionExchangeTokenInput struct { + // The IdP ID token which is used to authenticated the user. + Token string +} + +func (n *sessionImpl) ExchangeToken(ctx context.Context, input *SessionExchangeTokenInput) (*userv1.ExchangeSessionTokenResponse, error) { + req := internal.NewRequest( + "user.session.exchangeToken", + "POST", + "/user/v1/session:exchangeToken", + ) + + body := map[string]any{} + + if input != nil { + if !internal.IsEmpty(input.Token) { + body["token"] = input.Token + } + } + + req.SetBody(body) + + res, err := n.transport.Execute(ctx, req) + if err != nil { + return nil, err + } + + model := &userv1.ExchangeSessionTokenResponse{} + + err = res.DecodeBody(&model) + if err != nil { + return nil, err + } + + return model, nil +} + +// SessionCreatePortalInput is the input param for the CreatePortal method. +type SessionCreatePortalInput struct { + // The identifier of the organization. + // + // When specified the `{accountId}` in the `portalUrl` will be + // replaced with the organization ID, otherwise the user ID + // will be used. + OrganizationId string + // The Portal URL, this is the target URL on the portal site. + // + // If not defined the root URL for the portal will be used. + // + // This does not need to be the full URL, you have the option + // of passing in a path instead (e.g. `/`). + // + // You also have the option of including the `{accountId}` + // string in the path/URL which will be replaced with either the + // UserHub user ID (if `organizationId` is not specified) + // or the UserHub organization ID (if specified). + // + // Examples: + // * `/{accountId}` - the billing dashboard + // * `/{accountId}/checkout` - start a checkout + // * `/{accountId}/checkout/` - start a checkout with a specified plan + // * `/{accountId}/cancel` - cancel current plan + // * `/{accountId}/members` - manage organization members + // * `/{accountId}/invite` - invite a user to an organization + PortalUrl string + // The URL the user should be sent to when they want to return to + // the app (e.g. cancel checkout). + // + // If not defined the app URL will be used. + ReturnUrl string + // The URL the user should be sent after they successfully complete + // an action (e.g. checkout). + // + // If not defined the return URL will be used. + SuccessUrl string +} + +func (n *sessionImpl) CreatePortal(ctx context.Context, input *SessionCreatePortalInput) (*userv1.CreatePortalSessionResponse, error) { + req := internal.NewRequest( + "user.session.createPortal", + "POST", + "/user/v1/session:createPortal", + ) + + body := map[string]any{} + + if input != nil { + if !internal.IsEmpty(input.OrganizationId) { + body["organizationId"] = input.OrganizationId + } + if !internal.IsEmpty(input.PortalUrl) { + body["portalUrl"] = input.PortalUrl + } + if !internal.IsEmpty(input.ReturnUrl) { + body["returnUrl"] = input.ReturnUrl + } + if !internal.IsEmpty(input.SuccessUrl) { + body["successUrl"] = input.SuccessUrl + } + } + + req.SetBody(body) + + res, err := n.transport.Execute(ctx, req) + if err != nil { + return nil, err + } + + model := &userv1.CreatePortalSessionResponse{} + + err = res.DecodeBody(&model) + if err != nil { + return nil, err + } + + return model, nil +} diff --git a/userapi/session_test.go b/userapi/session_test.go index cae6d7c..af1e671 100644 --- a/userapi/session_test.go +++ b/userapi/session_test.go @@ -56,3 +56,46 @@ func TestSession_Get(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) } + +func TestSession_ExchangeToken(t *testing.T) { + t.Parallel() + + tr := &internal.TestTransport{} + tr.Body = `{ + "accessToken": "string", + "expireTime": "2024-02-05T23:07:46.483Z" +}` + + n := &sessionImpl{transport: tr} + + res, err := n.ExchangeToken(context.Background(), nil) + require.NoError(t, err) + require.NotNil(t, res) + require.Equal(t, `POST`, tr.Request.Method()) + require.Equal(t, `/user/v1/session:exchangeToken`, tr.Request.Path()) + + res, err = n.ExchangeToken(context.Background(), &SessionExchangeTokenInput{}) + require.NoError(t, err) + require.NotNil(t, res) +} + +func TestSession_CreatePortal(t *testing.T) { + t.Parallel() + + tr := &internal.TestTransport{} + tr.Body = `{ + "redirectUrl": "https://example.com" +}` + + n := &sessionImpl{transport: tr} + + res, err := n.CreatePortal(context.Background(), nil) + require.NoError(t, err) + require.NotNil(t, res) + require.Equal(t, `POST`, tr.Request.Method()) + require.Equal(t, `/user/v1/session:createPortal`, tr.Request.Path()) + + res, err = n.CreatePortal(context.Background(), &SessionCreatePortalInput{}) + require.NoError(t, err) + require.NotNil(t, res) +} diff --git a/userv1/billing_account.go b/userv1/billing_account.go index 991ab11..5545094 100644 --- a/userv1/billing_account.go +++ b/userv1/billing_account.go @@ -2,10 +2,24 @@ package userv1 +import ( + "github.com/userhubdev/go-sdk/commonv1" +) + // The billing account for an organization or user. type BillingAccount struct { // The status of the billing account. State string `json:"state"` + // The human-readable display name of the billing account. + DisplayName string `json:"displayName"` + // The email address of the billing account. + Email string `json:"email"` + // The E164 phone number for the billing account (e.g. `+12125550123`). + PhoneNumber string `json:"phoneNumber"` + // The billing address for the billing account. + Address *commonv1.Address `json:"address"` + // The ISO-4217 currency code for the billing account (e.g. `USD`). + CurrencyCode string `json:"currencyCode"` // The balance amount for the account. // // A negative value indicates an amount which will be subtracted from the next @@ -14,8 +28,8 @@ type BillingAccount struct { // A positive value indicates an amount which will be added to the next // invoice (debt). BalanceAmount string `json:"balanceAmount"` - // The ISO-4217 currency code for the account (e.g. `USD`). - CurrencyCode string `json:"currencyCode"` + // The available checkouts. + Checkouts []*BillingAccountCheckout `json:"checkouts"` // The default and latest 10 payment methods for the account. PaymentMethods []*PaymentMethod `json:"paymentMethods"` // The subscription for the account. diff --git a/userv1/billing_account_checkout.go b/userv1/billing_account_checkout.go new file mode 100644 index 0000000..329f60e --- /dev/null +++ b/userv1/billing_account_checkout.go @@ -0,0 +1,9 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// The discount. +type BillingAccountCheckout struct { + // The type of checkout. + Type string `json:"type"` +} diff --git a/userv1/billing_account_input.go b/userv1/billing_account_input.go new file mode 100644 index 0000000..0422083 --- /dev/null +++ b/userv1/billing_account_input.go @@ -0,0 +1,27 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +import ( + "github.com/userhubdev/go-sdk/commonv1" +) + +// BillingAccountInput input parameters. +type BillingAccountInput struct { + // The human-readable display name of the billing account. + // + // The maximum length is 200 characters. + // + // This might be further restricted by the billing provider. + DisplayName *string `json:"displayName"` + // The email address of the billing account. + // + // The maximum length is 320 characters. + // + // This might be further restricted by the billing provider. + Email *string `json:"email"` + // The E164 phone number of the billing account (e.g. `+12125550123`). + PhoneNumber *string `json:"phoneNumber"` + // The address for the billing account. + Address *commonv1.Address `json:"address"` +} diff --git a/userv1/checkout.go b/userv1/checkout.go new file mode 100644 index 0000000..47390d0 --- /dev/null +++ b/userv1/checkout.go @@ -0,0 +1,67 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +import ( + "github.com/userhubdev/go-sdk/apiv1" + "github.com/userhubdev/go-sdk/commonv1" +) + +// The checkout. +type Checkout struct { + // The system-assigned identifier of the checkout. + // + // This might not match the requested checkout identifier and you + // should update all references to it if it changes. + // + // Finalized identifiers will start with `co_`, all other identifiers + // are temporary. + Id string `json:"id"` + // The type of checkout. + Type string `json:"type"` + // The state of the checkout. + State string `json:"state"` + // The checkout error. + Error *apiv1.Status `json:"error"` + // The currently selected currency code. + CurrencyCode string `json:"currencyCode"` + // The plans available for checkout. + Plans []*CheckoutPlan `json:"plans"` + // The checkout payment method. + PaymentMethod *PaymentMethod `json:"paymentMethod"` + // The billing details company or individual name. + FullName string `json:"fullName"` + // The billing details address. + Address *commonv1.Address `json:"address"` + // The steps required to complete the checkout. + Steps []*CheckoutStep `json:"steps"` + // The checkout items. + Items []*CheckoutItem `json:"items"` + // The discounts applied to the checkout. + Discounts []*CheckoutDiscount `json:"discounts"` + // The subtotal amount for the checkout. + // + // This includes item-level discounts. + SubtotalAmount string `json:"subtotalAmount"` + // The top-level discount amount. + // + // This does not include item level discounts. + DiscountAmount string `json:"discountAmount"` + // The tax amount for the checkout. + // + // This is for rendering purposes only and is + // not the reported tax amount. + TaxAmount string `json:"taxAmount"` + // The total amount for the checkout. + TotalAmount string `json:"totalAmount"` + // The amount applied to the checkout from the balance. + // + // A negative amount means a debit from the account balance. + // A positive amount means a credit to the account balance. + BalanceAppliedAmount string `json:"balanceAppliedAmount"` + // The total amount minus any credits automatically + // associated with the invoice. + DueAmount string `json:"dueAmount"` + // The total normal recurring amount. + RenewAmount string `json:"renewAmount"` +} diff --git a/userv1/checkout_complete_payment_step.go b/userv1/checkout_complete_payment_step.go new file mode 100644 index 0000000..ba6273c --- /dev/null +++ b/userv1/checkout_complete_payment_step.go @@ -0,0 +1,9 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// The complete payment step details. +type CheckoutCompletePaymentStep struct { + // The payment intent for the checkout. + PaymentIntent *PaymentIntent `json:"paymentIntent"` +} diff --git a/userv1/checkout_discount.go b/userv1/checkout_discount.go new file mode 100644 index 0000000..f4e0f91 --- /dev/null +++ b/userv1/checkout_discount.go @@ -0,0 +1,11 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// The discount. +type CheckoutDiscount struct { + // The checkout discount identifier. + Id string `json:"id"` + // The discount code. + Code string `json:"code"` +} diff --git a/userv1/checkout_input.go b/userv1/checkout_input.go new file mode 100644 index 0000000..7ab223a --- /dev/null +++ b/userv1/checkout_input.go @@ -0,0 +1,17 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// Checkout input parameters. +type CheckoutInput struct { + // The identifier of the organization. + // + // This must be provided for organization checkouts. + OrganizationId string `json:"organizationId"` + // The type of the checkout. + Type string `json:"type"` + // The identifier of the plan group. + // + // This allows you to specify the currently selected plan. + PlanId string `json:"planId"` +} diff --git a/userv1/checkout_item.go b/userv1/checkout_item.go new file mode 100644 index 0000000..669f7b3 --- /dev/null +++ b/userv1/checkout_item.go @@ -0,0 +1,45 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +import ( + "github.com/userhubdev/go-sdk/commonv1" +) + +// The checkout item. +type CheckoutItem struct { + // The item identifier. + Id string `json:"id"` + // The type of the item. + Type string `json:"type"` + // The display name for the item. + DisplayName string `json:"displayName"` + // The quantity for the item. + Price *Price `json:"price"` + // The quantity for the item. + Quantity int32 `json:"quantity"` + // The quantity the plan is set to renew at. + RenewQuantity int32 `json:"renewQuantity"` + // The minimum quantity allowed. + MinQuantity int32 `json:"minQuantity"` + // The maximum quantity allowed. + MaxQuantity int32 `json:"maxQuantity"` + // The billing period for the item. + Period *commonv1.Period `json:"period"` + // The subtotal amount at checkout. + SubtotalAmount string `json:"subtotalAmount"` + // The item-level discount amount at checkout. + DiscountAmount string `json:"discountAmount"` + // The item-level normal recurring amount. + RenewAmount string `json:"renewAmount"` + // Whether this is a preview-only item. + // + // Preview-only items are generally prorations or other pending + // charges or credits. + Preview bool `json:"preview"` + // The parent item. + // + // This allows you to group related items and is generally set for preview + // items. + ParentItemId string `json:"parentItemId"` +} diff --git a/userv1/checkout_plan.go b/userv1/checkout_plan.go new file mode 100644 index 0000000..96288a7 --- /dev/null +++ b/userv1/checkout_plan.go @@ -0,0 +1,53 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +import ( + "github.com/userhubdev/go-sdk/commonv1" +) + +// The plan. +type CheckoutPlan struct { + // The system-assigned identifier of the plan. + Id string `json:"id"` + // The name of the plan. + DisplayName string `json:"displayName"` + // The description of the plan. + Description string `json:"description"` + // The billing interval for the plan. + BillingInterval *commonv1.Interval `json:"billingInterval"` + // The plan group for the plan. + Group *CheckoutPlanGroup `json:"group"` + // The revision for the plan. + Revision *CheckoutPlanRevision `json:"revision"` + // Whether this is the current plan for the subscription. + Current bool `json:"current"` + // Whether this is the selected plan for the checkout. + Selected bool `json:"selected"` + // Whether this is the default plan for the plan group. + Default bool `json:"default"` + // The trial settings. + // + // For authenticated requests, this will not be set when the account + // isn't eligible for a trial. + Trial *CheckoutPlanTrial `json:"trial"` + // Whether the change is considered an upgrade or + // a downgrade. + ChangePath string `json:"changePath"` + // The flat price for the plan. + // + // This might not exists for plans that are billed by seat. + Price *Price `json:"price"` + // The primary seat price for the plan. + SeatPrice *Price `json:"seatPrice"` + // The savings for the plan. + // + // The savings are in comparison to the plan in the revision with the + // shortest billing interval. + Savings *CheckoutPlanSavings `json:"savings"` + // Whether this plan is disabled for checkout. + // + // This will only be set when the current/selected plan is disabled, all + // other plans will be available for checkout. + Disabled bool `json:"disabled"` +} diff --git a/userv1/checkout_plan_group.go b/userv1/checkout_plan_group.go new file mode 100644 index 0000000..697bbfc --- /dev/null +++ b/userv1/checkout_plan_group.go @@ -0,0 +1,19 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// Plan group is a collection of related plans. +// +// A plan group will generally describe a tier of plans offered +// (e.g. Basic vs Pro) which might contain multiple billing options +// (e.g. monthly vs yearly, USD vs EUR). +type CheckoutPlanGroup struct { + // The system-assigned identifier of the plan group. + Id string `json:"id"` + // The client defined unique identifier of the plan group (e.g. `pro`). + UniqueId string `json:"uniqueId"` + // Whether this is the current plan group for the subscription. + Current bool `json:"current"` + // Whether this is the selected plan group for the checkout. + Selected bool `json:"selected"` +} diff --git a/userv1/checkout_plan_revision.go b/userv1/checkout_plan_revision.go new file mode 100644 index 0000000..af325f9 --- /dev/null +++ b/userv1/checkout_plan_revision.go @@ -0,0 +1,19 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// Revision is a collection of plans with the same revision. +// +// This will group plans with different billing cycles. +type CheckoutPlanRevision struct { + // The system-assigned identifier of the plan group revision. + Id string `json:"id"` + // Whether this is the current revision for the subscription. + Current bool `json:"current"` + // Whether this is the selected revision for the checkout. + Selected bool `json:"selected"` + // Whether this is the latest revision for the plan group. + // + // This will only be set for a current or selected plan group. + Latest bool `json:"latest"` +} diff --git a/userv1/checkout_plan_savings.go b/userv1/checkout_plan_savings.go new file mode 100644 index 0000000..112c475 --- /dev/null +++ b/userv1/checkout_plan_savings.go @@ -0,0 +1,11 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// The savings for the plan. +type CheckoutPlanSavings struct { + // The percentage savings (1-100). + // + // This percentage is rounded down. + Percentage int32 `json:"percentage"` +} diff --git a/userv1/checkout_plan_trial.go b/userv1/checkout_plan_trial.go new file mode 100644 index 0000000..62e335a --- /dev/null +++ b/userv1/checkout_plan_trial.go @@ -0,0 +1,9 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// The trial details. +type CheckoutPlanTrial struct { + // The number of days in the trial. + Days int32 `json:"days"` +} diff --git a/userv1/checkout_step.go b/userv1/checkout_step.go new file mode 100644 index 0000000..de819ae --- /dev/null +++ b/userv1/checkout_step.go @@ -0,0 +1,13 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// The checkout step. +type CheckoutStep struct { + // The type of step. + Type string `json:"type"` + // The state of the step. + State string `json:"state"` + // The complete payment step details. + CompletePayment *CheckoutCompletePaymentStep `json:"completePayment"` +} diff --git a/userv1/create_portal_session_response.go b/userv1/create_portal_session_response.go new file mode 100644 index 0000000..eff0d7f --- /dev/null +++ b/userv1/create_portal_session_response.go @@ -0,0 +1,10 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// Response message for CreatePortalSession. +type CreatePortalSessionResponse struct { + // The URL you should redirect the user to after calling create portal + // session. + RedirectUrl string `json:"redirectUrl"` +} diff --git a/userv1/exchange_session_token_response.go b/userv1/exchange_session_token_response.go new file mode 100644 index 0000000..5742f82 --- /dev/null +++ b/userv1/exchange_session_token_response.go @@ -0,0 +1,19 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +import ( + "time" +) + +// Response message for ExchangeToken. +type ExchangeSessionTokenResponse struct { + // An authorization token which can be used to make authenticated + // requests. + // + // This should be included in the `Authorization` header with a + // `Bearer` prefix. + AccessToken string `json:"accessToken"` + // The expiration time for the session. + ExpireTime time.Time `json:"expireTime"` +} diff --git a/userv1/flow.go b/userv1/flow.go index 4061fa6..890e1e7 100644 --- a/userv1/flow.go +++ b/userv1/flow.go @@ -22,12 +22,12 @@ type Flow struct { User *User `json:"user"` // The user who created the flow. Creator *User `json:"creator"` - // The time the flow will expire. - ExpireTime time.Time `json:"expireTime"` - // The creation time of the flow. - CreateTime time.Time `json:"createTime"` // The join organization flow type specific data. JoinOrganization *JoinOrganizationFlow `json:"joinOrganization"` // The signup flow type specific data. Signup *SignupFlow `json:"signup"` + // The time the flow will expire. + ExpireTime time.Time `json:"expireTime"` + // The creation time of the flow. + CreateTime time.Time `json:"createTime"` } diff --git a/userv1/price_tiered_price.go b/userv1/price_tiered_price.go index 06dfa4c..a866046 100644 --- a/userv1/price_tiered_price.go +++ b/userv1/price_tiered_price.go @@ -8,5 +8,5 @@ type PriceTieredPrice struct { // The strategy for evaluating the tiers. Mode string `json:"mode"` // The tiers for the price. - Tiers []*TieredPriceTier `json:"tiers"` + Tiers []*PriceTieredPriceTier `json:"tiers"` } diff --git a/userv1/price_tiered_price_tier.go b/userv1/price_tiered_price_tier.go new file mode 100644 index 0000000..a64a8e1 --- /dev/null +++ b/userv1/price_tiered_price_tier.go @@ -0,0 +1,13 @@ +// Code generated. DO NOT EDIT. + +package userv1 + +// A quantity range within the tiered price. +type PriceTieredPriceTier struct { + // The upper quantity for tier (inclusive). + Upper int32 `json:"upper"` + // The per quantity amount for the tier. + UnitAmount string `json:"unitAmount"` + // The flat amount for the tier. + FlatAmount string `json:"flatAmount"` +} diff --git a/userv1/stripe_payment_method_intent.go b/userv1/stripe_payment_method_intent.go index ef8ac91..01ec831 100644 --- a/userv1/stripe_payment_method_intent.go +++ b/userv1/stripe_payment_method_intent.go @@ -10,4 +10,6 @@ type StripePaymentMethodIntent struct { Live bool `json:"live"` // The Stripe Setup Intent client secret. ClientSecret string `json:"clientSecret"` + // The Stripe.js Payment Element options. + PaymentElementOptions map[string]any `json:"paymentElementOptions"` }