From 0e420e87ba9a69f76a7d15fe6196d36a0d739d91 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:30:04 +0000 Subject: [PATCH] SDK regeneration --- apple_pay.go | 2 +- applepay/client.go | 14 +- bank_accounts.go | 2 +- bankaccounts/client.go | 28 +- bookings.go | 2 +- bookings/client/client.go | 76 +++--- bookings/custom_attribute_definitions.go | 6 +- bookings/custom_attributes.go | 8 +- bookings/customattributedefinitions/client.go | 32 +-- bookings/customattributes/client.go | 36 +-- bookings/locationprofiles/client.go | 16 +- bookings/teammemberprofiles/client.go | 20 +- cards.go | 2 +- cards/client.go | 34 +-- cashdrawers/client/client.go | 8 +- cashdrawers/shifts.go | 4 +- cashdrawers/shifts/client.go | 26 +- catalog.go | 10 +- catalog/client/client.go | 66 ++--- catalog/images.go | 12 +- catalog/images/client.go | 18 +- catalog/object.go | 4 +- catalog/object/client.go | 22 +- checkout.go | 2 +- checkout/client/client.go | 32 +-- checkout/payment_links.go | 12 +- checkout/paymentlinks/client.go | 32 +-- client/client.go | 78 +++--- client/client_test.go | 2 +- core/request_option.go | 8 +- customers.go | 37 +-- customers/cards.go | 4 +- customers/cards/client.go | 18 +- customers/client/client.go | 88 +++---- customers/custom_attribute_definitions.go | 8 +- customers/custom_attributes.go | 4 +- .../customattributedefinitions/client.go | 36 +-- customers/customattributes/client.go | 28 +- customers/groups.go | 6 +- customers/groups/client.go | 40 +-- customers/segments/client.go | 20 +- devices.go | 2 +- devices/client/client.go | 24 +- devices/codes.go | 8 +- devices/codes/client.go | 24 +- disputes.go | 2 +- disputes/client/client.go | 48 ++-- disputes/evidence/client.go | 24 +- employees.go | 2 +- employees/client.go | 22 +- events.go | 2 +- events/client.go | 28 +- gift_cards.go | 2 +- giftcards/activities.go | 4 +- giftcards/activities/client.go | 20 +- giftcards/client/client.go | 54 ++-- go.mod | 2 +- internal/caller.go | 2 +- internal/caller_test.go | 2 +- internal/error_decoder.go | 2 +- internal/error_decoder_test.go | 2 +- internal/pager.go | 2 +- internal/retrier_test.go | 2 +- inventory.go | 2 +- inventory/client.go | 90 +++---- invoices.go | 2 +- invoices/client.go | 72 +++--- labor.go | 155 ----------- labor/break_types.go | 22 +- labor/breaktypes/client.go | 132 +++++++++- labor/client/client.go | 128 +-------- labor/employeewages/client.go | 20 +- labor/shifts.go | 8 +- labor/shifts/client.go | 30 +-- labor/teammemberwages/client.go | 20 +- labor/workweek_configs.go | 4 +- labor/workweekconfigs/client.go | 20 +- locations.go | 2 +- locations/client/client.go | 42 +-- locations/custom_attribute_definitions.go | 34 ++- locations/custom_attributes.go | 33 +-- .../customattributedefinitions/client.go | 112 +++++++- locations/customattributes/client.go | 163 +++++------- locations/transactions.go | 4 +- locations/transactions/client.go | 26 +- loyalty.go | 2 +- loyalty/accounts.go | 10 +- loyalty/accounts/client.go | 30 +-- loyalty/client/client.go | 20 +- loyalty/programs.go | 4 +- loyalty/programs/client/client.go | 24 +- loyalty/programs/promotions.go | 6 +- loyalty/programs/promotions/client.go | 28 +- loyalty/rewards.go | 6 +- loyalty/rewards/client.go | 30 +-- merchants.go | 2 +- merchants/client/client.go | 30 +-- merchants/custom_attribute_definitions.go | 29 ++- merchants/custom_attributes.go | 22 +- .../customattributedefinitions/client.go | 128 ++++++++- merchants/customattributes/client.go | 201 ++++++--------- mobile.go | 2 +- mobile/client.go | 14 +- o_auth.go | 2 +- oauth/client.go | 24 +- option/request_option.go | 2 +- orders.go | 2 +- orders/client/client.go | 60 ++--- orders/custom_attribute_definitions.go | 8 +- orders/custom_attributes.go | 10 +- orders/customattributedefinitions/client.go | 32 +-- orders/customattributes/client.go | 36 +-- payments.go | 57 +++- payments/client.go | 109 +++++--- payouts.go | 2 +- payouts/client.go | 30 +-- refunds.go | 2 +- refunds/client.go | 28 +- sites.go | 2 +- sites/client.go | 12 +- snippets.go | 2 +- snippets/client.go | 26 +- subscriptions.go | 2 +- subscriptions/client.go | 82 +++--- team.go | 2 +- team/client.go | 32 +-- team_members.go | 2 +- teammembers/client/client.go | 46 ++-- teammembers/wage_setting.go | 4 +- teammembers/wagesetting/client.go | 18 +- terminal.go | 2 +- terminal/actions.go | 6 +- terminal/actions/client.go | 26 +- terminal/checkouts.go | 6 +- terminal/checkouts/client.go | 26 +- terminal/client/client.go | 32 +-- terminal/refunds.go | 6 +- terminal/refunds/client.go | 26 +- types.go | 243 +++++++++++------- v1transactions.go | 2 +- v1transactions/client.go | 26 +- vendors.go | 2 +- vendors/client.go | 50 ++-- webhooks/client/client.go | 10 +- webhooks/eventtypes/client.go | 14 +- webhooks/subscriptions.go | 8 +- webhooks/subscriptions/client.go | 40 +-- 147 files changed, 2087 insertions(+), 1964 deletions(-) delete mode 100644 labor.go diff --git a/apple_pay.go b/apple_pay.go index d11c29c..c463578 100644 --- a/apple_pay.go +++ b/apple_pay.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type RegisterDomainRequest struct { diff --git a/applepay/client.go b/applepay/client.go index b2022f8..445604e 100644 --- a/applepay/client.go +++ b/applepay/client.go @@ -4,10 +4,10 @@ package applepay import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -54,9 +54,9 @@ func NewClient(opts ...option.RequestOption) *Client { // To learn more about the Web Payments SDK and how to add Apple Pay, see [Take an Apple Pay Payment](https://developer.squareup.com/docs/web-payments/apple-pay). func (c *Client) RegisterDomain( ctx context.Context, - request *squaregosdk.RegisterDomainRequest, + request *v2.RegisterDomainRequest, opts ...option.RequestOption, -) (*squaregosdk.RegisterDomainResponse, error) { +) (*v2.RegisterDomainResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -70,7 +70,7 @@ func (c *Client) RegisterDomain( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.RegisterDomainResponse + var response *v2.RegisterDomainResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/bank_accounts.go b/bank_accounts.go index f1c1a0b..610c07c 100644 --- a/bank_accounts.go +++ b/bank_accounts.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type BankAccountsGetByV1IDRequest struct { diff --git a/bankaccounts/client.go b/bankaccounts/client.go index edd212e..31fe4cd 100644 --- a/bankaccounts/client.go +++ b/bankaccounts/client.go @@ -5,10 +5,10 @@ package bankaccounts import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -42,9 +42,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Returns a list of [BankAccount](entity:BankAccount) objects linked to a Square account. func (c *Client) List( ctx context.Context, - request *squaregosdk.BankAccountsListRequest, + request *v2.BankAccountsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.BankAccount], error) { +) (*core.Page[*v2.BankAccount], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -80,10 +80,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListBankAccountsResponse) *internal.PageResponse[*string, *squaregosdk.BankAccount] { + readPageResponse := func(response *v2.ListBankAccountsResponse) *internal.PageResponse[*string, *v2.BankAccount] { next := response.Cursor results := response.BankAccounts - return &internal.PageResponse[*string, *squaregosdk.BankAccount]{ + return &internal.PageResponse[*string, *v2.BankAccount]{ Next: next, Results: results, } @@ -99,9 +99,9 @@ func (c *Client) List( // Returns details of a [BankAccount](entity:BankAccount) identified by V1 bank account ID. func (c *Client) GetByV1ID( ctx context.Context, - request *squaregosdk.BankAccountsGetByV1IDRequest, + request *v2.BankAccountsGetByV1IDRequest, opts ...option.RequestOption, -) (*squaregosdk.GetBankAccountByV1IDResponse, error) { +) (*v2.GetBankAccountByV1IDResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -117,7 +117,7 @@ func (c *Client) GetByV1ID( options.ToHeader(), ) - var response *squaregosdk.GetBankAccountByV1IDResponse + var response *v2.GetBankAccountByV1IDResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -140,9 +140,9 @@ func (c *Client) GetByV1ID( // linked to a Square account. func (c *Client) Get( ctx context.Context, - request *squaregosdk.BankAccountsGetRequest, + request *v2.BankAccountsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetBankAccountResponse, error) { +) (*v2.GetBankAccountResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -158,7 +158,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetBankAccountResponse + var response *v2.GetBankAccountResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/bookings.go b/bookings.go index b878639..2c64deb 100644 --- a/bookings.go +++ b/bookings.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type BulkRetrieveBookingsRequest struct { diff --git a/bookings/client/client.go b/bookings/client/client.go index 2e3a4cb..3dd6b3f 100644 --- a/bookings/client/client.go +++ b/bookings/client/client.go @@ -5,14 +5,14 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - customattributedefinitions "github.com/square/square-go-sdk/bookings/customattributedefinitions" - customattributes "github.com/square/square-go-sdk/bookings/customattributes" - locationprofiles "github.com/square/square-go-sdk/bookings/locationprofiles" - teammemberprofiles "github.com/square/square-go-sdk/bookings/teammemberprofiles" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + customattributedefinitions "github.com/square/square-go-sdk/v2/bookings/customattributedefinitions" + customattributes "github.com/square/square-go-sdk/v2/bookings/customattributes" + locationprofiles "github.com/square/square-go-sdk/v2/bookings/locationprofiles" + teammemberprofiles "github.com/square/square-go-sdk/v2/bookings/teammemberprofiles" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -58,9 +58,9 @@ func NewClient(opts ...option.RequestOption) *Client { // To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. func (c *Client) List( ctx context.Context, - request *squaregosdk.BookingsListRequest, + request *v2.BookingsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Booking], error) { +) (*core.Page[*v2.Booking], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -96,10 +96,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListBookingsResponse) *internal.PageResponse[*string, *squaregosdk.Booking] { + readPageResponse := func(response *v2.ListBookingsResponse) *internal.PageResponse[*string, *v2.Booking] { next := response.Cursor results := response.Bookings - return &internal.PageResponse[*string, *squaregosdk.Booking]{ + return &internal.PageResponse[*string, *v2.Booking]{ Next: next, Results: results, } @@ -128,9 +128,9 @@ func (c *Client) List( // or *Appointments Premium*. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateBookingRequest, + request *v2.CreateBookingRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateBookingResponse, error) { +) (*v2.CreateBookingResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -144,7 +144,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateBookingResponse + var response *v2.CreateBookingResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -170,9 +170,9 @@ func (c *Client) Create( // To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. func (c *Client) SearchAvailability( ctx context.Context, - request *squaregosdk.SearchAvailabilityRequest, + request *v2.SearchAvailabilityRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchAvailabilityResponse, error) { +) (*v2.SearchAvailabilityResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -186,7 +186,7 @@ func (c *Client) SearchAvailability( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchAvailabilityResponse + var response *v2.SearchAvailabilityResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -212,9 +212,9 @@ func (c *Client) SearchAvailability( // To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. func (c *Client) BulkRetrieveBookings( ctx context.Context, - request *squaregosdk.BulkRetrieveBookingsRequest, + request *v2.BulkRetrieveBookingsRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkRetrieveBookingsResponse, error) { +) (*v2.BulkRetrieveBookingsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -228,7 +228,7 @@ func (c *Client) BulkRetrieveBookings( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkRetrieveBookingsResponse + var response *v2.BulkRetrieveBookingsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -252,7 +252,7 @@ func (c *Client) BulkRetrieveBookings( func (c *Client) GetBusinessProfile( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.GetBusinessBookingProfileResponse, error) { +) (*v2.GetBusinessBookingProfileResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -265,7 +265,7 @@ func (c *Client) GetBusinessProfile( options.ToHeader(), ) - var response *squaregosdk.GetBusinessBookingProfileResponse + var response *v2.GetBusinessBookingProfileResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -287,9 +287,9 @@ func (c *Client) GetBusinessProfile( // Retrieves a seller's location booking profile. func (c *Client) RetrieveLocationBookingProfile( ctx context.Context, - request *squaregosdk.RetrieveLocationBookingProfileRequest, + request *v2.RetrieveLocationBookingProfileRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveLocationBookingProfileResponse, error) { +) (*v2.RetrieveLocationBookingProfileResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -305,7 +305,7 @@ func (c *Client) RetrieveLocationBookingProfile( options.ToHeader(), ) - var response *squaregosdk.RetrieveLocationBookingProfileResponse + var response *v2.RetrieveLocationBookingProfileResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -327,9 +327,9 @@ func (c *Client) RetrieveLocationBookingProfile( // Retrieves one or more team members' booking profiles. func (c *Client) BulkRetrieveTeamMemberBookingProfiles( ctx context.Context, - request *squaregosdk.BulkRetrieveTeamMemberBookingProfilesRequest, + request *v2.BulkRetrieveTeamMemberBookingProfilesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkRetrieveTeamMemberBookingProfilesResponse, error) { +) (*v2.BulkRetrieveTeamMemberBookingProfilesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -343,7 +343,7 @@ func (c *Client) BulkRetrieveTeamMemberBookingProfiles( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkRetrieveTeamMemberBookingProfilesResponse + var response *v2.BulkRetrieveTeamMemberBookingProfilesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -369,9 +369,9 @@ func (c *Client) BulkRetrieveTeamMemberBookingProfiles( // To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. func (c *Client) Get( ctx context.Context, - request *squaregosdk.BookingsGetRequest, + request *v2.BookingsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetBookingResponse, error) { +) (*v2.GetBookingResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -387,7 +387,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetBookingResponse + var response *v2.GetBookingResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -415,9 +415,9 @@ func (c *Client) Get( // or *Appointments Premium*. func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdateBookingRequest, + request *v2.UpdateBookingRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateBookingResponse, error) { +) (*v2.UpdateBookingResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -434,7 +434,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateBookingResponse + var response *v2.UpdateBookingResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -463,9 +463,9 @@ func (c *Client) Update( // or *Appointments Premium*. func (c *Client) Cancel( ctx context.Context, - request *squaregosdk.CancelBookingRequest, + request *v2.CancelBookingRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelBookingResponse, error) { +) (*v2.CancelBookingResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -482,7 +482,7 @@ func (c *Client) Cancel( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CancelBookingResponse + var response *v2.CancelBookingResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/bookings/custom_attribute_definitions.go b/bookings/custom_attribute_definitions.go index 7433cf8..0628cfe 100644 --- a/bookings/custom_attribute_definitions.go +++ b/bookings/custom_attribute_definitions.go @@ -3,7 +3,7 @@ package bookings import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateBookingCustomAttributeDefinitionRequest struct { @@ -22,7 +22,7 @@ type CreateBookingCustomAttributeDefinitionRequest struct { // - `schema`. With the exception of the `Selection` data type, the `schema` is specified as a // simple URL to the JSON schema definition hosted on the Square CDN. For more information, see // [Specifying the schema](https://developer.squareup.com/docs/booking-custom-attributes-api/custom-attribute-definitions#specify-schema). - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` @@ -70,7 +70,7 @@ type UpdateBookingCustomAttributeDefinitionRequest struct { // // To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // control, include the optional `version` field and specify the current version of the custom attribute definition. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/bookings/custom_attributes.go b/bookings/custom_attributes.go index 712f466..0ff4211 100644 --- a/bookings/custom_attributes.go +++ b/bookings/custom_attributes.go @@ -3,21 +3,21 @@ package bookings import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type BulkDeleteBookingCustomAttributesRequest struct { // A map containing 1 to 25 individual Delete requests. For each request, provide an // arbitrary ID that is unique for this `BulkDeleteBookingCustomAttributes` request and the // information needed to delete a custom attribute. - Values map[string]*squaregosdk.BookingCustomAttributeDeleteRequest `json:"values,omitempty" url:"-"` + Values map[string]*v2.BookingCustomAttributeDeleteRequest `json:"values,omitempty" url:"-"` } type BulkUpsertBookingCustomAttributesRequest struct { // A map containing 1 to 25 individual upsert requests. For each request, provide an // arbitrary ID that is unique for this `BulkUpsertBookingCustomAttributes` request and the // information needed to create or update a custom attribute. - Values map[string]*squaregosdk.BookingCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` + Values map[string]*v2.BookingCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` } type CustomAttributesDeleteRequest struct { @@ -79,7 +79,7 @@ type UpsertBookingCustomAttributeRequest struct { // - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // control for an update operation, include this optional field and specify the current version // of the custom attribute. - CustomAttribute *squaregosdk.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` + CustomAttribute *v2.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/bookings/customattributedefinitions/client.go b/bookings/customattributedefinitions/client.go index f8a677f..daec533 100644 --- a/bookings/customattributedefinitions/client.go +++ b/bookings/customattributedefinitions/client.go @@ -5,11 +5,11 @@ package customattributedefinitions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - bookings "github.com/square/square-go-sdk/bookings" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + bookings "github.com/square/square-go-sdk/v2/bookings" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -48,7 +48,7 @@ func (c *Client) List( ctx context.Context, request *bookings.CustomAttributeDefinitionsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttributeDefinition], error) { +) (*core.Page[*v2.CustomAttributeDefinition], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -84,10 +84,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListBookingCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition] { + readPageResponse := func(response *v2.ListBookingCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *v2.CustomAttributeDefinition] { next := response.Cursor results := response.CustomAttributeDefinitions - return &internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition]{ + return &internal.PageResponse[*string, *v2.CustomAttributeDefinition]{ Next: next, Results: results, } @@ -111,7 +111,7 @@ func (c *Client) Create( ctx context.Context, request *bookings.CreateBookingCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateBookingCustomAttributeDefinitionResponse, error) { +) (*v2.CreateBookingCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -125,7 +125,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateBookingCustomAttributeDefinitionResponse + var response *v2.CreateBookingCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -153,7 +153,7 @@ func (c *Client) Get( ctx context.Context, request *bookings.CustomAttributeDefinitionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveBookingCustomAttributeDefinitionResponse, error) { +) (*v2.RetrieveBookingCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -176,7 +176,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveBookingCustomAttributeDefinitionResponse + var response *v2.RetrieveBookingCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -206,7 +206,7 @@ func (c *Client) Update( ctx context.Context, request *bookings.UpdateBookingCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateBookingCustomAttributeDefinitionResponse, error) { +) (*v2.UpdateBookingCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -223,7 +223,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateBookingCustomAttributeDefinitionResponse + var response *v2.UpdateBookingCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -254,7 +254,7 @@ func (c *Client) Delete( ctx context.Context, request *bookings.CustomAttributeDefinitionsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteBookingCustomAttributeDefinitionResponse, error) { +) (*v2.DeleteBookingCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -270,7 +270,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteBookingCustomAttributeDefinitionResponse + var response *v2.DeleteBookingCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/bookings/customattributes/client.go b/bookings/customattributes/client.go index 5fb3840..8334692 100644 --- a/bookings/customattributes/client.go +++ b/bookings/customattributes/client.go @@ -5,11 +5,11 @@ package customattributes import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - bookings "github.com/square/square-go-sdk/bookings" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + bookings "github.com/square/square-go-sdk/v2/bookings" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -51,7 +51,7 @@ func (c *Client) BatchDelete( ctx context.Context, request *bookings.BulkDeleteBookingCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkDeleteBookingCustomAttributesResponse, error) { +) (*v2.BulkDeleteBookingCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -65,7 +65,7 @@ func (c *Client) BatchDelete( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkDeleteBookingCustomAttributesResponse + var response *v2.BulkDeleteBookingCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -96,7 +96,7 @@ func (c *Client) BatchUpsert( ctx context.Context, request *bookings.BulkUpsertBookingCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkUpsertBookingCustomAttributesResponse, error) { +) (*v2.BulkUpsertBookingCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -110,7 +110,7 @@ func (c *Client) BatchUpsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkUpsertBookingCustomAttributesResponse + var response *v2.BulkUpsertBookingCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -138,7 +138,7 @@ func (c *Client) List( ctx context.Context, request *bookings.CustomAttributesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttribute], error) { +) (*core.Page[*v2.CustomAttribute], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -177,10 +177,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListBookingCustomAttributesResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttribute] { + readPageResponse := func(response *v2.ListBookingCustomAttributesResponse) *internal.PageResponse[*string, *v2.CustomAttribute] { next := response.Cursor results := response.CustomAttributes - return &internal.PageResponse[*string, *squaregosdk.CustomAttribute]{ + return &internal.PageResponse[*string, *v2.CustomAttribute]{ Next: next, Results: results, } @@ -201,7 +201,7 @@ func (c *Client) Get( ctx context.Context, request *bookings.CustomAttributesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveBookingCustomAttributeResponse, error) { +) (*v2.RetrieveBookingCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -225,7 +225,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveBookingCustomAttributeResponse + var response *v2.RetrieveBookingCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -255,7 +255,7 @@ func (c *Client) Upsert( ctx context.Context, request *bookings.UpsertBookingCustomAttributeRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertBookingCustomAttributeResponse, error) { +) (*v2.UpsertBookingCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -273,7 +273,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertBookingCustomAttributeResponse + var response *v2.UpsertBookingCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -304,7 +304,7 @@ func (c *Client) Delete( ctx context.Context, request *bookings.CustomAttributesDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteBookingCustomAttributeResponse, error) { +) (*v2.DeleteBookingCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -321,7 +321,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteBookingCustomAttributeResponse + var response *v2.DeleteBookingCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/bookings/locationprofiles/client.go b/bookings/locationprofiles/client.go index 26cdf3f..455dc51 100644 --- a/bookings/locationprofiles/client.go +++ b/bookings/locationprofiles/client.go @@ -5,11 +5,11 @@ package locationprofiles import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - bookings "github.com/square/square-go-sdk/bookings" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + bookings "github.com/square/square-go-sdk/v2/bookings" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *bookings.LocationProfilesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.LocationBookingProfile], error) { +) (*core.Page[*v2.LocationBookingProfile], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListLocationBookingProfilesResponse) *internal.PageResponse[*string, *squaregosdk.LocationBookingProfile] { + readPageResponse := func(response *v2.ListLocationBookingProfilesResponse) *internal.PageResponse[*string, *v2.LocationBookingProfile] { next := response.Cursor results := response.LocationBookingProfiles - return &internal.PageResponse[*string, *squaregosdk.LocationBookingProfile]{ + return &internal.PageResponse[*string, *v2.LocationBookingProfile]{ Next: next, Results: results, } diff --git a/bookings/teammemberprofiles/client.go b/bookings/teammemberprofiles/client.go index 3484c59..b6dc274 100644 --- a/bookings/teammemberprofiles/client.go +++ b/bookings/teammemberprofiles/client.go @@ -5,11 +5,11 @@ package teammemberprofiles import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - bookings "github.com/square/square-go-sdk/bookings" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + bookings "github.com/square/square-go-sdk/v2/bookings" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *bookings.TeamMemberProfilesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.TeamMemberBookingProfile], error) { +) (*core.Page[*v2.TeamMemberBookingProfile], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListTeamMemberBookingProfilesResponse) *internal.PageResponse[*string, *squaregosdk.TeamMemberBookingProfile] { + readPageResponse := func(response *v2.ListTeamMemberBookingProfilesResponse) *internal.PageResponse[*string, *v2.TeamMemberBookingProfile] { next := response.Cursor results := response.TeamMemberBookingProfiles - return &internal.PageResponse[*string, *squaregosdk.TeamMemberBookingProfile]{ + return &internal.PageResponse[*string, *v2.TeamMemberBookingProfile]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Get( ctx context.Context, request *bookings.TeamMemberProfilesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTeamMemberBookingProfileResponse, error) { +) (*v2.GetTeamMemberBookingProfileResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -118,7 +118,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTeamMemberBookingProfileResponse + var response *v2.GetTeamMemberBookingProfileResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/cards.go b/cards.go index cbd7f67..bd955fc 100644 --- a/cards.go +++ b/cards.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type CreateCardRequest struct { diff --git a/cards/client.go b/cards/client.go index c30a6e0..e24a3e8 100644 --- a/cards/client.go +++ b/cards/client.go @@ -5,10 +5,10 @@ package cards import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -43,9 +43,9 @@ func NewClient(opts ...option.RequestOption) *Client { // A max of 25 cards will be returned. func (c *Client) List( ctx context.Context, - request *squaregosdk.CardsListRequest, + request *v2.CardsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Card], error) { +) (*core.Page[*v2.Card], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCardsResponse) *internal.PageResponse[*string, *squaregosdk.Card] { + readPageResponse := func(response *v2.ListCardsResponse) *internal.PageResponse[*string, *v2.Card] { next := response.Cursor results := response.Cards - return &internal.PageResponse[*string, *squaregosdk.Card]{ + return &internal.PageResponse[*string, *v2.Card]{ Next: next, Results: results, } @@ -100,9 +100,9 @@ func (c *Client) List( // Adds a card on file to an existing merchant. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateCardRequest, + request *v2.CreateCardRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCardResponse, error) { +) (*v2.CreateCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -116,7 +116,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateCardResponse + var response *v2.CreateCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -139,9 +139,9 @@ func (c *Client) Create( // Retrieves details for a specific Card. func (c *Client) Get( ctx context.Context, - request *squaregosdk.CardsGetRequest, + request *v2.CardsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCardResponse, error) { +) (*v2.GetCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -157,7 +157,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCardResponse + var response *v2.GetCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -180,9 +180,9 @@ func (c *Client) Get( // Disabling an already disabled card is allowed but has no effect. func (c *Client) Disable( ctx context.Context, - request *squaregosdk.CardsDisableRequest, + request *v2.CardsDisableRequest, opts ...option.RequestOption, -) (*squaregosdk.DisableCardResponse, error) { +) (*v2.DisableCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -198,7 +198,7 @@ func (c *Client) Disable( options.ToHeader(), ) - var response *squaregosdk.DisableCardResponse + var response *v2.DisableCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/cashdrawers/client/client.go b/cashdrawers/client/client.go index 5e40172..513c999 100644 --- a/cashdrawers/client/client.go +++ b/cashdrawers/client/client.go @@ -3,10 +3,10 @@ package client import ( - shifts "github.com/square/square-go-sdk/cashdrawers/shifts" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + shifts "github.com/square/square-go-sdk/v2/cashdrawers/shifts" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) diff --git a/cashdrawers/shifts.go b/cashdrawers/shifts.go index 0d6ae6f..6497750 100644 --- a/cashdrawers/shifts.go +++ b/cashdrawers/shifts.go @@ -3,7 +3,7 @@ package cashdrawers import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type ShiftsGetRequest struct { @@ -18,7 +18,7 @@ type ShiftsListRequest struct { LocationID string `json:"-" url:"location_id"` // The order in which cash drawer shifts are listed in the response, // based on their opened_at field. Default value: ASC - SortOrder *squaregosdk.SortOrder `json:"-" url:"sort_order,omitempty"` + SortOrder *v2.SortOrder `json:"-" url:"sort_order,omitempty"` // The inclusive start time of the query on opened_at, in ISO 8601 format. BeginTime *string `json:"-" url:"begin_time,omitempty"` // The exclusive end date of the query on opened_at, in ISO 8601 format. diff --git a/cashdrawers/shifts/client.go b/cashdrawers/shifts/client.go index 40b2639..d75696f 100644 --- a/cashdrawers/shifts/client.go +++ b/cashdrawers/shifts/client.go @@ -5,11 +5,11 @@ package shifts import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - cashdrawers "github.com/square/square-go-sdk/cashdrawers" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + cashdrawers "github.com/square/square-go-sdk/v2/cashdrawers" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -46,7 +46,7 @@ func (c *Client) List( ctx context.Context, request *cashdrawers.ShiftsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CashDrawerShiftSummary], error) { +) (*core.Page[*v2.CashDrawerShiftSummary], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -82,10 +82,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCashDrawerShiftsResponse) *internal.PageResponse[*string, *squaregosdk.CashDrawerShiftSummary] { + readPageResponse := func(response *v2.ListCashDrawerShiftsResponse) *internal.PageResponse[*string, *v2.CashDrawerShiftSummary] { next := response.Cursor results := response.CashDrawerShifts - return &internal.PageResponse[*string, *squaregosdk.CashDrawerShiftSummary]{ + return &internal.PageResponse[*string, *v2.CashDrawerShiftSummary]{ Next: next, Results: results, } @@ -104,7 +104,7 @@ func (c *Client) Get( ctx context.Context, request *cashdrawers.ShiftsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCashDrawerShiftResponse, error) { +) (*v2.GetCashDrawerShiftResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -127,7 +127,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCashDrawerShiftResponse + var response *v2.GetCashDrawerShiftResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -151,7 +151,7 @@ func (c *Client) ListEvents( ctx context.Context, request *cashdrawers.ShiftsListEventsRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CashDrawerShiftEvent], error) { +) (*core.Page[*v2.CashDrawerShiftEvent], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -190,10 +190,10 @@ func (c *Client) ListEvents( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCashDrawerShiftEventsResponse) *internal.PageResponse[*string, *squaregosdk.CashDrawerShiftEvent] { + readPageResponse := func(response *v2.ListCashDrawerShiftEventsResponse) *internal.PageResponse[*string, *v2.CashDrawerShiftEvent] { next := response.Cursor results := response.CashDrawerShiftEvents - return &internal.PageResponse[*string, *squaregosdk.CashDrawerShiftEvent]{ + return &internal.PageResponse[*string, *v2.CashDrawerShiftEvent]{ Next: next, Results: results, } diff --git a/catalog.go b/catalog.go index 96e18db..102e439 100644 --- a/catalog.go +++ b/catalog.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type SearchCatalogItemsRequest struct { @@ -180,8 +180,7 @@ type SearchCatalogObjectsRequest struct { // ITEM_OPTION_VAL, ITEM_VARIATION, or MODIFIER), you must explicitly include all the types of interest // in this field. ObjectTypes []CatalogObjectType `json:"object_types,omitempty" url:"-"` - // If `true`, deleted objects will be included in the results. Deleted objects will have their - // `is_deleted` field set to `true`. + // If `true`, deleted objects will be included in the results. Defaults to `false`. Deleted objects will have their `is_deleted` field set to `true`. If `include_deleted_objects` is `true`, then the `include_category_path_to_root` request parameter must be `false`. Both properties cannot be `true` at the same time. IncludeDeletedObjects *bool `json:"include_deleted_objects,omitempty" url:"-"` // If `true`, the response will include additional objects that are related to the // requested objects. Related objects are objects that are referenced by object ID by the objects @@ -208,10 +207,7 @@ type SearchCatalogObjectsRequest struct { // the implementation may return more or fewer results. If the supplied limit is negative, zero, or // is higher than the maximum limit of 1,000, it will be ignored. Limit *int `json:"limit,omitempty" url:"-"` - // Specifies whether or not to include the `path_to_root` list for each returned category instance. The `path_to_root` list consists - // of `CategoryPathToRootNode` objects and specifies the path that starts with the immediate parent category of the returned category - // and ends with its root category. If the returned category is a top-level category, the `path_to_root` list is empty and is not returned - // in the response payload. + // Specifies whether or not to include the `path_to_root` list for each returned category instance. The `path_to_root` list consists of `CategoryPathToRootNode` objects and specifies the path that starts with the immediate parent category of the returned category and ends with its root category. If the returned category is a top-level category, the `path_to_root` list is empty and is not returned in the response payload. If `include_category_path_to_root` is `true`, then the `include_deleted_objects` request parameter must be `false`. Both properties cannot be `true` at the same time. IncludeCategoryPathToRoot *bool `json:"include_category_path_to_root,omitempty" url:"-"` } diff --git a/catalog/client/client.go b/catalog/client/client.go index 36b2bad..5843ad4 100644 --- a/catalog/client/client.go +++ b/catalog/client/client.go @@ -5,12 +5,12 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - images "github.com/square/square-go-sdk/catalog/images" - object "github.com/square/square-go-sdk/catalog/object" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + images "github.com/square/square-go-sdk/v2/catalog/images" + object "github.com/square/square-go-sdk/v2/catalog/object" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -62,9 +62,9 @@ func NewClient(opts ...option.RequestOption) *Client { // delete requests are rejected with the `429` error code. func (c *Client) BatchDelete( ctx context.Context, - request *squaregosdk.BatchDeleteCatalogObjectsRequest, + request *v2.BatchDeleteCatalogObjectsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchDeleteCatalogObjectsResponse, error) { +) (*v2.BatchDeleteCatalogObjectsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -78,7 +78,7 @@ func (c *Client) BatchDelete( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchDeleteCatalogObjectsResponse + var response *v2.BatchDeleteCatalogObjectsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -106,9 +106,9 @@ func (c *Client) BatchDelete( // any [CatalogTax](entity:CatalogTax) objects that apply to it. func (c *Client) BatchGet( ctx context.Context, - request *squaregosdk.BatchGetCatalogObjectsRequest, + request *v2.BatchGetCatalogObjectsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetCatalogObjectsResponse, error) { +) (*v2.BatchGetCatalogObjectsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -122,7 +122,7 @@ func (c *Client) BatchGet( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetCatalogObjectsResponse + var response *v2.BatchGetCatalogObjectsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -157,9 +157,9 @@ func (c *Client) BatchGet( // update requests are rejected with the `429` error code. func (c *Client) BatchUpsert( ctx context.Context, - request *squaregosdk.BatchUpsertCatalogObjectsRequest, + request *v2.BatchUpsertCatalogObjectsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchUpsertCatalogObjectsResponse, error) { +) (*v2.BatchUpsertCatalogObjectsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -173,7 +173,7 @@ func (c *Client) BatchUpsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchUpsertCatalogObjectsResponse + var response *v2.BatchUpsertCatalogObjectsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -198,7 +198,7 @@ func (c *Client) BatchUpsert( func (c *Client) Info( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.CatalogInfoResponse, error) { +) (*v2.CatalogInfoResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -211,7 +211,7 @@ func (c *Client) Info( options.ToHeader(), ) - var response *squaregosdk.CatalogInfoResponse + var response *v2.CatalogInfoResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -240,9 +240,9 @@ func (c *Client) Info( // and set the `include_deleted_objects` attribute value to `true`. func (c *Client) List( ctx context.Context, - request *squaregosdk.CatalogListRequest, + request *v2.CatalogListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CatalogObject], error) { +) (*core.Page[*v2.CatalogObject], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -278,10 +278,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCatalogResponse) *internal.PageResponse[*string, *squaregosdk.CatalogObject] { + readPageResponse := func(response *v2.ListCatalogResponse) *internal.PageResponse[*string, *v2.CatalogObject] { next := response.Cursor results := response.Objects - return &internal.PageResponse[*string, *squaregosdk.CatalogObject]{ + return &internal.PageResponse[*string, *v2.CatalogObject]{ Next: next, Results: results, } @@ -306,9 +306,9 @@ func (c *Client) List( // - The both endpoints have different call conventions, including the query filter formats. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchCatalogObjectsRequest, + request *v2.SearchCatalogObjectsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchCatalogObjectsResponse, error) { +) (*v2.SearchCatalogObjectsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -322,7 +322,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchCatalogObjectsResponse + var response *v2.SearchCatalogObjectsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -354,9 +354,9 @@ func (c *Client) Search( // - The both endpoints use different call conventions, including the query filter formats. func (c *Client) SearchItems( ctx context.Context, - request *squaregosdk.SearchCatalogItemsRequest, + request *v2.SearchCatalogItemsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchCatalogItemsResponse, error) { +) (*v2.SearchCatalogItemsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -370,7 +370,7 @@ func (c *Client) SearchItems( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchCatalogItemsResponse + var response *v2.SearchCatalogItemsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -395,9 +395,9 @@ func (c *Client) SearchItems( // to perform an upsert on the entire item. func (c *Client) UpdateItemModifierLists( ctx context.Context, - request *squaregosdk.UpdateItemModifierListsRequest, + request *v2.UpdateItemModifierListsRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateItemModifierListsResponse, error) { +) (*v2.UpdateItemModifierListsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -411,7 +411,7 @@ func (c *Client) UpdateItemModifierLists( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateItemModifierListsResponse + var response *v2.UpdateItemModifierListsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -436,9 +436,9 @@ func (c *Client) UpdateItemModifierLists( // upsert on the entire item. func (c *Client) UpdateItemTaxes( ctx context.Context, - request *squaregosdk.UpdateItemTaxesRequest, + request *v2.UpdateItemTaxesRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateItemTaxesResponse, error) { +) (*v2.UpdateItemTaxesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -452,7 +452,7 @@ func (c *Client) UpdateItemTaxes( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateItemTaxesResponse + var response *v2.UpdateItemTaxesResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/catalog/images.go b/catalog/images.go index 11a7124..87c3101 100644 --- a/catalog/images.go +++ b/catalog/images.go @@ -3,18 +3,18 @@ package catalog import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" io "io" ) type ImagesCreateRequest struct { - ImageFile io.Reader `json:"-" url:"-"` - Request *squaregosdk.CreateCatalogImageRequest `json:"request,omitempty" url:"-"` + ImageFile io.Reader `json:"-" url:"-"` + Request *v2.CreateCatalogImageRequest `json:"request,omitempty" url:"-"` } type ImagesUpdateRequest struct { // The ID of the `CatalogImage` object to update the encapsulated image file. - ImageID string `json:"-" url:"-"` - ImageFile io.Reader `json:"-" url:"-"` - Request *squaregosdk.UpdateCatalogImageRequest `json:"request,omitempty" url:"-"` + ImageID string `json:"-" url:"-"` + ImageFile io.Reader `json:"-" url:"-"` + Request *v2.UpdateCatalogImageRequest `json:"request,omitempty" url:"-"` } diff --git a/catalog/images/client.go b/catalog/images/client.go index 4ac14e4..a318d56 100644 --- a/catalog/images/client.go +++ b/catalog/images/client.go @@ -4,11 +4,11 @@ package images import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - catalog "github.com/square/square-go-sdk/catalog" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + catalog "github.com/square/square-go-sdk/v2/catalog" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -49,7 +49,7 @@ func (c *Client) Create( ctx context.Context, request *catalog.ImagesCreateRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCatalogImageResponse, error) { +) (*v2.CreateCatalogImageResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -77,7 +77,7 @@ func (c *Client) Create( } headers.Set("Content-Type", writer.ContentType()) - var response *squaregosdk.CreateCatalogImageResponse + var response *v2.CreateCatalogImageResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -105,7 +105,7 @@ func (c *Client) Update( ctx context.Context, request *catalog.ImagesUpdateRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateCatalogImageResponse, error) { +) (*v2.UpdateCatalogImageResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -136,7 +136,7 @@ func (c *Client) Update( } headers.Set("Content-Type", writer.ContentType()) - var response *squaregosdk.UpdateCatalogImageResponse + var response *v2.UpdateCatalogImageResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/catalog/object.go b/catalog/object.go index 3cf9733..bb07592 100644 --- a/catalog/object.go +++ b/catalog/object.go @@ -3,7 +3,7 @@ package catalog import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type ObjectDeleteRequest struct { @@ -59,5 +59,5 @@ type UpsertCatalogObjectRequest struct { // // - For updates, the object must be active (the `is_deleted` field is not `true`). // - For creates, the object ID must start with `#`. The provided ID is replaced with a server-generated ID. - Object *squaregosdk.CatalogObject `json:"object,omitempty" url:"-"` + Object *v2.CatalogObject `json:"object,omitempty" url:"-"` } diff --git a/catalog/object/client.go b/catalog/object/client.go index 03a66ef..3c1dc92 100644 --- a/catalog/object/client.go +++ b/catalog/object/client.go @@ -4,11 +4,11 @@ package object import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - catalog "github.com/square/square-go-sdk/catalog" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + catalog "github.com/square/square-go-sdk/v2/catalog" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -48,7 +48,7 @@ func (c *Client) Upsert( ctx context.Context, request *catalog.UpsertCatalogObjectRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertCatalogObjectResponse, error) { +) (*v2.UpsertCatalogObjectResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -62,7 +62,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertCatalogObjectResponse + var response *v2.UpsertCatalogObjectResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -93,7 +93,7 @@ func (c *Client) Get( ctx context.Context, request *catalog.ObjectGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCatalogObjectResponse, error) { +) (*v2.GetCatalogObjectResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -116,7 +116,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCatalogObjectResponse + var response *v2.GetCatalogObjectResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -149,7 +149,7 @@ func (c *Client) Delete( ctx context.Context, request *catalog.ObjectDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteCatalogObjectResponse, error) { +) (*v2.DeleteCatalogObjectResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -165,7 +165,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteCatalogObjectResponse + var response *v2.DeleteCatalogObjectResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/checkout.go b/checkout.go index d2531a5..d31ae24 100644 --- a/checkout.go +++ b/checkout.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type RetrieveLocationSettingsRequest struct { diff --git a/checkout/client/client.go b/checkout/client/client.go index 49abde0..5bf1cbe 100644 --- a/checkout/client/client.go +++ b/checkout/client/client.go @@ -4,11 +4,11 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - paymentlinks "github.com/square/square-go-sdk/checkout/paymentlinks" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + paymentlinks "github.com/square/square-go-sdk/v2/checkout/paymentlinks" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,9 +45,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Retrieves the location-level settings for a Square-hosted checkout page. func (c *Client) RetrieveLocationSettings( ctx context.Context, - request *squaregosdk.RetrieveLocationSettingsRequest, + request *v2.RetrieveLocationSettingsRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveLocationSettingsResponse, error) { +) (*v2.RetrieveLocationSettingsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -63,7 +63,7 @@ func (c *Client) RetrieveLocationSettings( options.ToHeader(), ) - var response *squaregosdk.RetrieveLocationSettingsResponse + var response *v2.RetrieveLocationSettingsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -85,9 +85,9 @@ func (c *Client) RetrieveLocationSettings( // Updates the location-level settings for a Square-hosted checkout page. func (c *Client) UpdateLocationSettings( ctx context.Context, - request *squaregosdk.UpdateLocationSettingsRequest, + request *v2.UpdateLocationSettingsRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateLocationSettingsResponse, error) { +) (*v2.UpdateLocationSettingsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -104,7 +104,7 @@ func (c *Client) UpdateLocationSettings( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateLocationSettingsResponse + var response *v2.UpdateLocationSettingsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -128,7 +128,7 @@ func (c *Client) UpdateLocationSettings( func (c *Client) RetrieveMerchantSettings( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.RetrieveMerchantSettingsResponse, error) { +) (*v2.RetrieveMerchantSettingsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -141,7 +141,7 @@ func (c *Client) RetrieveMerchantSettings( options.ToHeader(), ) - var response *squaregosdk.RetrieveMerchantSettingsResponse + var response *v2.RetrieveMerchantSettingsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -163,9 +163,9 @@ func (c *Client) RetrieveMerchantSettings( // Updates the merchant-level settings for a Square-hosted checkout page. func (c *Client) UpdateMerchantSettings( ctx context.Context, - request *squaregosdk.UpdateMerchantSettingsRequest, + request *v2.UpdateMerchantSettingsRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateMerchantSettingsResponse, error) { +) (*v2.UpdateMerchantSettingsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -179,7 +179,7 @@ func (c *Client) UpdateMerchantSettings( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateMerchantSettingsResponse + var response *v2.UpdateMerchantSettingsResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/checkout/payment_links.go b/checkout/payment_links.go index e4f0e7d..f50c763 100644 --- a/checkout/payment_links.go +++ b/checkout/payment_links.go @@ -3,7 +3,7 @@ package checkout import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreatePaymentLinkRequest struct { @@ -19,18 +19,18 @@ type CreatePaymentLinkRequest struct { // Describes an ad hoc item and price for which to generate a quick pay checkout link. // For more information, // see [Quick Pay Checkout](https://developer.squareup.com/docs/checkout-api/quick-pay-checkout). - QuickPay *squaregosdk.QuickPay `json:"quick_pay,omitempty" url:"-"` + QuickPay *v2.QuickPay `json:"quick_pay,omitempty" url:"-"` // Describes the `Order` for which to create a checkout link. // For more information, // see [Square Order Checkout](https://developer.squareup.com/docs/checkout-api/square-order-checkout). - Order *squaregosdk.Order `json:"order,omitempty" url:"-"` + Order *v2.Order `json:"order,omitempty" url:"-"` // Describes optional fields to add to the resulting checkout page. // For more information, // see [Optional Checkout Configurations](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations). - CheckoutOptions *squaregosdk.CheckoutOptions `json:"checkout_options,omitempty" url:"-"` + CheckoutOptions *v2.CheckoutOptions `json:"checkout_options,omitempty" url:"-"` // Describes fields to prepopulate in the resulting checkout page. // For more information, see [Prepopulate the shipping address](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations#prepopulate-the-shipping-address). - PrePopulatedData *squaregosdk.PrePopulatedData `json:"pre_populated_data,omitempty" url:"-"` + PrePopulatedData *v2.PrePopulatedData `json:"pre_populated_data,omitempty" url:"-"` // A note for the payment. After processing the payment, Square adds this note to the resulting `Payment`. PaymentNote *string `json:"payment_note,omitempty" url:"-"` } @@ -64,5 +64,5 @@ type UpdatePaymentLinkRequest struct { ID string `json:"-" url:"-"` // The `payment_link` object describing the updates to apply. // For more information, see [Update a payment link](https://developer.squareup.com/docs/checkout-api/manage-checkout#update-a-payment-link). - PaymentLink *squaregosdk.PaymentLink `json:"payment_link,omitempty" url:"-"` + PaymentLink *v2.PaymentLink `json:"payment_link,omitempty" url:"-"` } diff --git a/checkout/paymentlinks/client.go b/checkout/paymentlinks/client.go index 60c9c52..5eab76c 100644 --- a/checkout/paymentlinks/client.go +++ b/checkout/paymentlinks/client.go @@ -5,11 +5,11 @@ package paymentlinks import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - checkout "github.com/square/square-go-sdk/checkout" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + checkout "github.com/square/square-go-sdk/v2/checkout" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *checkout.PaymentLinksListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.PaymentLink], error) { +) (*core.Page[*v2.PaymentLink], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListPaymentLinksResponse) *internal.PageResponse[*string, *squaregosdk.PaymentLink] { + readPageResponse := func(response *v2.ListPaymentLinksResponse) *internal.PageResponse[*string, *v2.PaymentLink] { next := response.Cursor results := response.PaymentLinks - return &internal.PageResponse[*string, *squaregosdk.PaymentLink]{ + return &internal.PageResponse[*string, *v2.PaymentLink]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Create( ctx context.Context, request *checkout.CreatePaymentLinkRequest, opts ...option.RequestOption, -) (*squaregosdk.CreatePaymentLinkResponse, error) { +) (*v2.CreatePaymentLinkResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -116,7 +116,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreatePaymentLinkResponse + var response *v2.CreatePaymentLinkResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -141,7 +141,7 @@ func (c *Client) Get( ctx context.Context, request *checkout.PaymentLinksGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetPaymentLinkResponse, error) { +) (*v2.GetPaymentLinkResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -157,7 +157,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetPaymentLinkResponse + var response *v2.GetPaymentLinkResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -183,7 +183,7 @@ func (c *Client) Update( ctx context.Context, request *checkout.UpdatePaymentLinkRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdatePaymentLinkResponse, error) { +) (*v2.UpdatePaymentLinkResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -200,7 +200,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdatePaymentLinkResponse + var response *v2.UpdatePaymentLinkResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -225,7 +225,7 @@ func (c *Client) Delete( ctx context.Context, request *checkout.PaymentLinksDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeletePaymentLinkResponse, error) { +) (*v2.DeletePaymentLinkResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -241,7 +241,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeletePaymentLinkResponse + var response *v2.DeletePaymentLinkResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/client/client.go b/client/client.go index 9a7073f..104684d 100644 --- a/client/client.go +++ b/client/client.go @@ -3,43 +3,43 @@ package client import ( - applepay "github.com/square/square-go-sdk/applepay" - bankaccounts "github.com/square/square-go-sdk/bankaccounts" - bookingsclient "github.com/square/square-go-sdk/bookings/client" - cards "github.com/square/square-go-sdk/cards" - cashdrawersclient "github.com/square/square-go-sdk/cashdrawers/client" - catalogclient "github.com/square/square-go-sdk/catalog/client" - checkoutclient "github.com/square/square-go-sdk/checkout/client" - core "github.com/square/square-go-sdk/core" - customersclient "github.com/square/square-go-sdk/customers/client" - devicesclient "github.com/square/square-go-sdk/devices/client" - disputesclient "github.com/square/square-go-sdk/disputes/client" - employees "github.com/square/square-go-sdk/employees" - events "github.com/square/square-go-sdk/events" - giftcardsclient "github.com/square/square-go-sdk/giftcards/client" - internal "github.com/square/square-go-sdk/internal" - inventory "github.com/square/square-go-sdk/inventory" - invoices "github.com/square/square-go-sdk/invoices" - laborclient "github.com/square/square-go-sdk/labor/client" - locationsclient "github.com/square/square-go-sdk/locations/client" - loyaltyclient "github.com/square/square-go-sdk/loyalty/client" - merchantsclient "github.com/square/square-go-sdk/merchants/client" - mobile "github.com/square/square-go-sdk/mobile" - oauth "github.com/square/square-go-sdk/oauth" - option "github.com/square/square-go-sdk/option" - ordersclient "github.com/square/square-go-sdk/orders/client" - payments "github.com/square/square-go-sdk/payments" - payouts "github.com/square/square-go-sdk/payouts" - refunds "github.com/square/square-go-sdk/refunds" - sites "github.com/square/square-go-sdk/sites" - snippets "github.com/square/square-go-sdk/snippets" - subscriptions "github.com/square/square-go-sdk/subscriptions" - team "github.com/square/square-go-sdk/team" - teammembersclient "github.com/square/square-go-sdk/teammembers/client" - terminalclient "github.com/square/square-go-sdk/terminal/client" - v1transactions "github.com/square/square-go-sdk/v1transactions" - vendors "github.com/square/square-go-sdk/vendors" - webhooksclient "github.com/square/square-go-sdk/webhooks/client" + applepay "github.com/square/square-go-sdk/v2/applepay" + bankaccounts "github.com/square/square-go-sdk/v2/bankaccounts" + bookingsclient "github.com/square/square-go-sdk/v2/bookings/client" + cards "github.com/square/square-go-sdk/v2/cards" + cashdrawersclient "github.com/square/square-go-sdk/v2/cashdrawers/client" + catalogclient "github.com/square/square-go-sdk/v2/catalog/client" + checkoutclient "github.com/square/square-go-sdk/v2/checkout/client" + core "github.com/square/square-go-sdk/v2/core" + customersclient "github.com/square/square-go-sdk/v2/customers/client" + devicesclient "github.com/square/square-go-sdk/v2/devices/client" + disputesclient "github.com/square/square-go-sdk/v2/disputes/client" + employees "github.com/square/square-go-sdk/v2/employees" + events "github.com/square/square-go-sdk/v2/events" + giftcardsclient "github.com/square/square-go-sdk/v2/giftcards/client" + internal "github.com/square/square-go-sdk/v2/internal" + inventory "github.com/square/square-go-sdk/v2/inventory" + invoices "github.com/square/square-go-sdk/v2/invoices" + laborclient "github.com/square/square-go-sdk/v2/labor/client" + locationsclient "github.com/square/square-go-sdk/v2/locations/client" + loyaltyclient "github.com/square/square-go-sdk/v2/loyalty/client" + merchantsclient "github.com/square/square-go-sdk/v2/merchants/client" + mobile "github.com/square/square-go-sdk/v2/mobile" + oauth "github.com/square/square-go-sdk/v2/oauth" + option "github.com/square/square-go-sdk/v2/option" + ordersclient "github.com/square/square-go-sdk/v2/orders/client" + payments "github.com/square/square-go-sdk/v2/payments" + payouts "github.com/square/square-go-sdk/v2/payouts" + refunds "github.com/square/square-go-sdk/v2/refunds" + sites "github.com/square/square-go-sdk/v2/sites" + snippets "github.com/square/square-go-sdk/v2/snippets" + subscriptions "github.com/square/square-go-sdk/v2/subscriptions" + team "github.com/square/square-go-sdk/v2/team" + teammembersclient "github.com/square/square-go-sdk/v2/teammembers/client" + terminalclient "github.com/square/square-go-sdk/v2/terminal/client" + v1transactions "github.com/square/square-go-sdk/v2/v1transactions" + vendors "github.com/square/square-go-sdk/v2/vendors" + webhooksclient "github.com/square/square-go-sdk/v2/webhooks/client" http "net/http" os "os" ) @@ -65,7 +65,6 @@ type Client struct { GiftCards *giftcardsclient.Client Inventory *inventory.Client Invoices *invoices.Client - Labor *laborclient.Client Locations *locationsclient.Client Loyalty *loyaltyclient.Client Merchants *merchantsclient.Client @@ -82,6 +81,7 @@ type Client struct { Terminal *terminalclient.Client Vendors *vendors.Client CashDrawers *cashdrawersclient.Client + Labor *laborclient.Client Webhooks *webhooksclient.Client } @@ -118,7 +118,6 @@ func NewClient(opts ...option.RequestOption) *Client { GiftCards: giftcardsclient.NewClient(opts...), Inventory: inventory.NewClient(opts...), Invoices: invoices.NewClient(opts...), - Labor: laborclient.NewClient(opts...), Locations: locationsclient.NewClient(opts...), Loyalty: loyaltyclient.NewClient(opts...), Merchants: merchantsclient.NewClient(opts...), @@ -135,6 +134,7 @@ func NewClient(opts ...option.RequestOption) *Client { Terminal: terminalclient.NewClient(opts...), Vendors: vendors.NewClient(opts...), CashDrawers: cashdrawersclient.NewClient(opts...), + Labor: laborclient.NewClient(opts...), Webhooks: webhooksclient.NewClient(opts...), } } diff --git a/client/client_test.go b/client/client_test.go index 367679a..9994266 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -3,7 +3,7 @@ package client import ( - option "github.com/square/square-go-sdk/option" + option "github.com/square/square-go-sdk/v2/option" assert "github.com/stretchr/testify/assert" http "net/http" testing "testing" diff --git a/core/request_option.go b/core/request_option.go index 69ccc70..0992833 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -52,7 +52,7 @@ func (r *RequestOptions) ToHeader() http.Header { if r.Token != "" { header.Set("Authorization", "Bearer "+r.Token) } - version := fmt.Sprintf("%v", "2024-11-20") + version := fmt.Sprintf("%v", "2025-01-23") if envValue := os.Getenv("VERSION"); envValue != "" { version = envValue } @@ -63,9 +63,9 @@ func (r *RequestOptions) ToHeader() http.Header { func (r *RequestOptions) cloneHeader() http.Header { headers := r.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") - headers.Set("X-Fern-SDK-Name", "github.com/square/square-go-sdk") - headers.Set("X-Fern-SDK-Version", "v1.0.1") - headers.Set("User-Agent", "github.com/square/square-go-sdk/1.0.1") + headers.Set("X-Fern-SDK-Name", "github.com/square/square-go-sdk/v2") + headers.Set("X-Fern-SDK-Version", "v2.0.0") + headers.Set("User-Agent", "github.com/square/square-go-sdk/v2.0.0") return headers } diff --git a/customers.go b/customers.go index 7594dd6..9c6356b 100644 --- a/customers.go +++ b/customers.go @@ -5,19 +5,9 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) -type BulkCreateCustomersRequest struct { - // A map of 1 to 100 individual create requests, represented by `idempotency key: { customer data }` - // key-value pairs. - // - // Each key is an [idempotency key](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) - // that uniquely identifies the create request. Each value contains the customer data used to create the - // customer profile. - Customers map[string]*BulkCreateCustomerData `json:"customers,omitempty" url:"-"` -} - type BulkDeleteCustomersRequest struct { // The IDs of the [customer profiles](entity:Customer) to delete. CustomerIDs []string `json:"customer_ids,omitempty" url:"-"` @@ -40,6 +30,16 @@ type BulkUpdateCustomersRequest struct { Customers map[string]*BulkUpdateCustomerData `json:"customers,omitempty" url:"-"` } +type BulkCreateCustomersRequest struct { + // A map of 1 to 100 individual create requests, represented by `idempotency key: { customer data }` + // key-value pairs. + // + // Each key is an [idempotency key](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + // that uniquely identifies the create request. Each value contains the customer data used to create the + // customer profile. + Customers map[string]*BulkCreateCustomerData `json:"customers,omitempty" url:"-"` +} + type CreateCustomerRequest struct { // The idempotency key for the request. For more information, see // [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). @@ -788,12 +788,6 @@ type Customer struct { CreatedAt *string `json:"created_at,omitempty" url:"created_at,omitempty"` // The timestamp when the customer profile was last updated, in RFC 3339 format. UpdatedAt *string `json:"updated_at,omitempty" url:"updated_at,omitempty"` - // Payment details of the credit, debit, and gift cards stored on file for the customer profile. - // - // DEPRECATED at version 2021-06-16 and will be RETIRED at version 2024-12-18. Replaced by calling [ListCards](api-endpoint:Cards-ListCards) (for credit and debit cards on file) - // or [ListGiftCards](api-endpoint:GiftCards-ListGiftCards) (for gift cards on file) and including the `customer_id` query parameter. - // For more information, see [Migration notes](https://developer.squareup.com/docs/customers-api/what-it-does#migrate-customer-cards). - Cards []*Card `json:"cards,omitempty" url:"cards,omitempty"` // The given name (that is, the first name) associated with the customer profile. GivenName *string `json:"given_name,omitempty" url:"given_name,omitempty"` // The family name (that is, the last name) associated with the customer profile. @@ -825,7 +819,7 @@ type Customer struct { GroupIDs []string `json:"group_ids,omitempty" url:"group_ids,omitempty"` // The IDs of [customer segments](entity:CustomerSegment) the customer belongs to. SegmentIDs []string `json:"segment_ids,omitempty" url:"segment_ids,omitempty"` - // The Square-assigned version number of the customer profile. The version number is incremented each time an update is committed to the customer profile, except for changes to customer segment membership and cards on file. + // The Square-assigned version number of the customer profile. The version number is incremented each time an update is committed to the customer profile, except for changes to customer segment membership. Version *int64 `json:"version,omitempty" url:"version,omitempty"` // The tax ID associated with the customer profile. This field is present only for customers of sellers in EU countries or the United Kingdom. // For more information, see [Customer tax IDs](https://developer.squareup.com/docs/customers-api/what-it-does#customer-tax-ids). @@ -856,13 +850,6 @@ func (c *Customer) GetUpdatedAt() *string { return c.UpdatedAt } -func (c *Customer) GetCards() []*Card { - if c == nil { - return nil - } - return c.Cards -} - func (c *Customer) GetGivenName() *string { if c == nil { return nil diff --git a/customers/cards.go b/customers/cards.go index 2688ebd..5b4fc22 100644 --- a/customers/cards.go +++ b/customers/cards.go @@ -3,7 +3,7 @@ package customers import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateCustomerCardRequest struct { @@ -23,7 +23,7 @@ type CreateCustomerCardRequest struct { // __NOTE:__ If a billing address is provided in the request, the // `CreateCustomerCardRequest.billing_address.postal_code` must match // the postal code encoded in the card nonce. - BillingAddress *squaregosdk.Address `json:"billing_address,omitempty" url:"-"` + BillingAddress *v2.Address `json:"billing_address,omitempty" url:"-"` // The full name printed on the credit card. CardholderName *string `json:"cardholder_name,omitempty" url:"-"` // An identifying token generated by [Payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer). diff --git a/customers/cards/client.go b/customers/cards/client.go index 70908e5..7aa73d5 100644 --- a/customers/cards/client.go +++ b/customers/cards/client.go @@ -4,11 +4,11 @@ package cards import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - customers "github.com/square/square-go-sdk/customers" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + customers "github.com/square/square-go-sdk/v2/customers" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -48,7 +48,7 @@ func (c *Client) Create( ctx context.Context, request *customers.CreateCustomerCardRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCustomerCardResponse, error) { +) (*v2.CreateCustomerCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -65,7 +65,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateCustomerCardResponse + var response *v2.CreateCustomerCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -90,7 +90,7 @@ func (c *Client) Delete( ctx context.Context, request *customers.CardsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteCustomerCardResponse, error) { +) (*v2.DeleteCustomerCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -107,7 +107,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteCustomerCardResponse + var response *v2.DeleteCustomerCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/customers/client/client.go b/customers/client/client.go index 4c3d800..e5d04b0 100644 --- a/customers/client/client.go +++ b/customers/client/client.go @@ -5,15 +5,15 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - cards "github.com/square/square-go-sdk/customers/cards" - customattributedefinitions "github.com/square/square-go-sdk/customers/customattributedefinitions" - customattributes "github.com/square/square-go-sdk/customers/customattributes" - groups "github.com/square/square-go-sdk/customers/groups" - segments "github.com/square/square-go-sdk/customers/segments" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + cards "github.com/square/square-go-sdk/v2/customers/cards" + customattributedefinitions "github.com/square/square-go-sdk/v2/customers/customattributedefinitions" + customattributes "github.com/square/square-go-sdk/v2/customers/customattributes" + groups "github.com/square/square-go-sdk/v2/customers/groups" + segments "github.com/square/square-go-sdk/v2/customers/segments" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -62,9 +62,9 @@ func NewClient(opts ...option.RequestOption) *Client { // profiles can take closer to one minute or longer, especially during network incidents and outages. func (c *Client) List( ctx context.Context, - request *squaregosdk.CustomersListRequest, + request *v2.CustomersListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Customer], error) { +) (*core.Page[*v2.Customer], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -100,10 +100,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCustomersResponse) *internal.PageResponse[*string, *squaregosdk.Customer] { + readPageResponse := func(response *v2.ListCustomersResponse) *internal.PageResponse[*string, *v2.Customer] { next := response.Cursor results := response.Customers - return &internal.PageResponse[*string, *squaregosdk.Customer]{ + return &internal.PageResponse[*string, *v2.Customer]{ Next: next, Results: results, } @@ -128,9 +128,9 @@ func (c *Client) List( // - `phone_number` func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateCustomerRequest, + request *v2.CreateCustomerRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCustomerResponse, error) { +) (*v2.CreateCustomerResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -144,7 +144,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateCustomerResponse + var response *v2.CreateCustomerResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -175,11 +175,11 @@ func (c *Client) Create( // - `company_name` // - `email_address` // - `phone_number` -func (c *Client) BulkCreateCustomers( +func (c *Client) BatchCreate( ctx context.Context, - request *squaregosdk.BulkCreateCustomersRequest, + request *v2.BulkCreateCustomersRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkCreateCustomersResponse, error) { +) (*v2.BulkCreateCustomersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -193,7 +193,7 @@ func (c *Client) BulkCreateCustomers( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkCreateCustomersResponse + var response *v2.BulkCreateCustomersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -218,9 +218,9 @@ func (c *Client) BulkCreateCustomers( // The endpoint takes a list of customer IDs and returns a map of responses. func (c *Client) BulkDeleteCustomers( ctx context.Context, - request *squaregosdk.BulkDeleteCustomersRequest, + request *v2.BulkDeleteCustomersRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkDeleteCustomersResponse, error) { +) (*v2.BulkDeleteCustomersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -234,7 +234,7 @@ func (c *Client) BulkDeleteCustomers( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkDeleteCustomersResponse + var response *v2.BulkDeleteCustomersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -259,9 +259,9 @@ func (c *Client) BulkDeleteCustomers( // This endpoint takes a list of customer IDs and returns a map of responses. func (c *Client) BulkRetrieveCustomers( ctx context.Context, - request *squaregosdk.BulkRetrieveCustomersRequest, + request *v2.BulkRetrieveCustomersRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkRetrieveCustomersResponse, error) { +) (*v2.BulkRetrieveCustomersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -275,7 +275,7 @@ func (c *Client) BulkRetrieveCustomers( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkRetrieveCustomersResponse + var response *v2.BulkRetrieveCustomersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -298,13 +298,11 @@ func (c *Client) BulkRetrieveCustomers( // Updates multiple customer profiles. // // This endpoint takes a map of individual update requests and returns a map of responses. -// -// You cannot use this endpoint to change cards on file. To make changes, use the [Cards API](api:Cards) or [Gift Cards API](api:GiftCards). func (c *Client) BulkUpdateCustomers( ctx context.Context, - request *squaregosdk.BulkUpdateCustomersRequest, + request *v2.BulkUpdateCustomersRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkUpdateCustomersResponse, error) { +) (*v2.BulkUpdateCustomersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -318,7 +316,7 @@ func (c *Client) BulkUpdateCustomers( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkUpdateCustomersResponse + var response *v2.BulkUpdateCustomersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -349,9 +347,9 @@ func (c *Client) BulkUpdateCustomers( // profiles can take closer to one minute or longer, especially during network incidents and outages. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchCustomersRequest, + request *v2.SearchCustomersRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchCustomersResponse, error) { +) (*v2.SearchCustomersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -365,7 +363,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchCustomersResponse + var response *v2.SearchCustomersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -388,9 +386,9 @@ func (c *Client) Search( // Returns details for a single customer. func (c *Client) Get( ctx context.Context, - request *squaregosdk.CustomersGetRequest, + request *v2.CustomersGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCustomerResponse, error) { +) (*v2.GetCustomerResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -406,7 +404,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCustomerResponse + var response *v2.GetCustomerResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -429,13 +427,11 @@ func (c *Client) Get( // To add or update a field, specify the new value. To remove a field, specify `null`. // // To update a customer profile that was created by merging existing profiles, you must use the ID of the newly created profile. -// -// You cannot use this endpoint to change cards on file. To make changes, use the [Cards API](api:Cards) or [Gift Cards API](api:GiftCards). func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdateCustomerRequest, + request *v2.UpdateCustomerRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateCustomerResponse, error) { +) (*v2.UpdateCustomerResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -452,7 +448,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateCustomerResponse + var response *v2.UpdateCustomerResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -472,14 +468,14 @@ func (c *Client) Update( return response, nil } -// Deletes a customer profile from a business. This operation also unlinks any associated cards on file. +// Deletes a customer profile from a business. // // To delete a customer profile that was created by merging existing profiles, you must use the ID of the newly created profile. func (c *Client) Delete( ctx context.Context, - request *squaregosdk.CustomersDeleteRequest, + request *v2.CustomersDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteCustomerResponse, error) { +) (*v2.DeleteCustomerResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -502,7 +498,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteCustomerResponse + var response *v2.DeleteCustomerResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/customers/custom_attribute_definitions.go b/customers/custom_attribute_definitions.go index 7897967..4cf904c 100644 --- a/customers/custom_attribute_definitions.go +++ b/customers/custom_attribute_definitions.go @@ -3,14 +3,14 @@ package customers import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type BatchUpsertCustomerCustomAttributesRequest struct { // A map containing 1 to 25 individual upsert requests. For each request, provide an // arbitrary ID that is unique for this `BulkUpsertCustomerCustomAttributes` request and the // information needed to create or update a custom attribute. - Values map[string]*squaregosdk.BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` + Values map[string]*v2.BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` } type CreateCustomerCustomAttributeDefinitionRequest struct { @@ -20,7 +20,7 @@ type CreateCustomerCustomAttributeDefinitionRequest struct { // [Specifying the schema](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attribute-definitions#specify-schema). // - If provided, `name` must be unique (case-sensitive) across all visible customer-related custom attribute definitions for the seller. // - All custom attributes are visible in exported customer data, including those set to `VISIBILITY_HIDDEN`. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` @@ -71,7 +71,7 @@ type UpdateCustomerCustomAttributeDefinitionRequest struct { // // To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // control, include the optional `version` field and specify the current version of the custom attribute definition. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/customers/custom_attributes.go b/customers/custom_attributes.go index b891b5a..94f4858 100644 --- a/customers/custom_attributes.go +++ b/customers/custom_attributes.go @@ -3,7 +3,7 @@ package customers import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CustomAttributesDeleteRequest struct { @@ -65,7 +65,7 @@ type UpsertCustomerCustomAttributeRequest struct { // - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // control for an update operation, include this optional field and specify the current version // of the custom attribute. - CustomAttribute *squaregosdk.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` + CustomAttribute *v2.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/customers/customattributedefinitions/client.go b/customers/customattributedefinitions/client.go index 3a2fa0c..5d11b50 100644 --- a/customers/customattributedefinitions/client.go +++ b/customers/customattributedefinitions/client.go @@ -5,11 +5,11 @@ package customattributedefinitions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - customers "github.com/square/square-go-sdk/customers" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + customers "github.com/square/square-go-sdk/v2/customers" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -50,7 +50,7 @@ func (c *Client) List( ctx context.Context, request *customers.CustomAttributeDefinitionsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttributeDefinition], error) { +) (*core.Page[*v2.CustomAttributeDefinition], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -86,10 +86,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCustomerCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition] { + readPageResponse := func(response *v2.ListCustomerCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *v2.CustomAttributeDefinition] { next := response.Cursor results := response.CustomAttributeDefinitions - return &internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition]{ + return &internal.PageResponse[*string, *v2.CustomAttributeDefinition]{ Next: next, Results: results, } @@ -117,7 +117,7 @@ func (c *Client) Create( ctx context.Context, request *customers.CreateCustomerCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCustomerCustomAttributeDefinitionResponse, error) { +) (*v2.CreateCustomerCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -131,7 +131,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateCustomerCustomAttributeDefinitionResponse + var response *v2.CreateCustomerCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -160,7 +160,7 @@ func (c *Client) Get( ctx context.Context, request *customers.CustomAttributeDefinitionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCustomerCustomAttributeDefinitionResponse, error) { +) (*v2.GetCustomerCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -183,7 +183,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCustomerCustomAttributeDefinitionResponse + var response *v2.GetCustomerCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -213,7 +213,7 @@ func (c *Client) Update( ctx context.Context, request *customers.UpdateCustomerCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateCustomerCustomAttributeDefinitionResponse, error) { +) (*v2.UpdateCustomerCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -230,7 +230,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateCustomerCustomAttributeDefinitionResponse + var response *v2.UpdateCustomerCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -260,7 +260,7 @@ func (c *Client) Delete( ctx context.Context, request *customers.CustomAttributeDefinitionsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteCustomerCustomAttributeDefinitionResponse, error) { +) (*v2.DeleteCustomerCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -276,7 +276,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteCustomerCustomAttributeDefinitionResponse + var response *v2.DeleteCustomerCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -313,7 +313,7 @@ func (c *Client) BatchUpsert( ctx context.Context, request *customers.BatchUpsertCustomerCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchUpsertCustomerCustomAttributesResponse, error) { +) (*v2.BatchUpsertCustomerCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -327,7 +327,7 @@ func (c *Client) BatchUpsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchUpsertCustomerCustomAttributesResponse + var response *v2.BatchUpsertCustomerCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/customers/customattributes/client.go b/customers/customattributes/client.go index ce500e6..f688c24 100644 --- a/customers/customattributes/client.go +++ b/customers/customattributes/client.go @@ -5,11 +5,11 @@ package customattributes import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - customers "github.com/square/square-go-sdk/customers" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + customers "github.com/square/square-go-sdk/v2/customers" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -52,7 +52,7 @@ func (c *Client) List( ctx context.Context, request *customers.CustomAttributesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttribute], error) { +) (*core.Page[*v2.CustomAttribute], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -91,10 +91,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCustomerCustomAttributesResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttribute] { + readPageResponse := func(response *v2.ListCustomerCustomAttributesResponse) *internal.PageResponse[*string, *v2.CustomAttribute] { next := response.Cursor results := response.CustomAttributes - return &internal.PageResponse[*string, *squaregosdk.CustomAttribute]{ + return &internal.PageResponse[*string, *v2.CustomAttribute]{ Next: next, Results: results, } @@ -119,7 +119,7 @@ func (c *Client) Get( ctx context.Context, request *customers.CustomAttributesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCustomerCustomAttributeResponse, error) { +) (*v2.GetCustomerCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -143,7 +143,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCustomerCustomAttributeResponse + var response *v2.GetCustomerCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -175,7 +175,7 @@ func (c *Client) Upsert( ctx context.Context, request *customers.UpsertCustomerCustomAttributeRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertCustomerCustomAttributeResponse, error) { +) (*v2.UpsertCustomerCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -193,7 +193,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertCustomerCustomAttributeResponse + var response *v2.UpsertCustomerCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -222,7 +222,7 @@ func (c *Client) Delete( ctx context.Context, request *customers.CustomAttributesDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteCustomerCustomAttributeResponse, error) { +) (*v2.DeleteCustomerCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -239,7 +239,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteCustomerCustomAttributeResponse + var response *v2.DeleteCustomerCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/customers/groups.go b/customers/groups.go index a87c5de..a7f2ad5 100644 --- a/customers/groups.go +++ b/customers/groups.go @@ -3,7 +3,7 @@ package customers import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type GroupsAddRequest struct { @@ -17,7 +17,7 @@ type CreateCustomerGroupRequest struct { // The idempotency key for the request. For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` // The customer group to create. - Group *squaregosdk.CustomerGroup `json:"group,omitempty" url:"-"` + Group *v2.CustomerGroup `json:"group,omitempty" url:"-"` } type GroupsDeleteRequest struct { @@ -54,5 +54,5 @@ type UpdateCustomerGroupRequest struct { // The ID of the customer group to update. GroupID string `json:"-" url:"-"` // The `CustomerGroup` object including all the updates you want to make. - Group *squaregosdk.CustomerGroup `json:"group,omitempty" url:"-"` + Group *v2.CustomerGroup `json:"group,omitempty" url:"-"` } diff --git a/customers/groups/client.go b/customers/groups/client.go index 5a314e3..fc16271 100644 --- a/customers/groups/client.go +++ b/customers/groups/client.go @@ -5,11 +5,11 @@ package groups import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - customers "github.com/square/square-go-sdk/customers" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + customers "github.com/square/square-go-sdk/v2/customers" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *customers.GroupsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomerGroup], error) { +) (*core.Page[*v2.CustomerGroup], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCustomerGroupsResponse) *internal.PageResponse[*string, *squaregosdk.CustomerGroup] { + readPageResponse := func(response *v2.ListCustomerGroupsResponse) *internal.PageResponse[*string, *v2.CustomerGroup] { next := response.Cursor results := response.Groups - return &internal.PageResponse[*string, *squaregosdk.CustomerGroup]{ + return &internal.PageResponse[*string, *v2.CustomerGroup]{ Next: next, Results: results, } @@ -104,7 +104,7 @@ func (c *Client) Create( ctx context.Context, request *customers.CreateCustomerGroupRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCustomerGroupResponse, error) { +) (*v2.CreateCustomerGroupResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -118,7 +118,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateCustomerGroupResponse + var response *v2.CreateCustomerGroupResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -143,7 +143,7 @@ func (c *Client) Get( ctx context.Context, request *customers.GroupsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCustomerGroupResponse, error) { +) (*v2.GetCustomerGroupResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -159,7 +159,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCustomerGroupResponse + var response *v2.GetCustomerGroupResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -183,7 +183,7 @@ func (c *Client) Update( ctx context.Context, request *customers.UpdateCustomerGroupRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateCustomerGroupResponse, error) { +) (*v2.UpdateCustomerGroupResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -200,7 +200,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateCustomerGroupResponse + var response *v2.UpdateCustomerGroupResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -225,7 +225,7 @@ func (c *Client) Delete( ctx context.Context, request *customers.GroupsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteCustomerGroupResponse, error) { +) (*v2.DeleteCustomerGroupResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -241,7 +241,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteCustomerGroupResponse + var response *v2.DeleteCustomerGroupResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -268,7 +268,7 @@ func (c *Client) Add( ctx context.Context, request *customers.GroupsAddRequest, opts ...option.RequestOption, -) (*squaregosdk.AddGroupToCustomerResponse, error) { +) (*v2.AddGroupToCustomerResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -285,7 +285,7 @@ func (c *Client) Add( options.ToHeader(), ) - var response *squaregosdk.AddGroupToCustomerResponse + var response *v2.AddGroupToCustomerResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -312,7 +312,7 @@ func (c *Client) Remove( ctx context.Context, request *customers.GroupsRemoveRequest, opts ...option.RequestOption, -) (*squaregosdk.RemoveGroupFromCustomerResponse, error) { +) (*v2.RemoveGroupFromCustomerResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -329,7 +329,7 @@ func (c *Client) Remove( options.ToHeader(), ) - var response *squaregosdk.RemoveGroupFromCustomerResponse + var response *v2.RemoveGroupFromCustomerResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/customers/segments/client.go b/customers/segments/client.go index 3988d40..ef1def3 100644 --- a/customers/segments/client.go +++ b/customers/segments/client.go @@ -5,11 +5,11 @@ package segments import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - customers "github.com/square/square-go-sdk/customers" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + customers "github.com/square/square-go-sdk/v2/customers" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *customers.SegmentsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomerSegment], error) { +) (*core.Page[*v2.CustomerSegment], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListCustomerSegmentsResponse) *internal.PageResponse[*string, *squaregosdk.CustomerSegment] { + readPageResponse := func(response *v2.ListCustomerSegmentsResponse) *internal.PageResponse[*string, *v2.CustomerSegment] { next := response.Cursor results := response.Segments - return &internal.PageResponse[*string, *squaregosdk.CustomerSegment]{ + return &internal.PageResponse[*string, *v2.CustomerSegment]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Get( ctx context.Context, request *customers.SegmentsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetCustomerSegmentResponse, error) { +) (*v2.GetCustomerSegmentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -118,7 +118,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetCustomerSegmentResponse + var response *v2.GetCustomerSegmentResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/devices.go b/devices.go index 3afb6cc..dfb26a0 100644 --- a/devices.go +++ b/devices.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type DevicesGetRequest struct { diff --git a/devices/client/client.go b/devices/client/client.go index 60be2ed..37a8d1d 100644 --- a/devices/client/client.go +++ b/devices/client/client.go @@ -5,11 +5,11 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - codes "github.com/square/square-go-sdk/devices/codes" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + codes "github.com/square/square-go-sdk/v2/devices/codes" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -47,9 +47,9 @@ func NewClient(opts ...option.RequestOption) *Client { // devices are supported. func (c *Client) List( ctx context.Context, - request *squaregosdk.DevicesListRequest, + request *v2.DevicesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Device], error) { +) (*core.Page[*v2.Device], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -85,10 +85,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListDevicesResponse) *internal.PageResponse[*string, *squaregosdk.Device] { + readPageResponse := func(response *v2.ListDevicesResponse) *internal.PageResponse[*string, *v2.Device] { next := response.Cursor results := response.Devices - return &internal.PageResponse[*string, *squaregosdk.Device]{ + return &internal.PageResponse[*string, *v2.Device]{ Next: next, Results: results, } @@ -104,9 +104,9 @@ func (c *Client) List( // Retrieves Device with the associated `device_id`. func (c *Client) Get( ctx context.Context, - request *squaregosdk.DevicesGetRequest, + request *v2.DevicesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetDeviceResponse, error) { +) (*v2.GetDeviceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -122,7 +122,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetDeviceResponse + var response *v2.GetDeviceResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/devices/codes.go b/devices/codes.go index e631978..69112d0 100644 --- a/devices/codes.go +++ b/devices/codes.go @@ -3,7 +3,7 @@ package devices import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateDeviceCodeRequest struct { @@ -13,7 +13,7 @@ type CreateDeviceCodeRequest struct { // See [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information. IdempotencyKey string `json:"idempotency_key" url:"-"` // The device code to create. - DeviceCode *squaregosdk.DeviceCode `json:"device_code,omitempty" url:"-"` + DeviceCode *v2.DeviceCode `json:"device_code,omitempty" url:"-"` } type CodesGetRequest struct { @@ -32,8 +32,8 @@ type CodesListRequest struct { LocationID *string `json:"-" url:"location_id,omitempty"` // If specified, only returns DeviceCodes targeting the specified product type. // Returns DeviceCodes of all product types if empty. - ProductType *squaregosdk.ProductType `json:"-" url:"product_type,omitempty"` + ProductType *v2.ProductType `json:"-" url:"product_type,omitempty"` // If specified, returns DeviceCodes with the specified statuses. // Returns DeviceCodes of status `PAIRED` and `UNPAIRED` if empty. - Status *squaregosdk.DeviceCodeStatus `json:"-" url:"status,omitempty"` + Status *v2.DeviceCodeStatus `json:"-" url:"status,omitempty"` } diff --git a/devices/codes/client.go b/devices/codes/client.go index 779a660..7bbbf0c 100644 --- a/devices/codes/client.go +++ b/devices/codes/client.go @@ -5,11 +5,11 @@ package codes import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - devices "github.com/square/square-go-sdk/devices" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + devices "github.com/square/square-go-sdk/v2/devices" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *devices.CodesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.DeviceCode], error) { +) (*core.Page[*v2.DeviceCode], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListDeviceCodesResponse) *internal.PageResponse[*string, *squaregosdk.DeviceCode] { + readPageResponse := func(response *v2.ListDeviceCodesResponse) *internal.PageResponse[*string, *v2.DeviceCode] { next := response.Cursor results := response.DeviceCodes - return &internal.PageResponse[*string, *squaregosdk.DeviceCode]{ + return &internal.PageResponse[*string, *v2.DeviceCode]{ Next: next, Results: results, } @@ -103,7 +103,7 @@ func (c *Client) Create( ctx context.Context, request *devices.CreateDeviceCodeRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateDeviceCodeResponse, error) { +) (*v2.CreateDeviceCodeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -117,7 +117,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateDeviceCodeResponse + var response *v2.CreateDeviceCodeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -142,7 +142,7 @@ func (c *Client) Get( ctx context.Context, request *devices.CodesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetDeviceCodeResponse, error) { +) (*v2.GetDeviceCodeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -158,7 +158,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetDeviceCodeResponse + var response *v2.GetDeviceCodeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/disputes.go b/disputes.go index dbfb9ca..305124f 100644 --- a/disputes.go +++ b/disputes.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" io "io" ) diff --git a/disputes/client/client.go b/disputes/client/client.go index 4af9855..cfd2168 100644 --- a/disputes/client/client.go +++ b/disputes/client/client.go @@ -5,11 +5,11 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - evidence "github.com/square/square-go-sdk/disputes/evidence" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + evidence "github.com/square/square-go-sdk/v2/disputes/evidence" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -46,9 +46,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Returns a list of disputes associated with a particular account. func (c *Client) List( ctx context.Context, - request *squaregosdk.DisputesListRequest, + request *v2.DisputesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Dispute], error) { +) (*core.Page[*v2.Dispute], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -84,10 +84,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListDisputesResponse) *internal.PageResponse[*string, *squaregosdk.Dispute] { + readPageResponse := func(response *v2.ListDisputesResponse) *internal.PageResponse[*string, *v2.Dispute] { next := response.Cursor results := response.Disputes - return &internal.PageResponse[*string, *squaregosdk.Dispute]{ + return &internal.PageResponse[*string, *v2.Dispute]{ Next: next, Results: results, } @@ -103,9 +103,9 @@ func (c *Client) List( // Returns details about a specific dispute. func (c *Client) Get( ctx context.Context, - request *squaregosdk.DisputesGetRequest, + request *v2.DisputesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetDisputeResponse, error) { +) (*v2.GetDisputeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -121,7 +121,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetDisputeResponse + var response *v2.GetDisputeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -147,9 +147,9 @@ func (c *Client) Get( // does not have sufficient funds, Square debits the associated bank account. func (c *Client) Accept( ctx context.Context, - request *squaregosdk.DisputesAcceptRequest, + request *v2.DisputesAcceptRequest, opts ...option.RequestOption, -) (*squaregosdk.AcceptDisputeResponse, error) { +) (*v2.AcceptDisputeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -165,7 +165,7 @@ func (c *Client) Accept( options.ToHeader(), ) - var response *squaregosdk.AcceptDisputeResponse + var response *v2.AcceptDisputeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -188,9 +188,9 @@ func (c *Client) Accept( // multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF formats. func (c *Client) CreateEvidenceFile( ctx context.Context, - request *squaregosdk.DisputesCreateEvidenceFileRequest, + request *v2.DisputesCreateEvidenceFileRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateDisputeEvidenceFileResponse, error) { +) (*v2.CreateDisputeEvidenceFileResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -221,7 +221,7 @@ func (c *Client) CreateEvidenceFile( } headers.Set("Content-Type", writer.ContentType()) - var response *squaregosdk.CreateDisputeEvidenceFileResponse + var response *v2.CreateDisputeEvidenceFileResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -244,9 +244,9 @@ func (c *Client) CreateEvidenceFile( // Uploads text to use as evidence for a dispute challenge. func (c *Client) CreateEvidenceText( ctx context.Context, - request *squaregosdk.CreateDisputeEvidenceTextRequest, + request *v2.CreateDisputeEvidenceTextRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateDisputeEvidenceTextResponse, error) { +) (*v2.CreateDisputeEvidenceTextResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -263,7 +263,7 @@ func (c *Client) CreateEvidenceText( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateDisputeEvidenceTextResponse + var response *v2.CreateDisputeEvidenceTextResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -292,9 +292,9 @@ func (c *Client) CreateEvidenceText( // a dispute after submission. func (c *Client) SubmitEvidence( ctx context.Context, - request *squaregosdk.DisputesSubmitEvidenceRequest, + request *v2.DisputesSubmitEvidenceRequest, opts ...option.RequestOption, -) (*squaregosdk.SubmitEvidenceResponse, error) { +) (*v2.SubmitEvidenceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -310,7 +310,7 @@ func (c *Client) SubmitEvidence( options.ToHeader(), ) - var response *squaregosdk.SubmitEvidenceResponse + var response *v2.SubmitEvidenceResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/disputes/evidence/client.go b/disputes/evidence/client.go index 3f2535e..bfd65f8 100644 --- a/disputes/evidence/client.go +++ b/disputes/evidence/client.go @@ -5,11 +5,11 @@ package evidence import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - disputes "github.com/square/square-go-sdk/disputes" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + disputes "github.com/square/square-go-sdk/v2/disputes" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *disputes.EvidenceListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.DisputeEvidence], error) { +) (*core.Page[*v2.DisputeEvidence], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -84,10 +84,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListDisputeEvidenceResponse) *internal.PageResponse[*string, *squaregosdk.DisputeEvidence] { + readPageResponse := func(response *v2.ListDisputeEvidenceResponse) *internal.PageResponse[*string, *v2.DisputeEvidence] { next := response.Cursor results := response.Evidence - return &internal.PageResponse[*string, *squaregosdk.DisputeEvidence]{ + return &internal.PageResponse[*string, *v2.DisputeEvidence]{ Next: next, Results: results, } @@ -107,7 +107,7 @@ func (c *Client) Get( ctx context.Context, request *disputes.EvidenceGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetDisputeEvidenceResponse, error) { +) (*v2.GetDisputeEvidenceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -124,7 +124,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetDisputeEvidenceResponse + var response *v2.GetDisputeEvidenceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -149,7 +149,7 @@ func (c *Client) Delete( ctx context.Context, request *disputes.EvidenceDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteDisputeEvidenceResponse, error) { +) (*v2.DeleteDisputeEvidenceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -166,7 +166,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteDisputeEvidenceResponse + var response *v2.DeleteDisputeEvidenceResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/employees.go b/employees.go index 3349c45..6ee6baa 100644 --- a/employees.go +++ b/employees.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type EmployeesGetRequest struct { diff --git a/employees/client.go b/employees/client.go index 102ef74..1c60aca 100644 --- a/employees/client.go +++ b/employees/client.go @@ -5,10 +5,10 @@ package employees import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -41,9 +41,9 @@ func NewClient(opts ...option.RequestOption) *Client { func (c *Client) List( ctx context.Context, - request *squaregosdk.EmployeesListRequest, + request *v2.EmployeesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Employee], error) { +) (*core.Page[*v2.Employee], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -79,10 +79,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListEmployeesResponse) *internal.PageResponse[*string, *squaregosdk.Employee] { + readPageResponse := func(response *v2.ListEmployeesResponse) *internal.PageResponse[*string, *v2.Employee] { next := response.Cursor results := response.Employees - return &internal.PageResponse[*string, *squaregosdk.Employee]{ + return &internal.PageResponse[*string, *v2.Employee]{ Next: next, Results: results, } @@ -97,9 +97,9 @@ func (c *Client) List( func (c *Client) Get( ctx context.Context, - request *squaregosdk.EmployeesGetRequest, + request *v2.EmployeesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetEmployeeResponse, error) { +) (*v2.GetEmployeeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -115,7 +115,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetEmployeeResponse + var response *v2.GetEmployeeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/events.go b/events.go index 6624eaf..9145bd0 100644 --- a/events.go +++ b/events.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type ListEventTypesRequest struct { diff --git a/events/client.go b/events/client.go index 082fbe1..76f2a5c 100644 --- a/events/client.go +++ b/events/client.go @@ -4,10 +4,10 @@ package events import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -41,9 +41,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Search for Square API events that occur within a 28-day timeframe. func (c *Client) SearchEvents( ctx context.Context, - request *squaregosdk.SearchEventsRequest, + request *v2.SearchEventsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchEventsResponse, error) { +) (*v2.SearchEventsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -57,7 +57,7 @@ func (c *Client) SearchEvents( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchEventsResponse + var response *v2.SearchEventsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -83,7 +83,7 @@ func (c *Client) SearchEvents( func (c *Client) DisableEvents( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.DisableEventsResponse, error) { +) (*v2.DisableEventsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -96,7 +96,7 @@ func (c *Client) DisableEvents( options.ToHeader(), ) - var response *squaregosdk.DisableEventsResponse + var response *v2.DisableEventsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -119,7 +119,7 @@ func (c *Client) DisableEvents( func (c *Client) EnableEvents( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.EnableEventsResponse, error) { +) (*v2.EnableEventsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -132,7 +132,7 @@ func (c *Client) EnableEvents( options.ToHeader(), ) - var response *squaregosdk.EnableEventsResponse + var response *v2.EnableEventsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -154,9 +154,9 @@ func (c *Client) EnableEvents( // Lists all event types that you can subscribe to as webhooks or query using the Events API. func (c *Client) ListEventTypes( ctx context.Context, - request *squaregosdk.ListEventTypesRequest, + request *v2.ListEventTypesRequest, opts ...option.RequestOption, -) (*squaregosdk.ListEventTypesResponse, error) { +) (*v2.ListEventTypesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -176,7 +176,7 @@ func (c *Client) ListEventTypes( options.ToHeader(), ) - var response *squaregosdk.ListEventTypesResponse + var response *v2.ListEventTypesResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/gift_cards.go b/gift_cards.go index 92f190c..7560d6e 100644 --- a/gift_cards.go +++ b/gift_cards.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type LinkCustomerToGiftCardRequest struct { diff --git a/giftcards/activities.go b/giftcards/activities.go index 4e05236..f0eea06 100644 --- a/giftcards/activities.go +++ b/giftcards/activities.go @@ -3,7 +3,7 @@ package giftcards import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateGiftCardActivityRequest struct { @@ -11,7 +11,7 @@ type CreateGiftCardActivityRequest struct { IdempotencyKey string `json:"idempotency_key" url:"-"` // The activity to create for the gift card. This activity must specify `gift_card_id` or `gift_card_gan` for the target // gift card, the `location_id` where the activity occurred, and the activity `type` along with the corresponding activity details. - GiftCardActivity *squaregosdk.GiftCardActivity `json:"gift_card_activity,omitempty" url:"-"` + GiftCardActivity *v2.GiftCardActivity `json:"gift_card_activity,omitempty" url:"-"` } type ActivitiesListRequest struct { diff --git a/giftcards/activities/client.go b/giftcards/activities/client.go index fcdbda8..fa1e0e9 100644 --- a/giftcards/activities/client.go +++ b/giftcards/activities/client.go @@ -5,11 +5,11 @@ package activities import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - giftcards "github.com/square/square-go-sdk/giftcards" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + giftcards "github.com/square/square-go-sdk/v2/giftcards" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -48,7 +48,7 @@ func (c *Client) List( ctx context.Context, request *giftcards.ActivitiesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.GiftCardActivity], error) { +) (*core.Page[*v2.GiftCardActivity], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -84,10 +84,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListGiftCardActivitiesResponse) *internal.PageResponse[*string, *squaregosdk.GiftCardActivity] { + readPageResponse := func(response *v2.ListGiftCardActivitiesResponse) *internal.PageResponse[*string, *v2.GiftCardActivity] { next := response.Cursor results := response.GiftCardActivities - return &internal.PageResponse[*string, *squaregosdk.GiftCardActivity]{ + return &internal.PageResponse[*string, *v2.GiftCardActivity]{ Next: next, Results: results, } @@ -106,7 +106,7 @@ func (c *Client) Create( ctx context.Context, request *giftcards.CreateGiftCardActivityRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateGiftCardActivityResponse, error) { +) (*v2.CreateGiftCardActivityResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -120,7 +120,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateGiftCardActivityResponse + var response *v2.CreateGiftCardActivityResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/giftcards/client/client.go b/giftcards/client/client.go index 97baa6c..6d2ea25 100644 --- a/giftcards/client/client.go +++ b/giftcards/client/client.go @@ -5,11 +5,11 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - activities "github.com/square/square-go-sdk/giftcards/activities" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + activities "github.com/square/square-go-sdk/v2/giftcards/activities" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -47,9 +47,9 @@ func NewClient(opts ...option.RequestOption) *Client { // a subset of the gift cards. Results are sorted by `created_at` in ascending order. func (c *Client) List( ctx context.Context, - request *squaregosdk.GiftCardsListRequest, + request *v2.GiftCardsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.GiftCard], error) { +) (*core.Page[*v2.GiftCard], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -85,10 +85,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListGiftCardsResponse) *internal.PageResponse[*string, *squaregosdk.GiftCard] { + readPageResponse := func(response *v2.ListGiftCardsResponse) *internal.PageResponse[*string, *v2.GiftCard] { next := response.Cursor results := response.GiftCards - return &internal.PageResponse[*string, *squaregosdk.GiftCard]{ + return &internal.PageResponse[*string, *v2.GiftCard]{ Next: next, Results: results, } @@ -108,9 +108,9 @@ func (c *Client) List( // to refund a payment to the new gift card. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateGiftCardRequest, + request *v2.CreateGiftCardRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateGiftCardResponse, error) { +) (*v2.CreateGiftCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -124,7 +124,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateGiftCardResponse + var response *v2.CreateGiftCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -147,9 +147,9 @@ func (c *Client) Create( // Retrieves a gift card using the gift card account number (GAN). func (c *Client) GetFromGan( ctx context.Context, - request *squaregosdk.GetGiftCardFromGanRequest, + request *v2.GetGiftCardFromGanRequest, opts ...option.RequestOption, -) (*squaregosdk.GetGiftCardFromGanResponse, error) { +) (*v2.GetGiftCardFromGanResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -163,7 +163,7 @@ func (c *Client) GetFromGan( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.GetGiftCardFromGanResponse + var response *v2.GetGiftCardFromGanResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -186,9 +186,9 @@ func (c *Client) GetFromGan( // Retrieves a gift card using a secure payment token that represents the gift card. func (c *Client) GetFromNonce( ctx context.Context, - request *squaregosdk.GetGiftCardFromNonceRequest, + request *v2.GetGiftCardFromNonceRequest, opts ...option.RequestOption, -) (*squaregosdk.GetGiftCardFromNonceResponse, error) { +) (*v2.GetGiftCardFromNonceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -202,7 +202,7 @@ func (c *Client) GetFromNonce( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.GetGiftCardFromNonceResponse + var response *v2.GetGiftCardFromNonceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -225,9 +225,9 @@ func (c *Client) GetFromNonce( // Links a customer to a gift card, which is also referred to as adding a card on file. func (c *Client) LinkCustomer( ctx context.Context, - request *squaregosdk.LinkCustomerToGiftCardRequest, + request *v2.LinkCustomerToGiftCardRequest, opts ...option.RequestOption, -) (*squaregosdk.LinkCustomerToGiftCardResponse, error) { +) (*v2.LinkCustomerToGiftCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -244,7 +244,7 @@ func (c *Client) LinkCustomer( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.LinkCustomerToGiftCardResponse + var response *v2.LinkCustomerToGiftCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -267,9 +267,9 @@ func (c *Client) LinkCustomer( // Unlinks a customer from a gift card, which is also referred to as removing a card on file. func (c *Client) UnlinkCustomer( ctx context.Context, - request *squaregosdk.UnlinkCustomerFromGiftCardRequest, + request *v2.UnlinkCustomerFromGiftCardRequest, opts ...option.RequestOption, -) (*squaregosdk.UnlinkCustomerFromGiftCardResponse, error) { +) (*v2.UnlinkCustomerFromGiftCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -286,7 +286,7 @@ func (c *Client) UnlinkCustomer( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UnlinkCustomerFromGiftCardResponse + var response *v2.UnlinkCustomerFromGiftCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -309,9 +309,9 @@ func (c *Client) UnlinkCustomer( // Retrieves a gift card using the gift card ID. func (c *Client) Get( ctx context.Context, - request *squaregosdk.GiftCardsGetRequest, + request *v2.GiftCardsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetGiftCardResponse, error) { +) (*v2.GetGiftCardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -327,7 +327,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetGiftCardResponse + var response *v2.GetGiftCardResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/go.mod b/go.mod index 786198b..382430f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/square/square-go-sdk +module github.com/square/square-go-sdk/v2 go 1.18 diff --git a/internal/caller.go b/internal/caller.go index dabbbf0..bc16310 100644 --- a/internal/caller.go +++ b/internal/caller.go @@ -12,7 +12,7 @@ import ( "reflect" "strings" - "github.com/square/square-go-sdk/core" + "github.com/square/square-go-sdk/v2/core" ) const ( diff --git a/internal/caller_test.go b/internal/caller_test.go index 2febc6d..bc6bac9 100644 --- a/internal/caller_test.go +++ b/internal/caller_test.go @@ -13,7 +13,7 @@ import ( "strconv" "testing" - "github.com/square/square-go-sdk/core" + "github.com/square/square-go-sdk/v2/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/error_decoder.go b/internal/error_decoder.go index 83b1646..903c477 100644 --- a/internal/error_decoder.go +++ b/internal/error_decoder.go @@ -7,7 +7,7 @@ import ( "fmt" "io" - "github.com/square/square-go-sdk/core" + "github.com/square/square-go-sdk/v2/core" ) // ErrorDecoder decodes *http.Response errors and returns a diff --git a/internal/error_decoder_test.go b/internal/error_decoder_test.go index e1cfa33..f05b1f7 100644 --- a/internal/error_decoder_test.go +++ b/internal/error_decoder_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/square/square-go-sdk/core" + "github.com/square/square-go-sdk/v2/core" "github.com/stretchr/testify/assert" ) diff --git a/internal/pager.go b/internal/pager.go index 50cd7dd..1eaa87e 100644 --- a/internal/pager.go +++ b/internal/pager.go @@ -3,7 +3,7 @@ package internal import ( "context" - "github.com/square/square-go-sdk/core" + "github.com/square/square-go-sdk/v2/core" ) // PagerMode represents the different types of pagination modes. diff --git a/internal/retrier_test.go b/internal/retrier_test.go index 6ee2423..5f6a05d 100644 --- a/internal/retrier_test.go +++ b/internal/retrier_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/square/square-go-sdk/core" + "github.com/square/square-go-sdk/v2/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/inventory.go b/inventory.go index 5e27d97..4633ed0 100644 --- a/inventory.go +++ b/inventory.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type InventoryDeprecatedGetAdjustmentRequest struct { diff --git a/inventory/client.go b/inventory/client.go index 182530e..e51d16f 100644 --- a/inventory/client.go +++ b/inventory/client.go @@ -5,10 +5,10 @@ package inventory import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -43,9 +43,9 @@ func NewClient(opts ...option.RequestOption) *Client { // is updated to conform to the standard convention. func (c *Client) DeprecatedGetAdjustment( ctx context.Context, - request *squaregosdk.InventoryDeprecatedGetAdjustmentRequest, + request *v2.InventoryDeprecatedGetAdjustmentRequest, opts ...option.RequestOption, -) (*squaregosdk.GetInventoryAdjustmentResponse, error) { +) (*v2.GetInventoryAdjustmentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -61,7 +61,7 @@ func (c *Client) DeprecatedGetAdjustment( options.ToHeader(), ) - var response *squaregosdk.GetInventoryAdjustmentResponse + var response *v2.GetInventoryAdjustmentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -84,9 +84,9 @@ func (c *Client) DeprecatedGetAdjustment( // with the provided `adjustment_id`. func (c *Client) GetAdjustment( ctx context.Context, - request *squaregosdk.InventoryGetAdjustmentRequest, + request *v2.InventoryGetAdjustmentRequest, opts ...option.RequestOption, -) (*squaregosdk.GetInventoryAdjustmentResponse, error) { +) (*v2.GetInventoryAdjustmentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -102,7 +102,7 @@ func (c *Client) GetAdjustment( options.ToHeader(), ) - var response *squaregosdk.GetInventoryAdjustmentResponse + var response *v2.GetInventoryAdjustmentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -125,9 +125,9 @@ func (c *Client) GetAdjustment( // is updated to conform to the standard convention. func (c *Client) DeprecatedBatchChange( ctx context.Context, - request *squaregosdk.BatchChangeInventoryRequest, + request *v2.BatchChangeInventoryRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchChangeInventoryResponse, error) { +) (*v2.BatchChangeInventoryResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -141,7 +141,7 @@ func (c *Client) DeprecatedBatchChange( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchChangeInventoryResponse + var response *v2.BatchChangeInventoryResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -165,9 +165,9 @@ func (c *Client) DeprecatedBatchChange( // is updated to conform to the standard convention. func (c *Client) DeprecatedBatchGetChanges( ctx context.Context, - request *squaregosdk.BatchRetrieveInventoryChangesRequest, + request *v2.BatchRetrieveInventoryChangesRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetInventoryChangesResponse, error) { +) (*v2.BatchGetInventoryChangesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -181,7 +181,7 @@ func (c *Client) DeprecatedBatchGetChanges( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetInventoryChangesResponse + var response *v2.BatchGetInventoryChangesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -205,9 +205,9 @@ func (c *Client) DeprecatedBatchGetChanges( // is updated to conform to the standard convention. func (c *Client) DeprecatedBatchGetCounts( ctx context.Context, - request *squaregosdk.BatchGetInventoryCountsRequest, + request *v2.BatchGetInventoryCountsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetInventoryCountsResponse, error) { +) (*v2.BatchGetInventoryCountsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -221,7 +221,7 @@ func (c *Client) DeprecatedBatchGetCounts( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetInventoryCountsResponse + var response *v2.BatchGetInventoryCountsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -248,9 +248,9 @@ func (c *Client) DeprecatedBatchGetCounts( // On failure: returns a list of related errors. func (c *Client) BatchCreateChanges( ctx context.Context, - request *squaregosdk.BatchChangeInventoryRequest, + request *v2.BatchChangeInventoryRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchChangeInventoryResponse, error) { +) (*v2.BatchChangeInventoryResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -264,7 +264,7 @@ func (c *Client) BatchCreateChanges( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchChangeInventoryResponse + var response *v2.BatchChangeInventoryResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -294,9 +294,9 @@ func (c *Client) BatchCreateChanges( // that cannot be handled by other, simpler endpoints. func (c *Client) BatchGetChanges( ctx context.Context, - request *squaregosdk.BatchRetrieveInventoryChangesRequest, + request *v2.BatchRetrieveInventoryChangesRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetInventoryChangesResponse, error) { +) (*v2.BatchGetInventoryChangesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -310,7 +310,7 @@ func (c *Client) BatchGetChanges( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetInventoryChangesResponse + var response *v2.BatchGetInventoryChangesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -343,9 +343,9 @@ func (c *Client) BatchGetChanges( // in response to receiving a Webhook notification. func (c *Client) BatchGetCounts( ctx context.Context, - request *squaregosdk.BatchGetInventoryCountsRequest, + request *v2.BatchGetInventoryCountsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetInventoryCountsResponse, error) { +) (*v2.BatchGetInventoryCountsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -359,7 +359,7 @@ func (c *Client) BatchGetCounts( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetInventoryCountsResponse + var response *v2.BatchGetInventoryCountsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -383,9 +383,9 @@ func (c *Client) BatchGetCounts( // is updated to conform to the standard convention. func (c *Client) DeprecatedGetPhysicalCount( ctx context.Context, - request *squaregosdk.InventoryDeprecatedGetPhysicalCountRequest, + request *v2.InventoryDeprecatedGetPhysicalCountRequest, opts ...option.RequestOption, -) (*squaregosdk.GetInventoryPhysicalCountResponse, error) { +) (*v2.GetInventoryPhysicalCountResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -401,7 +401,7 @@ func (c *Client) DeprecatedGetPhysicalCount( options.ToHeader(), ) - var response *squaregosdk.GetInventoryPhysicalCountResponse + var response *v2.GetInventoryPhysicalCountResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -424,9 +424,9 @@ func (c *Client) DeprecatedGetPhysicalCount( // object with the provided `physical_count_id`. func (c *Client) GetPhysicalCount( ctx context.Context, - request *squaregosdk.InventoryGetPhysicalCountRequest, + request *v2.InventoryGetPhysicalCountRequest, opts ...option.RequestOption, -) (*squaregosdk.GetInventoryPhysicalCountResponse, error) { +) (*v2.GetInventoryPhysicalCountResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -442,7 +442,7 @@ func (c *Client) GetPhysicalCount( options.ToHeader(), ) - var response *squaregosdk.GetInventoryPhysicalCountResponse + var response *v2.GetInventoryPhysicalCountResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -465,9 +465,9 @@ func (c *Client) GetPhysicalCount( // with the provided `transfer_id`. func (c *Client) GetTransfer( ctx context.Context, - request *squaregosdk.InventoryGetTransferRequest, + request *v2.InventoryGetTransferRequest, opts ...option.RequestOption, -) (*squaregosdk.GetInventoryTransferResponse, error) { +) (*v2.GetInventoryTransferResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -483,7 +483,7 @@ func (c *Client) GetTransfer( options.ToHeader(), ) - var response *squaregosdk.GetInventoryTransferResponse + var response *v2.GetInventoryTransferResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -508,9 +508,9 @@ func (c *Client) GetTransfer( // For more sophisticated queries, use a batch endpoint. func (c *Client) Get( ctx context.Context, - request *squaregosdk.InventoryGetRequest, + request *v2.InventoryGetRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.InventoryCount], error) { +) (*core.Page[*v2.InventoryCount], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -549,10 +549,10 @@ func (c *Client) Get( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.GetInventoryCountResponse) *internal.PageResponse[*string, *squaregosdk.InventoryCount] { + readPageResponse := func(response *v2.GetInventoryCountResponse) *internal.PageResponse[*string, *v2.InventoryCount] { next := response.Cursor results := response.Counts - return &internal.PageResponse[*string, *squaregosdk.InventoryCount]{ + return &internal.PageResponse[*string, *v2.InventoryCount]{ Next: next, Results: results, } @@ -580,9 +580,9 @@ func (c *Client) Get( // sophisticated queries, use a batch endpoint. func (c *Client) Changes( ctx context.Context, - request *squaregosdk.InventoryChangesRequest, + request *v2.InventoryChangesRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.InventoryChange], error) { +) (*core.Page[*v2.InventoryChange], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -621,10 +621,10 @@ func (c *Client) Changes( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.GetInventoryChangesResponse) *internal.PageResponse[*string, *squaregosdk.InventoryChange] { + readPageResponse := func(response *v2.GetInventoryChangesResponse) *internal.PageResponse[*string, *v2.InventoryChange] { next := response.Cursor results := response.Changes - return &internal.PageResponse[*string, *squaregosdk.InventoryChange]{ + return &internal.PageResponse[*string, *v2.InventoryChange]{ Next: next, Results: results, } diff --git a/invoices.go b/invoices.go index be55497..e927a78 100644 --- a/invoices.go +++ b/invoices.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" io "io" ) diff --git a/invoices/client.go b/invoices/client.go index 100644a..7a1710b 100644 --- a/invoices/client.go +++ b/invoices/client.go @@ -5,10 +5,10 @@ package invoices import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -44,9 +44,9 @@ func NewClient(opts ...option.RequestOption) *Client { // use in a subsequent request to retrieve the next set of invoices. func (c *Client) List( ctx context.Context, - request *squaregosdk.InvoicesListRequest, + request *v2.InvoicesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Invoice], error) { +) (*core.Page[*v2.Invoice], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -82,10 +82,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListInvoicesResponse) *internal.PageResponse[*string, *squaregosdk.Invoice] { + readPageResponse := func(response *v2.ListInvoicesResponse) *internal.PageResponse[*string, *v2.Invoice] { next := response.Cursor results := response.Invoices - return &internal.PageResponse[*string, *squaregosdk.Invoice]{ + return &internal.PageResponse[*string, *v2.Invoice]{ Next: next, Results: results, } @@ -105,9 +105,9 @@ func (c *Client) List( // You must publish the invoice before Square can process it (send it to the customer's email address or charge the customer’s card on file). func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateInvoiceRequest, + request *v2.CreateInvoiceRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateInvoiceResponse, error) { +) (*v2.CreateInvoiceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -121,7 +121,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateInvoiceResponse + var response *v2.CreateInvoiceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -150,9 +150,9 @@ func (c *Client) Create( // that you use in a subsequent request to retrieve the next set of invoices. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchInvoicesRequest, + request *v2.SearchInvoicesRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchInvoicesResponse, error) { +) (*v2.SearchInvoicesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -166,7 +166,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchInvoicesResponse + var response *v2.SearchInvoicesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -189,9 +189,9 @@ func (c *Client) Search( // Retrieves an invoice by invoice ID. func (c *Client) Get( ctx context.Context, - request *squaregosdk.InvoicesGetRequest, + request *v2.InvoicesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetInvoiceResponse, error) { +) (*v2.GetInvoiceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -207,7 +207,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetInvoiceResponse + var response *v2.GetInvoiceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -232,9 +232,9 @@ func (c *Client) Get( // `order_id` or `location_id` field. func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdateInvoiceRequest, + request *v2.UpdateInvoiceRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateInvoiceResponse, error) { +) (*v2.UpdateInvoiceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -251,7 +251,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateInvoiceResponse + var response *v2.UpdateInvoiceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -276,9 +276,9 @@ func (c *Client) Update( // invoice (you cannot delete a published invoice, including one that is scheduled for processing). func (c *Client) Delete( ctx context.Context, - request *squaregosdk.InvoicesDeleteRequest, + request *v2.InvoicesDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteInvoiceResponse, error) { +) (*v2.DeleteInvoiceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -301,7 +301,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteInvoiceResponse + var response *v2.DeleteInvoiceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -328,9 +328,9 @@ func (c *Client) Delete( // in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state. func (c *Client) CreateInvoiceAttachment( ctx context.Context, - request *squaregosdk.CreateInvoiceAttachmentRequest, + request *v2.CreateInvoiceAttachmentRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateInvoiceAttachmentResponse, error) { +) (*v2.CreateInvoiceAttachmentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -361,7 +361,7 @@ func (c *Client) CreateInvoiceAttachment( } headers.Set("Content-Type", writer.ContentType()) - var response *squaregosdk.CreateInvoiceAttachmentResponse + var response *v2.CreateInvoiceAttachmentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -385,9 +385,9 @@ func (c *Client) CreateInvoiceAttachment( // from invoices in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state. func (c *Client) DeleteInvoiceAttachment( ctx context.Context, - request *squaregosdk.DeleteInvoiceAttachmentRequest, + request *v2.DeleteInvoiceAttachmentRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteInvoiceAttachmentResponse, error) { +) (*v2.DeleteInvoiceAttachmentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -404,7 +404,7 @@ func (c *Client) DeleteInvoiceAttachment( options.ToHeader(), ) - var response *squaregosdk.DeleteInvoiceAttachmentResponse + var response *v2.DeleteInvoiceAttachmentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -429,9 +429,9 @@ func (c *Client) DeleteInvoiceAttachment( // You cannot cancel an invoice in the `DRAFT` state or in a terminal state: `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`. func (c *Client) Cancel( ctx context.Context, - request *squaregosdk.CancelInvoiceRequest, + request *v2.CancelInvoiceRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelInvoiceResponse, error) { +) (*v2.CancelInvoiceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -448,7 +448,7 @@ func (c *Client) Cancel( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CancelInvoiceResponse + var response *v2.CancelInvoiceResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -482,11 +482,11 @@ func (c *Client) Cancel( // // In addition to the required `ORDERS_WRITE` and `INVOICES_WRITE` permissions, `CUSTOMERS_READ` // and `PAYMENTS_WRITE` are required when publishing invoices configured for card-on-file payments. -func (c *Client) Publisb( +func (c *Client) Publish( ctx context.Context, - request *squaregosdk.PublishInvoiceRequest, + request *v2.PublishInvoiceRequest, opts ...option.RequestOption, -) (*squaregosdk.PublishInvoiceResponse, error) { +) (*v2.PublishInvoiceResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -503,7 +503,7 @@ func (c *Client) Publisb( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.PublishInvoiceResponse + var response *v2.PublishInvoiceResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/labor.go b/labor.go deleted file mode 100644 index 1bbed36..0000000 --- a/labor.go +++ /dev/null @@ -1,155 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -package square - -import ( - json "encoding/json" - fmt "fmt" - internal "github.com/square/square-go-sdk/internal" -) - -type CreateBreakTypeRequest struct { - // A unique string value to ensure the idempotency of the operation. - IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` - // The `BreakType` to be created. - BreakType *BreakType `json:"break_type,omitempty" url:"-"` -} - -type LaborListRequest struct { - // Filter the returned `BreakType` results to only those that are associated with the - // specified location. - LocationID *string `json:"-" url:"location_id,omitempty"` - // The maximum number of `BreakType` results to return per page. The number can range between 1 - // and 200. The default is 200. - Limit *int `json:"-" url:"limit,omitempty"` - // A pointer to the next page of `BreakType` results to fetch. - Cursor *string `json:"-" url:"cursor,omitempty"` -} - -// The response to the request to create a `BreakType`. The response contains -// the created `BreakType` object and might contain a set of `Error` objects if -// the request resulted in errors. -type CreateBreakTypeResponse struct { - // The `BreakType` that was created by the request. - BreakType *BreakType `json:"break_type,omitempty" url:"break_type,omitempty"` - // Any errors that occurred during the request. - Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` - - extraProperties map[string]interface{} - rawJSON json.RawMessage -} - -func (c *CreateBreakTypeResponse) GetBreakType() *BreakType { - if c == nil { - return nil - } - return c.BreakType -} - -func (c *CreateBreakTypeResponse) GetErrors() []*Error { - if c == nil { - return nil - } - return c.Errors -} - -func (c *CreateBreakTypeResponse) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *CreateBreakTypeResponse) UnmarshalJSON(data []byte) error { - type unmarshaler CreateBreakTypeResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = CreateBreakTypeResponse(value) - extraProperties, err := internal.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - c.rawJSON = json.RawMessage(data) - return nil -} - -func (c *CreateBreakTypeResponse) String() string { - if len(c.rawJSON) > 0 { - if value, err := internal.StringifyJSON(c.rawJSON); err == nil { - return value - } - } - if value, err := internal.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - -// The response to a request for a set of `BreakType` objects. The response contains -// the requested `BreakType` objects and might contain a set of `Error` objects if -// the request resulted in errors. -type ListBreakTypesResponse struct { - // A page of `BreakType` results. - BreakTypes []*BreakType `json:"break_types,omitempty" url:"break_types,omitempty"` - // The value supplied in the subsequent request to fetch the next page - // of `BreakType` results. - Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"` - // Any errors that occurred during the request. - Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` - - extraProperties map[string]interface{} - rawJSON json.RawMessage -} - -func (l *ListBreakTypesResponse) GetBreakTypes() []*BreakType { - if l == nil { - return nil - } - return l.BreakTypes -} - -func (l *ListBreakTypesResponse) GetCursor() *string { - if l == nil { - return nil - } - return l.Cursor -} - -func (l *ListBreakTypesResponse) GetErrors() []*Error { - if l == nil { - return nil - } - return l.Errors -} - -func (l *ListBreakTypesResponse) GetExtraProperties() map[string]interface{} { - return l.extraProperties -} - -func (l *ListBreakTypesResponse) UnmarshalJSON(data []byte) error { - type unmarshaler ListBreakTypesResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *l = ListBreakTypesResponse(value) - extraProperties, err := internal.ExtractExtraProperties(data, *l) - if err != nil { - return err - } - l.extraProperties = extraProperties - l.rawJSON = json.RawMessage(data) - return nil -} - -func (l *ListBreakTypesResponse) String() string { - if len(l.rawJSON) > 0 { - if value, err := internal.StringifyJSON(l.rawJSON); err == nil { - return value - } - } - if value, err := internal.StringifyJSON(l); err == nil { - return value - } - return fmt.Sprintf("%#v", l) -} diff --git a/labor/break_types.go b/labor/break_types.go index d2cdcc7..f9339a1 100644 --- a/labor/break_types.go +++ b/labor/break_types.go @@ -3,9 +3,16 @@ package labor import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) +type CreateBreakTypeRequest struct { + // A unique string value to ensure the idempotency of the operation. + IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` + // The `BreakType` to be created. + BreakType *v2.BreakType `json:"break_type,omitempty" url:"-"` +} + type BreakTypesDeleteRequest struct { // The UUID for the `BreakType` being deleted. ID string `json:"-" url:"-"` @@ -16,9 +23,20 @@ type BreakTypesGetRequest struct { ID string `json:"-" url:"-"` } +type BreakTypesListRequest struct { + // Filter the returned `BreakType` results to only those that are associated with the + // specified location. + LocationID *string `json:"-" url:"location_id,omitempty"` + // The maximum number of `BreakType` results to return per page. The number can range between 1 + // and 200. The default is 200. + Limit *int `json:"-" url:"limit,omitempty"` + // A pointer to the next page of `BreakType` results to fetch. + Cursor *string `json:"-" url:"cursor,omitempty"` +} + type UpdateBreakTypeRequest struct { // The UUID for the `BreakType` being updated. ID string `json:"-" url:"-"` // The updated `BreakType`. - BreakType *squaregosdk.BreakType `json:"break_type,omitempty" url:"-"` + BreakType *v2.BreakType `json:"break_type,omitempty" url:"-"` } diff --git a/labor/breaktypes/client.go b/labor/breaktypes/client.go index 4cd46dd..887b6c1 100644 --- a/labor/breaktypes/client.go +++ b/labor/breaktypes/client.go @@ -4,11 +4,12 @@ package breaktypes import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - labor "github.com/square/square-go-sdk/labor" - option "github.com/square/square-go-sdk/option" + fmt "fmt" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + labor "github.com/square/square-go-sdk/v2/labor" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -39,12 +40,121 @@ func NewClient(opts ...option.RequestOption) *Client { } } +// Returns a paginated list of `BreakType` instances for a business. +func (c *Client) List( + ctx context.Context, + request *labor.BreakTypesListRequest, + opts ...option.RequestOption, +) (*core.Page[*v2.BreakType], error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := baseURL + "/v2/labor/break-types" + queryParams, err := internal.QueryValues(request) + if err != nil { + return nil, err + } + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + prepareCall := func(pageRequest *internal.PageRequest[*string]) *internal.CallParams { + if pageRequest.Cursor != nil { + queryParams.Set("cursor", fmt.Sprintf("%v", *pageRequest.Cursor)) + } + nextURL := endpointURL + if len(queryParams) > 0 { + nextURL += "?" + queryParams.Encode() + } + return &internal.CallParams{ + URL: nextURL, + Method: http.MethodGet, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: pageRequest.Response, + } + } + readPageResponse := func(response *v2.ListBreakTypesResponse) *internal.PageResponse[*string, *v2.BreakType] { + next := response.Cursor + results := response.BreakTypes + return &internal.PageResponse[*string, *v2.BreakType]{ + Next: next, + Results: results, + } + } + pager := internal.NewCursorPager( + c.caller, + prepareCall, + readPageResponse, + ) + return pager.GetPage(ctx, request.Cursor) +} + +// Creates a new `BreakType`. +// +// A `BreakType` is a template for creating `Break` objects. +// You must provide the following values in your request to this +// endpoint: +// +// - `location_id` +// - `break_name` +// - `expected_duration` +// - `is_paid` +// +// You can only have three `BreakType` instances per location. If you attempt to add a fourth +// `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of 3 breaks per location." +// is returned. +func (c *Client) Create( + ctx context.Context, + request *labor.CreateBreakTypeRequest, + opts ...option.RequestOption, +) (*v2.CreateBreakTypeResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := baseURL + "/v2/labor/break-types" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + + var response *v2.CreateBreakTypeResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} + // Returns a single `BreakType` specified by `id`. func (c *Client) Get( ctx context.Context, request *labor.BreakTypesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetBreakTypeResponse, error) { +) (*v2.GetBreakTypeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -60,7 +170,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetBreakTypeResponse + var response *v2.GetBreakTypeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -84,7 +194,7 @@ func (c *Client) Update( ctx context.Context, request *labor.UpdateBreakTypeRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateBreakTypeResponse, error) { +) (*v2.UpdateBreakTypeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -101,7 +211,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateBreakTypeResponse + var response *v2.UpdateBreakTypeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -128,7 +238,7 @@ func (c *Client) Delete( ctx context.Context, request *labor.BreakTypesDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteBreakTypeResponse, error) { +) (*v2.DeleteBreakTypeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -144,7 +254,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteBreakTypeResponse + var response *v2.DeleteBreakTypeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/labor/client/client.go b/labor/client/client.go index 25226e8..f73d9e9 100644 --- a/labor/client/client.go +++ b/labor/client/client.go @@ -3,17 +3,14 @@ package client import ( - context "context" - fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - breaktypes "github.com/square/square-go-sdk/labor/breaktypes" - employeewages "github.com/square/square-go-sdk/labor/employeewages" - shifts "github.com/square/square-go-sdk/labor/shifts" - teammemberwages "github.com/square/square-go-sdk/labor/teammemberwages" - workweekconfigs "github.com/square/square-go-sdk/labor/workweekconfigs" - option "github.com/square/square-go-sdk/option" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + breaktypes "github.com/square/square-go-sdk/v2/labor/breaktypes" + employeewages "github.com/square/square-go-sdk/v2/labor/employeewages" + shifts "github.com/square/square-go-sdk/v2/labor/shifts" + teammemberwages "github.com/square/square-go-sdk/v2/labor/teammemberwages" + workweekconfigs "github.com/square/square-go-sdk/v2/labor/workweekconfigs" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -54,112 +51,3 @@ func NewClient(opts ...option.RequestOption) *Client { WorkweekConfigs: workweekconfigs.NewClient(opts...), } } - -// Returns a paginated list of `BreakType` instances for a business. -func (c *Client) List( - ctx context.Context, - request *squaregosdk.LaborListRequest, - opts ...option.RequestOption, -) (*core.Page[*squaregosdk.BreakType], error) { - options := core.NewRequestOptions(opts...) - baseURL := internal.ResolveBaseURL( - options.BaseURL, - c.baseURL, - "https://connect.squareup.com", - ) - endpointURL := baseURL + "/v2/labor/break-types" - queryParams, err := internal.QueryValues(request) - if err != nil { - return nil, err - } - headers := internal.MergeHeaders( - c.header.Clone(), - options.ToHeader(), - ) - - prepareCall := func(pageRequest *internal.PageRequest[*string]) *internal.CallParams { - if pageRequest.Cursor != nil { - queryParams.Set("cursor", fmt.Sprintf("%v", *pageRequest.Cursor)) - } - nextURL := endpointURL - if len(queryParams) > 0 { - nextURL += "?" + queryParams.Encode() - } - return &internal.CallParams{ - URL: nextURL, - Method: http.MethodGet, - Headers: headers, - MaxAttempts: options.MaxAttempts, - BodyProperties: options.BodyProperties, - QueryParameters: options.QueryParameters, - Client: options.HTTPClient, - Response: pageRequest.Response, - } - } - readPageResponse := func(response *squaregosdk.ListBreakTypesResponse) *internal.PageResponse[*string, *squaregosdk.BreakType] { - next := response.Cursor - results := response.BreakTypes - return &internal.PageResponse[*string, *squaregosdk.BreakType]{ - Next: next, - Results: results, - } - } - pager := internal.NewCursorPager( - c.caller, - prepareCall, - readPageResponse, - ) - return pager.GetPage(ctx, request.Cursor) -} - -// Creates a new `BreakType`. -// -// A `BreakType` is a template for creating `Break` objects. -// You must provide the following values in your request to this -// endpoint: -// -// - `location_id` -// - `break_name` -// - `expected_duration` -// - `is_paid` -// -// You can only have three `BreakType` instances per location. If you attempt to add a fourth -// `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of 3 breaks per location." -// is returned. -func (c *Client) Create( - ctx context.Context, - request *squaregosdk.CreateBreakTypeRequest, - opts ...option.RequestOption, -) (*squaregosdk.CreateBreakTypeResponse, error) { - options := core.NewRequestOptions(opts...) - baseURL := internal.ResolveBaseURL( - options.BaseURL, - c.baseURL, - "https://connect.squareup.com", - ) - endpointURL := baseURL + "/v2/labor/break-types" - headers := internal.MergeHeaders( - c.header.Clone(), - options.ToHeader(), - ) - headers.Set("Content-Type", "application/json") - - var response *squaregosdk.CreateBreakTypeResponse - if err := c.caller.Call( - ctx, - &internal.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - Headers: headers, - MaxAttempts: options.MaxAttempts, - BodyProperties: options.BodyProperties, - QueryParameters: options.QueryParameters, - Client: options.HTTPClient, - Request: request, - Response: &response, - }, - ); err != nil { - return nil, err - } - return response, nil -} diff --git a/labor/employeewages/client.go b/labor/employeewages/client.go index 8965ab9..c8e742f 100644 --- a/labor/employeewages/client.go +++ b/labor/employeewages/client.go @@ -5,11 +5,11 @@ package employeewages import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - labor "github.com/square/square-go-sdk/labor" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + labor "github.com/square/square-go-sdk/v2/labor" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *labor.EmployeeWagesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.EmployeeWage], error) { +) (*core.Page[*v2.EmployeeWage], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListEmployeeWagesResponse) *internal.PageResponse[*string, *squaregosdk.EmployeeWage] { + readPageResponse := func(response *v2.ListEmployeeWagesResponse) *internal.PageResponse[*string, *v2.EmployeeWage] { next := response.Cursor results := response.EmployeeWages - return &internal.PageResponse[*string, *squaregosdk.EmployeeWage]{ + return &internal.PageResponse[*string, *v2.EmployeeWage]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Get( ctx context.Context, request *labor.EmployeeWagesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetEmployeeWageResponse, error) { +) (*v2.GetEmployeeWageResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -118,7 +118,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetEmployeeWageResponse + var response *v2.GetEmployeeWageResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/labor/shifts.go b/labor/shifts.go index ebd792f..1bdbf62 100644 --- a/labor/shifts.go +++ b/labor/shifts.go @@ -3,14 +3,14 @@ package labor import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateShiftRequest struct { // A unique string value to ensure the idempotency of the operation. IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` // The `Shift` to be created. - Shift *squaregosdk.Shift `json:"shift,omitempty" url:"-"` + Shift *v2.Shift `json:"shift,omitempty" url:"-"` } type ShiftsDeleteRequest struct { @@ -25,7 +25,7 @@ type ShiftsGetRequest struct { type SearchShiftsRequest struct { // Query filters. - Query *squaregosdk.ShiftQuery `json:"query,omitempty" url:"-"` + Query *v2.ShiftQuery `json:"query,omitempty" url:"-"` // The number of resources in a page (200 by default). Limit *int `json:"limit,omitempty" url:"-"` // An opaque cursor for fetching the next page. @@ -36,5 +36,5 @@ type UpdateShiftRequest struct { // The ID of the object being updated. ID string `json:"-" url:"-"` // The updated `Shift` object. - Shift *squaregosdk.Shift `json:"shift,omitempty" url:"-"` + Shift *v2.Shift `json:"shift,omitempty" url:"-"` } diff --git a/labor/shifts/client.go b/labor/shifts/client.go index 4a26785..dbd61e3 100644 --- a/labor/shifts/client.go +++ b/labor/shifts/client.go @@ -4,11 +4,11 @@ package shifts import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - labor "github.com/square/square-go-sdk/labor" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + labor "github.com/square/square-go-sdk/v2/labor" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -61,7 +61,7 @@ func (c *Client) Create( ctx context.Context, request *labor.CreateShiftRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateShiftResponse, error) { +) (*v2.CreateShiftResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -75,7 +75,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateShiftResponse + var response *v2.CreateShiftResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -113,7 +113,7 @@ func (c *Client) Search( ctx context.Context, request *labor.SearchShiftsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchShiftsResponse, error) { +) (*v2.SearchShiftsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -127,7 +127,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchShiftsResponse + var response *v2.SearchShiftsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -152,7 +152,7 @@ func (c *Client) Get( ctx context.Context, request *labor.ShiftsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetShiftResponse, error) { +) (*v2.GetShiftResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -168,7 +168,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetShiftResponse + var response *v2.GetShiftResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -198,7 +198,7 @@ func (c *Client) Update( ctx context.Context, request *labor.UpdateShiftRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateShiftResponse, error) { +) (*v2.UpdateShiftResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -215,7 +215,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateShiftResponse + var response *v2.UpdateShiftResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -240,7 +240,7 @@ func (c *Client) Delete( ctx context.Context, request *labor.ShiftsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteShiftResponse, error) { +) (*v2.DeleteShiftResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -256,7 +256,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteShiftResponse + var response *v2.DeleteShiftResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/labor/teammemberwages/client.go b/labor/teammemberwages/client.go index e7272bd..fd7db90 100644 --- a/labor/teammemberwages/client.go +++ b/labor/teammemberwages/client.go @@ -5,11 +5,11 @@ package teammemberwages import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - labor "github.com/square/square-go-sdk/labor" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + labor "github.com/square/square-go-sdk/v2/labor" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *labor.TeamMemberWagesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.TeamMemberWage], error) { +) (*core.Page[*v2.TeamMemberWage], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListTeamMemberWagesResponse) *internal.PageResponse[*string, *squaregosdk.TeamMemberWage] { + readPageResponse := func(response *v2.ListTeamMemberWagesResponse) *internal.PageResponse[*string, *v2.TeamMemberWage] { next := response.Cursor results := response.TeamMemberWages - return &internal.PageResponse[*string, *squaregosdk.TeamMemberWage]{ + return &internal.PageResponse[*string, *v2.TeamMemberWage]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Get( ctx context.Context, request *labor.TeamMemberWagesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTeamMemberWageResponse, error) { +) (*v2.GetTeamMemberWageResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -118,7 +118,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTeamMemberWageResponse + var response *v2.GetTeamMemberWageResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/labor/workweek_configs.go b/labor/workweek_configs.go index e6bb2db..8ac4e9e 100644 --- a/labor/workweek_configs.go +++ b/labor/workweek_configs.go @@ -3,14 +3,14 @@ package labor import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type UpdateWorkweekConfigRequest struct { // The UUID for the `WorkweekConfig` object being updated. ID string `json:"-" url:"-"` // The updated `WorkweekConfig` object. - WorkweekConfig *squaregosdk.WorkweekConfig `json:"workweek_config,omitempty" url:"-"` + WorkweekConfig *v2.WorkweekConfig `json:"workweek_config,omitempty" url:"-"` } type WorkweekConfigsListRequest struct { diff --git a/labor/workweekconfigs/client.go b/labor/workweekconfigs/client.go index 6a5591f..319e55a 100644 --- a/labor/workweekconfigs/client.go +++ b/labor/workweekconfigs/client.go @@ -5,11 +5,11 @@ package workweekconfigs import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - labor "github.com/square/square-go-sdk/labor" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + labor "github.com/square/square-go-sdk/v2/labor" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *labor.WorkweekConfigsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.WorkweekConfig], error) { +) (*core.Page[*v2.WorkweekConfig], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListWorkweekConfigsResponse) *internal.PageResponse[*string, *squaregosdk.WorkweekConfig] { + readPageResponse := func(response *v2.ListWorkweekConfigsResponse) *internal.PageResponse[*string, *v2.WorkweekConfig] { next := response.Cursor results := response.WorkweekConfigs - return &internal.PageResponse[*string, *squaregosdk.WorkweekConfig]{ + return &internal.PageResponse[*string, *v2.WorkweekConfig]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Get( ctx context.Context, request *labor.UpdateWorkweekConfigRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateWorkweekConfigResponse, error) { +) (*v2.UpdateWorkweekConfigResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -119,7 +119,7 @@ func (c *Client) Get( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateWorkweekConfigResponse + var response *v2.UpdateWorkweekConfigResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/locations.go b/locations.go index aa1851b..b2219b2 100644 --- a/locations.go +++ b/locations.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type CreateCheckoutRequest struct { diff --git a/locations/client/client.go b/locations/client/client.go index 25d0c89..f6d5e25 100644 --- a/locations/client/client.go +++ b/locations/client/client.go @@ -4,13 +4,13 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - customattributedefinitions "github.com/square/square-go-sdk/locations/customattributedefinitions" - customattributes "github.com/square/square-go-sdk/locations/customattributes" - transactions "github.com/square/square-go-sdk/locations/transactions" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + customattributedefinitions "github.com/square/square-go-sdk/v2/locations/customattributedefinitions" + customattributes "github.com/square/square-go-sdk/v2/locations/customattributes" + transactions "github.com/square/square-go-sdk/v2/locations/transactions" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -53,7 +53,7 @@ func NewClient(opts ...option.RequestOption) *Client { func (c *Client) List( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.ListLocationsResponse, error) { +) (*v2.ListLocationsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -66,7 +66,7 @@ func (c *Client) List( options.ToHeader(), ) - var response *squaregosdk.ListLocationsResponse + var response *v2.ListLocationsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -94,9 +94,9 @@ func (c *Client) List( // each location has a sensible and unique name. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateLocationRequest, + request *v2.CreateLocationRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateLocationResponse, error) { +) (*v2.CreateLocationResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -110,7 +110,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateLocationResponse + var response *v2.CreateLocationResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -134,9 +134,9 @@ func (c *Client) Create( // as the location ID to retrieve details of the [main location](https://developer.squareup.com/docs/locations-api#about-the-main-location). func (c *Client) Get( ctx context.Context, - request *squaregosdk.LocationsGetRequest, + request *v2.LocationsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetLocationResponse, error) { +) (*v2.GetLocationResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -152,7 +152,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetLocationResponse + var response *v2.GetLocationResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -174,9 +174,9 @@ func (c *Client) Get( // Updates a [location](https://developer.squareup.com/docs/locations-api). func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdateLocationRequest, + request *v2.UpdateLocationRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateLocationResponse, error) { +) (*v2.UpdateLocationResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -193,7 +193,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateLocationResponse + var response *v2.UpdateLocationResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -221,9 +221,9 @@ func (c *Client) Update( // For more information, see [Checkout API highlights](https://developer.squareup.com/docs/checkout-api#checkout-api-highlights). func (c *Client) Checkouts( ctx context.Context, - request *squaregosdk.CreateCheckoutRequest, + request *v2.CreateCheckoutRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateCheckoutResponse, error) { +) (*v2.CreateCheckoutResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -240,7 +240,7 @@ func (c *Client) Checkouts( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateCheckoutResponse + var response *v2.CreateCheckoutResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/locations/custom_attribute_definitions.go b/locations/custom_attribute_definitions.go index 76c689c..fbf9176 100644 --- a/locations/custom_attribute_definitions.go +++ b/locations/custom_attribute_definitions.go @@ -3,7 +3,7 @@ package locations import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateLocationCustomAttributeDefinitionRequest struct { @@ -12,12 +12,17 @@ type CreateLocationCustomAttributeDefinitionRequest struct { // definition hosted on the Square CDN. For more information, including supported values and constraints, see // [Supported data types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). // - `name` is required unless `visibility` is set to `VISIBILITY_HIDDEN`. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` } +type CustomAttributeDefinitionsDeleteRequest struct { + // The key of the custom attribute definition to delete. + Key string `json:"-" url:"-"` +} + type CustomAttributeDefinitionsGetRequest struct { // The key of the custom attribute definition to retrieve. If the requesting application // is not the definition owner, you must use the qualified key. @@ -31,7 +36,7 @@ type CustomAttributeDefinitionsGetRequest struct { type CustomAttributeDefinitionsListRequest struct { // Filters the `CustomAttributeDefinition` results by their `visibility` values. - VisibilityFilter *squaregosdk.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` + VisibilityFilter *v2.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` // The maximum number of results to return in a single paged response. This limit is advisory. // The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100. // The default value is 20. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). @@ -41,3 +46,26 @@ type CustomAttributeDefinitionsListRequest struct { // For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). Cursor *string `json:"-" url:"cursor,omitempty"` } + +type UpdateLocationCustomAttributeDefinitionRequest struct { + // The key of the custom attribute definition to update. + Key string `json:"-" url:"-"` + // The custom attribute definition that contains the fields to update. This endpoint + // supports sparse updates, so only new or changed fields need to be included in the request. + // Only the following fields can be updated: + // - `name` + // - `description` + // - `visibility` + // - `schema` for a `Selection` data type. Only changes to the named options or the maximum number of allowed + // selections are supported. + // + // For more information, see + // [Update a location custom attribute definition](https://developer.squareup.com/docs/location-custom-attributes-api/custom-attribute-definitions#update-custom-attribute-definition). + // To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + // control, specify the current version of the custom attribute definition. + // If this is not important for your application, `version` can be set to -1. + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + // A unique identifier for this request, used to ensure idempotency. For more information, + // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` +} diff --git a/locations/custom_attributes.go b/locations/custom_attributes.go index 9898ae0..1e1577e 100644 --- a/locations/custom_attributes.go +++ b/locations/custom_attributes.go @@ -3,20 +3,20 @@ package locations import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type BulkDeleteLocationCustomAttributesRequest struct { // The data used to update the `CustomAttribute` objects. // The keys must be unique and are used to map to the corresponding response. - Values map[string]*squaregosdk.BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest `json:"values,omitempty" url:"-"` + Values map[string]*v2.BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest `json:"values,omitempty" url:"-"` } type BulkUpsertLocationCustomAttributesRequest struct { // A map containing 1 to 25 individual upsert requests. For each request, provide an // arbitrary ID that is unique for this `BulkUpsertLocationCustomAttributes` request and the // information needed to create or update a custom attribute. - Values map[string]*squaregosdk.BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` + Values map[string]*v2.BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` } type CustomAttributesDeleteRequest struct { @@ -50,7 +50,7 @@ type CustomAttributesListRequest struct { // The ID of the target [location](entity:Location). LocationID string `json:"-" url:"-"` // Filters the `CustomAttributeDefinition` results by their `visibility` values. - VisibilityFilter *squaregosdk.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` + VisibilityFilter *v2.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` // The maximum number of results to return in a single paged response. This limit is advisory. // The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100. // The default value is 20. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). @@ -65,29 +65,6 @@ type CustomAttributesListRequest struct { WithDefinitions *bool `json:"-" url:"with_definitions,omitempty"` } -type UpdateLocationCustomAttributeDefinitionRequest struct { - // The key of the custom attribute definition to update. - Key string `json:"-" url:"-"` - // The custom attribute definition that contains the fields to update. This endpoint - // supports sparse updates, so only new or changed fields need to be included in the request. - // Only the following fields can be updated: - // - `name` - // - `description` - // - `visibility` - // - `schema` for a `Selection` data type. Only changes to the named options or the maximum number of allowed - // selections are supported. - // - // For more information, see - // [Update a location custom attribute definition](https://developer.squareup.com/docs/location-custom-attributes-api/custom-attribute-definitions#update-custom-attribute-definition). - // To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) - // control, specify the current version of the custom attribute definition. - // If this is not important for your application, `version` can be set to -1. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` - // A unique identifier for this request, used to ensure idempotency. For more information, - // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). - IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` -} - type UpsertLocationCustomAttributeRequest struct { // The ID of the target [location](entity:Location). LocationID string `json:"-" url:"-"` @@ -101,7 +78,7 @@ type UpsertLocationCustomAttributeRequest struct { // - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // control for an update operation, include the current version of the custom attribute. // If this is not important for your application, version can be set to -1. - CustomAttribute *squaregosdk.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` + CustomAttribute *v2.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/locations/customattributedefinitions/client.go b/locations/customattributedefinitions/client.go index 63b09ba..e5aad3c 100644 --- a/locations/customattributedefinitions/client.go +++ b/locations/customattributedefinitions/client.go @@ -5,11 +5,11 @@ package customattributedefinitions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - locations "github.com/square/square-go-sdk/locations" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + locations "github.com/square/square-go-sdk/v2/locations" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -48,7 +48,7 @@ func (c *Client) List( ctx context.Context, request *locations.CustomAttributeDefinitionsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttributeDefinition], error) { +) (*core.Page[*v2.CustomAttributeDefinition], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -84,10 +84,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListLocationCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition] { + readPageResponse := func(response *v2.ListLocationCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *v2.CustomAttributeDefinition] { next := response.Cursor results := response.CustomAttributeDefinitions - return &internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition]{ + return &internal.PageResponse[*string, *v2.CustomAttributeDefinition]{ Next: next, Results: results, } @@ -111,7 +111,7 @@ func (c *Client) Create( ctx context.Context, request *locations.CreateLocationCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateLocationCustomAttributeDefinitionResponse, error) { +) (*v2.CreateLocationCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -125,7 +125,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateLocationCustomAttributeDefinitionResponse + var response *v2.CreateLocationCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -152,7 +152,7 @@ func (c *Client) Get( ctx context.Context, request *locations.CustomAttributeDefinitionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveLocationCustomAttributeDefinitionResponse, error) { +) (*v2.RetrieveLocationCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -175,7 +175,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveLocationCustomAttributeDefinitionResponse + var response *v2.RetrieveLocationCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -193,3 +193,91 @@ func (c *Client) Get( } return response, nil } + +// Updates a location-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account. +// Use this endpoint to update the following fields: `name`, `description`, `visibility`, or the +// `schema` for a `Selection` data type. +// Only the definition owner can update a custom attribute definition. +func (c *Client) Update( + ctx context.Context, + request *locations.UpdateLocationCustomAttributeDefinitionRequest, + opts ...option.RequestOption, +) (*v2.UpdateLocationCustomAttributeDefinitionResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := internal.EncodeURL( + baseURL+"/v2/locations/custom-attribute-definitions/%v", + request.Key, + ) + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + + var response *v2.UpdateLocationCustomAttributeDefinitionResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPut, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} + +// Deletes a location-related [custom attribute definition](entity:CustomAttributeDefinition) from a Square seller account. +// Deleting a custom attribute definition also deletes the corresponding custom attribute from +// all locations. +// Only the definition owner can delete a custom attribute definition. +func (c *Client) Delete( + ctx context.Context, + request *locations.CustomAttributeDefinitionsDeleteRequest, + opts ...option.RequestOption, +) (*v2.DeleteLocationCustomAttributeDefinitionResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := internal.EncodeURL( + baseURL+"/v2/locations/custom-attribute-definitions/%v", + request.Key, + ) + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + var response *v2.DeleteLocationCustomAttributeDefinitionResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodDelete, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} diff --git a/locations/customattributes/client.go b/locations/customattributes/client.go index b464e17..1d15812 100644 --- a/locations/customattributes/client.go +++ b/locations/customattributes/client.go @@ -5,11 +5,11 @@ package customattributes import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - locations "github.com/square/square-go-sdk/locations" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + locations "github.com/square/square-go-sdk/v2/locations" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -40,94 +40,6 @@ func NewClient(opts ...option.RequestOption) *Client { } } -// Updates a location-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account. -// Use this endpoint to update the following fields: `name`, `description`, `visibility`, or the -// `schema` for a `Selection` data type. -// Only the definition owner can update a custom attribute definition. -func (c *Client) Update( - ctx context.Context, - request *locations.UpdateLocationCustomAttributeDefinitionRequest, - opts ...option.RequestOption, -) (*squaregosdk.UpdateLocationCustomAttributeDefinitionResponse, error) { - options := core.NewRequestOptions(opts...) - baseURL := internal.ResolveBaseURL( - options.BaseURL, - c.baseURL, - "https://connect.squareup.com", - ) - endpointURL := internal.EncodeURL( - baseURL+"/v2/locations/custom-attribute-definitions/%v", - request.Key, - ) - headers := internal.MergeHeaders( - c.header.Clone(), - options.ToHeader(), - ) - headers.Set("Content-Type", "application/json") - - var response *squaregosdk.UpdateLocationCustomAttributeDefinitionResponse - if err := c.caller.Call( - ctx, - &internal.CallParams{ - URL: endpointURL, - Method: http.MethodPut, - Headers: headers, - MaxAttempts: options.MaxAttempts, - BodyProperties: options.BodyProperties, - QueryParameters: options.QueryParameters, - Client: options.HTTPClient, - Request: request, - Response: &response, - }, - ); err != nil { - return nil, err - } - return response, nil -} - -// Deletes a [custom attribute](entity:CustomAttribute) associated with a location. -// To delete a custom attribute owned by another application, the `visibility` setting must be -// `VISIBILITY_READ_WRITE_VALUES`. -func (c *Client) Delete( - ctx context.Context, - request *locations.CustomAttributesDeleteRequest, - opts ...option.RequestOption, -) (*squaregosdk.DeleteLocationCustomAttributeResponse, error) { - options := core.NewRequestOptions(opts...) - baseURL := internal.ResolveBaseURL( - options.BaseURL, - c.baseURL, - "https://connect.squareup.com", - ) - endpointURL := internal.EncodeURL( - baseURL+"/v2/locations/%v/custom-attributes/%v", - request.LocationID, - request.Key, - ) - headers := internal.MergeHeaders( - c.header.Clone(), - options.ToHeader(), - ) - - var response *squaregosdk.DeleteLocationCustomAttributeResponse - if err := c.caller.Call( - ctx, - &internal.CallParams{ - URL: endpointURL, - Method: http.MethodDelete, - Headers: headers, - MaxAttempts: options.MaxAttempts, - BodyProperties: options.BodyProperties, - QueryParameters: options.QueryParameters, - Client: options.HTTPClient, - Response: &response, - }, - ); err != nil { - return nil, err - } - return response, nil -} - // Deletes [custom attributes](entity:CustomAttribute) for locations as a bulk operation. // To delete a custom attribute owned by another application, the `visibility` setting must be // `VISIBILITY_READ_WRITE_VALUES`. @@ -135,7 +47,7 @@ func (c *Client) BatchDelete( ctx context.Context, request *locations.BulkDeleteLocationCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkDeleteLocationCustomAttributesResponse, error) { +) (*v2.BulkDeleteLocationCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -149,7 +61,7 @@ func (c *Client) BatchDelete( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkDeleteLocationCustomAttributesResponse + var response *v2.BulkDeleteLocationCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -183,7 +95,7 @@ func (c *Client) BatchUpsert( ctx context.Context, request *locations.BulkUpsertLocationCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkUpsertLocationCustomAttributesResponse, error) { +) (*v2.BulkUpsertLocationCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -197,7 +109,7 @@ func (c *Client) BatchUpsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkUpsertLocationCustomAttributesResponse + var response *v2.BulkUpsertLocationCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -227,7 +139,7 @@ func (c *Client) List( ctx context.Context, request *locations.CustomAttributesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttribute], error) { +) (*core.Page[*v2.CustomAttribute], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -266,10 +178,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListLocationCustomAttributesResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttribute] { + readPageResponse := func(response *v2.ListLocationCustomAttributesResponse) *internal.PageResponse[*string, *v2.CustomAttribute] { next := response.Cursor results := response.CustomAttributes - return &internal.PageResponse[*string, *squaregosdk.CustomAttribute]{ + return &internal.PageResponse[*string, *v2.CustomAttribute]{ Next: next, Results: results, } @@ -291,7 +203,7 @@ func (c *Client) Get( ctx context.Context, request *locations.CustomAttributesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveLocationCustomAttributeResponse, error) { +) (*v2.RetrieveLocationCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -315,7 +227,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveLocationCustomAttributeResponse + var response *v2.RetrieveLocationCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -344,7 +256,7 @@ func (c *Client) Upsert( ctx context.Context, request *locations.UpsertLocationCustomAttributeRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertLocationCustomAttributeResponse, error) { +) (*v2.UpsertLocationCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -362,7 +274,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertLocationCustomAttributeResponse + var response *v2.UpsertLocationCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -381,3 +293,46 @@ func (c *Client) Upsert( } return response, nil } + +// Deletes a [custom attribute](entity:CustomAttribute) associated with a location. +// To delete a custom attribute owned by another application, the `visibility` setting must be +// `VISIBILITY_READ_WRITE_VALUES`. +func (c *Client) Delete( + ctx context.Context, + request *locations.CustomAttributesDeleteRequest, + opts ...option.RequestOption, +) (*v2.DeleteLocationCustomAttributeResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := internal.EncodeURL( + baseURL+"/v2/locations/%v/custom-attributes/%v", + request.LocationID, + request.Key, + ) + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + var response *v2.DeleteLocationCustomAttributeResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodDelete, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} diff --git a/locations/transactions.go b/locations/transactions.go index ff2c499..84f8d10 100644 --- a/locations/transactions.go +++ b/locations/transactions.go @@ -3,7 +3,7 @@ package locations import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type TransactionsCaptureRequest struct { @@ -37,7 +37,7 @@ type TransactionsListRequest struct { // oldest first, `DESC` for newest first). // // Default value: `DESC` - SortOrder *squaregosdk.SortOrder `json:"-" url:"sort_order,omitempty"` + SortOrder *v2.SortOrder `json:"-" url:"sort_order,omitempty"` // A pagination cursor returned by a previous call to this endpoint. // Provide this to retrieve the next set of results for your original query. // diff --git a/locations/transactions/client.go b/locations/transactions/client.go index c70e082..87c6647 100644 --- a/locations/transactions/client.go +++ b/locations/transactions/client.go @@ -4,11 +4,11 @@ package transactions import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - locations "github.com/square/square-go-sdk/locations" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + locations "github.com/square/square-go-sdk/v2/locations" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -49,7 +49,7 @@ func (c *Client) List( ctx context.Context, request *locations.TransactionsListRequest, opts ...option.RequestOption, -) (*squaregosdk.ListTransactionsResponse, error) { +) (*v2.ListTransactionsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -72,7 +72,7 @@ func (c *Client) List( options.ToHeader(), ) - var response *squaregosdk.ListTransactionsResponse + var response *v2.ListTransactionsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -96,7 +96,7 @@ func (c *Client) Get( ctx context.Context, request *locations.TransactionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTransactionResponse, error) { +) (*v2.GetTransactionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -113,7 +113,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTransactionResponse + var response *v2.GetTransactionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -141,7 +141,7 @@ func (c *Client) Capture( ctx context.Context, request *locations.TransactionsCaptureRequest, opts ...option.RequestOption, -) (*squaregosdk.CaptureTransactionResponse, error) { +) (*v2.CaptureTransactionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -158,7 +158,7 @@ func (c *Client) Capture( options.ToHeader(), ) - var response *squaregosdk.CaptureTransactionResponse + var response *v2.CaptureTransactionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -186,7 +186,7 @@ func (c *Client) Void( ctx context.Context, request *locations.TransactionsVoidRequest, opts ...option.RequestOption, -) (*squaregosdk.VoidTransactionResponse, error) { +) (*v2.VoidTransactionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -203,7 +203,7 @@ func (c *Client) Void( options.ToHeader(), ) - var response *squaregosdk.VoidTransactionResponse + var response *v2.VoidTransactionResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/loyalty.go b/loyalty.go index 6f8fac0..d20473c 100644 --- a/loyalty.go +++ b/loyalty.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type SearchLoyaltyEventsRequest struct { diff --git a/loyalty/accounts.go b/loyalty/accounts.go index f1f7c1b..80dbf55 100644 --- a/loyalty/accounts.go +++ b/loyalty/accounts.go @@ -3,7 +3,7 @@ package loyalty import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type AccumulateLoyaltyPointsRequest struct { @@ -12,7 +12,7 @@ type AccumulateLoyaltyPointsRequest struct { // The points to add to the account. // If you are using the Orders API to manage orders, specify the order ID. // Otherwise, specify the points to add. - AccumulatePoints *squaregosdk.LoyaltyEventAccumulatePoints `json:"accumulate_points,omitempty" url:"-"` + AccumulatePoints *v2.LoyaltyEventAccumulatePoints `json:"accumulate_points,omitempty" url:"-"` // A unique string that identifies the `AccumulateLoyaltyPoints` request. // Keys can be any valid string but must be unique for every request. IdempotencyKey string `json:"idempotency_key" url:"-"` @@ -28,7 +28,7 @@ type AdjustLoyaltyPointsRequest struct { IdempotencyKey string `json:"idempotency_key" url:"-"` // The points to add or subtract and the reason for the adjustment. To add points, specify a positive integer. // To subtract points, specify a negative integer. - AdjustPoints *squaregosdk.LoyaltyEventAdjustPoints `json:"adjust_points,omitempty" url:"-"` + AdjustPoints *v2.LoyaltyEventAdjustPoints `json:"adjust_points,omitempty" url:"-"` // Indicates whether to allow a negative adjustment to result in a negative balance. If `true`, a negative // balance is allowed when subtracting points. If `false`, Square returns a `BAD_REQUEST` error when subtracting // the specified number of points would result in a negative balance. The default value is `false`. @@ -37,7 +37,7 @@ type AdjustLoyaltyPointsRequest struct { type CreateLoyaltyAccountRequest struct { // The loyalty account to create. - LoyaltyAccount *squaregosdk.LoyaltyAccount `json:"loyalty_account,omitempty" url:"-"` + LoyaltyAccount *v2.LoyaltyAccount `json:"loyalty_account,omitempty" url:"-"` // A unique string that identifies this `CreateLoyaltyAccount` request. // Keys can be any valid string, but must be unique for every request. IdempotencyKey string `json:"idempotency_key" url:"-"` @@ -50,7 +50,7 @@ type AccountsGetRequest struct { type SearchLoyaltyAccountsRequest struct { // The search criteria for the request. - Query *squaregosdk.SearchLoyaltyAccountsRequestLoyaltyAccountQuery `json:"query,omitempty" url:"-"` + Query *v2.SearchLoyaltyAccountsRequestLoyaltyAccountQuery `json:"query,omitempty" url:"-"` // The maximum number of results to include in the response. The default value is 30. Limit *int `json:"limit,omitempty" url:"-"` // A pagination cursor returned by a previous call to diff --git a/loyalty/accounts/client.go b/loyalty/accounts/client.go index 5238628..573bd8c 100644 --- a/loyalty/accounts/client.go +++ b/loyalty/accounts/client.go @@ -4,11 +4,11 @@ package accounts import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - loyalty "github.com/square/square-go-sdk/loyalty" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + loyalty "github.com/square/square-go-sdk/v2/loyalty" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -44,7 +44,7 @@ func (c *Client) Create( ctx context.Context, request *loyalty.CreateLoyaltyAccountRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateLoyaltyAccountResponse, error) { +) (*v2.CreateLoyaltyAccountResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -58,7 +58,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateLoyaltyAccountResponse + var response *v2.CreateLoyaltyAccountResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -87,7 +87,7 @@ func (c *Client) Search( ctx context.Context, request *loyalty.SearchLoyaltyAccountsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchLoyaltyAccountsResponse, error) { +) (*v2.SearchLoyaltyAccountsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -101,7 +101,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchLoyaltyAccountsResponse + var response *v2.SearchLoyaltyAccountsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -126,7 +126,7 @@ func (c *Client) Get( ctx context.Context, request *loyalty.AccountsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetLoyaltyAccountResponse, error) { +) (*v2.GetLoyaltyAccountResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -142,7 +142,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetLoyaltyAccountResponse + var response *v2.GetLoyaltyAccountResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -179,7 +179,7 @@ func (c *Client) AccumulatePoints( ctx context.Context, request *loyalty.AccumulateLoyaltyPointsRequest, opts ...option.RequestOption, -) (*squaregosdk.AccumulateLoyaltyPointsResponse, error) { +) (*v2.AccumulateLoyaltyPointsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -196,7 +196,7 @@ func (c *Client) AccumulatePoints( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.AccumulateLoyaltyPointsResponse + var response *v2.AccumulateLoyaltyPointsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -225,7 +225,7 @@ func (c *Client) Adjust( ctx context.Context, request *loyalty.AdjustLoyaltyPointsRequest, opts ...option.RequestOption, -) (*squaregosdk.AdjustLoyaltyPointsResponse, error) { +) (*v2.AdjustLoyaltyPointsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -242,7 +242,7 @@ func (c *Client) Adjust( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.AdjustLoyaltyPointsResponse + var response *v2.AdjustLoyaltyPointsResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/loyalty/client/client.go b/loyalty/client/client.go index 725e768..0ca3144 100644 --- a/loyalty/client/client.go +++ b/loyalty/client/client.go @@ -4,13 +4,13 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - accounts "github.com/square/square-go-sdk/loyalty/accounts" - programsclient "github.com/square/square-go-sdk/loyalty/programs/client" - rewards "github.com/square/square-go-sdk/loyalty/rewards" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + accounts "github.com/square/square-go-sdk/v2/loyalty/accounts" + programsclient "github.com/square/square-go-sdk/v2/loyalty/programs/client" + rewards "github.com/square/square-go-sdk/v2/loyalty/rewards" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -58,9 +58,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Search results are sorted by `created_at` in descending order. func (c *Client) SearchEvents( ctx context.Context, - request *squaregosdk.SearchLoyaltyEventsRequest, + request *v2.SearchLoyaltyEventsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchLoyaltyEventsResponse, error) { +) (*v2.SearchLoyaltyEventsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -74,7 +74,7 @@ func (c *Client) SearchEvents( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchLoyaltyEventsResponse + var response *v2.SearchLoyaltyEventsResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/loyalty/programs.go b/loyalty/programs.go index 37a2aed..87cddc7 100644 --- a/loyalty/programs.go +++ b/loyalty/programs.go @@ -3,7 +3,7 @@ package loyalty import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CalculateLoyaltyPointsRequest struct { @@ -16,7 +16,7 @@ type CalculateLoyaltyPointsRequest struct { // The purchase amount for which to calculate the points. // Specify this field if your application does not use the Orders API to process orders. // Otherwise, specify the `order_id`. - TransactionAmountMoney *squaregosdk.Money `json:"transaction_amount_money,omitempty" url:"-"` + TransactionAmountMoney *v2.Money `json:"transaction_amount_money,omitempty" url:"-"` // The ID of the target [loyalty account](entity:LoyaltyAccount). Optionally specify this field // if your application uses the Orders API to process orders. // diff --git a/loyalty/programs/client/client.go b/loyalty/programs/client/client.go index 89de1fc..75128a5 100644 --- a/loyalty/programs/client/client.go +++ b/loyalty/programs/client/client.go @@ -4,12 +4,12 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - loyalty "github.com/square/square-go-sdk/loyalty" - promotions "github.com/square/square-go-sdk/loyalty/programs/promotions" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + loyalty "github.com/square/square-go-sdk/v2/loyalty" + promotions "github.com/square/square-go-sdk/v2/loyalty/programs/promotions" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -50,7 +50,7 @@ func NewClient(opts ...option.RequestOption) *Client { func (c *Client) List( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.ListLoyaltyProgramsResponse, error) { +) (*v2.ListLoyaltyProgramsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -63,7 +63,7 @@ func (c *Client) List( options.ToHeader(), ) - var response *squaregosdk.ListLoyaltyProgramsResponse + var response *v2.ListLoyaltyProgramsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -89,7 +89,7 @@ func (c *Client) Get( ctx context.Context, request *loyalty.ProgramsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetLoyaltyProgramResponse, error) { +) (*v2.GetLoyaltyProgramResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -105,7 +105,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetLoyaltyProgramResponse + var response *v2.GetLoyaltyProgramResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -143,7 +143,7 @@ func (c *Client) Calculate( ctx context.Context, request *loyalty.CalculateLoyaltyPointsRequest, opts ...option.RequestOption, -) (*squaregosdk.CalculateLoyaltyPointsResponse, error) { +) (*v2.CalculateLoyaltyPointsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -160,7 +160,7 @@ func (c *Client) Calculate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CalculateLoyaltyPointsResponse + var response *v2.CalculateLoyaltyPointsResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/loyalty/programs/promotions.go b/loyalty/programs/promotions.go index 5dcb5d0..1c065b0 100644 --- a/loyalty/programs/promotions.go +++ b/loyalty/programs/promotions.go @@ -3,7 +3,7 @@ package programs import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type PromotionsCancelRequest struct { @@ -20,7 +20,7 @@ type CreateLoyaltyPromotionRequest struct { // using the `main` keyword. ProgramID string `json:"-" url:"-"` // The loyalty promotion to create. - LoyaltyPromotion *squaregosdk.LoyaltyPromotion `json:"loyalty_promotion,omitempty" url:"-"` + LoyaltyPromotion *v2.LoyaltyPromotion `json:"loyalty_promotion,omitempty" url:"-"` // A unique identifier for this request, which is used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey string `json:"idempotency_key" url:"-"` @@ -41,7 +41,7 @@ type PromotionsListRequest struct { // The status to filter the results by. If a status is provided, only loyalty promotions // with the specified status are returned. Otherwise, all loyalty promotions associated with // the loyalty program are returned. - Status *squaregosdk.LoyaltyPromotionStatus `json:"-" url:"status,omitempty"` + Status *v2.LoyaltyPromotionStatus `json:"-" url:"status,omitempty"` // The cursor returned in the paged response from the previous call to this endpoint. // Provide this cursor to retrieve the next page of results for your original request. // For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). diff --git a/loyalty/programs/promotions/client.go b/loyalty/programs/promotions/client.go index 420576c..e0e5fb0 100644 --- a/loyalty/programs/promotions/client.go +++ b/loyalty/programs/promotions/client.go @@ -5,11 +5,11 @@ package promotions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - programs "github.com/square/square-go-sdk/loyalty/programs" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + programs "github.com/square/square-go-sdk/v2/loyalty/programs" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -46,7 +46,7 @@ func (c *Client) List( ctx context.Context, request *programs.PromotionsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.LoyaltyPromotion], error) { +) (*core.Page[*v2.LoyaltyPromotion], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -85,10 +85,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListLoyaltyPromotionsResponse) *internal.PageResponse[*string, *squaregosdk.LoyaltyPromotion] { + readPageResponse := func(response *v2.ListLoyaltyPromotionsResponse) *internal.PageResponse[*string, *v2.LoyaltyPromotion] { next := response.Cursor results := response.LoyaltyPromotions - return &internal.PageResponse[*string, *squaregosdk.LoyaltyPromotion]{ + return &internal.PageResponse[*string, *v2.LoyaltyPromotion]{ Next: next, Results: results, } @@ -111,7 +111,7 @@ func (c *Client) Create( ctx context.Context, request *programs.CreateLoyaltyPromotionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateLoyaltyPromotionResponse, error) { +) (*v2.CreateLoyaltyPromotionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -128,7 +128,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateLoyaltyPromotionResponse + var response *v2.CreateLoyaltyPromotionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -153,7 +153,7 @@ func (c *Client) Get( ctx context.Context, request *programs.PromotionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetLoyaltyPromotionResponse, error) { +) (*v2.GetLoyaltyPromotionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -170,7 +170,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetLoyaltyPromotionResponse + var response *v2.GetLoyaltyPromotionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -199,7 +199,7 @@ func (c *Client) Cancel( ctx context.Context, request *programs.PromotionsCancelRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelLoyaltyPromotionResponse, error) { +) (*v2.CancelLoyaltyPromotionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -216,7 +216,7 @@ func (c *Client) Cancel( options.ToHeader(), ) - var response *squaregosdk.CancelLoyaltyPromotionResponse + var response *v2.CancelLoyaltyPromotionResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/loyalty/rewards.go b/loyalty/rewards.go index 75c4dca..3ae6ca8 100644 --- a/loyalty/rewards.go +++ b/loyalty/rewards.go @@ -3,12 +3,12 @@ package loyalty import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateLoyaltyRewardRequest struct { // The reward to create. - Reward *squaregosdk.LoyaltyReward `json:"reward,omitempty" url:"-"` + Reward *v2.LoyaltyReward `json:"reward,omitempty" url:"-"` // A unique string that identifies this `CreateLoyaltyReward` request. // Keys can be any valid string, but must be unique for every request. IdempotencyKey string `json:"idempotency_key" url:"-"` @@ -37,7 +37,7 @@ type RedeemLoyaltyRewardRequest struct { type SearchLoyaltyRewardsRequest struct { // The search criteria for the request. // If empty, the endpoint retrieves all loyalty rewards in the loyalty program. - Query *squaregosdk.SearchLoyaltyRewardsRequestLoyaltyRewardQuery `json:"query,omitempty" url:"-"` + Query *v2.SearchLoyaltyRewardsRequestLoyaltyRewardQuery `json:"query,omitempty" url:"-"` // The maximum number of results to return in the response. The default value is 30. Limit *int `json:"limit,omitempty" url:"-"` // A pagination cursor returned by a previous call to diff --git a/loyalty/rewards/client.go b/loyalty/rewards/client.go index 88f2125..aa84e5a 100644 --- a/loyalty/rewards/client.go +++ b/loyalty/rewards/client.go @@ -4,11 +4,11 @@ package rewards import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - loyalty "github.com/square/square-go-sdk/loyalty" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + loyalty "github.com/square/square-go-sdk/v2/loyalty" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -51,7 +51,7 @@ func (c *Client) Create( ctx context.Context, request *loyalty.CreateLoyaltyRewardRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateLoyaltyRewardResponse, error) { +) (*v2.CreateLoyaltyRewardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -65,7 +65,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateLoyaltyRewardResponse + var response *v2.CreateLoyaltyRewardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -96,7 +96,7 @@ func (c *Client) Search( ctx context.Context, request *loyalty.SearchLoyaltyRewardsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchLoyaltyRewardsResponse, error) { +) (*v2.SearchLoyaltyRewardsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -110,7 +110,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchLoyaltyRewardsResponse + var response *v2.SearchLoyaltyRewardsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -135,7 +135,7 @@ func (c *Client) Get( ctx context.Context, request *loyalty.RewardsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetLoyaltyRewardResponse, error) { +) (*v2.GetLoyaltyRewardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -151,7 +151,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetLoyaltyRewardResponse + var response *v2.GetLoyaltyRewardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -183,7 +183,7 @@ func (c *Client) Delete( ctx context.Context, request *loyalty.RewardsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteLoyaltyRewardResponse, error) { +) (*v2.DeleteLoyaltyRewardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -199,7 +199,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteLoyaltyRewardResponse + var response *v2.DeleteLoyaltyRewardResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -233,7 +233,7 @@ func (c *Client) Redeem( ctx context.Context, request *loyalty.RedeemLoyaltyRewardRequest, opts ...option.RequestOption, -) (*squaregosdk.RedeemLoyaltyRewardResponse, error) { +) (*v2.RedeemLoyaltyRewardResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -250,7 +250,7 @@ func (c *Client) Redeem( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.RedeemLoyaltyRewardResponse + var response *v2.RedeemLoyaltyRewardResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/merchants.go b/merchants.go index 958f142..c9adbbe 100644 --- a/merchants.go +++ b/merchants.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type MerchantsGetRequest struct { diff --git a/merchants/client/client.go b/merchants/client/client.go index ad8abfe..618d29c 100644 --- a/merchants/client/client.go +++ b/merchants/client/client.go @@ -5,12 +5,12 @@ package client import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - customattributedefinitions "github.com/square/square-go-sdk/merchants/customattributedefinitions" - customattributes "github.com/square/square-go-sdk/merchants/customattributes" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + customattributedefinitions "github.com/square/square-go-sdk/v2/merchants/customattributedefinitions" + customattributes "github.com/square/square-go-sdk/v2/merchants/customattributes" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -20,8 +20,8 @@ type Client struct { caller *internal.Caller header http.Header - CustomAttributes *customattributes.Client CustomAttributeDefinitions *customattributedefinitions.Client + CustomAttributes *customattributes.Client } func NewClient(opts ...option.RequestOption) *Client { @@ -41,8 +41,8 @@ func NewClient(opts ...option.RequestOption) *Client { }, ), header: options.ToHeader(), - CustomAttributes: customattributes.NewClient(opts...), CustomAttributeDefinitions: customattributedefinitions.NewClient(opts...), + CustomAttributes: customattributes.NewClient(opts...), } } @@ -58,9 +58,9 @@ func NewClient(opts ...option.RequestOption) *Client { // endpoint to retrieve the merchant information. func (c *Client) List( ctx context.Context, - request *squaregosdk.MerchantsListRequest, + request *v2.MerchantsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Merchant], error) { +) (*core.Page[*v2.Merchant], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -96,10 +96,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListMerchantsResponse) *internal.PageResponse[*int, *squaregosdk.Merchant] { + readPageResponse := func(response *v2.ListMerchantsResponse) *internal.PageResponse[*int, *v2.Merchant] { next := response.Cursor results := response.Merchant - return &internal.PageResponse[*int, *squaregosdk.Merchant]{ + return &internal.PageResponse[*int, *v2.Merchant]{ Next: next, Results: results, } @@ -115,9 +115,9 @@ func (c *Client) List( // Retrieves the `Merchant` object for the given `merchant_id`. func (c *Client) Get( ctx context.Context, - request *squaregosdk.MerchantsGetRequest, + request *v2.MerchantsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetMerchantResponse, error) { +) (*v2.GetMerchantResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -133,7 +133,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetMerchantResponse + var response *v2.GetMerchantResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/merchants/custom_attribute_definitions.go b/merchants/custom_attribute_definitions.go index 81adc9b..15617bd 100644 --- a/merchants/custom_attribute_definitions.go +++ b/merchants/custom_attribute_definitions.go @@ -3,9 +3,21 @@ package merchants import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) +type CreateMerchantCustomAttributeDefinitionRequest struct { + // The custom attribute definition to create. Note the following: + // - With the exception of the `Selection` data type, the `schema` is specified as a simple URL to the JSON schema + // definition hosted on the Square CDN. For more information, including supported values and constraints, see + // [Supported data types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). + // - `name` is required unless `visibility` is set to `VISIBILITY_HIDDEN`. + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + // A unique identifier for this request, used to ensure idempotency. For more information, + // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` +} + type CustomAttributeDefinitionsDeleteRequest struct { // The key of the custom attribute definition to delete. Key string `json:"-" url:"-"` @@ -22,6 +34,19 @@ type CustomAttributeDefinitionsGetRequest struct { Version *int `json:"-" url:"version,omitempty"` } +type CustomAttributeDefinitionsListRequest struct { + // Filters the `CustomAttributeDefinition` results by their `visibility` values. + VisibilityFilter *v2.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` + // The maximum number of results to return in a single paged response. This limit is advisory. + // The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100. + // The default value is 20. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + Limit *int `json:"-" url:"limit,omitempty"` + // The cursor returned in the paged response from the previous call to this endpoint. + // Provide this cursor to retrieve the next page of results for your original request. + // For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + Cursor *string `json:"-" url:"cursor,omitempty"` +} + type UpdateMerchantCustomAttributeDefinitionRequest struct { // The key of the custom attribute definition to update. Key string `json:"-" url:"-"` @@ -38,7 +63,7 @@ type UpdateMerchantCustomAttributeDefinitionRequest struct { // The version field must match the current version of the custom attribute definition to enable // [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // If this is not important for your application, version can be set to -1. For any other values, the request fails with a BAD_REQUEST error. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/merchants/custom_attributes.go b/merchants/custom_attributes.go index 2b90569..a981443 100644 --- a/merchants/custom_attributes.go +++ b/merchants/custom_attributes.go @@ -3,32 +3,20 @@ package merchants import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type BulkDeleteMerchantCustomAttributesRequest struct { // The data used to update the `CustomAttribute` objects. // The keys must be unique and are used to map to the corresponding response. - Values map[string]*squaregosdk.BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest `json:"values,omitempty" url:"-"` + Values map[string]*v2.BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest `json:"values,omitempty" url:"-"` } type BulkUpsertMerchantCustomAttributesRequest struct { // A map containing 1 to 25 individual upsert requests. For each request, provide an // arbitrary ID that is unique for this `BulkUpsertMerchantCustomAttributes` request and the // information needed to create or update a custom attribute. - Values map[string]*squaregosdk.BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` -} - -type CreateMerchantCustomAttributeDefinitionRequest struct { - // The custom attribute definition to create. Note the following: - // - With the exception of the `Selection` data type, the `schema` is specified as a simple URL to the JSON schema - // definition hosted on the Square CDN. For more information, including supported values and constraints, see - // [Supported data types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). - // - `name` is required unless `visibility` is set to `VISIBILITY_HIDDEN`. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` - // A unique identifier for this request, used to ensure idempotency. For more information, - // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). - IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` + Values map[string]*v2.BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest `json:"values,omitempty" url:"-"` } type CustomAttributesDeleteRequest struct { @@ -62,7 +50,7 @@ type CustomAttributesListRequest struct { // The ID of the target [merchant](entity:Merchant). MerchantID string `json:"-" url:"-"` // Filters the `CustomAttributeDefinition` results by their `visibility` values. - VisibilityFilter *squaregosdk.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` + VisibilityFilter *v2.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` // The maximum number of results to return in a single paged response. This limit is advisory. // The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100. // The default value is 20. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). @@ -90,7 +78,7 @@ type UpsertMerchantCustomAttributeRequest struct { // - The version field must match the current version of the custom attribute definition to enable // [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // If this is not important for your application, version can be set to -1. For any other values, the request fails with a BAD_REQUEST error. - CustomAttribute *squaregosdk.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` + CustomAttribute *v2.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. For more information, // see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/merchants/customattributedefinitions/client.go b/merchants/customattributedefinitions/client.go index 13d4dff..2aac22c 100644 --- a/merchants/customattributedefinitions/client.go +++ b/merchants/customattributedefinitions/client.go @@ -4,11 +4,12 @@ package customattributedefinitions import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - merchants "github.com/square/square-go-sdk/merchants" - option "github.com/square/square-go-sdk/option" + fmt "fmt" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + merchants "github.com/square/square-go-sdk/v2/merchants" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -39,6 +40,111 @@ func NewClient(opts ...option.RequestOption) *Client { } } +// Lists the merchant-related [custom attribute definitions](entity:CustomAttributeDefinition) that belong to a Square seller account. +// When all response pages are retrieved, the results include all custom attribute definitions +// that are visible to the requesting application, including those that are created by other +// applications and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. +func (c *Client) List( + ctx context.Context, + request *merchants.CustomAttributeDefinitionsListRequest, + opts ...option.RequestOption, +) (*core.Page[*v2.CustomAttributeDefinition], error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := baseURL + "/v2/merchants/custom-attribute-definitions" + queryParams, err := internal.QueryValues(request) + if err != nil { + return nil, err + } + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + prepareCall := func(pageRequest *internal.PageRequest[*string]) *internal.CallParams { + if pageRequest.Cursor != nil { + queryParams.Set("cursor", fmt.Sprintf("%v", *pageRequest.Cursor)) + } + nextURL := endpointURL + if len(queryParams) > 0 { + nextURL += "?" + queryParams.Encode() + } + return &internal.CallParams{ + URL: nextURL, + Method: http.MethodGet, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: pageRequest.Response, + } + } + readPageResponse := func(response *v2.ListMerchantCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *v2.CustomAttributeDefinition] { + next := response.Cursor + results := response.CustomAttributeDefinitions + return &internal.PageResponse[*string, *v2.CustomAttributeDefinition]{ + Next: next, + Results: results, + } + } + pager := internal.NewCursorPager( + c.caller, + prepareCall, + readPageResponse, + ) + return pager.GetPage(ctx, request.Cursor) +} + +// Creates a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account. +// Use this endpoint to define a custom attribute that can be associated with a merchant connecting to your application. +// A custom attribute definition specifies the `key`, `visibility`, `schema`, and other properties +// for a custom attribute. After the definition is created, you can call +// [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) or +// [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) +// to set the custom attribute for a merchant. +func (c *Client) Create( + ctx context.Context, + request *merchants.CreateMerchantCustomAttributeDefinitionRequest, + opts ...option.RequestOption, +) (*v2.CreateMerchantCustomAttributeDefinitionResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := baseURL + "/v2/merchants/custom-attribute-definitions" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + + var response *v2.CreateMerchantCustomAttributeDefinitionResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} + // Retrieves a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) from a Square seller account. // To retrieve a custom attribute definition created by another application, the `visibility` // setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. @@ -46,7 +152,7 @@ func (c *Client) Get( ctx context.Context, request *merchants.CustomAttributeDefinitionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveMerchantCustomAttributeDefinitionResponse, error) { +) (*v2.RetrieveMerchantCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -69,7 +175,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveMerchantCustomAttributeDefinitionResponse + var response *v2.RetrieveMerchantCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -96,7 +202,7 @@ func (c *Client) Update( ctx context.Context, request *merchants.UpdateMerchantCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateMerchantCustomAttributeDefinitionResponse, error) { +) (*v2.UpdateMerchantCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -113,7 +219,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateMerchantCustomAttributeDefinitionResponse + var response *v2.UpdateMerchantCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -141,7 +247,7 @@ func (c *Client) Delete( ctx context.Context, request *merchants.CustomAttributeDefinitionsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteMerchantCustomAttributeDefinitionResponse, error) { +) (*v2.DeleteMerchantCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -157,7 +263,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteMerchantCustomAttributeDefinitionResponse + var response *v2.DeleteMerchantCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/merchants/customattributes/client.go b/merchants/customattributes/client.go index acfb395..05ee8f9 100644 --- a/merchants/customattributes/client.go +++ b/merchants/customattributes/client.go @@ -5,11 +5,11 @@ package customattributes import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - merchants "github.com/square/square-go-sdk/merchants" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + merchants "github.com/square/square-go-sdk/v2/merchants" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -40,97 +40,28 @@ func NewClient(opts ...option.RequestOption) *Client { } } -// Lists the [custom attributes](entity:CustomAttribute) associated with a merchant. -// You can use the `with_definitions` query parameter to also retrieve custom attribute definitions -// in the same call. -// When all response pages are retrieved, the results include all custom attributes that are -// visible to the requesting application, including those that are owned by other applications -// and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. -func (c *Client) List( - ctx context.Context, - request *merchants.CustomAttributesListRequest, - opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttribute], error) { - options := core.NewRequestOptions(opts...) - baseURL := internal.ResolveBaseURL( - options.BaseURL, - c.baseURL, - "https://connect.squareup.com", - ) - endpointURL := internal.EncodeURL( - baseURL+"/v2/merchants/%v/custom-attributes", - request.MerchantID, - ) - queryParams, err := internal.QueryValues(request) - if err != nil { - return nil, err - } - headers := internal.MergeHeaders( - c.header.Clone(), - options.ToHeader(), - ) - - prepareCall := func(pageRequest *internal.PageRequest[*string]) *internal.CallParams { - if pageRequest.Cursor != nil { - queryParams.Set("cursor", fmt.Sprintf("%v", *pageRequest.Cursor)) - } - nextURL := endpointURL - if len(queryParams) > 0 { - nextURL += "?" + queryParams.Encode() - } - return &internal.CallParams{ - URL: nextURL, - Method: http.MethodGet, - Headers: headers, - MaxAttempts: options.MaxAttempts, - BodyProperties: options.BodyProperties, - QueryParameters: options.QueryParameters, - Client: options.HTTPClient, - Response: pageRequest.Response, - } - } - readPageResponse := func(response *squaregosdk.ListMerchantCustomAttributesResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttribute] { - next := response.Cursor - results := response.CustomAttributes - return &internal.PageResponse[*string, *squaregosdk.CustomAttribute]{ - Next: next, - Results: results, - } - } - pager := internal.NewCursorPager( - c.caller, - prepareCall, - readPageResponse, - ) - return pager.GetPage(ctx, request.Cursor) -} - -// Creates a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account. -// Use this endpoint to define a custom attribute that can be associated with a merchant connecting to your application. -// A custom attribute definition specifies the `key`, `visibility`, `schema`, and other properties -// for a custom attribute. After the definition is created, you can call -// [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) or -// [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) -// to set the custom attribute for a merchant. -func (c *Client) Create( +// Deletes [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation. +// To delete a custom attribute owned by another application, the `visibility` setting must be +// `VISIBILITY_READ_WRITE_VALUES`. +func (c *Client) BatchDelete( ctx context.Context, - request *merchants.CreateMerchantCustomAttributeDefinitionRequest, + request *merchants.BulkDeleteMerchantCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateMerchantCustomAttributeDefinitionResponse, error) { +) (*v2.BulkDeleteMerchantCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, c.baseURL, "https://connect.squareup.com", ) - endpointURL := baseURL + "/v2/merchants/custom-attribute-definitions" + endpointURL := baseURL + "/v2/merchants/custom-attributes/bulk-delete" headers := internal.MergeHeaders( c.header.Clone(), options.ToHeader(), ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateMerchantCustomAttributeDefinitionResponse + var response *v2.BulkDeleteMerchantCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -150,28 +81,35 @@ func (c *Client) Create( return response, nil } -// Deletes [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation. -// To delete a custom attribute owned by another application, the `visibility` setting must be -// `VISIBILITY_READ_WRITE_VALUES`. -func (c *Client) BatchDelete( +// Creates or updates [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation. +// Use this endpoint to set the value of one or more custom attributes for a merchant. +// A custom attribute is based on a custom attribute definition in a Square seller account, which is +// created using the [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) endpoint. +// This `BulkUpsertMerchantCustomAttributes` endpoint accepts a map of 1 to 25 individual upsert +// requests and returns a map of individual upsert responses. Each upsert request has a unique ID +// and provides a merchant ID and custom attribute. Each upsert response is returned with the ID +// of the corresponding request. +// To create or update a custom attribute owned by another application, the `visibility` setting +// must be `VISIBILITY_READ_WRITE_VALUES`. +func (c *Client) BatchUpsert( ctx context.Context, - request *merchants.BulkDeleteMerchantCustomAttributesRequest, + request *merchants.BulkUpsertMerchantCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkDeleteMerchantCustomAttributesResponse, error) { +) (*v2.BulkUpsertMerchantCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, c.baseURL, "https://connect.squareup.com", ) - endpointURL := baseURL + "/v2/merchants/custom-attributes/bulk-delete" + endpointURL := baseURL + "/v2/merchants/custom-attributes/bulk-upsert" headers := internal.MergeHeaders( c.header.Clone(), options.ToHeader(), ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkDeleteMerchantCustomAttributesResponse + var response *v2.BulkUpsertMerchantCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -191,52 +129,69 @@ func (c *Client) BatchDelete( return response, nil } -// Creates or updates [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation. -// Use this endpoint to set the value of one or more custom attributes for a merchant. -// A custom attribute is based on a custom attribute definition in a Square seller account, which is -// created using the [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) endpoint. -// This `BulkUpsertMerchantCustomAttributes` endpoint accepts a map of 1 to 25 individual upsert -// requests and returns a map of individual upsert responses. Each upsert request has a unique ID -// and provides a merchant ID and custom attribute. Each upsert response is returned with the ID -// of the corresponding request. -// To create or update a custom attribute owned by another application, the `visibility` setting -// must be `VISIBILITY_READ_WRITE_VALUES`. -func (c *Client) BatchUpsert( +// Lists the [custom attributes](entity:CustomAttribute) associated with a merchant. +// You can use the `with_definitions` query parameter to also retrieve custom attribute definitions +// in the same call. +// When all response pages are retrieved, the results include all custom attributes that are +// visible to the requesting application, including those that are owned by other applications +// and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. +func (c *Client) List( ctx context.Context, - request *merchants.BulkUpsertMerchantCustomAttributesRequest, + request *merchants.CustomAttributesListRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkUpsertMerchantCustomAttributesResponse, error) { +) (*core.Page[*v2.CustomAttribute], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, c.baseURL, "https://connect.squareup.com", ) - endpointURL := baseURL + "/v2/merchants/custom-attributes/bulk-upsert" + endpointURL := internal.EncodeURL( + baseURL+"/v2/merchants/%v/custom-attributes", + request.MerchantID, + ) + queryParams, err := internal.QueryValues(request) + if err != nil { + return nil, err + } headers := internal.MergeHeaders( c.header.Clone(), options.ToHeader(), ) - headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkUpsertMerchantCustomAttributesResponse - if err := c.caller.Call( - ctx, - &internal.CallParams{ - URL: endpointURL, - Method: http.MethodPost, + prepareCall := func(pageRequest *internal.PageRequest[*string]) *internal.CallParams { + if pageRequest.Cursor != nil { + queryParams.Set("cursor", fmt.Sprintf("%v", *pageRequest.Cursor)) + } + nextURL := endpointURL + if len(queryParams) > 0 { + nextURL += "?" + queryParams.Encode() + } + return &internal.CallParams{ + URL: nextURL, + Method: http.MethodGet, Headers: headers, MaxAttempts: options.MaxAttempts, BodyProperties: options.BodyProperties, QueryParameters: options.QueryParameters, Client: options.HTTPClient, - Request: request, - Response: &response, - }, - ); err != nil { - return nil, err + Response: pageRequest.Response, + } } - return response, nil + readPageResponse := func(response *v2.ListMerchantCustomAttributesResponse) *internal.PageResponse[*string, *v2.CustomAttribute] { + next := response.Cursor + results := response.CustomAttributes + return &internal.PageResponse[*string, *v2.CustomAttribute]{ + Next: next, + Results: results, + } + } + pager := internal.NewCursorPager( + c.caller, + prepareCall, + readPageResponse, + ) + return pager.GetPage(ctx, request.Cursor) } // Retrieves a [custom attribute](entity:CustomAttribute) associated with a merchant. @@ -248,7 +203,7 @@ func (c *Client) Get( ctx context.Context, request *merchants.CustomAttributesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveMerchantCustomAttributeResponse, error) { +) (*v2.RetrieveMerchantCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -272,7 +227,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveMerchantCustomAttributeResponse + var response *v2.RetrieveMerchantCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -301,7 +256,7 @@ func (c *Client) Upsert( ctx context.Context, request *merchants.UpsertMerchantCustomAttributeRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertMerchantCustomAttributeResponse, error) { +) (*v2.UpsertMerchantCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -319,7 +274,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertMerchantCustomAttributeResponse + var response *v2.UpsertMerchantCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -346,7 +301,7 @@ func (c *Client) Delete( ctx context.Context, request *merchants.CustomAttributesDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteMerchantCustomAttributeResponse, error) { +) (*v2.DeleteMerchantCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -363,7 +318,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteMerchantCustomAttributeResponse + var response *v2.DeleteMerchantCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/mobile.go b/mobile.go index aaf02fa..6afc604 100644 --- a/mobile.go +++ b/mobile.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type CreateMobileAuthorizationCodeRequest struct { diff --git a/mobile/client.go b/mobile/client.go index 0ac63ca..68d77b6 100644 --- a/mobile/client.go +++ b/mobile/client.go @@ -4,10 +4,10 @@ package mobile import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -52,9 +52,9 @@ func NewClient(opts ...option.RequestOption) *Client { // [valid production authorization credential](https://developer.squareup.com/docs/build-basics/access-tokens). func (c *Client) AuthorizationCode( ctx context.Context, - request *squaregosdk.CreateMobileAuthorizationCodeRequest, + request *v2.CreateMobileAuthorizationCodeRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateMobileAuthorizationCodeResponse, error) { +) (*v2.CreateMobileAuthorizationCodeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -68,7 +68,7 @@ func (c *Client) AuthorizationCode( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateMobileAuthorizationCodeResponse + var response *v2.CreateMobileAuthorizationCodeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/o_auth.go b/o_auth.go index 41a43db..0d64396 100644 --- a/o_auth.go +++ b/o_auth.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type ObtainTokenRequest struct { diff --git a/oauth/client.go b/oauth/client.go index 70585c6..35a3910 100644 --- a/oauth/client.go +++ b/oauth/client.go @@ -4,10 +4,10 @@ package oauth import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -54,9 +54,9 @@ func NewClient(opts ...option.RequestOption) *Client { // page for your application in the Developer Dashboard. func (c *Client) RevokeToken( ctx context.Context, - request *squaregosdk.RevokeTokenRequest, + request *v2.RevokeTokenRequest, opts ...option.RequestOption, -) (*squaregosdk.RevokeTokenResponse, error) { +) (*v2.RevokeTokenResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -70,7 +70,7 @@ func (c *Client) RevokeToken( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.RevokeTokenResponse + var response *v2.RevokeTokenResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -109,9 +109,9 @@ func (c *Client) RevokeToken( // Application clients should never interact directly with OAuth tokens. func (c *Client) ObtainToken( ctx context.Context, - request *squaregosdk.ObtainTokenRequest, + request *v2.ObtainTokenRequest, opts ...option.RequestOption, -) (*squaregosdk.ObtainTokenResponse, error) { +) (*v2.ObtainTokenResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -125,7 +125,7 @@ func (c *Client) ObtainToken( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.ObtainTokenResponse + var response *v2.ObtainTokenResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -162,7 +162,7 @@ func (c *Client) ObtainToken( func (c *Client) RetrieveTokenStatus( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.RetrieveTokenStatusResponse, error) { +) (*v2.RetrieveTokenStatusResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -175,7 +175,7 @@ func (c *Client) RetrieveTokenStatus( options.ToHeader(), ) - var response *squaregosdk.RetrieveTokenStatusResponse + var response *v2.RetrieveTokenStatusResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/option/request_option.go b/option/request_option.go index d975daa..f9d3ca2 100644 --- a/option/request_option.go +++ b/option/request_option.go @@ -3,7 +3,7 @@ package option import ( - core "github.com/square/square-go-sdk/core" + core "github.com/square/square-go-sdk/v2/core" http "net/http" url "net/url" ) diff --git a/orders.go b/orders.go index af7cf07..13911d1 100644 --- a/orders.go +++ b/orders.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type BatchGetOrdersRequest struct { diff --git a/orders/client/client.go b/orders/client/client.go index da2ac4d..c4b7a5a 100644 --- a/orders/client/client.go +++ b/orders/client/client.go @@ -4,12 +4,12 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - customattributedefinitions "github.com/square/square-go-sdk/orders/customattributedefinitions" - customattributes "github.com/square/square-go-sdk/orders/customattributes" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + customattributedefinitions "github.com/square/square-go-sdk/v2/orders/customattributedefinitions" + customattributes "github.com/square/square-go-sdk/v2/orders/customattributes" http "net/http" os "os" ) @@ -54,9 +54,9 @@ func NewClient(opts ...option.RequestOption) *Client { // You can modify open orders using the [UpdateOrder](api-endpoint:Orders-UpdateOrder) endpoint. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateOrderRequest, + request *v2.CreateOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateOrderResponse, error) { +) (*v2.CreateOrderResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -70,7 +70,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateOrderResponse + var response *v2.CreateOrderResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -95,9 +95,9 @@ func (c *Client) Create( // If a given order ID does not exist, the ID is ignored instead of generating an error. func (c *Client) BatchGet( ctx context.Context, - request *squaregosdk.BatchGetOrdersRequest, + request *v2.BatchGetOrdersRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetOrdersResponse, error) { +) (*v2.BatchGetOrdersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -111,7 +111,7 @@ func (c *Client) BatchGet( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetOrdersResponse + var response *v2.BatchGetOrdersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -134,9 +134,9 @@ func (c *Client) BatchGet( // Enables applications to preview order pricing without creating an order. func (c *Client) Calculate( ctx context.Context, - request *squaregosdk.CalculateOrderRequest, + request *v2.CalculateOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.CalculateOrderResponse, error) { +) (*v2.CalculateOrderResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -150,7 +150,7 @@ func (c *Client) Calculate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CalculateOrderResponse + var response *v2.CalculateOrderResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -174,9 +174,9 @@ func (c *Client) Calculate( // only the core fields (such as line items, taxes, and discounts) copied from the original order. func (c *Client) Clone( ctx context.Context, - request *squaregosdk.CloneOrderRequest, + request *v2.CloneOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.CloneOrderResponse, error) { +) (*v2.CloneOrderResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -190,7 +190,7 @@ func (c *Client) Clone( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CloneOrderResponse + var response *v2.CloneOrderResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -230,9 +230,9 @@ func (c *Client) Clone( // not the time it was subsequently transmitted to Square. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchOrdersRequest, + request *v2.SearchOrdersRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchOrdersResponse, error) { +) (*v2.SearchOrdersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -246,7 +246,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchOrdersResponse + var response *v2.SearchOrdersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -269,9 +269,9 @@ func (c *Client) Search( // Retrieves an [Order](entity:Order) by ID. func (c *Client) Get( ctx context.Context, - request *squaregosdk.OrdersGetRequest, + request *v2.OrdersGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetOrderResponse, error) { +) (*v2.GetOrderResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -287,7 +287,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetOrderResponse + var response *v2.GetOrderResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -323,9 +323,9 @@ func (c *Client) Get( // [Pay for Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders). func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdateOrderRequest, + request *v2.UpdateOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateOrderResponse, error) { +) (*v2.UpdateOrderResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -342,7 +342,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateOrderResponse + var response *v2.UpdateOrderResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -378,9 +378,9 @@ func (c *Client) Update( // Using a delayed capture payment with `PayOrder` completes the approved payment. func (c *Client) Pay( ctx context.Context, - request *squaregosdk.PayOrderRequest, + request *v2.PayOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.PayOrderResponse, error) { +) (*v2.PayOrderResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -397,7 +397,7 @@ func (c *Client) Pay( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.PayOrderResponse + var response *v2.PayOrderResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/orders/custom_attribute_definitions.go b/orders/custom_attribute_definitions.go index 1d9d914..baedba2 100644 --- a/orders/custom_attribute_definitions.go +++ b/orders/custom_attribute_definitions.go @@ -3,7 +3,7 @@ package orders import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateOrderCustomAttributeDefinitionRequest struct { @@ -13,7 +13,7 @@ type CreateOrderCustomAttributeDefinitionRequest struct { // [Specifying the schema](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attribute-definitions#specify-schema). // - If provided, `name` must be unique (case-sensitive) across all visible customer-related custom attribute definitions for the seller. // - All custom attributes are visible in exported customer data, including those set to `VISIBILITY_HIDDEN`. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. // For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` @@ -34,7 +34,7 @@ type CustomAttributeDefinitionsGetRequest struct { type CustomAttributeDefinitionsListRequest struct { // Requests that all of the custom attributes be returned, or only those that are read-only or read-write. - VisibilityFilter *squaregosdk.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` + VisibilityFilter *v2.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` // The cursor returned in the paged response from the previous call to this endpoint. // Provide this cursor to retrieve the next page of results for your original request. // For more information, see [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). @@ -54,7 +54,7 @@ type UpdateOrderCustomAttributeDefinitionRequest struct { // [Updatable definition fields](https://developer.squareup.com/docs/orders-custom-attributes-api/custom-attribute-definitions#updatable-definition-fields). // // To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) control, include the optional `version` field and specify the current version of the custom attribute definition. - CustomAttributeDefinition *squaregosdk.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` + CustomAttributeDefinition *v2.CustomAttributeDefinition `json:"custom_attribute_definition,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. // For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/orders/custom_attributes.go b/orders/custom_attributes.go index 13a9640..ee48fd1 100644 --- a/orders/custom_attributes.go +++ b/orders/custom_attributes.go @@ -3,17 +3,17 @@ package orders import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type BulkDeleteOrderCustomAttributesRequest struct { // A map of requests that correspond to individual delete operations for custom attributes. - Values map[string]*squaregosdk.BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute `json:"values,omitempty" url:"-"` + Values map[string]*v2.BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute `json:"values,omitempty" url:"-"` } type BulkUpsertOrderCustomAttributesRequest struct { // A map of requests that correspond to individual upsert operations for custom attributes. - Values map[string]*squaregosdk.BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute `json:"values,omitempty" url:"-"` + Values map[string]*v2.BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute `json:"values,omitempty" url:"-"` } type CustomAttributesDeleteRequest struct { @@ -43,7 +43,7 @@ type CustomAttributesListRequest struct { // The ID of the target [order](entity:Order). OrderID string `json:"-" url:"-"` // Requests that all of the custom attributes be returned, or only those that are read-only or read-write. - VisibilityFilter *squaregosdk.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` + VisibilityFilter *v2.VisibilityFilter `json:"-" url:"visibility_filter,omitempty"` // The cursor returned in the paged response from the previous call to this endpoint. // Provide this cursor to retrieve the next page of results for your original request. // For more information, see [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). @@ -72,7 +72,7 @@ type UpsertOrderCustomAttributeRequest struct { // // - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) // control, include this optional field and specify the current version of the custom attribute. - CustomAttribute *squaregosdk.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` + CustomAttribute *v2.CustomAttribute `json:"custom_attribute,omitempty" url:"-"` // A unique identifier for this request, used to ensure idempotency. // For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` diff --git a/orders/customattributedefinitions/client.go b/orders/customattributedefinitions/client.go index 8bb36ab..22f7d34 100644 --- a/orders/customattributedefinitions/client.go +++ b/orders/customattributedefinitions/client.go @@ -5,11 +5,11 @@ package customattributedefinitions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - orders "github.com/square/square-go-sdk/orders" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + orders "github.com/square/square-go-sdk/v2/orders" http "net/http" os "os" ) @@ -50,7 +50,7 @@ func (c *Client) List( ctx context.Context, request *orders.CustomAttributeDefinitionsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttributeDefinition], error) { +) (*core.Page[*v2.CustomAttributeDefinition], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -86,10 +86,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListOrderCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition] { + readPageResponse := func(response *v2.ListOrderCustomAttributeDefinitionsResponse) *internal.PageResponse[*string, *v2.CustomAttributeDefinition] { next := response.Cursor results := response.CustomAttributeDefinitions - return &internal.PageResponse[*string, *squaregosdk.CustomAttributeDefinition]{ + return &internal.PageResponse[*string, *v2.CustomAttributeDefinition]{ Next: next, Results: results, } @@ -111,7 +111,7 @@ func (c *Client) Create( ctx context.Context, request *orders.CreateOrderCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateOrderCustomAttributeDefinitionResponse, error) { +) (*v2.CreateOrderCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -125,7 +125,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateOrderCustomAttributeDefinitionResponse + var response *v2.CreateOrderCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -154,7 +154,7 @@ func (c *Client) Get( ctx context.Context, request *orders.CustomAttributeDefinitionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveOrderCustomAttributeDefinitionResponse, error) { +) (*v2.RetrieveOrderCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -177,7 +177,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveOrderCustomAttributeDefinitionResponse + var response *v2.RetrieveOrderCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -203,7 +203,7 @@ func (c *Client) Update( ctx context.Context, request *orders.UpdateOrderCustomAttributeDefinitionRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateOrderCustomAttributeDefinitionResponse, error) { +) (*v2.UpdateOrderCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -220,7 +220,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateOrderCustomAttributeDefinitionResponse + var response *v2.UpdateOrderCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -247,7 +247,7 @@ func (c *Client) Delete( ctx context.Context, request *orders.CustomAttributeDefinitionsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteOrderCustomAttributeDefinitionResponse, error) { +) (*v2.DeleteOrderCustomAttributeDefinitionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -263,7 +263,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteOrderCustomAttributeDefinitionResponse + var response *v2.DeleteOrderCustomAttributeDefinitionResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/orders/customattributes/client.go b/orders/customattributes/client.go index cf857ed..975de13 100644 --- a/orders/customattributes/client.go +++ b/orders/customattributes/client.go @@ -5,11 +5,11 @@ package customattributes import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - orders "github.com/square/square-go-sdk/orders" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + orders "github.com/square/square-go-sdk/v2/orders" http "net/http" os "os" ) @@ -58,7 +58,7 @@ func (c *Client) BatchDelete( ctx context.Context, request *orders.BulkDeleteOrderCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkDeleteOrderCustomAttributesResponse, error) { +) (*v2.BulkDeleteOrderCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -72,7 +72,7 @@ func (c *Client) BatchDelete( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkDeleteOrderCustomAttributesResponse + var response *v2.BulkDeleteOrderCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -110,7 +110,7 @@ func (c *Client) BatchUpsert( ctx context.Context, request *orders.BulkUpsertOrderCustomAttributesRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkUpsertOrderCustomAttributesResponse, error) { +) (*v2.BulkUpsertOrderCustomAttributesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -124,7 +124,7 @@ func (c *Client) BatchUpsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkUpsertOrderCustomAttributesResponse + var response *v2.BulkUpsertOrderCustomAttributesResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -156,7 +156,7 @@ func (c *Client) List( ctx context.Context, request *orders.CustomAttributesListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.CustomAttribute], error) { +) (*core.Page[*v2.CustomAttribute], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -195,10 +195,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListOrderCustomAttributesResponse) *internal.PageResponse[*string, *squaregosdk.CustomAttribute] { + readPageResponse := func(response *v2.ListOrderCustomAttributesResponse) *internal.PageResponse[*string, *v2.CustomAttribute] { next := response.Cursor results := response.CustomAttributes - return &internal.PageResponse[*string, *squaregosdk.CustomAttribute]{ + return &internal.PageResponse[*string, *v2.CustomAttribute]{ Next: next, Results: results, } @@ -223,7 +223,7 @@ func (c *Client) Get( ctx context.Context, request *orders.CustomAttributesGetRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveOrderCustomAttributeResponse, error) { +) (*v2.RetrieveOrderCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -247,7 +247,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.RetrieveOrderCustomAttributeResponse + var response *v2.RetrieveOrderCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -279,7 +279,7 @@ func (c *Client) Upsert( ctx context.Context, request *orders.UpsertOrderCustomAttributeRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertOrderCustomAttributeResponse, error) { +) (*v2.UpsertOrderCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -297,7 +297,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertOrderCustomAttributeResponse + var response *v2.UpsertOrderCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -326,7 +326,7 @@ func (c *Client) Delete( ctx context.Context, request *orders.CustomAttributesDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteOrderCustomAttributeResponse, error) { +) (*v2.DeleteOrderCustomAttributeResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -343,7 +343,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteOrderCustomAttributeResponse + var response *v2.DeleteOrderCustomAttributeResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/payments.go b/payments.go index 34696c0..61d4743 100644 --- a/payments.go +++ b/payments.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type PaymentsCancelRequest struct { @@ -13,6 +13,11 @@ type PaymentsCancelRequest struct { PaymentID string `json:"-" url:"-"` } +type CancelPaymentByIdempotencyKeyRequest struct { + // The `idempotency_key` identifying the payment to be canceled. + IdempotencyKey string `json:"idempotency_key" url:"-"` +} + type CompletePaymentRequest struct { // The unique ID identifying the payment to be completed. PaymentID string `json:"-" url:"-"` @@ -649,6 +654,56 @@ func (b *BuyNowPayLaterDetails) String() string { return fmt.Sprintf("%#v", b) } +// Defines the response returned by +// [CancelPaymentByIdempotencyKey](api-endpoint:Payments-CancelPaymentByIdempotencyKey). +// On success, `errors` is empty. +type CancelPaymentByIdempotencyKeyResponse struct { + // Any errors that occurred during the request. + Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *CancelPaymentByIdempotencyKeyResponse) GetErrors() []*Error { + if c == nil { + return nil + } + return c.Errors +} + +func (c *CancelPaymentByIdempotencyKeyResponse) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CancelPaymentByIdempotencyKeyResponse) UnmarshalJSON(data []byte) error { + type unmarshaler CancelPaymentByIdempotencyKeyResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CancelPaymentByIdempotencyKeyResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *CancelPaymentByIdempotencyKeyResponse) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + // Defines the response returned by [CancelPayment](api-endpoint:Payments-CancelPayment). type CancelPaymentResponse struct { // Information about errors encountered during the request. diff --git a/payments/client.go b/payments/client.go index d91c099..379164d 100644 --- a/payments/client.go +++ b/payments/client.go @@ -5,10 +5,10 @@ package payments import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -47,9 +47,9 @@ func NewClient(opts ...option.RequestOption) *Client { // The maximum results per page is 100. func (c *Client) List( ctx context.Context, - request *squaregosdk.PaymentsListRequest, + request *v2.PaymentsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Payment], error) { +) (*core.Page[*v2.Payment], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -85,10 +85,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListPaymentsResponse) *internal.PageResponse[*string, *squaregosdk.Payment] { + readPageResponse := func(response *v2.ListPaymentsResponse) *internal.PageResponse[*string, *v2.Payment] { next := response.Cursor results := response.Payments - return &internal.PageResponse[*string, *squaregosdk.Payment]{ + return &internal.PageResponse[*string, *v2.Payment]{ Next: next, Results: results, } @@ -111,9 +111,9 @@ func (c *Client) List( // `Payment` object and returns it in the response. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreatePaymentRequest, + request *v2.CreatePaymentRequest, opts ...option.RequestOption, -) (*squaregosdk.CreatePaymentResponse, error) { +) (*v2.CreatePaymentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -127,7 +127,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreatePaymentResponse + var response *v2.CreatePaymentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -147,29 +147,36 @@ func (c *Client) Create( return response, nil } -// Cancels (voids) a payment. You can use this endpoint to cancel a payment with -// the APPROVED `status`. -func (c *Client) Cancel( +// Cancels (voids) a payment identified by the idempotency key that is specified in the +// request. +// +// Use this method when the status of a `CreatePayment` request is unknown (for example, after you send a +// `CreatePayment` request, a network error occurs and you do not get a response). In this case, you can +// direct Square to cancel the payment using this endpoint. In the request, you provide the same +// idempotency key that you provided in your `CreatePayment` request that you want to cancel. After +// canceling the payment, you can submit your `CreatePayment` request again. +// +// Note that if no payment with the specified idempotency key is found, no action is taken and the endpoint +// returns successfully. +func (c *Client) CancelByIdempotencyKey( ctx context.Context, - request *squaregosdk.PaymentsCancelRequest, + request *v2.CancelPaymentByIdempotencyKeyRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelPaymentResponse, error) { +) (*v2.CancelPaymentByIdempotencyKeyResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, c.baseURL, "https://connect.squareup.com", ) - endpointURL := internal.EncodeURL( - baseURL+"/v2/payments/%v/cancel", - request.PaymentID, - ) + endpointURL := baseURL + "/v2/payments/cancel" headers := internal.MergeHeaders( c.header.Clone(), options.ToHeader(), ) + headers.Set("Content-Type", "application/json") - var response *squaregosdk.CancelPaymentResponse + var response *v2.CancelPaymentByIdempotencyKeyResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -180,6 +187,7 @@ func (c *Client) Cancel( BodyProperties: options.BodyProperties, QueryParameters: options.QueryParameters, Client: options.HTTPClient, + Request: request, Response: &response, }, ); err != nil { @@ -191,9 +199,9 @@ func (c *Client) Cancel( // Retrieves details for a specific payment. func (c *Client) Get( ctx context.Context, - request *squaregosdk.PaymentsGetRequest, + request *v2.PaymentsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetPaymentResponse, error) { +) (*v2.GetPaymentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -209,7 +217,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetPaymentResponse + var response *v2.GetPaymentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -232,9 +240,9 @@ func (c *Client) Get( // You can update the `amount_money` and `tip_money` using this endpoint. func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdatePaymentRequest, + request *v2.UpdatePaymentRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdatePaymentResponse, error) { +) (*v2.UpdatePaymentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -251,7 +259,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdatePaymentResponse + var response *v2.UpdatePaymentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -271,15 +279,56 @@ func (c *Client) Update( return response, nil } +// Cancels (voids) a payment. You can use this endpoint to cancel a payment with +// the APPROVED `status`. +func (c *Client) Cancel( + ctx context.Context, + request *v2.PaymentsCancelRequest, + opts ...option.RequestOption, +) (*v2.CancelPaymentResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://connect.squareup.com", + ) + endpointURL := internal.EncodeURL( + baseURL+"/v2/payments/%v/cancel", + request.PaymentID, + ) + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + var response *v2.CancelPaymentResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} + // Completes (captures) a payment. // By default, payments are set to complete immediately after they are created. // // You can use this endpoint to complete a payment with the APPROVED `status`. func (c *Client) Complete( ctx context.Context, - request *squaregosdk.CompletePaymentRequest, + request *v2.CompletePaymentRequest, opts ...option.RequestOption, -) (*squaregosdk.CompletePaymentResponse, error) { +) (*v2.CompletePaymentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -296,7 +345,7 @@ func (c *Client) Complete( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CompletePaymentResponse + var response *v2.CompletePaymentResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/payouts.go b/payouts.go index 9503579..6a792ad 100644 --- a/payouts.go +++ b/payouts.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type PayoutsListEntriesRequest struct { diff --git a/payouts/client.go b/payouts/client.go index 3772df9..bb06f75 100644 --- a/payouts/client.go +++ b/payouts/client.go @@ -5,10 +5,10 @@ package payouts import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -44,9 +44,9 @@ func NewClient(opts ...option.RequestOption) *Client { // To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. func (c *Client) List( ctx context.Context, - request *squaregosdk.PayoutsListRequest, + request *v2.PayoutsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.Payout], error) { +) (*core.Page[*v2.Payout], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -82,10 +82,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListPayoutsResponse) *internal.PageResponse[*string, *squaregosdk.Payout] { + readPageResponse := func(response *v2.ListPayoutsResponse) *internal.PageResponse[*string, *v2.Payout] { next := response.Cursor results := response.Payouts - return &internal.PageResponse[*string, *squaregosdk.Payout]{ + return &internal.PageResponse[*string, *v2.Payout]{ Next: next, Results: results, } @@ -102,9 +102,9 @@ func (c *Client) List( // To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. func (c *Client) Get( ctx context.Context, - request *squaregosdk.PayoutsGetRequest, + request *v2.PayoutsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetPayoutResponse, error) { +) (*v2.GetPayoutResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -120,7 +120,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetPayoutResponse + var response *v2.GetPayoutResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -143,9 +143,9 @@ func (c *Client) Get( // To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. func (c *Client) ListEntries( ctx context.Context, - request *squaregosdk.PayoutsListEntriesRequest, + request *v2.PayoutsListEntriesRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.PayoutEntry], error) { +) (*core.Page[*v2.PayoutEntry], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -184,10 +184,10 @@ func (c *Client) ListEntries( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListPayoutEntriesResponse) *internal.PageResponse[*string, *squaregosdk.PayoutEntry] { + readPageResponse := func(response *v2.ListPayoutEntriesResponse) *internal.PageResponse[*string, *v2.PayoutEntry] { next := response.Cursor results := response.PayoutEntries - return &internal.PageResponse[*string, *squaregosdk.PayoutEntry]{ + return &internal.PageResponse[*string, *v2.PayoutEntry]{ Next: next, Results: results, } diff --git a/refunds.go b/refunds.go index 6fe0f32..582a7aa 100644 --- a/refunds.go +++ b/refunds.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type RefundPaymentRequest struct { diff --git a/refunds/client.go b/refunds/client.go index 7f067fc..0ec4d4a 100644 --- a/refunds/client.go +++ b/refunds/client.go @@ -5,10 +5,10 @@ package refunds import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -47,9 +47,9 @@ func NewClient(opts ...option.RequestOption) *Client { // The maximum results per page is 100. func (c *Client) List( ctx context.Context, - request *squaregosdk.RefundsListRequest, + request *v2.RefundsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.PaymentRefund], error) { +) (*core.Page[*v2.PaymentRefund], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -85,10 +85,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListPaymentRefundsResponse) *internal.PageResponse[*string, *squaregosdk.PaymentRefund] { + readPageResponse := func(response *v2.ListPaymentRefundsResponse) *internal.PageResponse[*string, *v2.PaymentRefund] { next := response.Cursor results := response.Refunds - return &internal.PageResponse[*string, *squaregosdk.PaymentRefund]{ + return &internal.PageResponse[*string, *v2.PaymentRefund]{ Next: next, Results: results, } @@ -107,9 +107,9 @@ func (c *Client) List( // [Refund Payment](https://developer.squareup.com/docs/payments-api/refund-payments). func (c *Client) RefundPayment( ctx context.Context, - request *squaregosdk.RefundPaymentRequest, + request *v2.RefundPaymentRequest, opts ...option.RequestOption, -) (*squaregosdk.RefundPaymentResponse, error) { +) (*v2.RefundPaymentResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -123,7 +123,7 @@ func (c *Client) RefundPayment( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.RefundPaymentResponse + var response *v2.RefundPaymentResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -146,9 +146,9 @@ func (c *Client) RefundPayment( // Retrieves a specific refund using the `refund_id`. func (c *Client) Get( ctx context.Context, - request *squaregosdk.RefundsGetRequest, + request *v2.RefundsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetPaymentRefundResponse, error) { +) (*v2.GetPaymentRefundResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -164,7 +164,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetPaymentRefundResponse + var response *v2.GetPaymentRefundResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/sites.go b/sites.go index d9eb8dd..8453cab 100644 --- a/sites.go +++ b/sites.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) // Represents a `ListSites` response. The response can include either `sites` or `errors`. diff --git a/sites/client.go b/sites/client.go index 19f44ff..dc315aa 100644 --- a/sites/client.go +++ b/sites/client.go @@ -4,10 +4,10 @@ package sites import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -44,7 +44,7 @@ func NewClient(opts ...option.RequestOption) *Client { func (c *Client) List( ctx context.Context, opts ...option.RequestOption, -) (*squaregosdk.ListSitesResponse, error) { +) (*v2.ListSitesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -57,7 +57,7 @@ func (c *Client) List( options.ToHeader(), ) - var response *squaregosdk.ListSitesResponse + var response *v2.ListSitesResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/snippets.go b/snippets.go index 14ef4fa..e2a97b6 100644 --- a/snippets.go +++ b/snippets.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type SnippetsDeleteRequest struct { diff --git a/snippets/client.go b/snippets/client.go index 6d3c1c7..1355f84 100644 --- a/snippets/client.go +++ b/snippets/client.go @@ -4,10 +4,10 @@ package snippets import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -45,9 +45,9 @@ func NewClient(opts ...option.RequestOption) *Client { // __Note:__ Square Online APIs are publicly available as part of an early access program. For more information, see [Early access program for Square Online APIs](https://developer.squareup.com/docs/online-api#early-access-program-for-square-online-apis). func (c *Client) Get( ctx context.Context, - request *squaregosdk.SnippetsGetRequest, + request *v2.SnippetsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetSnippetResponse, error) { +) (*v2.GetSnippetResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -63,7 +63,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetSnippetResponse + var response *v2.GetSnippetResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -90,9 +90,9 @@ func (c *Client) Get( // __Note:__ Square Online APIs are publicly available as part of an early access program. For more information, see [Early access program for Square Online APIs](https://developer.squareup.com/docs/online-api#early-access-program-for-square-online-apis). func (c *Client) Upsert( ctx context.Context, - request *squaregosdk.UpsertSnippetRequest, + request *v2.UpsertSnippetRequest, opts ...option.RequestOption, -) (*squaregosdk.UpsertSnippetResponse, error) { +) (*v2.UpsertSnippetResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -109,7 +109,7 @@ func (c *Client) Upsert( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpsertSnippetResponse + var response *v2.UpsertSnippetResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -136,9 +136,9 @@ func (c *Client) Upsert( // __Note:__ Square Online APIs are publicly available as part of an early access program. For more information, see [Early access program for Square Online APIs](https://developer.squareup.com/docs/online-api#early-access-program-for-square-online-apis). func (c *Client) Delete( ctx context.Context, - request *squaregosdk.SnippetsDeleteRequest, + request *v2.SnippetsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteSnippetResponse, error) { +) (*v2.DeleteSnippetResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -154,7 +154,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteSnippetResponse + var response *v2.DeleteSnippetResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/subscriptions.go b/subscriptions.go index 66e034e..7a454eb 100644 --- a/subscriptions.go +++ b/subscriptions.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type BulkSwapPlanRequest struct { diff --git a/subscriptions/client.go b/subscriptions/client.go index 033a00e..894fd82 100644 --- a/subscriptions/client.go +++ b/subscriptions/client.go @@ -5,10 +5,10 @@ package subscriptions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -49,9 +49,9 @@ func NewClient(opts ...option.RequestOption) *Client { // For more information, see [Create a subscription](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#create-a-subscription). func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateSubscriptionRequest, + request *v2.CreateSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateSubscriptionResponse, error) { +) (*v2.CreateSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -65,7 +65,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateSubscriptionResponse + var response *v2.CreateSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -89,9 +89,9 @@ func (c *Client) Create( // variation. For more information, see [Swap Subscription Plan Variations](https://developer.squareup.com/docs/subscriptions-api/swap-plan-variations). func (c *Client) BulkSwapPlan( ctx context.Context, - request *squaregosdk.BulkSwapPlanRequest, + request *v2.BulkSwapPlanRequest, opts ...option.RequestOption, -) (*squaregosdk.BulkSwapPlanResponse, error) { +) (*v2.BulkSwapPlanResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -105,7 +105,7 @@ func (c *Client) BulkSwapPlan( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BulkSwapPlanResponse + var response *v2.BulkSwapPlanResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -141,9 +141,9 @@ func (c *Client) BulkSwapPlan( // customer by subscription creation date. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchSubscriptionsRequest, + request *v2.SearchSubscriptionsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchSubscriptionsResponse, error) { +) (*v2.SearchSubscriptionsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -157,7 +157,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchSubscriptionsResponse + var response *v2.SearchSubscriptionsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -180,9 +180,9 @@ func (c *Client) Search( // Retrieves a specific subscription. func (c *Client) Get( ctx context.Context, - request *squaregosdk.SubscriptionsGetRequest, + request *v2.SubscriptionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetSubscriptionResponse, error) { +) (*v2.GetSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -205,7 +205,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetSubscriptionResponse + var response *v2.GetSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -228,9 +228,9 @@ func (c *Client) Get( // To clear a field, set its value to `null`. func (c *Client) Update( ctx context.Context, - request *squaregosdk.UpdateSubscriptionRequest, + request *v2.UpdateSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateSubscriptionResponse, error) { +) (*v2.UpdateSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -247,7 +247,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateSubscriptionResponse + var response *v2.UpdateSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -270,9 +270,9 @@ func (c *Client) Update( // Deletes a scheduled action for a subscription. func (c *Client) DeleteAction( ctx context.Context, - request *squaregosdk.SubscriptionsDeleteActionRequest, + request *v2.SubscriptionsDeleteActionRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteSubscriptionActionResponse, error) { +) (*v2.DeleteSubscriptionActionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -289,7 +289,7 @@ func (c *Client) DeleteAction( options.ToHeader(), ) - var response *squaregosdk.DeleteSubscriptionActionResponse + var response *v2.DeleteSubscriptionActionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -312,9 +312,9 @@ func (c *Client) DeleteAction( // for a subscription. func (c *Client) ChangeBillingAnchorDate( ctx context.Context, - request *squaregosdk.ChangeBillingAnchorDateRequest, + request *v2.ChangeBillingAnchorDateRequest, opts ...option.RequestOption, -) (*squaregosdk.ChangeBillingAnchorDateResponse, error) { +) (*v2.ChangeBillingAnchorDateResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -331,7 +331,7 @@ func (c *Client) ChangeBillingAnchorDate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.ChangeBillingAnchorDateResponse + var response *v2.ChangeBillingAnchorDateResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -356,9 +356,9 @@ func (c *Client) ChangeBillingAnchorDate( // the subscription status changes from ACTIVE to CANCELED. func (c *Client) Cancel( ctx context.Context, - request *squaregosdk.SubscriptionsCancelRequest, + request *v2.SubscriptionsCancelRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelSubscriptionResponse, error) { +) (*v2.CancelSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -374,7 +374,7 @@ func (c *Client) Cancel( options.ToHeader(), ) - var response *squaregosdk.CancelSubscriptionResponse + var response *v2.CancelSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -396,9 +396,9 @@ func (c *Client) Cancel( // Lists all [events](https://developer.squareup.com/docs/subscriptions-api/actions-events) for a specific subscription. func (c *Client) ListEvents( ctx context.Context, - request *squaregosdk.SubscriptionsListEventsRequest, + request *v2.SubscriptionsListEventsRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.SubscriptionEvent], error) { +) (*core.Page[*v2.SubscriptionEvent], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -437,10 +437,10 @@ func (c *Client) ListEvents( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListSubscriptionEventsResponse) *internal.PageResponse[*string, *squaregosdk.SubscriptionEvent] { + readPageResponse := func(response *v2.ListSubscriptionEventsResponse) *internal.PageResponse[*string, *v2.SubscriptionEvent] { next := response.Cursor results := response.SubscriptionEvents - return &internal.PageResponse[*string, *squaregosdk.SubscriptionEvent]{ + return &internal.PageResponse[*string, *v2.SubscriptionEvent]{ Next: next, Results: results, } @@ -456,9 +456,9 @@ func (c *Client) ListEvents( // Schedules a `PAUSE` action to pause an active subscription. func (c *Client) Pause( ctx context.Context, - request *squaregosdk.PauseSubscriptionRequest, + request *v2.PauseSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.PauseSubscriptionResponse, error) { +) (*v2.PauseSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -475,7 +475,7 @@ func (c *Client) Pause( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.PauseSubscriptionResponse + var response *v2.PauseSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -498,9 +498,9 @@ func (c *Client) Pause( // Schedules a `RESUME` action to resume a paused or a deactivated subscription. func (c *Client) Resume( ctx context.Context, - request *squaregosdk.ResumeSubscriptionRequest, + request *v2.ResumeSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.ResumeSubscriptionResponse, error) { +) (*v2.ResumeSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -517,7 +517,7 @@ func (c *Client) Resume( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.ResumeSubscriptionResponse + var response *v2.ResumeSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -541,9 +541,9 @@ func (c *Client) Resume( // For more information, see [Swap Subscription Plan Variations](https://developer.squareup.com/docs/subscriptions-api/swap-plan-variations). func (c *Client) SwapPlan( ctx context.Context, - request *squaregosdk.SwapPlanRequest, + request *v2.SwapPlanRequest, opts ...option.RequestOption, -) (*squaregosdk.SwapPlanResponse, error) { +) (*v2.SwapPlanResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -560,7 +560,7 @@ func (c *Client) SwapPlan( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SwapPlanResponse + var response *v2.SwapPlanResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/team.go b/team.go index 649595b..4af53f9 100644 --- a/team.go +++ b/team.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type CreateJobRequest struct { diff --git a/team/client.go b/team/client.go index 0b75c98..e996bf1 100644 --- a/team/client.go +++ b/team/client.go @@ -4,10 +4,10 @@ package team import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -41,9 +41,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Lists jobs in a seller account. Results are sorted by title in ascending order. func (c *Client) ListJobs( ctx context.Context, - request *squaregosdk.ListJobsRequest, + request *v2.ListJobsRequest, opts ...option.RequestOption, -) (*squaregosdk.ListJobsResponse, error) { +) (*v2.ListJobsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -63,7 +63,7 @@ func (c *Client) ListJobs( options.ToHeader(), ) - var response *squaregosdk.ListJobsResponse + var response *v2.ListJobsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -86,9 +86,9 @@ func (c *Client) ListJobs( // compensation is defined in a [job assignment](entity:JobAssignment) in a team member's wage setting. func (c *Client) CreateJob( ctx context.Context, - request *squaregosdk.CreateJobRequest, + request *v2.CreateJobRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateJobResponse, error) { +) (*v2.CreateJobResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -102,7 +102,7 @@ func (c *Client) CreateJob( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateJobResponse + var response *v2.CreateJobResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -125,9 +125,9 @@ func (c *Client) CreateJob( // Retrieves a specified job. func (c *Client) RetrieveJob( ctx context.Context, - request *squaregosdk.RetrieveJobRequest, + request *v2.RetrieveJobRequest, opts ...option.RequestOption, -) (*squaregosdk.RetrieveJobResponse, error) { +) (*v2.RetrieveJobResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -143,7 +143,7 @@ func (c *Client) RetrieveJob( options.ToHeader(), ) - var response *squaregosdk.RetrieveJobResponse + var response *v2.RetrieveJobResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -167,9 +167,9 @@ func (c *Client) RetrieveJob( // tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID. func (c *Client) UpdateJob( ctx context.Context, - request *squaregosdk.UpdateJobRequest, + request *v2.UpdateJobRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateJobResponse, error) { +) (*v2.UpdateJobResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -186,7 +186,7 @@ func (c *Client) UpdateJob( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateJobResponse + var response *v2.UpdateJobResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/team_members.go b/team_members.go index 5f2c7f4..6f02c1c 100644 --- a/team_members.go +++ b/team_members.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type BatchCreateTeamMembersRequest struct { diff --git a/teammembers/client/client.go b/teammembers/client/client.go index b96ec1f..74f1557 100644 --- a/teammembers/client/client.go +++ b/teammembers/client/client.go @@ -4,11 +4,11 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - wagesetting "github.com/square/square-go-sdk/teammembers/wagesetting" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + wagesetting "github.com/square/square-go-sdk/v2/teammembers/wagesetting" http "net/http" os "os" ) @@ -50,9 +50,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#createteammember). func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateTeamMemberRequest, + request *v2.CreateTeamMemberRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateTeamMemberResponse, error) { +) (*v2.CreateTeamMemberResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -66,7 +66,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateTeamMemberResponse + var response *v2.CreateTeamMemberResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -94,9 +94,9 @@ func (c *Client) Create( // Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#bulk-create-team-members). func (c *Client) BatchCreate( ctx context.Context, - request *squaregosdk.BatchCreateTeamMembersRequest, + request *v2.BatchCreateTeamMembersRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchCreateTeamMembersResponse, error) { +) (*v2.BatchCreateTeamMembersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -110,7 +110,7 @@ func (c *Client) BatchCreate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchCreateTeamMembersResponse + var response *v2.BatchCreateTeamMembersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -137,9 +137,9 @@ func (c *Client) BatchCreate( // Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#bulk-update-team-members). func (c *Client) BatchUpdate( ctx context.Context, - request *squaregosdk.BatchUpdateTeamMembersRequest, + request *v2.BatchUpdateTeamMembersRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchUpdateTeamMembersResponse, error) { +) (*v2.BatchUpdateTeamMembersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -153,7 +153,7 @@ func (c *Client) BatchUpdate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchUpdateTeamMembersResponse + var response *v2.BatchUpdateTeamMembersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -178,9 +178,9 @@ func (c *Client) BatchUpdate( // the team member is the Square account owner. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchTeamMembersRequest, + request *v2.SearchTeamMembersRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchTeamMembersResponse, error) { +) (*v2.SearchTeamMembersResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -194,7 +194,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchTeamMembersResponse + var response *v2.SearchTeamMembersResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -218,9 +218,9 @@ func (c *Client) Search( // Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#retrieve-a-team-member). func (c *Client) Get( ctx context.Context, - request *squaregosdk.TeamMembersGetRequest, + request *v2.TeamMembersGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTeamMemberResponse, error) { +) (*v2.GetTeamMemberResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -236,7 +236,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTeamMemberResponse + var response *v2.GetTeamMemberResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -259,9 +259,9 @@ func (c *Client) Get( // Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/team/troubleshooting#update-a-team-member). func (c *Client) Update( ctx context.Context, - request *squaregosdk.TeamMembersUpdateRequest, + request *v2.TeamMembersUpdateRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateTeamMemberResponse, error) { +) (*v2.UpdateTeamMemberResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -278,7 +278,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateTeamMemberResponse + var response *v2.UpdateTeamMemberResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/teammembers/wage_setting.go b/teammembers/wage_setting.go index dcd27f5..8e3b3bc 100644 --- a/teammembers/wage_setting.go +++ b/teammembers/wage_setting.go @@ -3,7 +3,7 @@ package teammembers import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type WageSettingGetRequest struct { @@ -19,5 +19,5 @@ type UpdateWageSettingRequest struct { // Requires Square API version 2024-12-18 or later. // - `job_title` - Use the exact, case-sensitive spelling of an existing title unless you want to create a new job. // This value is ignored if `job_id` is also provided. - WageSetting *squaregosdk.WageSetting `json:"wage_setting,omitempty" url:"-"` + WageSetting *v2.WageSetting `json:"wage_setting,omitempty" url:"-"` } diff --git a/teammembers/wagesetting/client.go b/teammembers/wagesetting/client.go index efdca2e..ccca353 100644 --- a/teammembers/wagesetting/client.go +++ b/teammembers/wagesetting/client.go @@ -4,11 +4,11 @@ package wagesetting import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - teammembers "github.com/square/square-go-sdk/teammembers" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + teammembers "github.com/square/square-go-sdk/v2/teammembers" http "net/http" os "os" ) @@ -49,7 +49,7 @@ func (c *Client) Get( ctx context.Context, request *teammembers.WageSettingGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetWageSettingResponse, error) { +) (*v2.GetWageSettingResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -65,7 +65,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetWageSettingResponse + var response *v2.GetWageSettingResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -96,7 +96,7 @@ func (c *Client) Update( ctx context.Context, request *teammembers.UpdateWageSettingRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateWageSettingResponse, error) { +) (*v2.UpdateWageSettingResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -113,7 +113,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateWageSettingResponse + var response *v2.UpdateWageSettingResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/terminal.go b/terminal.go index a119073..3a26d81 100644 --- a/terminal.go +++ b/terminal.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type DismissTerminalActionRequest struct { diff --git a/terminal/actions.go b/terminal/actions.go index 642dd25..9455b51 100644 --- a/terminal/actions.go +++ b/terminal/actions.go @@ -3,7 +3,7 @@ package terminal import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type ActionsCancelRequest struct { @@ -19,7 +19,7 @@ type CreateTerminalActionRequest struct { // information. IdempotencyKey string `json:"idempotency_key" url:"-"` // The Action to create. - Action *squaregosdk.TerminalAction `json:"action,omitempty" url:"-"` + Action *v2.TerminalAction `json:"action,omitempty" url:"-"` } type ActionsGetRequest struct { @@ -30,7 +30,7 @@ type ActionsGetRequest struct { type SearchTerminalActionsRequest struct { // Queries terminal actions based on given conditions and sort order. // Leaving this unset will return all actions with the default sort order. - Query *squaregosdk.TerminalActionQuery `json:"query,omitempty" url:"-"` + Query *v2.TerminalActionQuery `json:"query,omitempty" url:"-"` // A pagination cursor returned by a previous call to this endpoint. // Provide this to retrieve the next set of results for the original query. // See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) for more diff --git a/terminal/actions/client.go b/terminal/actions/client.go index 80daf2d..e47fb46 100644 --- a/terminal/actions/client.go +++ b/terminal/actions/client.go @@ -4,11 +4,11 @@ package actions import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - terminal "github.com/square/square-go-sdk/terminal" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + terminal "github.com/square/square-go-sdk/v2/terminal" http "net/http" os "os" ) @@ -44,7 +44,7 @@ func (c *Client) Create( ctx context.Context, request *terminal.CreateTerminalActionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateTerminalActionResponse, error) { +) (*v2.CreateTerminalActionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -58,7 +58,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateTerminalActionResponse + var response *v2.CreateTerminalActionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -83,7 +83,7 @@ func (c *Client) Search( ctx context.Context, request *terminal.SearchTerminalActionsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchTerminalActionsResponse, error) { +) (*v2.SearchTerminalActionsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -97,7 +97,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchTerminalActionsResponse + var response *v2.SearchTerminalActionsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -122,7 +122,7 @@ func (c *Client) Get( ctx context.Context, request *terminal.ActionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTerminalActionResponse, error) { +) (*v2.GetTerminalActionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -138,7 +138,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTerminalActionResponse + var response *v2.GetTerminalActionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -162,7 +162,7 @@ func (c *Client) Cancel( ctx context.Context, request *terminal.ActionsCancelRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelTerminalActionResponse, error) { +) (*v2.CancelTerminalActionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -178,7 +178,7 @@ func (c *Client) Cancel( options.ToHeader(), ) - var response *squaregosdk.CancelTerminalActionResponse + var response *v2.CancelTerminalActionResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/terminal/checkouts.go b/terminal/checkouts.go index a5a6903..be4775c 100644 --- a/terminal/checkouts.go +++ b/terminal/checkouts.go @@ -3,7 +3,7 @@ package terminal import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CheckoutsCancelRequest struct { @@ -18,7 +18,7 @@ type CreateTerminalCheckoutRequest struct { // See [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information. IdempotencyKey string `json:"idempotency_key" url:"-"` // The checkout to create. - Checkout *squaregosdk.TerminalCheckout `json:"checkout,omitempty" url:"-"` + Checkout *v2.TerminalCheckout `json:"checkout,omitempty" url:"-"` } type CheckoutsGetRequest struct { @@ -29,7 +29,7 @@ type CheckoutsGetRequest struct { type SearchTerminalCheckoutsRequest struct { // Queries Terminal checkouts based on given conditions and the sort order. // Leaving these unset returns all checkouts with the default sort order. - Query *squaregosdk.TerminalCheckoutQuery `json:"query,omitempty" url:"-"` + Query *v2.TerminalCheckoutQuery `json:"query,omitempty" url:"-"` // A pagination cursor returned by a previous call to this endpoint. // Provide this cursor to retrieve the next set of results for the original query. // See [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) for more information. diff --git a/terminal/checkouts/client.go b/terminal/checkouts/client.go index a1bfb28..8c289f6 100644 --- a/terminal/checkouts/client.go +++ b/terminal/checkouts/client.go @@ -4,11 +4,11 @@ package checkouts import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - terminal "github.com/square/square-go-sdk/terminal" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + terminal "github.com/square/square-go-sdk/v2/terminal" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) Create( ctx context.Context, request *terminal.CreateTerminalCheckoutRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateTerminalCheckoutResponse, error) { +) (*v2.CreateTerminalCheckoutResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -59,7 +59,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateTerminalCheckoutResponse + var response *v2.CreateTerminalCheckoutResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -84,7 +84,7 @@ func (c *Client) Search( ctx context.Context, request *terminal.SearchTerminalCheckoutsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchTerminalCheckoutsResponse, error) { +) (*v2.SearchTerminalCheckoutsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -98,7 +98,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchTerminalCheckoutsResponse + var response *v2.SearchTerminalCheckoutsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -123,7 +123,7 @@ func (c *Client) Get( ctx context.Context, request *terminal.CheckoutsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTerminalCheckoutResponse, error) { +) (*v2.GetTerminalCheckoutResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -139,7 +139,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTerminalCheckoutResponse + var response *v2.GetTerminalCheckoutResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -163,7 +163,7 @@ func (c *Client) Cancel( ctx context.Context, request *terminal.CheckoutsCancelRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelTerminalCheckoutResponse, error) { +) (*v2.CancelTerminalCheckoutResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -179,7 +179,7 @@ func (c *Client) Cancel( options.ToHeader(), ) - var response *squaregosdk.CancelTerminalCheckoutResponse + var response *v2.CancelTerminalCheckoutResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/terminal/client/client.go b/terminal/client/client.go index 403bb87..8a72d34 100644 --- a/terminal/client/client.go +++ b/terminal/client/client.go @@ -4,13 +4,13 @@ package client import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - actions "github.com/square/square-go-sdk/terminal/actions" - checkouts "github.com/square/square-go-sdk/terminal/checkouts" - refunds "github.com/square/square-go-sdk/terminal/refunds" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + actions "github.com/square/square-go-sdk/v2/terminal/actions" + checkouts "github.com/square/square-go-sdk/v2/terminal/checkouts" + refunds "github.com/square/square-go-sdk/v2/terminal/refunds" http "net/http" os "os" ) @@ -53,9 +53,9 @@ func NewClient(opts ...option.RequestOption) *Client { // See [Link and Dismiss Actions](https://developer.squareup.com/docs/terminal-api/advanced-features/custom-workflows/link-and-dismiss-actions) for more details. func (c *Client) DismissTerminalAction( ctx context.Context, - request *squaregosdk.DismissTerminalActionRequest, + request *v2.DismissTerminalActionRequest, opts ...option.RequestOption, -) (*squaregosdk.DismissTerminalActionResponse, error) { +) (*v2.DismissTerminalActionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -71,7 +71,7 @@ func (c *Client) DismissTerminalAction( options.ToHeader(), ) - var response *squaregosdk.DismissTerminalActionResponse + var response *v2.DismissTerminalActionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -93,9 +93,9 @@ func (c *Client) DismissTerminalAction( // Dismisses a Terminal checkout request if the status and type of the request permits it. func (c *Client) DismissTerminalCheckout( ctx context.Context, - request *squaregosdk.DismissTerminalCheckoutRequest, + request *v2.DismissTerminalCheckoutRequest, opts ...option.RequestOption, -) (*squaregosdk.DismissTerminalCheckoutResponse, error) { +) (*v2.DismissTerminalCheckoutResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -111,7 +111,7 @@ func (c *Client) DismissTerminalCheckout( options.ToHeader(), ) - var response *squaregosdk.DismissTerminalCheckoutResponse + var response *v2.DismissTerminalCheckoutResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -133,9 +133,9 @@ func (c *Client) DismissTerminalCheckout( // Dismisses a Terminal refund request if the status and type of the request permits it. func (c *Client) DismissTerminalRefund( ctx context.Context, - request *squaregosdk.DismissTerminalRefundRequest, + request *v2.DismissTerminalRefundRequest, opts ...option.RequestOption, -) (*squaregosdk.DismissTerminalRefundResponse, error) { +) (*v2.DismissTerminalRefundResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -151,7 +151,7 @@ func (c *Client) DismissTerminalRefund( options.ToHeader(), ) - var response *squaregosdk.DismissTerminalRefundResponse + var response *v2.DismissTerminalRefundResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/terminal/refunds.go b/terminal/refunds.go index a8160a6..d8bf941 100644 --- a/terminal/refunds.go +++ b/terminal/refunds.go @@ -3,7 +3,7 @@ package terminal import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type RefundsCancelRequest struct { @@ -18,7 +18,7 @@ type CreateTerminalRefundRequest struct { // See [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information. IdempotencyKey string `json:"idempotency_key" url:"-"` // The refund to create. - Refund *squaregosdk.TerminalRefund `json:"refund,omitempty" url:"-"` + Refund *v2.TerminalRefund `json:"refund,omitempty" url:"-"` } type RefundsGetRequest struct { @@ -30,7 +30,7 @@ type SearchTerminalRefundsRequest struct { // Queries the Terminal refunds based on given conditions and the sort order. Calling // `SearchTerminalRefunds` without an explicit query parameter returns all available // refunds with the default sort order. - Query *squaregosdk.TerminalRefundQuery `json:"query,omitempty" url:"-"` + Query *v2.TerminalRefundQuery `json:"query,omitempty" url:"-"` // A pagination cursor returned by a previous call to this endpoint. // Provide this cursor to retrieve the next set of results for the original query. Cursor *string `json:"cursor,omitempty" url:"-"` diff --git a/terminal/refunds/client.go b/terminal/refunds/client.go index c203feb..50bfdfd 100644 --- a/terminal/refunds/client.go +++ b/terminal/refunds/client.go @@ -4,11 +4,11 @@ package refunds import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - terminal "github.com/square/square-go-sdk/terminal" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + terminal "github.com/square/square-go-sdk/v2/terminal" http "net/http" os "os" ) @@ -44,7 +44,7 @@ func (c *Client) Create( ctx context.Context, request *terminal.CreateTerminalRefundRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateTerminalRefundResponse, error) { +) (*v2.CreateTerminalRefundResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -58,7 +58,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateTerminalRefundResponse + var response *v2.CreateTerminalRefundResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -83,7 +83,7 @@ func (c *Client) Search( ctx context.Context, request *terminal.SearchTerminalRefundsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchTerminalRefundsResponse, error) { +) (*v2.SearchTerminalRefundsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -97,7 +97,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchTerminalRefundsResponse + var response *v2.SearchTerminalRefundsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -122,7 +122,7 @@ func (c *Client) Get( ctx context.Context, request *terminal.RefundsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetTerminalRefundResponse, error) { +) (*v2.GetTerminalRefundResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -138,7 +138,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetTerminalRefundResponse + var response *v2.GetTerminalRefundResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -162,7 +162,7 @@ func (c *Client) Cancel( ctx context.Context, request *terminal.RefundsCancelRequest, opts ...option.RequestOption, -) (*squaregosdk.CancelTerminalRefundResponse, error) { +) (*v2.CancelTerminalRefundResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -178,7 +178,7 @@ func (c *Client) Cancel( options.ToHeader(), ) - var response *squaregosdk.CancelTerminalRefundResponse + var response *v2.CancelTerminalRefundResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/types.go b/types.go index 7bcd960..f448385 100644 --- a/types.go +++ b/types.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type AcceptedPaymentMethods struct { @@ -2443,56 +2443,6 @@ func (c *CancelLoyaltyPromotionResponse) String() string { return fmt.Sprintf("%#v", c) } -// Defines the response returned by -// [CancelPaymentByIdempotencyKey](api-endpoint:Payments-CancelPaymentByIdempotencyKey). -// On success, `errors` is empty. -type CancelPaymentByIdempotencyKeyResponse struct { - // Any errors that occurred during the request. - Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` - - extraProperties map[string]interface{} - rawJSON json.RawMessage -} - -func (c *CancelPaymentByIdempotencyKeyResponse) GetErrors() []*Error { - if c == nil { - return nil - } - return c.Errors -} - -func (c *CancelPaymentByIdempotencyKeyResponse) GetExtraProperties() map[string]interface{} { - return c.extraProperties -} - -func (c *CancelPaymentByIdempotencyKeyResponse) UnmarshalJSON(data []byte) error { - type unmarshaler CancelPaymentByIdempotencyKeyResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *c = CancelPaymentByIdempotencyKeyResponse(value) - extraProperties, err := internal.ExtractExtraProperties(data, *c) - if err != nil { - return err - } - c.extraProperties = extraProperties - c.rawJSON = json.RawMessage(data) - return nil -} - -func (c *CancelPaymentByIdempotencyKeyResponse) String() string { - if len(c.rawJSON) > 0 { - if value, err := internal.StringifyJSON(c.rawJSON); err == nil { - return value - } - } - if value, err := internal.StringifyJSON(c); err == nil { - return value - } - return fmt.Sprintf("%#v", c) -} - type CancelTerminalActionResponse struct { // Information on errors encountered during the request. Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` @@ -4868,12 +4818,6 @@ type CatalogItem struct { LabelColor *string `json:"label_color,omitempty" url:"label_color,omitempty"` // Indicates whether the item is taxable (`true`) or non-taxable (`false`). Default is `true`. IsTaxable *bool `json:"is_taxable,omitempty" url:"is_taxable,omitempty"` - // If `true`, the item can be added to shipping orders from the merchant's online store. - AvailableOnline *bool `json:"available_online,omitempty" url:"available_online,omitempty"` - // If `true`, the item can be added to pickup orders from the merchant's online store. - AvailableForPickup *bool `json:"available_for_pickup,omitempty" url:"available_for_pickup,omitempty"` - // If `true`, the item can be added to electronically fulfilled orders from the merchant's online store. - AvailableElectronically *bool `json:"available_electronically,omitempty" url:"available_electronically,omitempty"` // The ID of the item's category, if any. Deprecated since 2023-12-13. Use `CatalogItem.categories`, instead. CategoryID *string `json:"category_id,omitempty" url:"category_id,omitempty"` // A set of IDs indicating the taxes enabled for @@ -4946,6 +4890,7 @@ type CatalogItem struct { // A server-generated plaintext version of the `description_html` field, without formatting tags. DescriptionPlaintext *string `json:"description_plaintext,omitempty" url:"description_plaintext,omitempty"` // A list of IDs representing channels, such as a Square Online site, where the item can be made visible or available. + // This field is read only and cannot be edited. Channels []string `json:"channels,omitempty" url:"channels,omitempty"` // Indicates whether this item is archived (`true`) or not (`false`). IsArchived *bool `json:"is_archived,omitempty" url:"is_archived,omitempty"` @@ -4995,27 +4940,6 @@ func (c *CatalogItem) GetIsTaxable() *bool { return c.IsTaxable } -func (c *CatalogItem) GetAvailableOnline() *bool { - if c == nil { - return nil - } - return c.AvailableOnline -} - -func (c *CatalogItem) GetAvailableForPickup() *bool { - if c == nil { - return nil - } - return c.AvailableForPickup -} - -func (c *CatalogItem) GetAvailableElectronically() *bool { - if c == nil { - return nil - } - return c.AvailableElectronically -} - func (c *CatalogItem) GetCategoryID() *string { if c == nil { return nil @@ -14066,6 +13990,65 @@ func (c *CreateBookingCustomAttributeDefinitionResponse) String() string { return fmt.Sprintf("%#v", c) } +// The response to the request to create a `BreakType`. The response contains +// the created `BreakType` object and might contain a set of `Error` objects if +// the request resulted in errors. +type CreateBreakTypeResponse struct { + // The `BreakType` that was created by the request. + BreakType *BreakType `json:"break_type,omitempty" url:"break_type,omitempty"` + // Any errors that occurred during the request. + Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *CreateBreakTypeResponse) GetBreakType() *BreakType { + if c == nil { + return nil + } + return c.BreakType +} + +func (c *CreateBreakTypeResponse) GetErrors() []*Error { + if c == nil { + return nil + } + return c.Errors +} + +func (c *CreateBreakTypeResponse) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CreateBreakTypeResponse) UnmarshalJSON(data []byte) error { + type unmarshaler CreateBreakTypeResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CreateBreakTypeResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *CreateBreakTypeResponse) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + type CreateCatalogImageRequest struct { // A unique string that identifies this CreateCatalogImage request. // Keys can be any valid string but must be unique for every CreateCatalogImage request. @@ -23389,6 +23372,75 @@ func (l *ListBookingCustomAttributesResponse) String() string { return fmt.Sprintf("%#v", l) } +// The response to a request for a set of `BreakType` objects. The response contains +// the requested `BreakType` objects and might contain a set of `Error` objects if +// the request resulted in errors. +type ListBreakTypesResponse struct { + // A page of `BreakType` results. + BreakTypes []*BreakType `json:"break_types,omitempty" url:"break_types,omitempty"` + // The value supplied in the subsequent request to fetch the next page + // of `BreakType` results. + Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"` + // Any errors that occurred during the request. + Errors []*Error `json:"errors,omitempty" url:"errors,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (l *ListBreakTypesResponse) GetBreakTypes() []*BreakType { + if l == nil { + return nil + } + return l.BreakTypes +} + +func (l *ListBreakTypesResponse) GetCursor() *string { + if l == nil { + return nil + } + return l.Cursor +} + +func (l *ListBreakTypesResponse) GetErrors() []*Error { + if l == nil { + return nil + } + return l.Errors +} + +func (l *ListBreakTypesResponse) GetExtraProperties() map[string]interface{} { + return l.extraProperties +} + +func (l *ListBreakTypesResponse) UnmarshalJSON(data []byte) error { + type unmarshaler ListBreakTypesResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *l = ListBreakTypesResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *l) + if err != nil { + return err + } + l.extraProperties = extraProperties + l.rawJSON = json.RawMessage(data) + return nil +} + +func (l *ListBreakTypesResponse) String() string { + if len(l.rawJSON) > 0 { + if value, err := internal.StringifyJSON(l.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(l); err == nil { + return value + } + return fmt.Sprintf("%#v", l) +} + type ListCashDrawerShiftEventsResponse struct { // Opaque cursor for fetching the next page. Cursor is not present in // the last page of results. @@ -32240,19 +32292,21 @@ func (p *PaymentLinkRelatedResources) String() string { type PaymentOptions struct { // Indicates whether the `Payment` objects created from this `TerminalCheckout` are automatically // `COMPLETED` or left in an `APPROVED` state for later modification. + // + // Default: true Autocomplete *bool `json:"autocomplete,omitempty" url:"autocomplete,omitempty"` - // The duration of time after the payment's creation when Square automatically cancels the - // payment. This automatic cancellation applies only to payments that do not reach a terminal state - // (COMPLETED or CANCELED) before the `delay_duration` time period. + // The duration of time after the payment's creation when Square automatically resolves the + // payment. This automatic resolution applies only to payments that do not reach a terminal state + // (`COMPLETED` or `CANCELED`) before the `delay_duration` time period. // // This parameter should be specified as a time duration, in RFC 3339 format, with a minimum value - // of 1 minute. + // of 1 minute and a maximum value of 36 hours. This feature is only supported for card payments, + // and all payments will be considered card-present. + // + // This parameter can only be set for a delayed capture payment (`autocomplete=false`). For more + // information, see [Delayed Capture](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold). // - // Note: This feature is only supported for card payments. This parameter can only be set for a delayed - // capture payment (`autocomplete=false`). - // Default: - // - Card-present payments: "PT36H" (36 hours) from the creation time. - // - Card-not-present payments: "P7D" (7 days) from the creation time. + // Default: "PT36H" (36 hours) from the creation time DelayDuration *string `json:"delay_duration,omitempty" url:"delay_duration,omitempty"` // If set to `true` and charging a Square Gift Card, a payment might be returned with // `amount_money` equal to less than what was requested. For example, a request for $20 when charging @@ -32260,18 +32314,21 @@ type PaymentOptions struct { // to prompt the buyer for an additional payment to cover the remainder or cancel the Gift Card // payment. // - // This field cannot be `true` when `autocomplete = true`. - // This field cannot be `true` when an `order_id` isn't specified. + // This parameter can only be set for a delayed capture payment (`autocomplete=false`). // - // For more information, see - // [Take Partial Payments](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/partial-payments-with-gift-cards). + // For more information, see [Take Partial Payments](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/partial-payments-with-gift-cards). // // Default: false AcceptPartialAuthorization *bool `json:"accept_partial_authorization,omitempty" url:"accept_partial_authorization,omitempty"` - // The action to be applied to the payment when the delay_duration has elapsed. + // The action to be applied to the `Payment` when the delay_duration has elapsed. // The action must be CANCEL or COMPLETE. // - // This parameter can only be set for a delayed capture payment (when `autocomplete` is `false`). + // The action cannot be set to COMPLETE if an `order_id` is present on the TerminalCheckout. + // + // This parameter can only be set for a delayed capture payment (`autocomplete=false`). For more + // information, see [Delayed Capture](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold). + // + // Default: CANCEL // See [DelayAction](#type-delayaction) for possible values DelayAction *PaymentOptionsDelayAction `json:"delay_action,omitempty" url:"delay_action,omitempty"` diff --git a/v1transactions.go b/v1transactions.go index f20346d..c9bcdb1 100644 --- a/v1transactions.go +++ b/v1transactions.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type V1ListOrdersRequest struct { diff --git a/v1transactions/client.go b/v1transactions/client.go index 31cb646..af5be76 100644 --- a/v1transactions/client.go +++ b/v1transactions/client.go @@ -4,10 +4,10 @@ package v1transactions import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -41,9 +41,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Provides summary information for a merchant's online store orders. func (c *Client) V1ListOrders( ctx context.Context, - request *squaregosdk.V1ListOrdersRequest, + request *v2.V1ListOrdersRequest, opts ...option.RequestOption, -) ([]*squaregosdk.V1Order, error) { +) ([]*v2.V1Order, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -66,7 +66,7 @@ func (c *Client) V1ListOrders( options.ToHeader(), ) - var response []*squaregosdk.V1Order + var response []*v2.V1Order if err := c.caller.Call( ctx, &internal.CallParams{ @@ -88,9 +88,9 @@ func (c *Client) V1ListOrders( // Provides comprehensive information for a single online store order, including the order's history. func (c *Client) V1RetrieveOrder( ctx context.Context, - request *squaregosdk.V1RetrieveOrderRequest, + request *v2.V1RetrieveOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.V1Order, error) { +) (*v2.V1Order, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -107,7 +107,7 @@ func (c *Client) V1RetrieveOrder( options.ToHeader(), ) - var response *squaregosdk.V1Order + var response *v2.V1Order if err := c.caller.Call( ctx, &internal.CallParams{ @@ -129,9 +129,9 @@ func (c *Client) V1RetrieveOrder( // Updates the details of an online store order. Every update you perform on an order corresponds to one of three actions: func (c *Client) V1UpdateOrder( ctx context.Context, - request *squaregosdk.V1UpdateOrderRequest, + request *v2.V1UpdateOrderRequest, opts ...option.RequestOption, -) (*squaregosdk.V1Order, error) { +) (*v2.V1Order, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -149,7 +149,7 @@ func (c *Client) V1UpdateOrder( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.V1Order + var response *v2.V1Order if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/vendors.go b/vendors.go index e2e8f06..46f0ed4 100644 --- a/vendors.go +++ b/vendors.go @@ -5,7 +5,7 @@ package square import ( json "encoding/json" fmt "fmt" - internal "github.com/square/square-go-sdk/internal" + internal "github.com/square/square-go-sdk/v2/internal" ) type BatchCreateVendorsRequest struct { diff --git a/vendors/client.go b/vendors/client.go index 5a169e7..6e467e6 100644 --- a/vendors/client.go +++ b/vendors/client.go @@ -4,10 +4,10 @@ package vendors import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" http "net/http" os "os" ) @@ -41,9 +41,9 @@ func NewClient(opts ...option.RequestOption) *Client { // Creates one or more [Vendor](entity:Vendor) objects to represent suppliers to a seller. func (c *Client) BatchCreate( ctx context.Context, - request *squaregosdk.BatchCreateVendorsRequest, + request *v2.BatchCreateVendorsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchCreateVendorsResponse, error) { +) (*v2.BatchCreateVendorsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -57,7 +57,7 @@ func (c *Client) BatchCreate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchCreateVendorsResponse + var response *v2.BatchCreateVendorsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -80,9 +80,9 @@ func (c *Client) BatchCreate( // Retrieves one or more vendors of specified [Vendor](entity:Vendor) IDs. func (c *Client) BatchGet( ctx context.Context, - request *squaregosdk.BatchGetVendorsRequest, + request *v2.BatchGetVendorsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchGetVendorsResponse, error) { +) (*v2.BatchGetVendorsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -96,7 +96,7 @@ func (c *Client) BatchGet( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchGetVendorsResponse + var response *v2.BatchGetVendorsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -119,9 +119,9 @@ func (c *Client) BatchGet( // Updates one or more of existing [Vendor](entity:Vendor) objects as suppliers to a seller. func (c *Client) BatchUpdate( ctx context.Context, - request *squaregosdk.BatchUpdateVendorsRequest, + request *v2.BatchUpdateVendorsRequest, opts ...option.RequestOption, -) (*squaregosdk.BatchUpdateVendorsResponse, error) { +) (*v2.BatchUpdateVendorsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -135,7 +135,7 @@ func (c *Client) BatchUpdate( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.BatchUpdateVendorsResponse + var response *v2.BatchUpdateVendorsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -158,9 +158,9 @@ func (c *Client) BatchUpdate( // Creates a single [Vendor](entity:Vendor) object to represent a supplier to a seller. func (c *Client) Create( ctx context.Context, - request *squaregosdk.CreateVendorRequest, + request *v2.CreateVendorRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateVendorResponse, error) { +) (*v2.CreateVendorResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -174,7 +174,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateVendorResponse + var response *v2.CreateVendorResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -197,9 +197,9 @@ func (c *Client) Create( // Searches for vendors using a filter against supported [Vendor](entity:Vendor) properties and a supported sorter. func (c *Client) Search( ctx context.Context, - request *squaregosdk.SearchVendorsRequest, + request *v2.SearchVendorsRequest, opts ...option.RequestOption, -) (*squaregosdk.SearchVendorsResponse, error) { +) (*v2.SearchVendorsResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -213,7 +213,7 @@ func (c *Client) Search( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.SearchVendorsResponse + var response *v2.SearchVendorsResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -236,9 +236,9 @@ func (c *Client) Search( // Retrieves the vendor of a specified [Vendor](entity:Vendor) ID. func (c *Client) Get( ctx context.Context, - request *squaregosdk.VendorsGetRequest, + request *v2.VendorsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetVendorResponse, error) { +) (*v2.GetVendorResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -254,7 +254,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetVendorResponse + var response *v2.GetVendorResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -276,9 +276,9 @@ func (c *Client) Get( // Updates an existing [Vendor](entity:Vendor) object as a supplier to a seller. func (c *Client) Update( ctx context.Context, - request *squaregosdk.VendorsUpdateRequest, + request *v2.VendorsUpdateRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateVendorResponse, error) { +) (*v2.UpdateVendorResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -295,7 +295,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateVendorResponse + var response *v2.UpdateVendorResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/webhooks/client/client.go b/webhooks/client/client.go index de98945..d7ceabb 100644 --- a/webhooks/client/client.go +++ b/webhooks/client/client.go @@ -3,11 +3,11 @@ package client import ( - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - eventtypes "github.com/square/square-go-sdk/webhooks/eventtypes" - subscriptions "github.com/square/square-go-sdk/webhooks/subscriptions" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + eventtypes "github.com/square/square-go-sdk/v2/webhooks/eventtypes" + subscriptions "github.com/square/square-go-sdk/v2/webhooks/subscriptions" http "net/http" os "os" ) diff --git a/webhooks/eventtypes/client.go b/webhooks/eventtypes/client.go index 512a35a..ebdb55b 100644 --- a/webhooks/eventtypes/client.go +++ b/webhooks/eventtypes/client.go @@ -4,11 +4,11 @@ package eventtypes import ( context "context" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - webhooks "github.com/square/square-go-sdk/webhooks" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + webhooks "github.com/square/square-go-sdk/v2/webhooks" http "net/http" os "os" ) @@ -44,7 +44,7 @@ func (c *Client) List( ctx context.Context, request *webhooks.EventTypesListRequest, opts ...option.RequestOption, -) (*squaregosdk.ListWebhookEventTypesResponse, error) { +) (*v2.ListWebhookEventTypesResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -64,7 +64,7 @@ func (c *Client) List( options.ToHeader(), ) - var response *squaregosdk.ListWebhookEventTypesResponse + var response *v2.ListWebhookEventTypesResponse if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/webhooks/subscriptions.go b/webhooks/subscriptions.go index 791bed5..e7acbc7 100644 --- a/webhooks/subscriptions.go +++ b/webhooks/subscriptions.go @@ -3,14 +3,14 @@ package webhooks import ( - squaregosdk "github.com/square/square-go-sdk" + v2 "github.com/square/square-go-sdk/v2" ) type CreateWebhookSubscriptionRequest struct { // A unique string that identifies the [CreateWebhookSubscription](api-endpoint:WebhookSubscriptions-CreateWebhookSubscription) request. IdempotencyKey *string `json:"idempotency_key,omitempty" url:"-"` // The [Subscription](entity:WebhookSubscription) to create. - Subscription *squaregosdk.WebhookSubscription `json:"subscription,omitempty" url:"-"` + Subscription *v2.WebhookSubscription `json:"subscription,omitempty" url:"-"` } type SubscriptionsDeleteRequest struct { @@ -34,7 +34,7 @@ type SubscriptionsListRequest struct { IncludeDisabled *bool `json:"-" url:"include_disabled,omitempty"` // Sorts the returned list by when the [Subscription](entity:WebhookSubscription) was created with the specified order. // This field defaults to ASC. - SortOrder *squaregosdk.SortOrder `json:"-" url:"sort_order,omitempty"` + SortOrder *v2.SortOrder `json:"-" url:"sort_order,omitempty"` // The maximum number of results to be returned in a single page. // It is possible to receive fewer results than the specified limit on a given page. // The default value of 100 is also the maximum allowed value. @@ -55,7 +55,7 @@ type UpdateWebhookSubscriptionRequest struct { // [REQUIRED] The ID of the [Subscription](entity:WebhookSubscription) to update. SubscriptionID string `json:"-" url:"-"` // The [Subscription](entity:WebhookSubscription) to update. - Subscription *squaregosdk.WebhookSubscription `json:"subscription,omitempty" url:"-"` + Subscription *v2.WebhookSubscription `json:"subscription,omitempty" url:"-"` } type UpdateWebhookSubscriptionSignatureKeyRequest struct { diff --git a/webhooks/subscriptions/client.go b/webhooks/subscriptions/client.go index 408c48e..f5f50cf 100644 --- a/webhooks/subscriptions/client.go +++ b/webhooks/subscriptions/client.go @@ -5,11 +5,11 @@ package subscriptions import ( context "context" fmt "fmt" - squaregosdk "github.com/square/square-go-sdk" - core "github.com/square/square-go-sdk/core" - internal "github.com/square/square-go-sdk/internal" - option "github.com/square/square-go-sdk/option" - webhooks "github.com/square/square-go-sdk/webhooks" + v2 "github.com/square/square-go-sdk/v2" + core "github.com/square/square-go-sdk/v2/core" + internal "github.com/square/square-go-sdk/v2/internal" + option "github.com/square/square-go-sdk/v2/option" + webhooks "github.com/square/square-go-sdk/v2/webhooks" http "net/http" os "os" ) @@ -45,7 +45,7 @@ func (c *Client) List( ctx context.Context, request *webhooks.SubscriptionsListRequest, opts ...option.RequestOption, -) (*core.Page[*squaregosdk.WebhookSubscription], error) { +) (*core.Page[*v2.WebhookSubscription], error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -81,10 +81,10 @@ func (c *Client) List( Response: pageRequest.Response, } } - readPageResponse := func(response *squaregosdk.ListWebhookSubscriptionsResponse) *internal.PageResponse[*string, *squaregosdk.WebhookSubscription] { + readPageResponse := func(response *v2.ListWebhookSubscriptionsResponse) *internal.PageResponse[*string, *v2.WebhookSubscription] { next := response.Cursor results := response.Subscriptions - return &internal.PageResponse[*string, *squaregosdk.WebhookSubscription]{ + return &internal.PageResponse[*string, *v2.WebhookSubscription]{ Next: next, Results: results, } @@ -102,7 +102,7 @@ func (c *Client) Create( ctx context.Context, request *webhooks.CreateWebhookSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.CreateWebhookSubscriptionResponse, error) { +) (*v2.CreateWebhookSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -116,7 +116,7 @@ func (c *Client) Create( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.CreateWebhookSubscriptionResponse + var response *v2.CreateWebhookSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -141,7 +141,7 @@ func (c *Client) Get( ctx context.Context, request *webhooks.SubscriptionsGetRequest, opts ...option.RequestOption, -) (*squaregosdk.GetWebhookSubscriptionResponse, error) { +) (*v2.GetWebhookSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -157,7 +157,7 @@ func (c *Client) Get( options.ToHeader(), ) - var response *squaregosdk.GetWebhookSubscriptionResponse + var response *v2.GetWebhookSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -181,7 +181,7 @@ func (c *Client) Update( ctx context.Context, request *webhooks.UpdateWebhookSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateWebhookSubscriptionResponse, error) { +) (*v2.UpdateWebhookSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -198,7 +198,7 @@ func (c *Client) Update( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateWebhookSubscriptionResponse + var response *v2.UpdateWebhookSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -223,7 +223,7 @@ func (c *Client) Delete( ctx context.Context, request *webhooks.SubscriptionsDeleteRequest, opts ...option.RequestOption, -) (*squaregosdk.DeleteWebhookSubscriptionResponse, error) { +) (*v2.DeleteWebhookSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -239,7 +239,7 @@ func (c *Client) Delete( options.ToHeader(), ) - var response *squaregosdk.DeleteWebhookSubscriptionResponse + var response *v2.DeleteWebhookSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -263,7 +263,7 @@ func (c *Client) UpdateSignatureKey( ctx context.Context, request *webhooks.UpdateWebhookSubscriptionSignatureKeyRequest, opts ...option.RequestOption, -) (*squaregosdk.UpdateWebhookSubscriptionSignatureKeyResponse, error) { +) (*v2.UpdateWebhookSubscriptionSignatureKeyResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -280,7 +280,7 @@ func (c *Client) UpdateSignatureKey( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.UpdateWebhookSubscriptionSignatureKeyResponse + var response *v2.UpdateWebhookSubscriptionSignatureKeyResponse if err := c.caller.Call( ctx, &internal.CallParams{ @@ -305,7 +305,7 @@ func (c *Client) Test( ctx context.Context, request *webhooks.TestWebhookSubscriptionRequest, opts ...option.RequestOption, -) (*squaregosdk.TestWebhookSubscriptionResponse, error) { +) (*v2.TestWebhookSubscriptionResponse, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, @@ -322,7 +322,7 @@ func (c *Client) Test( ) headers.Set("Content-Type", "application/json") - var response *squaregosdk.TestWebhookSubscriptionResponse + var response *v2.TestWebhookSubscriptionResponse if err := c.caller.Call( ctx, &internal.CallParams{