From f33842a54ffee7b6ed060ed19aebeb3258fd55b1 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:38:16 +0000 Subject: [PATCH] SDK regeneration --- .editorconfig | 7 +- .mock/definition/__package__.yml | 35513 ++++++++++++++++ .mock/definition/api.yml | 19 + .mock/definition/applePay.yml | 81 + .mock/definition/bankAccounts.yml | 222 + .mock/definition/bookings.yml | 909 + .../bookings/customAttributeDefinitions.yml | 413 + .../definition/bookings/customAttributes.yml | 565 + .../definition/bookings/locationProfiles.yml | 59 + .../bookings/teamMemberProfiles.yml | 114 + .mock/definition/cards.yml | 365 + .mock/definition/cashDrawers/shifts.yml | 277 + .mock/definition/catalog.yml | 1226 + .mock/definition/catalog/images.yml | 152 + .mock/definition/catalog/object.yml | 400 + .mock/definition/channels.yml | 189 + .mock/definition/checkout.yml | 341 + .mock/definition/checkout/paymentLinks.yml | 466 + .mock/definition/customers.yml | 1180 + .mock/definition/customers/cards.yml | 181 + .../customers/customAttributeDefinitions.yml | 605 + .../definition/customers/customAttributes.yml | 399 + .mock/definition/customers/groups.yml | 324 + .mock/definition/customers/segments.yml | 124 + .mock/definition/devices.yml | 212 + .mock/definition/devices/codes.yml | 211 + .mock/definition/disputes.yml | 422 + .mock/definition/disputes/evidence.yml | 168 + .mock/definition/employees.yml | 115 + .mock/definition/events.yml | 198 + .mock/definition/giftCards.yml | 502 + .mock/definition/giftCards/activities.yml | 337 + .mock/definition/inventory.yml | 847 + .mock/definition/invoices.yml | 1236 + .mock/definition/labor.yml | 1046 + .mock/definition/labor/breakTypes.yml | 290 + .mock/definition/labor/employeeWages.yml | 125 + .mock/definition/labor/shifts.yml | 472 + .mock/definition/labor/teamMemberWages.yml | 135 + .mock/definition/labor/workweekConfigs.yml | 109 + .mock/definition/locations.yml | 807 + .../locations/customAttributeDefinitions.yml | 419 + .../definition/locations/customAttributes.yml | 577 + .mock/definition/locations/transactions.yml | 344 + .mock/definition/loyalty.yml | 139 + .mock/definition/loyalty/accounts.yml | 482 + .mock/definition/loyalty/programs.yml | 280 + .../loyalty/programs/promotions.yml | 476 + .mock/definition/loyalty/rewards.yml | 390 + .mock/definition/merchants.yml | 122 + .../merchants/customAttributeDefinitions.yml | 421 + .../definition/merchants/customAttributes.yml | 552 + .mock/definition/mobile.yml | 80 + .mock/definition/oAuth.yml | 376 + .mock/definition/orders.yml | 1734 + .../orders/customAttributeDefinitions.yml | 404 + .mock/definition/orders/customAttributes.yml | 581 + .mock/definition/payments.yml | 1646 + .mock/definition/payouts.yml | 297 + .mock/definition/refunds.yml | 507 + .mock/definition/sites.yml | 54 + .mock/definition/snippets.yml | 168 + .mock/definition/subscriptions.yml | 1309 + .mock/definition/team.yml | 228 + .mock/definition/teamMembers.yml | 789 + .mock/definition/teamMembers/wageSetting.yml | 178 + .mock/definition/terminal.yml | 241 + .mock/definition/terminal/actions.yml | 464 + .mock/definition/terminal/checkouts.yml | 370 + .mock/definition/terminal/refunds.yml | 269 + .mock/definition/transferOrders.yml | 807 + .mock/definition/v1Transactions.yml | 382 + .mock/definition/vendors.yml | 558 + .mock/definition/webhooks/eventTypes.yml | 47 + .mock/definition/webhooks/subscriptions.yml | 395 + .mock/fern.config.json | 4 + reference.md | 1389 +- .../Core/Json/AdditionalPropertiesTests.cs | 365 + .../Core/Json/JsonAccessAttributeTests.cs | 4 +- .../Core/Pagination/IntOffsetTest.cs | 9 +- .../Core/Pagination/NoRequestCursorTest.cs | 7 +- .../Core/Pagination/NoRequestOffsetTest.cs | 7 +- .../Core/Pagination/StringCursorTest.cs | 64 + .../Core/QueryStringConverterTests.cs | 8 +- .../RawClientTests/AdditionalHeadersTests.cs | 5 +- .../Core/RawClientTests/MultipartFormTests.cs | 22 +- .../RawClientTests/QueryParameterTests.cs | 63 + src/Square.Test/Square.Test.csproj | 68 +- .../MockServer/ApplePay/RegisterDomainTest.cs | 60 + .../MockServer/BankAccounts/GetByV1IdTest.cs | 71 + .../Unit/MockServer/BankAccounts/GetTest.cs | 70 + .../Unit/MockServer/BankAccounts/ListTest.cs | 99 + .../Unit/MockServer/BaseMockServerTest.cs | 39 + .../Bookings/BulkRetrieveBookingsTest.cs | 130 + ...lkRetrieveTeamMemberBookingProfilesTest.cs | 106 + .../Unit/MockServer/Bookings/CancelTest.cs | 102 + .../Unit/MockServer/Bookings/CreateTest.cs | 104 + .../CustomAttributeDefinitions/CreateTest.cs | 79 + .../CustomAttributeDefinitions/DeleteTest.cs | 58 + .../CustomAttributeDefinitions/GetTest.cs | 72 + .../CustomAttributeDefinitions/ListTest.cs | 82 + .../CustomAttributeDefinitions/UpdateTest.cs | 80 + .../CustomAttributes/BatchDeleteTest.cs | 109 + .../CustomAttributes/BatchUpsertTest.cs | 167 + .../Bookings/CustomAttributes/DeleteTest.cs | 55 + .../Bookings/CustomAttributes/GetTest.cs | 78 + .../Bookings/CustomAttributes/ListTest.cs | 76 + .../Bookings/CustomAttributes/UpsertTest.cs | 85 + .../Bookings/GetBusinessProfileTest.cs | 77 + .../Unit/MockServer/Bookings/GetTest.cs | 96 + .../Unit/MockServer/Bookings/ListTest.cs | 92 + .../Bookings/LocationProfiles/ListTest.cs | 65 + .../RetrieveLocationBookingProfileTest.cs | 57 + .../Bookings/SearchAvailabilityTest.cs | 288 + .../Bookings/TeamMemberProfiles/GetTest.cs | 59 + .../Bookings/TeamMemberProfiles/ListTest.cs | 76 + .../Unit/MockServer/Bookings/UpdateTest.cs | 104 + .../Unit/MockServer/Cards/CreateTest.cs | 129 + .../Unit/MockServer/Cards/DisableTest.cs | 88 + .../Unit/MockServer/Cards/GetTest.cs | 83 + .../Unit/MockServer/Cards/ListTest.cs | 94 + .../MockServer/CashDrawers/Shifts/GetTest.cs | 105 + .../CashDrawers/Shifts/ListEventsTest.cs | 128 + .../MockServer/CashDrawers/Shifts/ListTest.cs | 91 + .../MockServer/Catalog/BatchDeleteTest.cs | 75 + .../Unit/MockServer/Catalog/BatchGetTest.cs | 161 + .../MockServer/Catalog/BatchUpsertTest.cs | 224 + .../Unit/MockServer/Catalog/InfoTest.cs | 64 + .../Unit/MockServer/Catalog/ListTest.cs | 104 + .../MockServer/Catalog/Object/DeleteTest.cs | 57 + .../Unit/MockServer/Catalog/Object/GetTest.cs | 161 + .../MockServer/Catalog/Object/UpsertTest.cs | 141 + .../MockServer/Catalog/SearchItemsTest.cs | 160 + .../Unit/MockServer/Catalog/SearchTest.cs | 150 + .../Catalog/UpdateItemModifierListsTest.cs | 84 + .../MockServer/Catalog/UpdateItemTaxesTest.cs | 78 + .../MockServer/Channels/BulkRetrieveTest.cs | 119 + .../Unit/MockServer/Channels/GetTest.cs | 64 + .../Unit/MockServer/Channels/ListTest.cs | 79 + .../Checkout/PaymentLinks/CreateTest.cs | 211 + .../Checkout/PaymentLinks/DeleteTest.cs | 54 + .../Checkout/PaymentLinks/GetTest.cs | 83 + .../Checkout/PaymentLinks/ListTest.cs | 80 + .../Checkout/PaymentLinks/UpdateTest.cs | 105 + .../Checkout/RetrieveLocationSettingsTest.cs | 84 + .../Checkout/RetrieveMerchantSettingsTest.cs | 83 + .../Checkout/UpdateLocationSettingsTest.cs | 101 + .../Checkout/UpdateMerchantSettingsTest.cs | 94 + .../MockServer/Customers/BatchCreateTest.cs | 206 + .../Customers/BulkDeleteCustomersTest.cs | 99 + .../Customers/BulkRetrieveCustomersTest.cs | 126 + .../Customers/BulkUpdateCustomersTest.cs | 139 + .../MockServer/Customers/Cards/CreateTest.cs | 120 + .../MockServer/Customers/Cards/DeleteTest.cs | 52 + .../Unit/MockServer/Customers/CreateTest.cs | 133 + .../BatchUpsertTest.cs | 253 + .../CustomAttributeDefinitions/CreateTest.cs | 100 + .../CustomAttributeDefinitions/DeleteTest.cs | 58 + .../CustomAttributeDefinitions/GetTest.cs | 72 + .../CustomAttributeDefinitions/ListTest.cs | 82 + .../CustomAttributeDefinitions/UpdateTest.cs | 87 + .../Customers/CustomAttributes/DeleteTest.cs | 55 + .../Customers/CustomAttributes/GetTest.cs | 78 + .../Customers/CustomAttributes/ListTest.cs | 76 + .../Customers/CustomAttributes/UpsertTest.cs | 87 + .../Unit/MockServer/Customers/DeleteTest.cs | 52 + .../Unit/MockServer/Customers/GetTest.cs | 95 + .../MockServer/Customers/Groups/AddTest.cs | 52 + .../MockServer/Customers/Groups/CreateTest.cs | 71 + .../MockServer/Customers/Groups/DeleteTest.cs | 52 + .../MockServer/Customers/Groups/GetTest.cs | 58 + .../MockServer/Customers/Groups/ListTest.cs | 67 + .../MockServer/Customers/Groups/RemoveTest.cs | 52 + .../MockServer/Customers/Groups/UpdateTest.cs | 72 + .../Unit/MockServer/Customers/ListTest.cs | 99 + .../Unit/MockServer/Customers/SearchTest.cs | 187 + .../MockServer/Customers/Segments/GetTest.cs | 58 + .../MockServer/Customers/Segments/ListTest.cs | 79 + .../Unit/MockServer/Customers/UpdateTest.cs | 111 + .../MockServer/Devices/Codes/CreateTest.cs | 87 + .../Unit/MockServer/Devices/Codes/GetTest.cs | 62 + .../Unit/MockServer/Devices/Codes/ListTest.cs | 90 + .../Unit/MockServer/Devices/GetTest.cs | 108 + .../Unit/MockServer/Devices/ListTest.cs | 178 + .../Unit/MockServer/Disputes/AcceptTest.cs | 76 + .../Disputes/CreateEvidenceTextTest.cs | 80 + .../Disputes/Evidence/DeleteTest.cs | 52 + .../MockServer/Disputes/Evidence/GetTest.cs | 64 + .../MockServer/Disputes/Evidence/ListTest.cs | 78 + .../Unit/MockServer/Disputes/GetTest.cs | 76 + .../Unit/MockServer/Disputes/ListTest.cs | 112 + .../MockServer/Disputes/SubmitEvidenceTest.cs | 76 + .../Unit/MockServer/Employees/GetTest.cs | 60 + .../Unit/MockServer/Employees/ListTest.cs | 78 + .../MockServer/Events/DisableEventsTest.cs | 45 + .../MockServer/Events/EnableEventsTest.cs | 45 + .../MockServer/Events/ListEventTypesTest.cs | 61 + .../MockServer/Events/SearchEventsTest.cs | 97 + .../GiftCards/Activities/CreateTest.cs | 165 + .../GiftCards/Activities/ListTest.cs | 186 + .../Unit/MockServer/GiftCards/CreateTest.cs | 83 + .../MockServer/GiftCards/GetFromGanTest.cs | 75 + .../MockServer/GiftCards/GetFromNonceTest.cs | 75 + .../Unit/MockServer/GiftCards/GetTest.cs | 61 + .../MockServer/GiftCards/LinkCustomerTest.cs | 79 + .../Unit/MockServer/GiftCards/ListTest.cs | 95 + .../GiftCards/UnlinkCustomerTest.cs | 79 + .../Inventory/BatchCreateChangesTest.cs | 112 + .../Inventory/BatchGetChangesTest.cs | 103 + .../Inventory/BatchGetCountsTest.cs | 81 + .../Unit/MockServer/Inventory/ChangesTest.cs | 87 + .../Inventory/DeprecatedBatchChangeTest.cs | 112 + .../DeprecatedBatchGetChangesTest.cs | 104 + .../Inventory/DeprecatedBatchGetCountsTest.cs | 82 + .../Inventory/DeprecatedGetAdjustmentTest.cs | 85 + .../DeprecatedGetPhysicalCountTest.cs | 70 + .../MockServer/Inventory/GetAdjustmentTest.cs | 85 + .../Inventory/GetPhysicalCountTest.cs | 70 + .../Unit/MockServer/Inventory/GetTest.cs | 69 + .../MockServer/Inventory/GetTransferTest.cs | 71 + .../Unit/MockServer/Invoices/CancelTest.cs | 139 + .../Unit/MockServer/Invoices/CreateTest.cs | 246 + .../Invoices/DeleteInvoiceAttachmentTest.cs | 56 + .../Unit/MockServer/Invoices/DeleteTest.cs | 52 + .../Unit/MockServer/Invoices/GetTest.cs | 131 + .../Unit/MockServer/Invoices/ListTest.cs | 224 + .../Unit/MockServer/Invoices/PublishTest.cs | 145 + .../Unit/MockServer/Invoices/SearchTest.cs | 243 + .../Unit/MockServer/Invoices/UpdateTest.cs | 156 + .../MockServer/Labor/BreakTypes/CreateTest.cs | 85 + .../MockServer/Labor/BreakTypes/DeleteTest.cs | 51 + .../MockServer/Labor/BreakTypes/GetTest.cs | 61 + .../MockServer/Labor/BreakTypes/ListTest.cs | 81 + .../MockServer/Labor/BreakTypes/UpdateTest.cs | 86 + .../Labor/BulkPublishScheduledShiftsTest.cs | 116 + .../Labor/CreateScheduledShiftTest.cs | 113 + .../MockServer/Labor/CreateTimecardTest.cs | 152 + .../MockServer/Labor/DeleteTimecardTest.cs | 51 + .../MockServer/Labor/EmployeeWages/GetTest.cs | 60 + .../Labor/EmployeeWages/ListTest.cs | 97 + .../Labor/PublishScheduledShiftTest.cs | 94 + .../Labor/RetrieveScheduledShiftTest.cs | 78 + .../MockServer/Labor/RetrieveTimecardTest.cs | 88 + .../Labor/SearchScheduledShiftsTest.cs | 105 + .../MockServer/Labor/SearchTimecardsTest.cs | 174 + .../MockServer/Labor/Shifts/CreateTest.cs | 153 + .../MockServer/Labor/Shifts/DeleteTest.cs | 49 + .../Unit/MockServer/Labor/Shifts/GetTest.cs | 84 + .../MockServer/Labor/Shifts/SearchTest.cs | 176 + .../MockServer/Labor/Shifts/UpdateTest.cs | 156 + .../Labor/TeamMemberWages/GetTest.cs | 63 + .../Labor/TeamMemberWages/ListTest.cs | 105 + .../Labor/UpdateScheduledShiftTest.cs | 114 + .../MockServer/Labor/UpdateTimecardTest.cs | 157 + .../Labor/WorkweekConfigs/GetTest.cs | 81 + .../Labor/WorkweekConfigs/ListTest.cs | 63 + .../MockServer/Locations/CheckoutsTest.cs | 426 + .../Unit/MockServer/Locations/CreateTest.cs | 141 + .../CustomAttributeDefinitions/CreateTest.cs | 100 + .../CustomAttributeDefinitions/DeleteTest.cs | 58 + .../CustomAttributeDefinitions/GetTest.cs | 72 + .../CustomAttributeDefinitions/ListTest.cs | 85 + .../CustomAttributeDefinitions/UpdateTest.cs | 87 + .../CustomAttributes/BatchDeleteTest.cs | 130 + .../CustomAttributes/BatchUpsertTest.cs | 181 + .../Locations/CustomAttributes/DeleteTest.cs | 55 + .../Locations/CustomAttributes/GetTest.cs | 78 + .../Locations/CustomAttributes/ListTest.cs | 79 + .../Locations/CustomAttributes/UpsertTest.cs | 87 + .../Unit/MockServer/Locations/GetTest.cs | 110 + .../Unit/MockServer/Locations/ListTest.cs | 116 + .../Locations/Transactions/CaptureTest.cs | 56 + .../Locations/Transactions/GetTest.cs | 125 + .../Locations/Transactions/ListTest.cs | 140 + .../Locations/Transactions/VoidTest.cs | 55 + .../Unit/MockServer/Locations/UpdateTest.cs | 184 + .../Loyalty/Accounts/AccumulatePointsTest.cs | 144 + .../MockServer/Loyalty/Accounts/AdjustTest.cs | 120 + .../MockServer/Loyalty/Accounts/CreateTest.cs | 95 + .../MockServer/Loyalty/Accounts/GetTest.cs | 73 + .../MockServer/Loyalty/Accounts/SearchTest.cs | 101 + .../Loyalty/Programs/CalculateTest.cs | 68 + .../MockServer/Loyalty/Programs/GetTest.cs | 101 + .../MockServer/Loyalty/Programs/ListTest.cs | 100 + .../Loyalty/Programs/Promotions/CancelTest.cs | 92 + .../Loyalty/Programs/Promotions/CreateTest.cs | 155 + .../Loyalty/Programs/Promotions/GetTest.cs | 93 + .../Loyalty/Programs/Promotions/ListTest.cs | 137 + .../MockServer/Loyalty/Rewards/CreateTest.cs | 85 + .../MockServer/Loyalty/Rewards/DeleteTest.cs | 52 + .../MockServer/Loyalty/Rewards/GetTest.cs | 63 + .../MockServer/Loyalty/Rewards/RedeemTest.cs | 113 + .../MockServer/Loyalty/Rewards/SearchTest.cs | 117 + .../MockServer/Loyalty/SearchEventsTest.cs | 149 + .../CustomAttributeDefinitions/CreateTest.cs | 100 + .../CustomAttributeDefinitions/DeleteTest.cs | 58 + .../CustomAttributeDefinitions/GetTest.cs | 72 + .../CustomAttributeDefinitions/ListTest.cs | 85 + .../CustomAttributeDefinitions/UpdateTest.cs | 87 + .../CustomAttributes/BatchDeleteTest.cs | 109 + .../CustomAttributes/BatchUpsertTest.cs | 145 + .../Merchants/CustomAttributes/DeleteTest.cs | 55 + .../Merchants/CustomAttributes/GetTest.cs | 78 + .../Merchants/CustomAttributes/ListTest.cs | 79 + .../Merchants/CustomAttributes/UpsertTest.cs | 87 + .../Unit/MockServer/Merchants/GetTest.cs | 61 + .../Unit/MockServer/Merchants/ListTest.cs | 62 + .../Mobile/AuthorizationCodeTest.cs | 62 + .../Unit/MockServer/OAuth/AuthorizeTest.cs | 20 + .../Unit/MockServer/OAuth/ObtainTokenTest.cs | 78 + .../OAuth/RetrieveTokenStatusTest.cs | 56 + .../Unit/MockServer/OAuth/RevokeTokenTest.cs | 61 + .../Unit/MockServer/Orders/BatchGetTest.cs | 152 + .../Unit/MockServer/Orders/CalculateTest.cs | 321 + .../Unit/MockServer/Orders/CloneTest.cs | 368 + .../Unit/MockServer/Orders/CreateTest.cs | 484 + .../CustomAttributeDefinitions/CreateTest.cs | 102 + .../CustomAttributeDefinitions/DeleteTest.cs | 58 + .../CustomAttributeDefinitions/GetTest.cs | 72 + .../CustomAttributeDefinitions/ListTest.cs | 97 + .../CustomAttributeDefinitions/UpdateTest.cs | 91 + .../CustomAttributes/BatchDeleteTest.cs | 111 + .../CustomAttributes/BatchUpsertTest.cs | 143 + .../Orders/CustomAttributes/DeleteTest.cs | 55 + .../Orders/CustomAttributes/GetTest.cs | 78 + .../Orders/CustomAttributes/ListTest.cs | 71 + .../Orders/CustomAttributes/UpsertTest.cs | 94 + .../Unit/MockServer/Orders/GetTest.cs | 251 + .../Unit/MockServer/Orders/PayTest.cs | 282 + .../Unit/MockServer/Orders/SearchTest.cs | 183 + .../Unit/MockServer/Orders/UpdateTest.cs | 268 + .../Payments/CancelByIdempotencyKeyTest.cs | 63 + .../Unit/MockServer/Payments/CancelTest.cs | 228 + .../Unit/MockServer/Payments/CompleteTest.cs | 241 + .../Unit/MockServer/Payments/CreateTest.cs | 261 + .../Unit/MockServer/Payments/GetTest.cs | 235 + .../Unit/MockServer/Payments/ListTest.cs | 170 + .../Unit/MockServer/Payments/UpdateTest.cs | 259 + .../Unit/MockServer/Payouts/GetTest.cs | 73 + .../MockServer/Payouts/ListEntriesTest.cs | 100 + .../Unit/MockServer/Payouts/ListTest.cs | 118 + .../Unit/MockServer/Refunds/GetTest.cs | 92 + .../Unit/MockServer/Refunds/ListTest.cs | 106 + .../MockServer/Refunds/RefundPaymentTest.cs | 110 + .../Unit/MockServer/Sites/ListTest.cs | 61 + .../Unit/MockServer/Snippets/DeleteTest.cs | 51 + .../Unit/MockServer/Snippets/GetTest.cs | 58 + .../Unit/MockServer/Snippets/UpsertTest.cs | 72 + .../Subscriptions/BulkSwapPlanTest.cs | 67 + .../MockServer/Subscriptions/CancelTest.cs | 98 + .../ChangeBillingAnchorDateTest.cs | 114 + .../MockServer/Subscriptions/CreateTest.cs | 127 + .../Subscriptions/DeleteActionTest.cs | 90 + .../Unit/MockServer/Subscriptions/GetTest.cs | 89 + .../Subscriptions/ListEventsTest.cs | 134 + .../MockServer/Subscriptions/PauseTest.cs | 108 + .../MockServer/Subscriptions/ResumeTest.cs | 108 + .../MockServer/Subscriptions/SearchTest.cs | 183 + .../MockServer/Subscriptions/SwapPlanTest.cs | 130 + .../MockServer/Subscriptions/UpdateTest.cs | 100 + .../Unit/MockServer/Team/CreateJobTest.cs | 75 + .../Unit/MockServer/Team/ListJobsTest.cs | 69 + .../Unit/MockServer/Team/RetrieveJobTest.cs | 59 + .../Unit/MockServer/Team/UpdateJobTest.cs | 74 + .../MockServer/TeamMembers/BatchCreateTest.cs | 185 + .../MockServer/TeamMembers/BatchUpdateTest.cs | 197 + .../Unit/MockServer/TeamMembers/CreateTest.cs | 189 + .../Unit/MockServer/TeamMembers/GetTest.cs | 102 + .../Unit/MockServer/TeamMembers/SearchTest.cs | 336 + .../Unit/MockServer/TeamMembers/UpdateTest.cs | 196 + .../TeamMembers/WageSetting/GetTest.cs | 75 + .../TeamMembers/WageSetting/UpdateTest.cs | 134 + .../MockServer/Terminal/Actions/CancelTest.cs | 127 + .../MockServer/Terminal/Actions/CreateTest.cs | 158 + .../MockServer/Terminal/Actions/GetTest.cs | 127 + .../MockServer/Terminal/Actions/SearchTest.cs | 185 + .../Terminal/Checkouts/CancelTest.cs | 99 + .../Terminal/Checkouts/CreateTest.cs | 131 + .../MockServer/Terminal/Checkouts/GetTest.cs | 99 + .../Terminal/Checkouts/SearchTest.cs | 137 + .../Terminal/DismissTerminalActionTest.cs | 130 + .../Terminal/DismissTerminalCheckoutTest.cs | 101 + .../Terminal/DismissTerminalRefundTest.cs | 71 + .../MockServer/Terminal/Refunds/CancelTest.cs | 71 + .../MockServer/Terminal/Refunds/CreateTest.cs | 98 + .../MockServer/Terminal/Refunds/GetTest.cs | 73 + .../MockServer/Terminal/Refunds/SearchTest.cs | 94 + .../MockServer/TransferOrders/CancelTest.cs | 100 + .../MockServer/TransferOrders/CreateTest.cs | 137 + .../MockServer/TransferOrders/DeleteTest.cs | 57 + .../Unit/MockServer/TransferOrders/GetTest.cs | 86 + .../MockServer/TransferOrders/ReceiveTest.cs | 134 + .../MockServer/TransferOrders/SearchTest.cs | 156 + .../MockServer/TransferOrders/StartTest.cs | 100 + .../MockServer/TransferOrders/UpdateTest.cs | 139 + .../V1Transactions/V1ListOrdersTest.cs | 129 + .../V1Transactions/V1RetrieveOrderTest.cs | 139 + .../V1Transactions/V1UpdateOrderTest.cs | 152 + .../MockServer/Vendors/BatchCreateTest.cs | 152 + .../Unit/MockServer/Vendors/BatchGetTest.cs | 101 + .../MockServer/Vendors/BatchUpdateTest.cs | 149 + .../Unit/MockServer/Vendors/CreateTest.cs | 143 + .../Unit/MockServer/Vendors/GetTest.cs | 86 + .../Unit/MockServer/Vendors/SearchTest.cs | 85 + .../Unit/MockServer/Vendors/UpdateTest.cs | 114 + .../Webhooks/EventTypes/ListTest.cs | 62 + .../Webhooks/Subscriptions/CreateTest.cs | 93 + .../Webhooks/Subscriptions/DeleteTest.cs | 52 + .../Webhooks/Subscriptions/GetTest.cs | 68 + .../Webhooks/Subscriptions/ListTest.cs | 77 + .../Webhooks/Subscriptions/TestTest.cs | 71 + .../Subscriptions/UpdateSignatureKeyTest.cs | 69 + .../Webhooks/Subscriptions/UpdateTest.cs | 85 + src/Square/ApplePay/ApplePayClient.cs | 1 + .../Requests/RegisterDomainRequest.cs | 1 + src/Square/BankAccounts/BankAccountsClient.cs | 1 + .../Requests/GetBankAccountsRequest.cs | 1 + .../Requests/GetByV1IdBankAccountsRequest.cs | 1 + .../Requests/ListBankAccountsRequest.cs | 1 + src/Square/Bookings/BookingsClient.cs | 14 +- .../CustomAttributeDefinitionsClient.cs | 18 +- ...BookingCustomAttributeDefinitionRequest.cs | 1 + ...DeleteCustomAttributeDefinitionsRequest.cs | 1 + .../GetCustomAttributeDefinitionsRequest.cs | 1 + .../ListCustomAttributeDefinitionsRequest.cs | 1 + ...BookingCustomAttributeDefinitionRequest.cs | 1 + .../CustomAttributesClient.cs | 11 +- ...ulkDeleteBookingCustomAttributesRequest.cs | 1 + ...ulkUpsertBookingCustomAttributesRequest.cs | 1 + .../Requests/DeleteCustomAttributesRequest.cs | 1 + .../Requests/GetCustomAttributesRequest.cs | 1 + .../Requests/ListCustomAttributesRequest.cs | 1 + .../UpsertBookingCustomAttributeRequest.cs | 1 + .../LocationProfilesClient.cs | 1 + .../Requests/ListLocationProfilesRequest.cs | 1 + .../Requests/BulkRetrieveBookingsRequest.cs | 1 + ...etrieveTeamMemberBookingProfilesRequest.cs | 1 + .../Bookings/Requests/CancelBookingRequest.cs | 1 + .../Bookings/Requests/CreateBookingRequest.cs | 1 + .../Bookings/Requests/GetBookingsRequest.cs | 1 + .../Bookings/Requests/ListBookingsRequest.cs | 1 + .../RetrieveLocationBookingProfileRequest.cs | 1 + .../Requests/SearchAvailabilityRequest.cs | 1 + .../Bookings/Requests/UpdateBookingRequest.cs | 1 + .../Requests/GetTeamMemberProfilesRequest.cs | 1 + .../Requests/ListTeamMemberProfilesRequest.cs | 1 + .../TeamMemberProfilesClient.cs | 1 + src/Square/Cards/CardsClient.cs | 1 + .../Cards/Requests/CreateCardRequest.cs | 1 + .../Cards/Requests/DisableCardsRequest.cs | 1 + src/Square/Cards/Requests/GetCardsRequest.cs | 1 + src/Square/Cards/Requests/ListCardsRequest.cs | 1 + src/Square/CashDrawers/CashDrawersClient.cs | 5 +- .../Shifts/Requests/GetShiftsRequest.cs | 1 + .../Requests/ListEventsShiftsRequest.cs | 1 + .../Shifts/Requests/ListShiftsRequest.cs | 1 + src/Square/CashDrawers/Shifts/ShiftsClient.cs | 7 +- src/Square/Catalog/CatalogClient.cs | 3 +- src/Square/Catalog/Images/ImagesClient.cs | 1 + .../Images/Requests/CreateImagesRequest.cs | 1 + .../Images/Requests/UpdateImagesRequest.cs | 1 + src/Square/Catalog/Object/ObjectClient.cs | 1 + .../Object/Requests/DeleteObjectRequest.cs | 1 + .../Object/Requests/GetObjectRequest.cs | 1 + .../Requests/UpsertCatalogObjectRequest.cs | 1 + .../BatchDeleteCatalogObjectsRequest.cs | 1 + .../Requests/BatchGetCatalogObjectsRequest.cs | 1 + .../BatchUpsertCatalogObjectsRequest.cs | 1 + .../Catalog/Requests/ListCatalogRequest.cs | 1 + .../Requests/SearchCatalogItemsRequest.cs | 1 + .../Requests/SearchCatalogObjectsRequest.cs | 1 + .../UpdateItemModifierListsRequest.cs | 1 + .../Requests/UpdateItemTaxesRequest.cs | 1 + src/Square/Channels/ChannelsClient.cs | 1 + .../Requests/BulkRetrieveChannelsRequest.cs | 1 + .../Channels/Requests/GetChannelsRequest.cs | 1 + .../Channels/Requests/ListChannelsRequest.cs | 1 + src/Square/Checkout/CheckoutClient.cs | 1 + .../PaymentLinks/PaymentLinksClient.cs | 1 + .../Requests/CreatePaymentLinkRequest.cs | 1 + .../Requests/DeletePaymentLinksRequest.cs | 1 + .../Requests/GetPaymentLinksRequest.cs | 1 + .../Requests/ListPaymentLinksRequest.cs | 1 + .../Requests/UpdatePaymentLinkRequest.cs | 1 + .../RetrieveLocationSettingsRequest.cs | 1 + .../Requests/UpdateLocationSettingsRequest.cs | 1 + .../Requests/UpdateMerchantSettingsRequest.cs | 1 + src/Square/Checkout/Types/Checkout.cs | 21 +- src/Square/Core/CollectionItemSerializer.cs | 2 +- src/Square/Core/DateOnlyConverter.cs | 3 +- src/Square/Core/Extensions.cs | 47 +- src/Square/Core/IRequestOptions.cs | 1 - src/Square/Core/JsonConfiguration.cs | 25 + src/Square/Core/Pager.cs | 8 +- .../Core/Public/AdditionalProperties.cs | 353 + src/Square/Core/Public/ClientOptions.cs | 2 +- src/Square/Core/Public/RequestOptions.cs | 2 +- src/Square/Core/Public/SquareEnvironment.cs | 1 + src/Square/Core/Public/SquareException.cs | 2 - src/Square/Core/Public/Version.cs | 3 +- src/Square/Core/QueryStringConverter.cs | 2 +- src/Square/Core/RawClient.cs | 53 +- src/Square/Core/StringEnumSerializer.cs | 7 +- src/Square/Core/ValueConvert.cs | 6 + src/Square/Customers/Cards/CardsClient.cs | 1 + .../Requests/CreateCustomerCardRequest.cs | 1 + .../Cards/Requests/DeleteCardsRequest.cs | 1 + .../CustomAttributeDefinitionsClient.cs | 20 +- ...chUpsertCustomerCustomAttributesRequest.cs | 1 + ...ustomerCustomAttributeDefinitionRequest.cs | 1 + ...DeleteCustomAttributeDefinitionsRequest.cs | 1 + .../GetCustomAttributeDefinitionsRequest.cs | 1 + .../ListCustomAttributeDefinitionsRequest.cs | 1 + ...ustomerCustomAttributeDefinitionRequest.cs | 1 + .../CustomAttributesClient.cs | 11 +- .../Requests/DeleteCustomAttributesRequest.cs | 1 + .../Requests/GetCustomAttributesRequest.cs | 1 + .../Requests/ListCustomAttributesRequest.cs | 1 + .../UpsertCustomerCustomAttributeRequest.cs | 1 + src/Square/Customers/CustomersClient.cs | 19 +- src/Square/Customers/Groups/GroupsClient.cs | 1 + .../Groups/Requests/AddGroupsRequest.cs | 1 + .../Requests/CreateCustomerGroupRequest.cs | 1 + .../Groups/Requests/DeleteGroupsRequest.cs | 1 + .../Groups/Requests/GetGroupsRequest.cs | 1 + .../Groups/Requests/ListGroupsRequest.cs | 1 + .../Groups/Requests/RemoveGroupsRequest.cs | 1 + .../Requests/UpdateCustomerGroupRequest.cs | 1 + .../Requests/BulkCreateCustomersRequest.cs | 1 + .../Requests/BulkDeleteCustomersRequest.cs | 1 + .../Requests/BulkRetrieveCustomersRequest.cs | 1 + .../Requests/BulkUpdateCustomersRequest.cs | 1 + .../Requests/CreateCustomerRequest.cs | 1 + .../Requests/DeleteCustomersRequest.cs | 1 + .../Customers/Requests/GetCustomersRequest.cs | 1 + .../Requests/ListCustomersRequest.cs | 1 + .../Requests/SearchCustomersRequest.cs | 1 + .../Requests/UpdateCustomerRequest.cs | 1 + .../Segments/Requests/GetSegmentsRequest.cs | 1 + .../Segments/Requests/ListSegmentsRequest.cs | 1 + .../Customers/Segments/SegmentsClient.cs | 1 + src/Square/Devices/Codes/CodesClient.cs | 1 + .../Codes/Requests/CreateDeviceCodeRequest.cs | 1 + .../Devices/Codes/Requests/GetCodesRequest.cs | 1 + .../Codes/Requests/ListCodesRequest.cs | 1 + src/Square/Devices/DevicesClient.cs | 1 + .../Devices/Requests/GetDevicesRequest.cs | 1 + .../Devices/Requests/ListDevicesRequest.cs | 1 + src/Square/Disputes/DisputesClient.cs | 1 + .../Disputes/Evidence/EvidenceClient.cs | 1 + .../Requests/DeleteEvidenceRequest.cs | 1 + .../Evidence/Requests/GetEvidenceRequest.cs | 1 + .../Evidence/Requests/ListEvidenceRequest.cs | 1 + .../Requests/AcceptDisputesRequest.cs | 1 + .../CreateDisputeEvidenceTextRequest.cs | 1 + .../CreateEvidenceFileDisputesRequest.cs | 1 + .../Disputes/Requests/GetDisputesRequest.cs | 1 + .../Disputes/Requests/ListDisputesRequest.cs | 1 + .../Requests/SubmitEvidenceDisputesRequest.cs | 1 + src/Square/Employees/EmployeesClient.cs | 1 + .../Employees/Requests/GetEmployeesRequest.cs | 1 + .../Requests/ListEmployeesRequest.cs | 1 + src/Square/Events/EventsClient.cs | 5 +- .../Events/Requests/ListEventTypesRequest.cs | 1 + .../Events/Requests/SearchEventsRequest.cs | 1 + .../GiftCards/Activities/ActivitiesClient.cs | 1 + .../Requests/CreateGiftCardActivityRequest.cs | 1 + .../Requests/ListActivitiesRequest.cs | 1 + src/Square/GiftCards/GiftCardsClient.cs | 1 + .../Requests/CreateGiftCardRequest.cs | 1 + .../Requests/GetGiftCardFromGanRequest.cs | 1 + .../Requests/GetGiftCardFromNonceRequest.cs | 1 + .../GiftCards/Requests/GetGiftCardsRequest.cs | 1 + .../Requests/LinkCustomerToGiftCardRequest.cs | 1 + .../Requests/ListGiftCardsRequest.cs | 1 + .../UnlinkCustomerFromGiftCardRequest.cs | 1 + src/Square/Inventory/InventoryClient.cs | 1 + .../Requests/ChangesInventoryRequest.cs | 1 + ...DeprecatedGetAdjustmentInventoryRequest.cs | 1 + ...recatedGetPhysicalCountInventoryRequest.cs | 1 + .../Requests/GetAdjustmentInventoryRequest.cs | 1 + .../Inventory/Requests/GetInventoryRequest.cs | 1 + .../GetPhysicalCountInventoryRequest.cs | 1 + .../Requests/GetTransferInventoryRequest.cs | 1 + src/Square/Invoices/InvoicesClient.cs | 1 + .../Invoices/Requests/CancelInvoiceRequest.cs | 1 + .../CreateInvoiceAttachmentRequest.cs | 1 + .../Invoices/Requests/CreateInvoiceRequest.cs | 1 + .../DeleteInvoiceAttachmentRequest.cs | 1 + .../Requests/DeleteInvoicesRequest.cs | 1 + .../Invoices/Requests/GetInvoicesRequest.cs | 1 + .../Invoices/Requests/ListInvoicesRequest.cs | 1 + .../Requests/PublishInvoiceRequest.cs | 1 + .../Requests/SearchInvoicesRequest.cs | 1 + .../Invoices/Requests/UpdateInvoiceRequest.cs | 1 + .../Labor/BreakTypes/BreakTypesClient.cs | 1 + .../Requests/CreateBreakTypeRequest.cs | 1 + .../Requests/DeleteBreakTypesRequest.cs | 1 + .../Requests/GetBreakTypesRequest.cs | 1 + .../Requests/ListBreakTypesRequest.cs | 1 + .../Requests/UpdateBreakTypeRequest.cs | 1 + .../EmployeeWages/EmployeeWagesClient.cs | 1 + .../Requests/GetEmployeeWagesRequest.cs | 1 + .../Requests/ListEmployeeWagesRequest.cs | 1 + src/Square/Labor/LaborClient.cs | 6 +- .../BulkPublishScheduledShiftsRequest.cs | 1 + .../Requests/CreateScheduledShiftRequest.cs | 1 + .../Labor/Requests/CreateTimecardRequest.cs | 1 + .../Labor/Requests/DeleteTimecardRequest.cs | 1 + .../Requests/PublishScheduledShiftRequest.cs | 1 + .../Requests/RetrieveScheduledShiftRequest.cs | 1 + .../Labor/Requests/RetrieveTimecardRequest.cs | 1 + .../Requests/SearchScheduledShiftsRequest.cs | 1 + .../Labor/Requests/SearchTimecardsRequest.cs | 1 + .../Requests/UpdateScheduledShiftRequest.cs | 1 + .../Labor/Requests/UpdateTimecardRequest.cs | 1 + .../Shifts/Requests/CreateShiftRequest.cs | 1 + .../Shifts/Requests/DeleteShiftsRequest.cs | 1 + .../Labor/Shifts/Requests/GetShiftsRequest.cs | 1 + .../Shifts/Requests/SearchShiftsRequest.cs | 1 + .../Shifts/Requests/UpdateShiftRequest.cs | 1 + src/Square/Labor/Shifts/ShiftsClient.cs | 3 +- .../Requests/GetTeamMemberWagesRequest.cs | 1 + .../Requests/ListTeamMemberWagesRequest.cs | 1 + .../TeamMemberWages/TeamMemberWagesClient.cs | 1 + .../Requests/ListWorkweekConfigsRequest.cs | 1 + .../Requests/UpdateWorkweekConfigRequest.cs | 1 + .../WorkweekConfigs/WorkweekConfigsClient.cs | 1 + .../CustomAttributeDefinitionsClient.cs | 16 +- ...ocationCustomAttributeDefinitionRequest.cs | 1 + ...DeleteCustomAttributeDefinitionsRequest.cs | 1 + .../GetCustomAttributeDefinitionsRequest.cs | 1 + .../ListCustomAttributeDefinitionsRequest.cs | 1 + ...ocationCustomAttributeDefinitionRequest.cs | 1 + .../CustomAttributesClient.cs | 11 +- ...lkDeleteLocationCustomAttributesRequest.cs | 1 + ...lkUpsertLocationCustomAttributesRequest.cs | 1 + .../Requests/DeleteCustomAttributesRequest.cs | 1 + .../Requests/GetCustomAttributesRequest.cs | 1 + .../Requests/ListCustomAttributesRequest.cs | 1 + .../UpsertLocationCustomAttributeRequest.cs | 1 + src/Square/Locations/LocationsClient.cs | 20 +- .../Requests/CreateCheckoutRequest.cs | 1 + .../Requests/CreateLocationRequest.cs | 1 + .../Locations/Requests/GetLocationsRequest.cs | 1 + .../Requests/UpdateLocationRequest.cs | 1 + .../Requests/CaptureTransactionsRequest.cs | 1 + .../Requests/GetTransactionsRequest.cs | 1 + .../Requests/ListTransactionsRequest.cs | 1 + .../Requests/VoidTransactionsRequest.cs | 1 + .../Transactions/TransactionsClient.cs | 1 + src/Square/Loyalty/Accounts/AccountsClient.cs | 1 + .../AccumulateLoyaltyPointsRequest.cs | 1 + .../Requests/AdjustLoyaltyPointsRequest.cs | 1 + .../Requests/CreateLoyaltyAccountRequest.cs | 1 + .../Accounts/Requests/GetAccountsRequest.cs | 1 + .../Requests/SearchLoyaltyAccountsRequest.cs | 1 + src/Square/Loyalty/LoyaltyClient.cs | 1 + src/Square/Loyalty/Programs/ProgramsClient.cs | 1 + .../Programs/Promotions/PromotionsClient.cs | 1 + .../Requests/CancelPromotionsRequest.cs | 1 + .../Requests/CreateLoyaltyPromotionRequest.cs | 1 + .../Requests/GetPromotionsRequest.cs | 1 + .../Requests/ListPromotionsRequest.cs | 1 + .../Requests/CalculateLoyaltyPointsRequest.cs | 1 + .../Programs/Requests/GetProgramsRequest.cs | 1 + .../Requests/SearchLoyaltyEventsRequest.cs | 1 + .../Requests/CreateLoyaltyRewardRequest.cs | 1 + .../Rewards/Requests/DeleteRewardsRequest.cs | 1 + .../Rewards/Requests/GetRewardsRequest.cs | 1 + .../Requests/RedeemLoyaltyRewardRequest.cs | 1 + .../Requests/SearchLoyaltyRewardsRequest.cs | 1 + src/Square/Loyalty/Rewards/RewardsClient.cs | 1 + .../CustomAttributeDefinitionsClient.cs | 16 +- ...erchantCustomAttributeDefinitionRequest.cs | 1 + ...DeleteCustomAttributeDefinitionsRequest.cs | 1 + .../GetCustomAttributeDefinitionsRequest.cs | 1 + .../ListCustomAttributeDefinitionsRequest.cs | 1 + ...erchantCustomAttributeDefinitionRequest.cs | 1 + .../CustomAttributesClient.cs | 11 +- ...lkDeleteMerchantCustomAttributesRequest.cs | 1 + ...lkUpsertMerchantCustomAttributesRequest.cs | 1 + .../Requests/DeleteCustomAttributesRequest.cs | 1 + .../Requests/GetCustomAttributesRequest.cs | 1 + .../Requests/ListCustomAttributesRequest.cs | 1 + .../UpsertMerchantCustomAttributeRequest.cs | 1 + src/Square/Merchants/MerchantsClient.cs | 14 +- .../Merchants/Requests/GetMerchantsRequest.cs | 1 + .../Requests/ListMerchantsRequest.cs | 1 + src/Square/Mobile/MobileClient.cs | 1 + .../CreateMobileAuthorizationCodeRequest.cs | 1 + src/Square/OAuth/OAuthClient.cs | 4 +- .../OAuth/Requests/ObtainTokenRequest.cs | 1 + .../OAuth/Requests/RevokeTokenRequest.cs | 1 + .../CustomAttributeDefinitionsClient.cs | 16 +- ...teOrderCustomAttributeDefinitionRequest.cs | 1 + ...DeleteCustomAttributeDefinitionsRequest.cs | 1 + .../GetCustomAttributeDefinitionsRequest.cs | 1 + .../ListCustomAttributeDefinitionsRequest.cs | 1 + ...teOrderCustomAttributeDefinitionRequest.cs | 1 + .../CustomAttributesClient.cs | 7 +- .../BulkDeleteOrderCustomAttributesRequest.cs | 1 + .../BulkUpsertOrderCustomAttributesRequest.cs | 1 + .../Requests/DeleteCustomAttributesRequest.cs | 1 + .../Requests/GetCustomAttributesRequest.cs | 1 + .../Requests/ListCustomAttributesRequest.cs | 1 + .../UpsertOrderCustomAttributeRequest.cs | 1 + src/Square/Orders/OrdersClient.cs | 12 +- .../Orders/Requests/BatchGetOrdersRequest.cs | 1 + .../Orders/Requests/CalculateOrderRequest.cs | 1 + .../Orders/Requests/CloneOrderRequest.cs | 1 + .../Orders/Requests/GetOrdersRequest.cs | 1 + src/Square/Orders/Requests/PayOrderRequest.cs | 1 + .../Orders/Requests/SearchOrdersRequest.cs | 1 + .../Orders/Requests/UpdateOrderRequest.cs | 1 + src/Square/Payments/PaymentsClient.cs | 1 + .../CancelPaymentByIdempotencyKeyRequest.cs | 1 + .../Requests/CancelPaymentsRequest.cs | 1 + .../Requests/CompletePaymentRequest.cs | 1 + .../Payments/Requests/CreatePaymentRequest.cs | 1 + .../Payments/Requests/GetPaymentsRequest.cs | 1 + .../Payments/Requests/ListPaymentsRequest.cs | 1 + .../Payments/Requests/UpdatePaymentRequest.cs | 1 + src/Square/Payouts/PayoutsClient.cs | 1 + .../Payouts/Requests/GetPayoutsRequest.cs | 1 + .../Requests/ListEntriesPayoutsRequest.cs | 1 + .../Payouts/Requests/ListPayoutsRequest.cs | 1 + src/Square/Refunds/RefundsClient.cs | 3 +- .../Refunds/Requests/GetRefundsRequest.cs | 1 + .../Refunds/Requests/ListRefundsRequest.cs | 1 + .../Refunds/Requests/RefundPaymentRequest.cs | 1 + src/Square/Sites/SitesClient.cs | 1 + .../Requests/DeleteSnippetsRequest.cs | 1 + .../Snippets/Requests/GetSnippetsRequest.cs | 1 + .../Snippets/Requests/UpsertSnippetRequest.cs | 1 + src/Square/Snippets/SnippetsClient.cs | 1 + src/Square/Square.csproj | 100 +- src/Square/SquareClient.cs | 17 +- .../Requests/BulkSwapPlanRequest.cs | 1 + .../Requests/CancelSubscriptionsRequest.cs | 1 + .../ChangeBillingAnchorDateRequest.cs | 1 + .../Requests/CreateSubscriptionRequest.cs | 1 + .../DeleteActionSubscriptionsRequest.cs | 1 + .../Requests/GetSubscriptionsRequest.cs | 1 + .../ListEventsSubscriptionsRequest.cs | 1 + .../Requests/PauseSubscriptionRequest.cs | 1 + .../Requests/ResumeSubscriptionRequest.cs | 1 + .../Requests/SearchSubscriptionsRequest.cs | 1 + .../Subscriptions/Requests/SwapPlanRequest.cs | 1 + .../Requests/UpdateSubscriptionRequest.cs | 1 + .../Subscriptions/SubscriptionsClient.cs | 7 +- src/Square/Team/Requests/CreateJobRequest.cs | 1 + src/Square/Team/Requests/ListJobsRequest.cs | 1 + .../Team/Requests/RetrieveJobRequest.cs | 1 + src/Square/Team/Requests/UpdateJobRequest.cs | 1 + src/Square/Team/TeamClient.cs | 1 + .../Requests/BatchCreateTeamMembersRequest.cs | 1 + .../Requests/BatchUpdateTeamMembersRequest.cs | 1 + .../Requests/GetTeamMembersRequest.cs | 1 + .../Requests/SearchTeamMembersRequest.cs | 1 + .../Requests/UpdateTeamMembersRequest.cs | 1 + src/Square/TeamMembers/TeamMembersClient.cs | 1 + .../Requests/GetWageSettingRequest.cs | 1 + .../Requests/UpdateWageSettingRequest.cs | 1 + .../WageSetting/WageSettingClient.cs | 1 + src/Square/Terminal/Actions/ActionsClient.cs | 1 + .../Actions/Requests/CancelActionsRequest.cs | 1 + .../Requests/CreateTerminalActionRequest.cs | 1 + .../Actions/Requests/GetActionsRequest.cs | 1 + .../Requests/SearchTerminalActionsRequest.cs | 1 + .../Terminal/Checkouts/CheckoutsClient.cs | 1 + .../Requests/CancelCheckoutsRequest.cs | 1 + .../Requests/CreateTerminalCheckoutRequest.cs | 1 + .../Checkouts/Requests/GetCheckoutsRequest.cs | 1 + .../SearchTerminalCheckoutsRequest.cs | 1 + src/Square/Terminal/Refunds/RefundsClient.cs | 3 +- .../Refunds/Requests/CancelRefundsRequest.cs | 1 + .../Requests/CreateTerminalRefundRequest.cs | 1 + .../Refunds/Requests/GetRefundsRequest.cs | 1 + .../Requests/SearchTerminalRefundsRequest.cs | 1 + .../Requests/DismissTerminalActionRequest.cs | 1 + .../DismissTerminalCheckoutRequest.cs | 1 + .../Requests/DismissTerminalRefundRequest.cs | 1 + src/Square/Terminal/TerminalClient.cs | 6 +- .../Requests/CancelTransferOrderRequest.cs | 1 + .../Requests/CreateTransferOrderRequest.cs | 1 + .../Requests/DeleteTransferOrdersRequest.cs | 1 + .../Requests/GetTransferOrdersRequest.cs | 1 + .../Requests/ReceiveTransferOrderRequest.cs | 1 + .../Requests/SearchTransferOrdersRequest.cs | 1 + .../Requests/StartTransferOrderRequest.cs | 1 + .../Requests/UpdateTransferOrderRequest.cs | 1 + .../TransferOrders/TransferOrdersClient.cs | 1 + src/Square/Types/AcceptDisputeResponse.cs | 21 +- src/Square/Types/AcceptedPaymentMethods.cs | 21 +- .../Types/AccumulateLoyaltyPointsResponse.cs | 21 +- src/Square/Types/AchDetails.cs | 21 +- src/Square/Types/ActionCancelReason.cs | 2 + src/Square/Types/ActivityType.cs | 2 + .../Types/AddGroupToCustomerResponse.cs | 21 +- src/Square/Types/AdditionalRecipient.cs | 21 +- src/Square/Types/Address.cs | 21 +- .../Types/AdjustLoyaltyPointsResponse.cs | 21 +- src/Square/Types/AfterpayDetails.cs | 21 +- src/Square/Types/ApplicationDetails.cs | 21 +- ...ApplicationDetailsExternalSquareProduct.cs | 2 + src/Square/Types/AppointmentSegment.cs | 21 +- src/Square/Types/ArchivedState.cs | 2 + src/Square/Types/Availability.cs | 21 +- src/Square/Types/BankAccount.cs | 21 +- src/Square/Types/BankAccountCreatedEvent.cs | 21 +- .../Types/BankAccountCreatedEventData.cs | 21 +- .../Types/BankAccountCreatedEventObject.cs | 21 +- src/Square/Types/BankAccountDisabledEvent.cs | 21 +- .../Types/BankAccountDisabledEventData.cs | 21 +- .../Types/BankAccountDisabledEventObject.cs | 21 +- src/Square/Types/BankAccountPaymentDetails.cs | 21 +- src/Square/Types/BankAccountStatus.cs | 2 + src/Square/Types/BankAccountType.cs | 2 + src/Square/Types/BankAccountVerifiedEvent.cs | 21 +- .../Types/BankAccountVerifiedEventData.cs | 21 +- .../Types/BankAccountVerifiedEventObject.cs | 21 +- .../Types/BatchChangeInventoryRequest.cs | 21 +- .../Types/BatchChangeInventoryResponse.cs | 21 +- .../Types/BatchCreateTeamMembersResponse.cs | 21 +- .../Types/BatchCreateVendorsResponse.cs | 21 +- .../BatchDeleteCatalogObjectsResponse.cs | 21 +- .../Types/BatchGetCatalogObjectsResponse.cs | 21 +- .../Types/BatchGetInventoryChangesResponse.cs | 21 +- .../Types/BatchGetInventoryCountsRequest.cs | 21 +- .../Types/BatchGetInventoryCountsResponse.cs | 21 +- src/Square/Types/BatchGetOrdersResponse.cs | 21 +- src/Square/Types/BatchGetVendorsResponse.cs | 21 +- .../BatchRetrieveInventoryChangesRequest.cs | 21 +- .../Types/BatchUpdateTeamMembersResponse.cs | 21 +- .../Types/BatchUpdateVendorsResponse.cs | 21 +- .../BatchUpsertCatalogObjectsResponse.cs | 21 +- ...estCustomerCustomAttributeUpsertRequest.cs | 20 +- ...hUpsertCustomerCustomAttributesResponse.cs | 21 +- ...seCustomerCustomAttributeUpsertResponse.cs | 20 +- src/Square/Types/Booking.cs | 21 +- src/Square/Types/BookingBookingSource.cs | 2 + src/Square/Types/BookingCreatedEvent.cs | 21 +- src/Square/Types/BookingCreatedEventData.cs | 21 +- src/Square/Types/BookingCreatedEventObject.cs | 21 +- src/Square/Types/BookingCreatorDetails.cs | 21 +- .../Types/BookingCreatorDetailsCreatorType.cs | 2 + ...tomAttributeDefinitionOwnedCreatedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedDeletedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedUpdatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleCreatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleDeletedEvent.cs | 21 +- ...mAttributeDefinitionVisibleUpdatedEvent.cs | 21 +- .../BookingCustomAttributeDeleteRequest.cs | 21 +- .../BookingCustomAttributeDeleteResponse.cs | 21 +- ...BookingCustomAttributeOwnedDeletedEvent.cs | 21 +- ...BookingCustomAttributeOwnedUpdatedEvent.cs | 21 +- .../BookingCustomAttributeUpsertRequest.cs | 21 +- .../BookingCustomAttributeUpsertResponse.cs | 21 +- ...okingCustomAttributeVisibleDeletedEvent.cs | 21 +- ...okingCustomAttributeVisibleUpdatedEvent.cs | 21 +- src/Square/Types/BookingStatus.cs | 2 + src/Square/Types/BookingUpdatedEvent.cs | 21 +- src/Square/Types/BookingUpdatedEventData.cs | 21 +- src/Square/Types/BookingUpdatedEventObject.cs | 21 +- src/Square/Types/Break.cs | 21 +- src/Square/Types/BreakType.cs | 21 +- src/Square/Types/BulkCreateCustomerData.cs | 21 +- .../Types/BulkCreateCustomersResponse.cs | 21 +- ...lkDeleteBookingCustomAttributesResponse.cs | 21 +- .../Types/BulkDeleteCustomersResponse.cs | 21 +- ...estLocationCustomAttributeDeleteRequest.cs | 20 +- ...kDeleteLocationCustomAttributesResponse.cs | 21 +- ...seLocationCustomAttributeDeleteResponse.cs | 20 +- ...estMerchantCustomAttributeDeleteRequest.cs | 20 +- ...kDeleteMerchantCustomAttributesResponse.cs | 21 +- ...seMerchantCustomAttributeDeleteResponse.cs | 20 +- ...mAttributesRequestDeleteCustomAttribute.cs | 21 +- ...BulkDeleteOrderCustomAttributesResponse.cs | 21 +- .../Types/BulkPublishScheduledShiftsData.cs | 21 +- .../BulkPublishScheduledShiftsResponse.cs | 21 +- .../Types/BulkRetrieveBookingsResponse.cs | 21 +- .../Types/BulkRetrieveChannelsResponse.cs | 21 +- .../Types/BulkRetrieveCustomersResponse.cs | 21 +- ...trieveTeamMemberBookingProfilesResponse.cs | 21 +- src/Square/Types/BulkSwapPlanResponse.cs | 21 +- src/Square/Types/BulkUpdateCustomerData.cs | 21 +- .../Types/BulkUpdateCustomersResponse.cs | 21 +- ...lkUpsertBookingCustomAttributesResponse.cs | 21 +- ...estLocationCustomAttributeUpsertRequest.cs | 20 +- ...kUpsertLocationCustomAttributesResponse.cs | 21 +- ...seLocationCustomAttributeUpsertResponse.cs | 20 +- ...estMerchantCustomAttributeUpsertRequest.cs | 20 +- ...kUpsertMerchantCustomAttributesResponse.cs | 21 +- ...seMerchantCustomAttributeUpsertResponse.cs | 20 +- ...mAttributesRequestUpsertCustomAttribute.cs | 21 +- ...BulkUpsertOrderCustomAttributesResponse.cs | 21 +- .../Types/BusinessAppointmentSettings.cs | 21 +- ...usinessAppointmentSettingsAlignmentTime.cs | 2 + ...sAppointmentSettingsBookingLocationType.cs | 2 + ...ssAppointmentSettingsCancellationPolicy.cs | 2 + ...tSettingsMaxAppointmentsPerDayLimitType.cs | 2 + src/Square/Types/BusinessBookingProfile.cs | 21 +- .../BusinessBookingProfileBookingPolicy.cs | 2 + ...essBookingProfileCustomerTimezoneChoice.cs | 2 + src/Square/Types/BusinessHours.cs | 21 +- src/Square/Types/BusinessHoursPeriod.cs | 21 +- src/Square/Types/BuyNowPayLaterDetails.cs | 21 +- .../Types/CalculateLoyaltyPointsResponse.cs | 21 +- src/Square/Types/CalculateOrderResponse.cs | 21 +- src/Square/Types/CancelBookingResponse.cs | 21 +- src/Square/Types/CancelInvoiceResponse.cs | 21 +- .../Types/CancelLoyaltyPromotionResponse.cs | 21 +- .../CancelPaymentByIdempotencyKeyResponse.cs | 21 +- src/Square/Types/CancelPaymentResponse.cs | 21 +- .../Types/CancelSubscriptionResponse.cs | 21 +- .../Types/CancelTerminalActionResponse.cs | 21 +- .../Types/CancelTerminalCheckoutResponse.cs | 21 +- .../Types/CancelTerminalRefundResponse.cs | 21 +- .../Types/CancelTransferOrderResponse.cs | 21 +- .../Types/CaptureTransactionResponse.cs | 21 +- src/Square/Types/Card.cs | 21 +- .../Types/CardAutomaticallyUpdatedEvent.cs | 21 +- .../CardAutomaticallyUpdatedEventData.cs | 21 +- .../CardAutomaticallyUpdatedEventObject.cs | 21 +- src/Square/Types/CardBrand.cs | 2 + src/Square/Types/CardCoBrand.cs | 2 + src/Square/Types/CardCreatedEvent.cs | 21 +- src/Square/Types/CardCreatedEventData.cs | 21 +- src/Square/Types/CardCreatedEventObject.cs | 21 +- src/Square/Types/CardDisabledEvent.cs | 21 +- src/Square/Types/CardDisabledEventData.cs | 21 +- src/Square/Types/CardDisabledEventObject.cs | 21 +- src/Square/Types/CardForgottenEvent.cs | 21 +- src/Square/Types/CardForgottenEventCard.cs | 21 +- src/Square/Types/CardForgottenEventData.cs | 21 +- src/Square/Types/CardForgottenEventObject.cs | 21 +- src/Square/Types/CardPaymentDetails.cs | 21 +- src/Square/Types/CardPaymentTimeline.cs | 21 +- src/Square/Types/CardPrepaidType.cs | 2 + src/Square/Types/CardType.cs | 2 + src/Square/Types/CardUpdatedEvent.cs | 21 +- src/Square/Types/CardUpdatedEventData.cs | 21 +- src/Square/Types/CardUpdatedEventObject.cs | 21 +- src/Square/Types/CashAppDetails.cs | 21 +- src/Square/Types/CashDrawerDevice.cs | 21 +- src/Square/Types/CashDrawerEventType.cs | 2 + src/Square/Types/CashDrawerShift.cs | 21 +- src/Square/Types/CashDrawerShiftEvent.cs | 21 +- src/Square/Types/CashDrawerShiftState.cs | 2 + src/Square/Types/CashDrawerShiftSummary.cs | 21 +- src/Square/Types/CashPaymentDetails.cs | 21 +- src/Square/Types/CatalogAvailabilityPeriod.cs | 21 +- src/Square/Types/CatalogCategory.cs | 21 +- src/Square/Types/CatalogCategoryType.cs | 2 + .../Types/CatalogCustomAttributeDefinition.cs | 21 +- ...gCustomAttributeDefinitionAppVisibility.cs | 2 + ...ogCustomAttributeDefinitionNumberConfig.cs | 21 +- ...ustomAttributeDefinitionSelectionConfig.cs | 21 +- ...SelectionConfigCustomAttributeSelection.cs | 20 +- ...stomAttributeDefinitionSellerVisibility.cs | 2 + ...ogCustomAttributeDefinitionStringConfig.cs | 21 +- .../CatalogCustomAttributeDefinitionType.cs | 2 + .../Types/CatalogCustomAttributeValue.cs | 21 +- src/Square/Types/CatalogDiscount.cs | 21 +- .../Types/CatalogDiscountModifyTaxBasis.cs | 2 + src/Square/Types/CatalogDiscountType.cs | 2 + src/Square/Types/CatalogEcomSeoData.cs | 21 +- src/Square/Types/CatalogIdMapping.cs | 21 +- src/Square/Types/CatalogImage.cs | 21 +- src/Square/Types/CatalogInfoResponse.cs | 21 +- src/Square/Types/CatalogInfoResponseLimits.cs | 21 +- src/Square/Types/CatalogItem.cs | 21 +- .../CatalogItemFoodAndBeverageDetails.cs | 21 +- ...FoodAndBeverageDetailsDietaryPreference.cs | 21 +- ...taryPreferenceStandardDietaryPreference.cs | 2 + ...AndBeverageDetailsDietaryPreferenceType.cs | 2 + ...logItemFoodAndBeverageDetailsIngredient.cs | 21 +- ...rageDetailsIngredientStandardIngredient.cs | 2 + .../Types/CatalogItemModifierListInfo.cs | 21 +- src/Square/Types/CatalogItemOption.cs | 21 +- src/Square/Types/CatalogItemOptionForItem.cs | 21 +- src/Square/Types/CatalogItemOptionValue.cs | 21 +- .../CatalogItemOptionValueForItemVariation.cs | 21 +- src/Square/Types/CatalogItemProductType.cs | 2 + src/Square/Types/CatalogItemVariation.cs | 21 +- src/Square/Types/CatalogMeasurementUnit.cs | 21 +- src/Square/Types/CatalogModifier.cs | 21 +- src/Square/Types/CatalogModifierList.cs | 21 +- .../Types/CatalogModifierListModifierType.cs | 2 + .../Types/CatalogModifierListSelectionType.cs | 2 + src/Square/Types/CatalogModifierOverride.cs | 21 +- src/Square/Types/CatalogObject.cs | 205 +- .../Types/CatalogObjectAvailabilityPeriod.cs | 21 +- src/Square/Types/CatalogObjectBase.cs | 21 +- src/Square/Types/CatalogObjectBatch.cs | 21 +- src/Square/Types/CatalogObjectCategory.cs | 21 +- .../CatalogObjectCustomAttributeDefinition.cs | 21 +- src/Square/Types/CatalogObjectDiscount.cs | 21 +- src/Square/Types/CatalogObjectImage.cs | 21 +- src/Square/Types/CatalogObjectItem.cs | 21 +- src/Square/Types/CatalogObjectItemOption.cs | 21 +- .../Types/CatalogObjectItemOptionValue.cs | 21 +- .../Types/CatalogObjectItemVariation.cs | 21 +- .../Types/CatalogObjectMeasurementUnit.cs | 21 +- src/Square/Types/CatalogObjectModifier.cs | 21 +- src/Square/Types/CatalogObjectModifierList.cs | 21 +- src/Square/Types/CatalogObjectPricingRule.cs | 21 +- src/Square/Types/CatalogObjectProductSet.cs | 21 +- .../CatalogObjectQuickAmountsSettings.cs | 21 +- src/Square/Types/CatalogObjectReference.cs | 21 +- .../Types/CatalogObjectSubscriptionPlan.cs | 21 +- .../CatalogObjectSubscriptionPlanVariation.cs | 21 +- src/Square/Types/CatalogObjectTax.cs | 21 +- src/Square/Types/CatalogObjectTimePeriod.cs | 21 +- src/Square/Types/CatalogObjectType.cs | 2 + src/Square/Types/CatalogPricingRule.cs | 21 +- src/Square/Types/CatalogPricingType.cs | 2 + src/Square/Types/CatalogProductSet.cs | 21 +- src/Square/Types/CatalogQuery.cs | 21 +- src/Square/Types/CatalogQueryExact.cs | 21 +- ...gQueryItemVariationsForItemOptionValues.cs | 21 +- .../Types/CatalogQueryItemsForItemOptions.cs | 21 +- .../Types/CatalogQueryItemsForModifierList.cs | 21 +- src/Square/Types/CatalogQueryItemsForTax.cs | 21 +- src/Square/Types/CatalogQueryPrefix.cs | 21 +- src/Square/Types/CatalogQueryRange.cs | 21 +- src/Square/Types/CatalogQuerySet.cs | 21 +- .../Types/CatalogQuerySortedAttribute.cs | 21 +- src/Square/Types/CatalogQueryText.cs | 21 +- src/Square/Types/CatalogQuickAmount.cs | 21 +- src/Square/Types/CatalogQuickAmountType.cs | 2 + .../Types/CatalogQuickAmountsSettings.cs | 21 +- .../CatalogQuickAmountsSettingsOption.cs | 2 + src/Square/Types/CatalogStockConversion.cs | 21 +- src/Square/Types/CatalogSubscriptionPlan.cs | 21 +- .../Types/CatalogSubscriptionPlanVariation.cs | 21 +- src/Square/Types/CatalogTax.cs | 21 +- src/Square/Types/CatalogTimePeriod.cs | 21 +- src/Square/Types/CatalogV1Id.cs | 21 +- .../Types/CatalogVersionUpdatedEvent.cs | 21 +- ...atalogVersionUpdatedEventCatalogVersion.cs | 21 +- .../Types/CatalogVersionUpdatedEventData.cs | 21 +- .../Types/CatalogVersionUpdatedEventObject.cs | 21 +- src/Square/Types/CategoryPathToRootNode.cs | 21 +- .../Types/ChangeBillingAnchorDateResponse.cs | 21 +- src/Square/Types/ChangeTiming.cs | 2 + src/Square/Types/Channel.cs | 21 +- src/Square/Types/ChannelStatus.cs | 2 + .../Types/ChargeRequestAdditionalRecipient.cs | 21 +- src/Square/Types/CheckoutLocationSettings.cs | 21 +- .../Types/CheckoutLocationSettingsBranding.cs | 21 +- ...koutLocationSettingsBrandingButtonShape.cs | 2 + ...ckoutLocationSettingsBrandingHeaderType.cs | 2 + .../Types/CheckoutLocationSettingsCoupons.cs | 21 +- .../Types/CheckoutLocationSettingsPolicy.cs | 21 +- .../Types/CheckoutLocationSettingsTipping.cs | 21 +- src/Square/Types/CheckoutMerchantSettings.cs | 21 +- .../CheckoutMerchantSettingsPaymentMethods.cs | 21 +- ...tSettingsPaymentMethodsAfterpayClearpay.cs | 21 +- ...MethodsAfterpayClearpayEligibilityRange.cs | 20 +- ...hantSettingsPaymentMethodsPaymentMethod.cs | 21 +- src/Square/Types/CheckoutOptions.cs | 21 +- .../Types/CheckoutOptionsPaymentType.cs | 2 + src/Square/Types/ClearpayDetails.cs | 21 +- src/Square/Types/CloneOrderResponse.cs | 21 +- src/Square/Types/CollectedData.cs | 21 +- src/Square/Types/CompletePaymentResponse.cs | 21 +- src/Square/Types/Component.cs | 21 +- src/Square/Types/ComponentComponentType.cs | 2 + src/Square/Types/ConfirmationDecision.cs | 21 +- src/Square/Types/ConfirmationOptions.cs | 21 +- src/Square/Types/Coordinates.cs | 21 +- src/Square/Types/Country.cs | 2 + ...ookingCustomAttributeDefinitionResponse.cs | 21 +- src/Square/Types/CreateBookingResponse.cs | 21 +- src/Square/Types/CreateBreakTypeResponse.cs | 21 +- src/Square/Types/CreateCardResponse.cs | 21 +- src/Square/Types/CreateCatalogImageRequest.cs | 21 +- .../Types/CreateCatalogImageResponse.cs | 21 +- src/Square/Types/CreateCheckoutResponse.cs | 23 +- .../Types/CreateCustomerCardResponse.cs | 21 +- ...stomerCustomAttributeDefinitionResponse.cs | 21 +- .../Types/CreateCustomerGroupResponse.cs | 21 +- src/Square/Types/CreateCustomerResponse.cs | 21 +- src/Square/Types/CreateDeviceCodeResponse.cs | 21 +- .../Types/CreateDisputeEvidenceFileRequest.cs | 21 +- .../CreateDisputeEvidenceFileResponse.cs | 21 +- .../CreateDisputeEvidenceTextResponse.cs | 21 +- .../Types/CreateGiftCardActivityResponse.cs | 21 +- src/Square/Types/CreateGiftCardResponse.cs | 21 +- .../CreateInvoiceAttachmentRequestData.cs | 21 +- .../Types/CreateInvoiceAttachmentResponse.cs | 21 +- src/Square/Types/CreateInvoiceResponse.cs | 21 +- src/Square/Types/CreateJobResponse.cs | 21 +- ...cationCustomAttributeDefinitionResponse.cs | 21 +- src/Square/Types/CreateLocationResponse.cs | 21 +- .../Types/CreateLoyaltyAccountResponse.cs | 21 +- .../Types/CreateLoyaltyPromotionResponse.cs | 21 +- .../Types/CreateLoyaltyRewardResponse.cs | 21 +- ...rchantCustomAttributeDefinitionResponse.cs | 21 +- .../CreateMobileAuthorizationCodeResponse.cs | 21 +- ...eOrderCustomAttributeDefinitionResponse.cs | 21 +- src/Square/Types/CreateOrderRequest.cs | 21 +- src/Square/Types/CreateOrderResponse.cs | 21 +- src/Square/Types/CreatePaymentLinkResponse.cs | 21 +- src/Square/Types/CreatePaymentResponse.cs | 21 +- .../Types/CreateScheduledShiftResponse.cs | 21 +- src/Square/Types/CreateShiftResponse.cs | 21 +- .../Types/CreateSubscriptionResponse.cs | 21 +- src/Square/Types/CreateTeamMemberRequest.cs | 21 +- src/Square/Types/CreateTeamMemberResponse.cs | 21 +- .../Types/CreateTerminalActionResponse.cs | 21 +- .../Types/CreateTerminalCheckoutResponse.cs | 21 +- .../Types/CreateTerminalRefundResponse.cs | 21 +- src/Square/Types/CreateTimecardResponse.cs | 21 +- src/Square/Types/CreateTransferOrderData.cs | 21 +- .../Types/CreateTransferOrderLineData.cs | 21 +- .../Types/CreateTransferOrderResponse.cs | 21 +- src/Square/Types/CreateVendorResponse.cs | 21 +- .../CreateWebhookSubscriptionResponse.cs | 21 +- src/Square/Types/Currency.cs | 2 + src/Square/Types/CustomAttribute.cs | 21 +- src/Square/Types/CustomAttributeDefinition.cs | 23 +- .../CustomAttributeDefinitionEventData.cs | 21 +- ...ustomAttributeDefinitionEventDataObject.cs | 21 +- .../CustomAttributeDefinitionVisibility.cs | 2 + src/Square/Types/CustomAttributeEventData.cs | 21 +- .../Types/CustomAttributeEventDataObject.cs | 21 +- src/Square/Types/CustomAttributeFilter.cs | 21 +- src/Square/Types/CustomField.cs | 21 +- src/Square/Types/Customer.cs | 21 +- src/Square/Types/CustomerAddressFilter.cs | 21 +- src/Square/Types/CustomerCreatedEvent.cs | 21 +- src/Square/Types/CustomerCreatedEventData.cs | 21 +- .../Types/CustomerCreatedEventEventContext.cs | 21 +- .../CustomerCreatedEventEventContextMerge.cs | 21 +- .../Types/CustomerCreatedEventObject.cs | 21 +- src/Square/Types/CustomerCreationSource.cs | 2 + .../Types/CustomerCreationSourceFilter.cs | 21 +- ...erCustomAttributeDefinitionCreatedEvent.cs | 21 +- ...omAttributeDefinitionCreatedPublicEvent.cs | 21 +- ...erCustomAttributeDefinitionDeletedEvent.cs | 21 +- ...omAttributeDefinitionDeletedPublicEvent.cs | 21 +- ...tomAttributeDefinitionOwnedCreatedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedDeletedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedUpdatedEvent.cs | 21 +- ...erCustomAttributeDefinitionUpdatedEvent.cs | 21 +- ...omAttributeDefinitionUpdatedPublicEvent.cs | 21 +- ...mAttributeDefinitionVisibleCreatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleDeletedEvent.cs | 21 +- ...mAttributeDefinitionVisibleUpdatedEvent.cs | 21 +- .../CustomerCustomAttributeDeletedEvent.cs | 21 +- ...stomerCustomAttributeDeletedPublicEvent.cs | 21 +- .../Types/CustomerCustomAttributeFilter.cs | 21 +- .../CustomerCustomAttributeFilterValue.cs | 21 +- .../Types/CustomerCustomAttributeFilters.cs | 21 +- ...ustomerCustomAttributeOwnedDeletedEvent.cs | 21 +- ...ustomerCustomAttributeOwnedUpdatedEvent.cs | 21 +- .../CustomerCustomAttributeUpdatedEvent.cs | 21 +- ...stomerCustomAttributeUpdatedPublicEvent.cs | 21 +- ...tomerCustomAttributeVisibleDeletedEvent.cs | 21 +- ...tomerCustomAttributeVisibleUpdatedEvent.cs | 21 +- src/Square/Types/CustomerDeletedEvent.cs | 21 +- src/Square/Types/CustomerDeletedEventData.cs | 21 +- .../Types/CustomerDeletedEventEventContext.cs | 21 +- .../CustomerDeletedEventEventContextMerge.cs | 21 +- .../Types/CustomerDeletedEventObject.cs | 21 +- src/Square/Types/CustomerDetails.cs | 21 +- src/Square/Types/CustomerFilter.cs | 21 +- src/Square/Types/CustomerGroup.cs | 21 +- .../Types/CustomerInclusionExclusion.cs | 2 + src/Square/Types/CustomerPreferences.cs | 21 +- src/Square/Types/CustomerQuery.cs | 21 +- src/Square/Types/CustomerSegment.cs | 21 +- src/Square/Types/CustomerSort.cs | 21 +- src/Square/Types/CustomerSortField.cs | 2 + src/Square/Types/CustomerTaxIds.cs | 21 +- src/Square/Types/CustomerTextFilter.cs | 21 +- src/Square/Types/CustomerUpdatedEvent.cs | 21 +- src/Square/Types/CustomerUpdatedEventData.cs | 21 +- .../Types/CustomerUpdatedEventObject.cs | 21 +- src/Square/Types/DataCollectionOptions.cs | 21 +- .../Types/DataCollectionOptionsInputType.cs | 2 + src/Square/Types/DateRange.cs | 21 +- src/Square/Types/DayOfWeek.cs | 2 + ...ookingCustomAttributeDefinitionResponse.cs | 21 +- .../DeleteBookingCustomAttributeResponse.cs | 21 +- src/Square/Types/DeleteBreakTypeResponse.cs | 21 +- .../Types/DeleteCatalogObjectResponse.cs | 21 +- .../Types/DeleteCustomerCardResponse.cs | 21 +- ...stomerCustomAttributeDefinitionResponse.cs | 21 +- .../DeleteCustomerCustomAttributeResponse.cs | 21 +- .../Types/DeleteCustomerGroupResponse.cs | 21 +- src/Square/Types/DeleteCustomerResponse.cs | 21 +- .../Types/DeleteDisputeEvidenceResponse.cs | 21 +- .../Types/DeleteInvoiceAttachmentResponse.cs | 21 +- src/Square/Types/DeleteInvoiceResponse.cs | 21 +- ...cationCustomAttributeDefinitionResponse.cs | 21 +- .../DeleteLocationCustomAttributeResponse.cs | 21 +- .../Types/DeleteLoyaltyRewardResponse.cs | 21 +- ...rchantCustomAttributeDefinitionResponse.cs | 21 +- .../DeleteMerchantCustomAttributeResponse.cs | 21 +- ...eOrderCustomAttributeDefinitionResponse.cs | 21 +- .../DeleteOrderCustomAttributeResponse.cs | 21 +- src/Square/Types/DeletePaymentLinkResponse.cs | 21 +- src/Square/Types/DeleteShiftResponse.cs | 21 +- src/Square/Types/DeleteSnippetResponse.cs | 21 +- .../Types/DeleteSubscriptionActionResponse.cs | 21 +- src/Square/Types/DeleteTimecardResponse.cs | 21 +- .../Types/DeleteTransferOrderResponse.cs | 21 +- .../DeleteWebhookSubscriptionResponse.cs | 21 +- src/Square/Types/Destination.cs | 21 +- src/Square/Types/DestinationDetails.cs | 21 +- .../DestinationDetailsCardRefundDetails.cs | 21 +- .../DestinationDetailsCashRefundDetails.cs | 21 +- ...DestinationDetailsExternalRefundDetails.cs | 21 +- src/Square/Types/DestinationType.cs | 2 + src/Square/Types/Device.cs | 21 +- src/Square/Types/DeviceAttributes.cs | 21 +- .../Types/DeviceAttributesDeviceType.cs | 2 + src/Square/Types/DeviceCheckoutOptions.cs | 21 +- src/Square/Types/DeviceCode.cs | 21 +- src/Square/Types/DeviceCodePairedEvent.cs | 21 +- src/Square/Types/DeviceCodePairedEventData.cs | 21 +- .../Types/DeviceCodePairedEventObject.cs | 21 +- src/Square/Types/DeviceCodeStatus.cs | 2 + ...eviceComponentDetailsApplicationDetails.cs | 21 +- .../DeviceComponentDetailsBatteryDetails.cs | 21 +- ...DeviceComponentDetailsCardReaderDetails.cs | 21 +- .../DeviceComponentDetailsEthernetDetails.cs | 21 +- .../DeviceComponentDetailsExternalPower.cs | 2 + .../DeviceComponentDetailsMeasurement.cs | 21 +- .../DeviceComponentDetailsWiFiDetails.cs | 21 +- src/Square/Types/DeviceCreatedEvent.cs | 21 +- src/Square/Types/DeviceCreatedEventData.cs | 21 +- src/Square/Types/DeviceCreatedEventObject.cs | 21 +- src/Square/Types/DeviceDetails.cs | 21 +- src/Square/Types/DeviceMetadata.cs | 21 +- src/Square/Types/DeviceStatus.cs | 21 +- src/Square/Types/DeviceStatusCategory.cs | 2 + src/Square/Types/DigitalWalletDetails.cs | 21 +- src/Square/Types/DisableCardResponse.cs | 21 +- src/Square/Types/DisableEventsResponse.cs | 21 +- .../Types/DismissTerminalActionResponse.cs | 21 +- .../Types/DismissTerminalCheckoutResponse.cs | 21 +- .../Types/DismissTerminalRefundResponse.cs | 21 +- src/Square/Types/Dispute.cs | 21 +- src/Square/Types/DisputeCreatedEvent.cs | 21 +- src/Square/Types/DisputeCreatedEventData.cs | 21 +- src/Square/Types/DisputeCreatedEventObject.cs | 21 +- src/Square/Types/DisputeEvidence.cs | 21 +- src/Square/Types/DisputeEvidenceAddedEvent.cs | 21 +- .../Types/DisputeEvidenceAddedEventData.cs | 21 +- .../Types/DisputeEvidenceAddedEventObject.cs | 21 +- .../Types/DisputeEvidenceCreatedEvent.cs | 21 +- .../Types/DisputeEvidenceCreatedEventData.cs | 21 +- .../DisputeEvidenceCreatedEventObject.cs | 21 +- .../Types/DisputeEvidenceDeletedEvent.cs | 21 +- .../Types/DisputeEvidenceDeletedEventData.cs | 21 +- .../DisputeEvidenceDeletedEventObject.cs | 21 +- src/Square/Types/DisputeEvidenceFile.cs | 21 +- .../Types/DisputeEvidenceRemovedEvent.cs | 21 +- .../Types/DisputeEvidenceRemovedEventData.cs | 21 +- .../DisputeEvidenceRemovedEventObject.cs | 21 +- src/Square/Types/DisputeEvidenceType.cs | 2 + src/Square/Types/DisputeReason.cs | 2 + src/Square/Types/DisputeState.cs | 2 + src/Square/Types/DisputeStateChangedEvent.cs | 21 +- .../Types/DisputeStateChangedEventData.cs | 21 +- .../Types/DisputeStateChangedEventObject.cs | 21 +- src/Square/Types/DisputeStateUpdatedEvent.cs | 21 +- .../Types/DisputeStateUpdatedEventData.cs | 21 +- .../Types/DisputeStateUpdatedEventObject.cs | 21 +- src/Square/Types/DisputedPayment.cs | 21 +- src/Square/Types/EcomVisibility.cs | 2 + src/Square/Types/Employee.cs | 21 +- src/Square/Types/EmployeeStatus.cs | 2 + src/Square/Types/EmployeeWage.cs | 21 +- src/Square/Types/EnableEventsResponse.cs | 21 +- src/Square/Types/Error.cs | 21 +- src/Square/Types/ErrorCategory.cs | 2 + src/Square/Types/ErrorCode.cs | 2 + src/Square/Types/Event.cs | 21 +- src/Square/Types/EventData.cs | 23 +- src/Square/Types/EventMetadata.cs | 21 +- src/Square/Types/EventTypeMetadata.cs | 21 +- src/Square/Types/ExcludeStrategy.cs | 2 + src/Square/Types/ExternalPaymentDetails.cs | 21 +- src/Square/Types/FilterValue.cs | 21 +- src/Square/Types/FloatNumberRange.cs | 21 +- src/Square/Types/Fulfillment.cs | 21 +- .../Types/FulfillmentDeliveryDetails.cs | 21 +- ...rFulfillmentDeliveryDetailsScheduleType.cs | 2 + .../Types/FulfillmentFulfillmentEntry.cs | 21 +- ...lfillmentFulfillmentLineItemApplication.cs | 2 + src/Square/Types/FulfillmentPickupDetails.cs | 21 +- ...lmentPickupDetailsCurbsidePickupDetails.cs | 21 +- .../FulfillmentPickupDetailsScheduleType.cs | 2 + src/Square/Types/FulfillmentRecipient.cs | 21 +- .../Types/FulfillmentShipmentDetails.cs | 21 +- src/Square/Types/FulfillmentState.cs | 2 + src/Square/Types/FulfillmentType.cs | 2 + .../Types/GetBankAccountByV1IdResponse.cs | 21 +- src/Square/Types/GetBankAccountResponse.cs | 21 +- src/Square/Types/GetBookingResponse.cs | 21 +- src/Square/Types/GetBreakTypeResponse.cs | 21 +- .../GetBusinessBookingProfileResponse.cs | 21 +- src/Square/Types/GetCardResponse.cs | 21 +- .../Types/GetCashDrawerShiftResponse.cs | 21 +- src/Square/Types/GetCatalogObjectResponse.cs | 21 +- ...stomerCustomAttributeDefinitionResponse.cs | 21 +- .../GetCustomerCustomAttributeResponse.cs | 21 +- src/Square/Types/GetCustomerGroupResponse.cs | 21 +- src/Square/Types/GetCustomerResponse.cs | 21 +- .../Types/GetCustomerSegmentResponse.cs | 21 +- src/Square/Types/GetDeviceCodeResponse.cs | 21 +- src/Square/Types/GetDeviceResponse.cs | 21 +- .../Types/GetDisputeEvidenceResponse.cs | 21 +- src/Square/Types/GetDisputeResponse.cs | 21 +- src/Square/Types/GetEmployeeResponse.cs | 21 +- src/Square/Types/GetEmployeeWageResponse.cs | 21 +- .../Types/GetGiftCardFromGanResponse.cs | 21 +- .../Types/GetGiftCardFromNonceResponse.cs | 21 +- src/Square/Types/GetGiftCardResponse.cs | 21 +- .../Types/GetInventoryAdjustmentResponse.cs | 21 +- .../Types/GetInventoryChangesResponse.cs | 21 +- src/Square/Types/GetInventoryCountResponse.cs | 21 +- .../GetInventoryPhysicalCountResponse.cs | 21 +- .../Types/GetInventoryTransferResponse.cs | 21 +- src/Square/Types/GetInvoiceResponse.cs | 21 +- src/Square/Types/GetLocationResponse.cs | 21 +- src/Square/Types/GetLoyaltyAccountResponse.cs | 21 +- src/Square/Types/GetLoyaltyProgramResponse.cs | 21 +- .../Types/GetLoyaltyPromotionResponse.cs | 21 +- src/Square/Types/GetLoyaltyRewardResponse.cs | 21 +- src/Square/Types/GetMerchantResponse.cs | 21 +- src/Square/Types/GetOrderResponse.cs | 21 +- src/Square/Types/GetPaymentLinkResponse.cs | 21 +- src/Square/Types/GetPaymentRefundResponse.cs | 21 +- src/Square/Types/GetPaymentResponse.cs | 21 +- src/Square/Types/GetPayoutResponse.cs | 21 +- src/Square/Types/GetShiftResponse.cs | 21 +- src/Square/Types/GetSnippetResponse.cs | 21 +- src/Square/Types/GetSubscriptionResponse.cs | 21 +- .../GetTeamMemberBookingProfileResponse.cs | 21 +- src/Square/Types/GetTeamMemberResponse.cs | 21 +- src/Square/Types/GetTeamMemberWageResponse.cs | 21 +- src/Square/Types/GetTerminalActionResponse.cs | 21 +- .../Types/GetTerminalCheckoutResponse.cs | 21 +- src/Square/Types/GetTerminalRefundResponse.cs | 21 +- src/Square/Types/GetTransactionResponse.cs | 21 +- src/Square/Types/GetVendorResponse.cs | 21 +- src/Square/Types/GetWageSettingResponse.cs | 21 +- .../Types/GetWebhookSubscriptionResponse.cs | 21 +- src/Square/Types/GiftCard.cs | 21 +- src/Square/Types/GiftCardActivity.cs | 21 +- src/Square/Types/GiftCardActivityActivate.cs | 21 +- .../Types/GiftCardActivityAdjustDecrement.cs | 21 +- .../GiftCardActivityAdjustDecrementReason.cs | 2 + .../Types/GiftCardActivityAdjustIncrement.cs | 21 +- .../GiftCardActivityAdjustIncrementReason.cs | 2 + src/Square/Types/GiftCardActivityBlock.cs | 21 +- .../Types/GiftCardActivityClearBalance.cs | 21 +- .../GiftCardActivityClearBalanceReason.cs | 2 + .../Types/GiftCardActivityCreatedEvent.cs | 21 +- .../Types/GiftCardActivityCreatedEventData.cs | 21 +- .../GiftCardActivityCreatedEventObject.cs | 21 +- .../Types/GiftCardActivityDeactivate.cs | 21 +- .../Types/GiftCardActivityDeactivateReason.cs | 2 + src/Square/Types/GiftCardActivityImport.cs | 21 +- .../Types/GiftCardActivityImportReversal.cs | 21 +- src/Square/Types/GiftCardActivityLoad.cs | 21 +- src/Square/Types/GiftCardActivityRedeem.cs | 21 +- .../Types/GiftCardActivityRedeemStatus.cs | 2 + src/Square/Types/GiftCardActivityRefund.cs | 21 +- .../GiftCardActivityTransferBalanceFrom.cs | 21 +- .../GiftCardActivityTransferBalanceTo.cs | 21 +- src/Square/Types/GiftCardActivityType.cs | 2 + src/Square/Types/GiftCardActivityUnblock.cs | 21 +- .../GiftCardActivityUnlinkedActivityRefund.cs | 21 +- .../Types/GiftCardActivityUpdatedEvent.cs | 21 +- .../Types/GiftCardActivityUpdatedEventData.cs | 21 +- .../GiftCardActivityUpdatedEventObject.cs | 21 +- src/Square/Types/GiftCardCreatedEvent.cs | 21 +- src/Square/Types/GiftCardCreatedEventData.cs | 21 +- .../Types/GiftCardCreatedEventObject.cs | 21 +- .../Types/GiftCardCustomerLinkedEvent.cs | 21 +- .../Types/GiftCardCustomerLinkedEventData.cs | 21 +- .../GiftCardCustomerLinkedEventObject.cs | 21 +- .../Types/GiftCardCustomerUnlinkedEvent.cs | 21 +- .../GiftCardCustomerUnlinkedEventData.cs | 21 +- .../GiftCardCustomerUnlinkedEventObject.cs | 21 +- src/Square/Types/GiftCardGanSource.cs | 2 + src/Square/Types/GiftCardStatus.cs | 2 + src/Square/Types/GiftCardType.cs | 2 + src/Square/Types/GiftCardUpdatedEvent.cs | 21 +- src/Square/Types/GiftCardUpdatedEventData.cs | 21 +- .../Types/GiftCardUpdatedEventObject.cs | 21 +- src/Square/Types/InventoryAdjustment.cs | 21 +- src/Square/Types/InventoryAdjustmentGroup.cs | 21 +- src/Square/Types/InventoryAlertType.cs | 2 + src/Square/Types/InventoryChange.cs | 21 +- src/Square/Types/InventoryChangeType.cs | 2 + src/Square/Types/InventoryCount.cs | 21 +- .../Types/InventoryCountUpdatedEvent.cs | 21 +- .../Types/InventoryCountUpdatedEventData.cs | 21 +- .../Types/InventoryCountUpdatedEventObject.cs | 21 +- src/Square/Types/InventoryPhysicalCount.cs | 21 +- src/Square/Types/InventoryState.cs | 2 + src/Square/Types/InventoryTransfer.cs | 21 +- src/Square/Types/Invoice.cs | 21 +- .../Types/InvoiceAcceptedPaymentMethods.cs | 21 +- src/Square/Types/InvoiceAttachment.cs | 21 +- .../Types/InvoiceAutomaticPaymentSource.cs | 2 + src/Square/Types/InvoiceCanceledEvent.cs | 21 +- src/Square/Types/InvoiceCanceledEventData.cs | 21 +- .../Types/InvoiceCanceledEventObject.cs | 21 +- src/Square/Types/InvoiceCreatedEvent.cs | 21 +- src/Square/Types/InvoiceCreatedEventData.cs | 21 +- src/Square/Types/InvoiceCreatedEventObject.cs | 21 +- src/Square/Types/InvoiceCustomField.cs | 21 +- .../Types/InvoiceCustomFieldPlacement.cs | 2 + src/Square/Types/InvoiceDeletedEvent.cs | 21 +- src/Square/Types/InvoiceDeletedEventData.cs | 21 +- src/Square/Types/InvoiceDeliveryMethod.cs | 2 + src/Square/Types/InvoiceFilter.cs | 21 +- src/Square/Types/InvoicePaymentMadeEvent.cs | 21 +- .../Types/InvoicePaymentMadeEventData.cs | 21 +- .../Types/InvoicePaymentMadeEventObject.cs | 21 +- src/Square/Types/InvoicePaymentReminder.cs | 21 +- .../Types/InvoicePaymentReminderStatus.cs | 2 + src/Square/Types/InvoicePaymentRequest.cs | 21 +- src/Square/Types/InvoicePublishedEvent.cs | 21 +- src/Square/Types/InvoicePublishedEventData.cs | 21 +- .../Types/InvoicePublishedEventObject.cs | 21 +- src/Square/Types/InvoiceQuery.cs | 21 +- src/Square/Types/InvoiceRecipient.cs | 21 +- src/Square/Types/InvoiceRecipientTaxIds.cs | 21 +- src/Square/Types/InvoiceRefundedEvent.cs | 21 +- src/Square/Types/InvoiceRefundedEventData.cs | 21 +- .../Types/InvoiceRefundedEventObject.cs | 21 +- src/Square/Types/InvoiceRequestMethod.cs | 2 + src/Square/Types/InvoiceRequestType.cs | 2 + .../InvoiceScheduledChargeFailedEvent.cs | 21 +- .../InvoiceScheduledChargeFailedEventData.cs | 21 +- ...InvoiceScheduledChargeFailedEventObject.cs | 21 +- src/Square/Types/InvoiceSort.cs | 21 +- src/Square/Types/InvoiceStatus.cs | 2 + src/Square/Types/InvoiceUpdatedEvent.cs | 21 +- src/Square/Types/InvoiceUpdatedEventData.cs | 21 +- src/Square/Types/InvoiceUpdatedEventObject.cs | 21 +- .../Types/ItemVariationLocationOverrides.cs | 21 +- src/Square/Types/Job.cs | 21 +- src/Square/Types/JobAssignment.cs | 21 +- src/Square/Types/JobAssignmentPayType.cs | 2 + src/Square/Types/JobCreatedEvent.cs | 21 +- src/Square/Types/JobCreatedEventData.cs | 21 +- src/Square/Types/JobCreatedEventObject.cs | 21 +- src/Square/Types/JobUpdatedEvent.cs | 21 +- src/Square/Types/JobUpdatedEventData.cs | 21 +- src/Square/Types/JobUpdatedEventObject.cs | 21 +- .../Types/LaborScheduledShiftCreatedEvent.cs | 21 +- .../LaborScheduledShiftCreatedEventData.cs | 21 +- .../LaborScheduledShiftCreatedEventObject.cs | 21 +- .../Types/LaborScheduledShiftDeletedEvent.cs | 21 +- .../LaborScheduledShiftDeletedEventData.cs | 21 +- .../LaborScheduledShiftPublishedEvent.cs | 21 +- .../LaborScheduledShiftPublishedEventData.cs | 21 +- ...LaborScheduledShiftPublishedEventObject.cs | 21 +- .../Types/LaborScheduledShiftUpdatedEvent.cs | 21 +- .../LaborScheduledShiftUpdatedEventData.cs | 21 +- .../LaborScheduledShiftUpdatedEventObject.cs | 21 +- src/Square/Types/LaborShiftCreatedEvent.cs | 21 +- .../Types/LaborShiftCreatedEventData.cs | 21 +- .../Types/LaborShiftCreatedEventObject.cs | 21 +- src/Square/Types/LaborShiftDeletedEvent.cs | 21 +- .../Types/LaborShiftDeletedEventData.cs | 21 +- src/Square/Types/LaborShiftUpdatedEvent.cs | 21 +- .../Types/LaborShiftUpdatedEventData.cs | 21 +- .../Types/LaborShiftUpdatedEventObject.cs | 21 +- src/Square/Types/LaborTimecardCreatedEvent.cs | 21 +- .../Types/LaborTimecardCreatedEventData.cs | 21 +- .../Types/LaborTimecardCreatedEventObject.cs | 21 +- src/Square/Types/LaborTimecardDeletedEvent.cs | 21 +- .../Types/LaborTimecardDeletedEventData.cs | 21 +- src/Square/Types/LaborTimecardUpdatedEvent.cs | 21 +- .../Types/LaborTimecardUpdatedEventData.cs | 21 +- .../Types/LaborTimecardUpdatedEventObject.cs | 21 +- .../Types/LinkCustomerToGiftCardResponse.cs | 21 +- src/Square/Types/ListBankAccountsResponse.cs | 21 +- ...okingCustomAttributeDefinitionsResponse.cs | 21 +- .../ListBookingCustomAttributesResponse.cs | 21 +- src/Square/Types/ListBookingsResponse.cs | 21 +- src/Square/Types/ListBreakTypesResponse.cs | 21 +- src/Square/Types/ListCardsResponse.cs | 21 +- .../ListCashDrawerShiftEventsResponse.cs | 21 +- .../Types/ListCashDrawerShiftsResponse.cs | 21 +- src/Square/Types/ListCatalogResponse.cs | 21 +- src/Square/Types/ListChannelsResponse.cs | 21 +- ...tomerCustomAttributeDefinitionsResponse.cs | 21 +- .../ListCustomerCustomAttributesResponse.cs | 21 +- .../Types/ListCustomerGroupsResponse.cs | 21 +- .../Types/ListCustomerSegmentsResponse.cs | 21 +- src/Square/Types/ListCustomersResponse.cs | 21 +- src/Square/Types/ListDeviceCodesResponse.cs | 21 +- src/Square/Types/ListDevicesResponse.cs | 21 +- .../Types/ListDisputeEvidenceResponse.cs | 21 +- src/Square/Types/ListDisputesResponse.cs | 21 +- src/Square/Types/ListEmployeeWagesResponse.cs | 21 +- src/Square/Types/ListEmployeesResponse.cs | 21 +- src/Square/Types/ListEventTypesResponse.cs | 21 +- .../Types/ListGiftCardActivitiesResponse.cs | 21 +- src/Square/Types/ListGiftCardsResponse.cs | 21 +- src/Square/Types/ListInvoicesResponse.cs | 21 +- src/Square/Types/ListJobsResponse.cs | 21 +- .../ListLocationBookingProfilesResponse.cs | 21 +- ...ationCustomAttributeDefinitionsResponse.cs | 21 +- .../ListLocationCustomAttributesResponse.cs | 21 +- src/Square/Types/ListLocationsResponse.cs | 21 +- .../Types/ListLoyaltyProgramsResponse.cs | 21 +- .../Types/ListLoyaltyPromotionsResponse.cs | 21 +- ...chantCustomAttributeDefinitionsResponse.cs | 21 +- .../ListMerchantCustomAttributesResponse.cs | 21 +- src/Square/Types/ListMerchantsResponse.cs | 21 +- ...OrderCustomAttributeDefinitionsResponse.cs | 21 +- .../ListOrderCustomAttributesResponse.cs | 21 +- src/Square/Types/ListPaymentLinksResponse.cs | 21 +- .../ListPaymentRefundsRequestSortField.cs | 2 + .../Types/ListPaymentRefundsResponse.cs | 21 +- .../Types/ListPaymentsRequestSortField.cs | 2 + src/Square/Types/ListPaymentsResponse.cs | 21 +- src/Square/Types/ListPayoutEntriesResponse.cs | 21 +- src/Square/Types/ListPayoutsResponse.cs | 21 +- src/Square/Types/ListSitesResponse.cs | 21 +- .../Types/ListSubscriptionEventsResponse.cs | 21 +- .../ListTeamMemberBookingProfilesResponse.cs | 21 +- .../Types/ListTeamMemberWagesResponse.cs | 21 +- src/Square/Types/ListTransactionsResponse.cs | 21 +- .../Types/ListWebhookEventTypesResponse.cs | 21 +- .../Types/ListWebhookSubscriptionsResponse.cs | 21 +- .../Types/ListWorkweekConfigsResponse.cs | 21 +- src/Square/Types/Location.cs | 21 +- src/Square/Types/LocationBookingProfile.cs | 21 +- src/Square/Types/LocationCapability.cs | 2 + src/Square/Types/LocationCreatedEvent.cs | 21 +- src/Square/Types/LocationCreatedEventData.cs | 21 +- ...tomAttributeDefinitionOwnedCreatedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedDeletedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedUpdatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleCreatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleDeletedEvent.cs | 21 +- ...mAttributeDefinitionVisibleUpdatedEvent.cs | 21 +- ...ocationCustomAttributeOwnedDeletedEvent.cs | 21 +- ...ocationCustomAttributeOwnedUpdatedEvent.cs | 21 +- ...ationCustomAttributeVisibleDeletedEvent.cs | 21 +- ...ationCustomAttributeVisibleUpdatedEvent.cs | 21 +- .../Types/LocationSettingsUpdatedEvent.cs | 21 +- .../Types/LocationSettingsUpdatedEventData.cs | 21 +- .../LocationSettingsUpdatedEventObject.cs | 21 +- src/Square/Types/LocationStatus.cs | 2 + src/Square/Types/LocationType.cs | 2 + src/Square/Types/LocationUpdatedEvent.cs | 21 +- src/Square/Types/LocationUpdatedEventData.cs | 21 +- src/Square/Types/LoyaltyAccount.cs | 21 +- .../Types/LoyaltyAccountCreatedEvent.cs | 21 +- .../Types/LoyaltyAccountCreatedEventData.cs | 21 +- .../Types/LoyaltyAccountCreatedEventObject.cs | 21 +- .../Types/LoyaltyAccountDeletedEvent.cs | 21 +- .../Types/LoyaltyAccountDeletedEventData.cs | 21 +- .../Types/LoyaltyAccountDeletedEventObject.cs | 21 +- .../LoyaltyAccountExpiringPointDeadline.cs | 21 +- src/Square/Types/LoyaltyAccountMapping.cs | 21 +- .../Types/LoyaltyAccountUpdatedEvent.cs | 21 +- .../Types/LoyaltyAccountUpdatedEventData.cs | 21 +- .../Types/LoyaltyAccountUpdatedEventObject.cs | 21 +- src/Square/Types/LoyaltyEvent.cs | 21 +- .../Types/LoyaltyEventAccumulatePoints.cs | 21 +- .../LoyaltyEventAccumulatePromotionPoints.cs | 21 +- src/Square/Types/LoyaltyEventAdjustPoints.cs | 21 +- src/Square/Types/LoyaltyEventCreateReward.cs | 21 +- src/Square/Types/LoyaltyEventCreatedEvent.cs | 21 +- .../Types/LoyaltyEventCreatedEventData.cs | 21 +- .../Types/LoyaltyEventCreatedEventObject.cs | 21 +- .../Types/LoyaltyEventDateTimeFilter.cs | 21 +- src/Square/Types/LoyaltyEventDeleteReward.cs | 21 +- src/Square/Types/LoyaltyEventExpirePoints.cs | 21 +- src/Square/Types/LoyaltyEventFilter.cs | 21 +- .../Types/LoyaltyEventLocationFilter.cs | 21 +- .../Types/LoyaltyEventLoyaltyAccountFilter.cs | 21 +- src/Square/Types/LoyaltyEventOrderFilter.cs | 21 +- src/Square/Types/LoyaltyEventOther.cs | 21 +- src/Square/Types/LoyaltyEventQuery.cs | 21 +- src/Square/Types/LoyaltyEventRedeemReward.cs | 21 +- src/Square/Types/LoyaltyEventSource.cs | 2 + src/Square/Types/LoyaltyEventType.cs | 2 + src/Square/Types/LoyaltyEventTypeFilter.cs | 21 +- src/Square/Types/LoyaltyProgram.cs | 21 +- src/Square/Types/LoyaltyProgramAccrualRule.cs | 21 +- .../LoyaltyProgramAccrualRuleCategoryData.cs | 21 +- ...altyProgramAccrualRuleItemVariationData.cs | 21 +- .../LoyaltyProgramAccrualRuleSpendData.cs | 21 +- .../Types/LoyaltyProgramAccrualRuleTaxMode.cs | 2 + .../Types/LoyaltyProgramAccrualRuleType.cs | 2 + .../LoyaltyProgramAccrualRuleVisitData.cs | 21 +- .../Types/LoyaltyProgramCreatedEvent.cs | 21 +- .../Types/LoyaltyProgramCreatedEventData.cs | 21 +- .../Types/LoyaltyProgramCreatedEventObject.cs | 21 +- .../Types/LoyaltyProgramExpirationPolicy.cs | 21 +- src/Square/Types/LoyaltyProgramRewardTier.cs | 21 +- src/Square/Types/LoyaltyProgramStatus.cs | 2 + src/Square/Types/LoyaltyProgramTerminology.cs | 21 +- .../Types/LoyaltyProgramUpdatedEvent.cs | 21 +- .../Types/LoyaltyProgramUpdatedEventData.cs | 21 +- .../Types/LoyaltyProgramUpdatedEventObject.cs | 21 +- src/Square/Types/LoyaltyPromotion.cs | 21 +- .../LoyaltyPromotionAvailableTimeData.cs | 21 +- .../Types/LoyaltyPromotionCreatedEvent.cs | 21 +- .../Types/LoyaltyPromotionCreatedEventData.cs | 21 +- .../LoyaltyPromotionCreatedEventObject.cs | 21 +- src/Square/Types/LoyaltyPromotionIncentive.cs | 21 +- ...ltyPromotionIncentivePointsAdditionData.cs | 21 +- ...yPromotionIncentivePointsMultiplierData.cs | 21 +- .../Types/LoyaltyPromotionIncentiveType.cs | 2 + src/Square/Types/LoyaltyPromotionStatus.cs | 2 + .../Types/LoyaltyPromotionTriggerLimit.cs | 21 +- .../LoyaltyPromotionTriggerLimitInterval.cs | 2 + .../Types/LoyaltyPromotionUpdatedEvent.cs | 21 +- .../Types/LoyaltyPromotionUpdatedEventData.cs | 21 +- .../LoyaltyPromotionUpdatedEventObject.cs | 21 +- src/Square/Types/LoyaltyReward.cs | 21 +- src/Square/Types/LoyaltyRewardStatus.cs | 2 + src/Square/Types/MeasurementUnit.cs | 21 +- src/Square/Types/MeasurementUnitArea.cs | 2 + src/Square/Types/MeasurementUnitCustom.cs | 21 +- src/Square/Types/MeasurementUnitLength.cs | 2 + src/Square/Types/MeasurementUnitTime.cs | 2 + src/Square/Types/MeasurementUnitUnitType.cs | 2 + src/Square/Types/MeasurementUnitVolume.cs | 2 + src/Square/Types/MeasurementUnitWeight.cs | 2 + src/Square/Types/Merchant.cs | 21 +- ...tomAttributeDefinitionOwnedCreatedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedDeletedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedUpdatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleCreatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleDeletedEvent.cs | 21 +- ...mAttributeDefinitionVisibleUpdatedEvent.cs | 21 +- ...erchantCustomAttributeOwnedDeletedEvent.cs | 21 +- ...erchantCustomAttributeOwnedUpdatedEvent.cs | 21 +- ...chantCustomAttributeVisibleDeletedEvent.cs | 21 +- ...chantCustomAttributeVisibleUpdatedEvent.cs | 21 +- .../Types/MerchantSettingsUpdatedEvent.cs | 21 +- .../Types/MerchantSettingsUpdatedEventData.cs | 21 +- .../MerchantSettingsUpdatedEventObject.cs | 21 +- src/Square/Types/MerchantStatus.cs | 2 + src/Square/Types/ModifierLocationOverrides.cs | 21 +- src/Square/Types/Money.cs | 21 +- .../Types/OauthAuthorizationRevokedEvent.cs | 21 +- .../OauthAuthorizationRevokedEventData.cs | 21 +- .../OauthAuthorizationRevokedEventObject.cs | 21 +- ...thorizationRevokedEventRevocationObject.cs | 21 +- ...uthAuthorizationRevokedEventRevokerType.cs | 2 + src/Square/Types/ObtainTokenResponse.cs | 21 +- src/Square/Types/OfflinePaymentDetails.cs | 21 +- src/Square/Types/Order.cs | 21 +- src/Square/Types/OrderCreated.cs | 21 +- src/Square/Types/OrderCreatedEvent.cs | 21 +- src/Square/Types/OrderCreatedEventData.cs | 21 +- src/Square/Types/OrderCreatedObject.cs | 21 +- ...tomAttributeDefinitionOwnedCreatedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedDeletedEvent.cs | 21 +- ...tomAttributeDefinitionOwnedUpdatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleCreatedEvent.cs | 21 +- ...mAttributeDefinitionVisibleDeletedEvent.cs | 21 +- ...mAttributeDefinitionVisibleUpdatedEvent.cs | 21 +- .../OrderCustomAttributeOwnedDeletedEvent.cs | 21 +- .../OrderCustomAttributeOwnedUpdatedEvent.cs | 21 +- ...OrderCustomAttributeVisibleDeletedEvent.cs | 21 +- ...OrderCustomAttributeVisibleUpdatedEvent.cs | 21 +- src/Square/Types/OrderEntry.cs | 21 +- ...rFulfillmentDeliveryDetailsScheduleType.cs | 2 + ...lfillmentFulfillmentLineItemApplication.cs | 2 + ...derFulfillmentPickupDetailsScheduleType.cs | 2 + src/Square/Types/OrderFulfillmentState.cs | 2 + src/Square/Types/OrderFulfillmentType.cs | 2 + src/Square/Types/OrderFulfillmentUpdated.cs | 21 +- .../Types/OrderFulfillmentUpdatedEvent.cs | 21 +- .../Types/OrderFulfillmentUpdatedEventData.cs | 21 +- .../Types/OrderFulfillmentUpdatedObject.cs | 21 +- .../Types/OrderFulfillmentUpdatedUpdate.cs | 21 +- src/Square/Types/OrderLineItem.cs | 21 +- .../Types/OrderLineItemAppliedDiscount.cs | 21 +- .../OrderLineItemAppliedServiceCharge.cs | 21 +- src/Square/Types/OrderLineItemAppliedTax.cs | 21 +- src/Square/Types/OrderLineItemDiscount.cs | 21 +- .../Types/OrderLineItemDiscountScope.cs | 2 + src/Square/Types/OrderLineItemDiscountType.cs | 2 + src/Square/Types/OrderLineItemItemType.cs | 2 + src/Square/Types/OrderLineItemModifier.cs | 21 +- .../Types/OrderLineItemPricingBlocklists.cs | 21 +- ...ineItemPricingBlocklistsBlockedDiscount.cs | 21 +- ...rderLineItemPricingBlocklistsBlockedTax.cs | 21 +- src/Square/Types/OrderLineItemTax.cs | 21 +- src/Square/Types/OrderLineItemTaxScope.cs | 2 + src/Square/Types/OrderLineItemTaxType.cs | 2 + src/Square/Types/OrderMoneyAmounts.cs | 21 +- src/Square/Types/OrderPricingOptions.cs | 21 +- src/Square/Types/OrderQuantityUnit.cs | 21 +- src/Square/Types/OrderReturn.cs | 21 +- src/Square/Types/OrderReturnDiscount.cs | 21 +- src/Square/Types/OrderReturnLineItem.cs | 21 +- .../Types/OrderReturnLineItemModifier.cs | 21 +- src/Square/Types/OrderReturnServiceCharge.cs | 21 +- src/Square/Types/OrderReturnTax.cs | 21 +- src/Square/Types/OrderReturnTip.cs | 21 +- src/Square/Types/OrderReward.cs | 21 +- src/Square/Types/OrderRoundingAdjustment.cs | 21 +- src/Square/Types/OrderServiceCharge.cs | 21 +- .../OrderServiceChargeCalculationPhase.cs | 2 + src/Square/Types/OrderServiceChargeScope.cs | 2 + .../Types/OrderServiceChargeTreatmentType.cs | 2 + src/Square/Types/OrderServiceChargeType.cs | 2 + src/Square/Types/OrderSource.cs | 21 +- src/Square/Types/OrderState.cs | 2 + src/Square/Types/OrderUpdated.cs | 21 +- src/Square/Types/OrderUpdatedEvent.cs | 21 +- src/Square/Types/OrderUpdatedEventData.cs | 21 +- src/Square/Types/OrderUpdatedObject.cs | 21 +- src/Square/Types/PauseSubscriptionResponse.cs | 21 +- src/Square/Types/PayOrderResponse.cs | 21 +- src/Square/Types/Payment.cs | 21 +- ...aymentBalanceActivityAppFeeRefundDetail.cs | 21 +- ...ymentBalanceActivityAppFeeRevenueDetail.cs | 21 +- ...ntBalanceActivityAutomaticSavingsDetail.cs | 21 +- ...eActivityAutomaticSavingsReversedDetail.cs | 21 +- .../PaymentBalanceActivityChargeDetail.cs | 21 +- .../PaymentBalanceActivityDepositFeeDetail.cs | 21 +- ...BalanceActivityDepositFeeReversedDetail.cs | 21 +- .../PaymentBalanceActivityDisputeDetail.cs | 21 +- .../Types/PaymentBalanceActivityFeeDetail.cs | 21 +- ...mentBalanceActivityFreeProcessingDetail.cs | 21 +- ...mentBalanceActivityHoldAdjustmentDetail.cs | 21 +- ...PaymentBalanceActivityOpenDisputeDetail.cs | 21 +- ...entBalanceActivityOtherAdjustmentDetail.cs | 21 +- .../PaymentBalanceActivityOtherDetail.cs | 21 +- .../PaymentBalanceActivityRefundDetail.cs | 21 +- ...tBalanceActivityReleaseAdjustmentDetail.cs | 21 +- ...PaymentBalanceActivityReserveHoldDetail.cs | 21 +- ...mentBalanceActivityReserveReleaseDetail.cs | 21 +- ...lanceActivitySquareCapitalPaymentDetail.cs | 21 +- ...ivitySquareCapitalReversedPaymentDetail.cs | 21 +- ...anceActivitySquarePayrollTransferDetail.cs | 21 +- ...vitySquarePayrollTransferReversedDetail.cs | 21 +- .../PaymentBalanceActivityTaxOnFeeDetail.cs | 21 +- ...ymentBalanceActivityThirdPartyFeeDetail.cs | 21 +- ...alanceActivityThirdPartyFeeRefundDetail.cs | 21 +- src/Square/Types/PaymentCreatedEvent.cs | 21 +- src/Square/Types/PaymentCreatedEventData.cs | 21 +- src/Square/Types/PaymentCreatedEventObject.cs | 21 +- src/Square/Types/PaymentLink.cs | 21 +- .../Types/PaymentLinkRelatedResources.cs | 21 +- src/Square/Types/PaymentOptions.cs | 21 +- src/Square/Types/PaymentOptionsDelayAction.cs | 2 + src/Square/Types/PaymentRefund.cs | 21 +- src/Square/Types/PaymentUpdatedEvent.cs | 21 +- src/Square/Types/PaymentUpdatedEventData.cs | 21 +- src/Square/Types/PaymentUpdatedEventObject.cs | 21 +- src/Square/Types/Payout.cs | 21 +- src/Square/Types/PayoutEntry.cs | 21 +- src/Square/Types/PayoutFailedEvent.cs | 21 +- src/Square/Types/PayoutFailedEventData.cs | 21 +- src/Square/Types/PayoutFailedEventObject.cs | 21 +- src/Square/Types/PayoutFee.cs | 21 +- src/Square/Types/PayoutFeeType.cs | 2 + src/Square/Types/PayoutPaidEvent.cs | 21 +- src/Square/Types/PayoutPaidEventData.cs | 21 +- src/Square/Types/PayoutPaidEventObject.cs | 21 +- src/Square/Types/PayoutSentEvent.cs | 21 +- src/Square/Types/PayoutSentEventData.cs | 21 +- src/Square/Types/PayoutSentEventObject.cs | 21 +- src/Square/Types/PayoutStatus.cs | 2 + src/Square/Types/PayoutType.cs | 2 + src/Square/Types/Phase.cs | 21 +- src/Square/Types/PhaseInput.cs | 21 +- src/Square/Types/PrePopulatedData.cs | 21 +- src/Square/Types/ProcessingFee.cs | 21 +- src/Square/Types/Product.cs | 2 + src/Square/Types/PublishInvoiceResponse.cs | 21 +- .../Types/PublishScheduledShiftResponse.cs | 21 +- src/Square/Types/QrCodeOptions.cs | 21 +- src/Square/Types/QuickPay.cs | 21 +- src/Square/Types/Range.cs | 21 +- src/Square/Types/ReceiptOptions.cs | 21 +- .../Types/ReceiveTransferOrderResponse.cs | 21 +- .../Types/RedeemLoyaltyRewardResponse.cs | 21 +- src/Square/Types/Reference.cs | 21 +- src/Square/Types/ReferenceType.cs | 2 + src/Square/Types/Refund.cs | 21 +- src/Square/Types/RefundCreatedEvent.cs | 21 +- src/Square/Types/RefundCreatedEventData.cs | 21 +- src/Square/Types/RefundCreatedEventObject.cs | 21 +- src/Square/Types/RefundPaymentResponse.cs | 21 +- src/Square/Types/RefundStatus.cs | 2 + src/Square/Types/RefundUpdatedEvent.cs | 21 +- src/Square/Types/RefundUpdatedEventData.cs | 21 +- src/Square/Types/RefundUpdatedEventObject.cs | 21 +- src/Square/Types/RegisterDomainResponse.cs | 21 +- .../Types/RegisterDomainResponseStatus.cs | 2 + .../Types/RemoveGroupFromCustomerResponse.cs | 21 +- .../Types/ResumeSubscriptionResponse.cs | 21 +- ...ookingCustomAttributeDefinitionResponse.cs | 21 +- .../RetrieveBookingCustomAttributeResponse.cs | 21 +- src/Square/Types/RetrieveChannelResponse.cs | 21 +- src/Square/Types/RetrieveJobResponse.cs | 21 +- .../RetrieveLocationBookingProfileResponse.cs | 21 +- ...cationCustomAttributeDefinitionResponse.cs | 21 +- ...RetrieveLocationCustomAttributeResponse.cs | 21 +- .../Types/RetrieveLocationSettingsResponse.cs | 21 +- ...rchantCustomAttributeDefinitionResponse.cs | 21 +- ...RetrieveMerchantCustomAttributeResponse.cs | 21 +- .../Types/RetrieveMerchantSettingsResponse.cs | 21 +- ...eOrderCustomAttributeDefinitionResponse.cs | 21 +- .../RetrieveOrderCustomAttributeResponse.cs | 21 +- .../Types/RetrieveScheduledShiftResponse.cs | 21 +- src/Square/Types/RetrieveTimecardResponse.cs | 21 +- .../Types/RetrieveTokenStatusResponse.cs | 21 +- .../Types/RetrieveTransferOrderResponse.cs | 21 +- src/Square/Types/RevokeTokenResponse.cs | 21 +- src/Square/Types/RiskEvaluation.cs | 21 +- src/Square/Types/RiskEvaluationRiskLevel.cs | 2 + src/Square/Types/SaveCardOptions.cs | 21 +- src/Square/Types/ScheduledShift.cs | 21 +- src/Square/Types/ScheduledShiftDetails.cs | 21 +- src/Square/Types/ScheduledShiftFilter.cs | 21 +- .../ScheduledShiftFilterAssignmentStatus.cs | 2 + ...cheduledShiftFilterScheduledShiftStatus.cs | 2 + .../ScheduledShiftNotificationAudience.cs | 2 + src/Square/Types/ScheduledShiftQuery.cs | 21 +- src/Square/Types/ScheduledShiftSort.cs | 21 +- src/Square/Types/ScheduledShiftSortField.cs | 2 + src/Square/Types/ScheduledShiftWorkday.cs | 21 +- .../Types/ScheduledShiftWorkdayMatcher.cs | 2 + src/Square/Types/SearchAvailabilityFilter.cs | 21 +- src/Square/Types/SearchAvailabilityQuery.cs | 21 +- .../Types/SearchAvailabilityResponse.cs | 21 +- .../SearchCatalogItemsRequestStockLevel.cs | 2 + .../Types/SearchCatalogItemsResponse.cs | 21 +- .../Types/SearchCatalogObjectsResponse.cs | 21 +- src/Square/Types/SearchCustomersResponse.cs | 21 +- src/Square/Types/SearchEventsFilter.cs | 21 +- src/Square/Types/SearchEventsQuery.cs | 21 +- src/Square/Types/SearchEventsResponse.cs | 21 +- src/Square/Types/SearchEventsSort.cs | 21 +- src/Square/Types/SearchInvoicesResponse.cs | 21 +- ...yaltyAccountsRequestLoyaltyAccountQuery.cs | 21 +- .../Types/SearchLoyaltyAccountsResponse.cs | 21 +- .../Types/SearchLoyaltyEventsResponse.cs | 21 +- ...LoyaltyRewardsRequestLoyaltyRewardQuery.cs | 21 +- .../Types/SearchLoyaltyRewardsResponse.cs | 21 +- .../Types/SearchOrdersCustomerFilter.cs | 21 +- .../Types/SearchOrdersDateTimeFilter.cs | 21 +- src/Square/Types/SearchOrdersFilter.cs | 21 +- .../Types/SearchOrdersFulfillmentFilter.cs | 21 +- src/Square/Types/SearchOrdersQuery.cs | 21 +- src/Square/Types/SearchOrdersResponse.cs | 21 +- src/Square/Types/SearchOrdersSort.cs | 21 +- src/Square/Types/SearchOrdersSortField.cs | 2 + src/Square/Types/SearchOrdersSourceFilter.cs | 21 +- src/Square/Types/SearchOrdersStateFilter.cs | 21 +- .../Types/SearchScheduledShiftsResponse.cs | 21 +- src/Square/Types/SearchShiftsResponse.cs | 21 +- src/Square/Types/SearchSubscriptionsFilter.cs | 21 +- src/Square/Types/SearchSubscriptionsQuery.cs | 21 +- .../Types/SearchSubscriptionsResponse.cs | 21 +- src/Square/Types/SearchTeamMembersFilter.cs | 21 +- src/Square/Types/SearchTeamMembersQuery.cs | 21 +- src/Square/Types/SearchTeamMembersResponse.cs | 21 +- .../Types/SearchTerminalActionsResponse.cs | 21 +- .../Types/SearchTerminalCheckoutsResponse.cs | 21 +- .../Types/SearchTerminalRefundsResponse.cs | 21 +- src/Square/Types/SearchTimecardsResponse.cs | 21 +- .../Types/SearchTransferOrdersResponse.cs | 21 +- .../Types/SearchVendorsRequestFilter.cs | 21 +- src/Square/Types/SearchVendorsRequestSort.cs | 21 +- .../Types/SearchVendorsRequestSortField.cs | 2 + src/Square/Types/SearchVendorsResponse.cs | 21 +- src/Square/Types/SegmentFilter.cs | 21 +- src/Square/Types/SelectOption.cs | 21 +- src/Square/Types/SelectOptions.cs | 21 +- src/Square/Types/Shift.cs | 21 +- src/Square/Types/ShiftFilter.cs | 21 +- src/Square/Types/ShiftFilterStatus.cs | 2 + src/Square/Types/ShiftQuery.cs | 21 +- src/Square/Types/ShiftSort.cs | 21 +- src/Square/Types/ShiftSortField.cs | 2 + src/Square/Types/ShiftStatus.cs | 2 + src/Square/Types/ShiftWage.cs | 21 +- src/Square/Types/ShiftWorkday.cs | 21 +- src/Square/Types/ShiftWorkdayMatcher.cs | 2 + src/Square/Types/ShippingFee.cs | 21 +- src/Square/Types/SignatureImage.cs | 21 +- src/Square/Types/SignatureOptions.cs | 21 +- src/Square/Types/Site.cs | 21 +- src/Square/Types/Snippet.cs | 21 +- src/Square/Types/SortOrder.cs | 2 + src/Square/Types/SourceApplication.cs | 21 +- src/Square/Types/SquareAccountDetails.cs | 21 +- src/Square/Types/StandardUnitDescription.cs | 21 +- .../Types/StandardUnitDescriptionGroup.cs | 21 +- .../Types/StartTransferOrderResponse.cs | 21 +- src/Square/Types/SubmitEvidenceResponse.cs | 21 +- src/Square/Types/Subscription.cs | 21 +- src/Square/Types/SubscriptionAction.cs | 21 +- src/Square/Types/SubscriptionActionType.cs | 2 + src/Square/Types/SubscriptionCadence.cs | 2 + src/Square/Types/SubscriptionCreatedEvent.cs | 21 +- .../Types/SubscriptionCreatedEventData.cs | 21 +- .../Types/SubscriptionCreatedEventObject.cs | 21 +- src/Square/Types/SubscriptionEvent.cs | 21 +- src/Square/Types/SubscriptionEventInfo.cs | 21 +- src/Square/Types/SubscriptionEventInfoCode.cs | 2 + .../SubscriptionEventSubscriptionEventType.cs | 2 + src/Square/Types/SubscriptionPhase.cs | 21 +- src/Square/Types/SubscriptionPricing.cs | 21 +- src/Square/Types/SubscriptionPricingType.cs | 2 + src/Square/Types/SubscriptionSource.cs | 21 +- src/Square/Types/SubscriptionStatus.cs | 2 + src/Square/Types/SubscriptionTestResult.cs | 21 +- src/Square/Types/SubscriptionUpdatedEvent.cs | 21 +- .../Types/SubscriptionUpdatedEventData.cs | 21 +- .../Types/SubscriptionUpdatedEventObject.cs | 21 +- src/Square/Types/SwapPlanResponse.cs | 21 +- src/Square/Types/TaxCalculationPhase.cs | 2 + src/Square/Types/TaxIds.cs | 21 +- src/Square/Types/TaxInclusionType.cs | 2 + src/Square/Types/TeamMember.cs | 21 +- .../Types/TeamMemberAssignedLocations.cs | 21 +- ...amMemberAssignedLocationsAssignmentType.cs | 2 + src/Square/Types/TeamMemberBookingProfile.cs | 21 +- src/Square/Types/TeamMemberCreatedEvent.cs | 21 +- .../Types/TeamMemberCreatedEventData.cs | 21 +- .../Types/TeamMemberCreatedEventObject.cs | 21 +- .../Types/TeamMemberInvitationStatus.cs | 2 + src/Square/Types/TeamMemberStatus.cs | 2 + src/Square/Types/TeamMemberUpdatedEvent.cs | 21 +- .../Types/TeamMemberUpdatedEventData.cs | 21 +- .../Types/TeamMemberUpdatedEventObject.cs | 21 +- src/Square/Types/TeamMemberWage.cs | 21 +- .../TeamMemberWageSettingUpdatedEvent.cs | 21 +- .../TeamMemberWageSettingUpdatedEventData.cs | 21 +- ...TeamMemberWageSettingUpdatedEventObject.cs | 21 +- src/Square/Types/Tender.cs | 21 +- src/Square/Types/TenderBankAccountDetails.cs | 21 +- .../Types/TenderBankAccountDetailsStatus.cs | 2 + .../Types/TenderBuyNowPayLaterDetails.cs | 21 +- .../Types/TenderBuyNowPayLaterDetailsBrand.cs | 2 + .../TenderBuyNowPayLaterDetailsStatus.cs | 2 + src/Square/Types/TenderCardDetails.cs | 21 +- .../Types/TenderCardDetailsEntryMethod.cs | 2 + src/Square/Types/TenderCardDetailsStatus.cs | 2 + src/Square/Types/TenderCashDetails.cs | 21 +- .../Types/TenderSquareAccountDetails.cs | 21 +- .../Types/TenderSquareAccountDetailsStatus.cs | 2 + src/Square/Types/TenderType.cs | 2 + src/Square/Types/TerminalAction.cs | 21 +- src/Square/Types/TerminalActionActionType.cs | 2 + .../Types/TerminalActionCreatedEvent.cs | 21 +- .../Types/TerminalActionCreatedEventData.cs | 21 +- .../Types/TerminalActionCreatedEventObject.cs | 21 +- src/Square/Types/TerminalActionQuery.cs | 21 +- src/Square/Types/TerminalActionQueryFilter.cs | 21 +- src/Square/Types/TerminalActionQuerySort.cs | 21 +- .../Types/TerminalActionUpdatedEvent.cs | 21 +- .../Types/TerminalActionUpdatedEventData.cs | 21 +- .../Types/TerminalActionUpdatedEventObject.cs | 21 +- src/Square/Types/TerminalCheckout.cs | 21 +- .../Types/TerminalCheckoutCreatedEvent.cs | 21 +- .../Types/TerminalCheckoutCreatedEventData.cs | 21 +- .../TerminalCheckoutCreatedEventObject.cs | 21 +- src/Square/Types/TerminalCheckoutQuery.cs | 21 +- .../Types/TerminalCheckoutQueryFilter.cs | 21 +- src/Square/Types/TerminalCheckoutQuerySort.cs | 21 +- .../Types/TerminalCheckoutUpdatedEvent.cs | 21 +- .../Types/TerminalCheckoutUpdatedEventData.cs | 21 +- .../TerminalCheckoutUpdatedEventObject.cs | 21 +- src/Square/Types/TerminalRefund.cs | 21 +- .../Types/TerminalRefundCreatedEvent.cs | 21 +- .../Types/TerminalRefundCreatedEventData.cs | 21 +- .../Types/TerminalRefundCreatedEventObject.cs | 21 +- src/Square/Types/TerminalRefundQuery.cs | 21 +- src/Square/Types/TerminalRefundQueryFilter.cs | 21 +- src/Square/Types/TerminalRefundQuerySort.cs | 21 +- .../Types/TerminalRefundUpdatedEvent.cs | 21 +- .../Types/TerminalRefundUpdatedEventData.cs | 21 +- .../Types/TerminalRefundUpdatedEventObject.cs | 21 +- .../Types/TestWebhookSubscriptionResponse.cs | 21 +- src/Square/Types/TimeRange.cs | 21 +- src/Square/Types/Timecard.cs | 21 +- src/Square/Types/TimecardFilter.cs | 21 +- src/Square/Types/TimecardFilterStatus.cs | 2 + src/Square/Types/TimecardQuery.cs | 21 +- src/Square/Types/TimecardSort.cs | 21 +- src/Square/Types/TimecardSortField.cs | 2 + src/Square/Types/TimecardStatus.cs | 2 + src/Square/Types/TimecardWage.cs | 21 +- src/Square/Types/TimecardWorkday.cs | 21 +- src/Square/Types/TimecardWorkdayMatcher.cs | 2 + src/Square/Types/TipSettings.cs | 21 +- src/Square/Types/Transaction.cs | 21 +- src/Square/Types/TransactionProduct.cs | 2 + src/Square/Types/TransactionType.cs | 2 + src/Square/Types/TransferOrder.cs | 21 +- src/Square/Types/TransferOrderCreatedEvent.cs | 21 +- .../Types/TransferOrderCreatedEventData.cs | 21 +- .../Types/TransferOrderCreatedEventObject.cs | 21 +- src/Square/Types/TransferOrderDeletedEvent.cs | 21 +- .../Types/TransferOrderDeletedEventData.cs | 21 +- src/Square/Types/TransferOrderFilter.cs | 21 +- src/Square/Types/TransferOrderGoodsReceipt.cs | 21 +- .../TransferOrderGoodsReceiptLineItem.cs | 21 +- src/Square/Types/TransferOrderLine.cs | 21 +- src/Square/Types/TransferOrderQuery.cs | 21 +- src/Square/Types/TransferOrderSort.cs | 21 +- src/Square/Types/TransferOrderSortField.cs | 2 + src/Square/Types/TransferOrderStatus.cs | 2 + src/Square/Types/TransferOrderUpdatedEvent.cs | 21 +- .../Types/TransferOrderUpdatedEventData.cs | 21 +- .../Types/TransferOrderUpdatedEventObject.cs | 21 +- .../UnlinkCustomerFromGiftCardResponse.cs | 21 +- ...ookingCustomAttributeDefinitionResponse.cs | 21 +- src/Square/Types/UpdateBookingResponse.cs | 21 +- src/Square/Types/UpdateBreakTypeResponse.cs | 21 +- src/Square/Types/UpdateCatalogImageRequest.cs | 21 +- .../Types/UpdateCatalogImageResponse.cs | 21 +- ...stomerCustomAttributeDefinitionResponse.cs | 21 +- .../Types/UpdateCustomerGroupResponse.cs | 21 +- src/Square/Types/UpdateCustomerResponse.cs | 21 +- src/Square/Types/UpdateInvoiceResponse.cs | 21 +- .../Types/UpdateItemModifierListsResponse.cs | 21 +- src/Square/Types/UpdateItemTaxesResponse.cs | 21 +- src/Square/Types/UpdateJobResponse.cs | 21 +- ...cationCustomAttributeDefinitionResponse.cs | 21 +- src/Square/Types/UpdateLocationResponse.cs | 21 +- .../Types/UpdateLocationSettingsResponse.cs | 21 +- ...rchantCustomAttributeDefinitionResponse.cs | 21 +- .../Types/UpdateMerchantSettingsResponse.cs | 21 +- ...eOrderCustomAttributeDefinitionResponse.cs | 21 +- src/Square/Types/UpdateOrderResponse.cs | 21 +- src/Square/Types/UpdatePaymentLinkResponse.cs | 21 +- src/Square/Types/UpdatePaymentResponse.cs | 21 +- .../Types/UpdateScheduledShiftResponse.cs | 21 +- src/Square/Types/UpdateShiftResponse.cs | 21 +- .../Types/UpdateSubscriptionResponse.cs | 21 +- src/Square/Types/UpdateTeamMemberRequest.cs | 21 +- src/Square/Types/UpdateTeamMemberResponse.cs | 21 +- src/Square/Types/UpdateTimecardResponse.cs | 21 +- src/Square/Types/UpdateTransferOrderData.cs | 21 +- .../Types/UpdateTransferOrderLineData.cs | 21 +- .../Types/UpdateTransferOrderResponse.cs | 21 +- src/Square/Types/UpdateVendorRequest.cs | 21 +- src/Square/Types/UpdateVendorResponse.cs | 21 +- src/Square/Types/UpdateWageSettingResponse.cs | 21 +- .../UpdateWebhookSubscriptionResponse.cs | 21 +- ...WebhookSubscriptionSignatureKeyResponse.cs | 21 +- .../Types/UpdateWorkweekConfigResponse.cs | 21 +- .../UpsertBookingCustomAttributeResponse.cs | 21 +- .../Types/UpsertCatalogObjectResponse.cs | 21 +- .../UpsertCustomerCustomAttributeResponse.cs | 21 +- .../UpsertLocationCustomAttributeResponse.cs | 21 +- .../UpsertMerchantCustomAttributeResponse.cs | 21 +- .../UpsertOrderCustomAttributeResponse.cs | 21 +- src/Square/Types/UpsertSnippetResponse.cs | 21 +- src/Square/Types/V1Money.cs | 21 +- src/Square/Types/V1Order.cs | 21 +- src/Square/Types/V1OrderHistoryEntry.cs | 21 +- src/Square/Types/V1OrderHistoryEntryAction.cs | 2 + src/Square/Types/V1OrderState.cs | 2 + src/Square/Types/V1Tender.cs | 21 +- src/Square/Types/V1TenderCardBrand.cs | 2 + src/Square/Types/V1TenderEntryMethod.cs | 2 + src/Square/Types/V1TenderType.cs | 2 + .../Types/V1UpdateOrderRequestAction.cs | 2 + src/Square/Types/Vendor.cs | 21 +- src/Square/Types/VendorContact.cs | 21 +- src/Square/Types/VendorCreatedEvent.cs | 21 +- src/Square/Types/VendorCreatedEventData.cs | 21 +- src/Square/Types/VendorCreatedEventObject.cs | 21 +- src/Square/Types/VendorStatus.cs | 2 + src/Square/Types/VendorUpdatedEvent.cs | 21 +- src/Square/Types/VendorUpdatedEventData.cs | 21 +- src/Square/Types/VendorUpdatedEventObject.cs | 21 +- src/Square/Types/VisibilityFilter.cs | 2 + src/Square/Types/VoidTransactionResponse.cs | 21 +- src/Square/Types/WageSetting.cs | 21 +- src/Square/Types/WebhookSubscription.cs | 21 +- src/Square/Types/Weekday.cs | 2 + src/Square/Types/WorkweekConfig.cs | 21 +- .../Requests/V1ListOrdersRequest.cs | 1 + .../Requests/V1RetrieveOrderRequest.cs | 1 + .../Requests/V1UpdateOrderRequest.cs | 1 + .../V1Transactions/V1TransactionsClient.cs | 1 + .../Requests/BatchCreateVendorsRequest.cs | 1 + .../Requests/BatchGetVendorsRequest.cs | 1 + .../Requests/BatchUpdateVendorsRequest.cs | 1 + .../Vendors/Requests/CreateVendorRequest.cs | 1 + .../Vendors/Requests/GetVendorsRequest.cs | 1 + .../Vendors/Requests/SearchVendorsRequest.cs | 1 + .../Vendors/Requests/UpdateVendorsRequest.cs | 1 + src/Square/Vendors/VendorsClient.cs | 1 + .../Webhooks/EventTypes/EventTypesClient.cs | 3 +- .../Requests/ListEventTypesRequest.cs | 1 + .../CreateWebhookSubscriptionRequest.cs | 1 + .../Requests/DeleteSubscriptionsRequest.cs | 1 + .../Requests/GetSubscriptionsRequest.cs | 1 + .../Requests/ListSubscriptionsRequest.cs | 1 + .../TestWebhookSubscriptionRequest.cs | 1 + .../UpdateWebhookSubscriptionRequest.cs | 1 + ...eWebhookSubscriptionSignatureKeyRequest.cs | 1 + .../Subscriptions/SubscriptionsClient.cs | 3 +- src/Square/Webhooks/WebhooksClient.cs | 5 +- 2120 files changed, 117791 insertions(+), 12198 deletions(-) create mode 100644 .mock/definition/__package__.yml create mode 100644 .mock/definition/api.yml create mode 100644 .mock/definition/applePay.yml create mode 100644 .mock/definition/bankAccounts.yml create mode 100644 .mock/definition/bookings.yml create mode 100644 .mock/definition/bookings/customAttributeDefinitions.yml create mode 100644 .mock/definition/bookings/customAttributes.yml create mode 100644 .mock/definition/bookings/locationProfiles.yml create mode 100644 .mock/definition/bookings/teamMemberProfiles.yml create mode 100644 .mock/definition/cards.yml create mode 100644 .mock/definition/cashDrawers/shifts.yml create mode 100644 .mock/definition/catalog.yml create mode 100644 .mock/definition/catalog/images.yml create mode 100644 .mock/definition/catalog/object.yml create mode 100644 .mock/definition/channels.yml create mode 100644 .mock/definition/checkout.yml create mode 100644 .mock/definition/checkout/paymentLinks.yml create mode 100644 .mock/definition/customers.yml create mode 100644 .mock/definition/customers/cards.yml create mode 100644 .mock/definition/customers/customAttributeDefinitions.yml create mode 100644 .mock/definition/customers/customAttributes.yml create mode 100644 .mock/definition/customers/groups.yml create mode 100644 .mock/definition/customers/segments.yml create mode 100644 .mock/definition/devices.yml create mode 100644 .mock/definition/devices/codes.yml create mode 100644 .mock/definition/disputes.yml create mode 100644 .mock/definition/disputes/evidence.yml create mode 100644 .mock/definition/employees.yml create mode 100644 .mock/definition/events.yml create mode 100644 .mock/definition/giftCards.yml create mode 100644 .mock/definition/giftCards/activities.yml create mode 100644 .mock/definition/inventory.yml create mode 100644 .mock/definition/invoices.yml create mode 100644 .mock/definition/labor.yml create mode 100644 .mock/definition/labor/breakTypes.yml create mode 100644 .mock/definition/labor/employeeWages.yml create mode 100644 .mock/definition/labor/shifts.yml create mode 100644 .mock/definition/labor/teamMemberWages.yml create mode 100644 .mock/definition/labor/workweekConfigs.yml create mode 100644 .mock/definition/locations.yml create mode 100644 .mock/definition/locations/customAttributeDefinitions.yml create mode 100644 .mock/definition/locations/customAttributes.yml create mode 100644 .mock/definition/locations/transactions.yml create mode 100644 .mock/definition/loyalty.yml create mode 100644 .mock/definition/loyalty/accounts.yml create mode 100644 .mock/definition/loyalty/programs.yml create mode 100644 .mock/definition/loyalty/programs/promotions.yml create mode 100644 .mock/definition/loyalty/rewards.yml create mode 100644 .mock/definition/merchants.yml create mode 100644 .mock/definition/merchants/customAttributeDefinitions.yml create mode 100644 .mock/definition/merchants/customAttributes.yml create mode 100644 .mock/definition/mobile.yml create mode 100644 .mock/definition/oAuth.yml create mode 100644 .mock/definition/orders.yml create mode 100644 .mock/definition/orders/customAttributeDefinitions.yml create mode 100644 .mock/definition/orders/customAttributes.yml create mode 100644 .mock/definition/payments.yml create mode 100644 .mock/definition/payouts.yml create mode 100644 .mock/definition/refunds.yml create mode 100644 .mock/definition/sites.yml create mode 100644 .mock/definition/snippets.yml create mode 100644 .mock/definition/subscriptions.yml create mode 100644 .mock/definition/team.yml create mode 100644 .mock/definition/teamMembers.yml create mode 100644 .mock/definition/teamMembers/wageSetting.yml create mode 100644 .mock/definition/terminal.yml create mode 100644 .mock/definition/terminal/actions.yml create mode 100644 .mock/definition/terminal/checkouts.yml create mode 100644 .mock/definition/terminal/refunds.yml create mode 100644 .mock/definition/transferOrders.yml create mode 100644 .mock/definition/v1Transactions.yml create mode 100644 .mock/definition/vendors.yml create mode 100644 .mock/definition/webhooks/eventTypes.yml create mode 100644 .mock/definition/webhooks/subscriptions.yml create mode 100644 .mock/fern.config.json create mode 100644 src/Square.Test/Core/Json/AdditionalPropertiesTests.cs create mode 100644 src/Square.Test/Core/RawClientTests/QueryParameterTests.cs create mode 100644 src/Square.Test/Unit/MockServer/ApplePay/RegisterDomainTest.cs create mode 100644 src/Square.Test/Unit/MockServer/BankAccounts/GetByV1IdTest.cs create mode 100644 src/Square.Test/Unit/MockServer/BankAccounts/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/BankAccounts/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/BaseMockServerTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveBookingsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveTeamMemberBookingProfilesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchDeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchUpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/GetBusinessProfileTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/LocationProfiles/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/RetrieveLocationBookingProfileTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/SearchAvailabilityTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Bookings/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Cards/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Cards/DisableTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Cards/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Cards/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/CashDrawers/Shifts/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListEventsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/BatchDeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/BatchGetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/BatchUpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/InfoTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/Object/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/Object/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/Object/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/SearchItemsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/UpdateItemModifierListsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Catalog/UpdateItemTaxesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Channels/BulkRetrieveTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Channels/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Channels/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/RetrieveLocationSettingsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/RetrieveMerchantSettingsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/UpdateLocationSettingsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Checkout/UpdateMerchantSettingsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/BatchCreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/BulkDeleteCustomersTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/BulkRetrieveCustomersTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/BulkUpdateCustomersTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Cards/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Cards/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/BatchUpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributes/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/CustomAttributes/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/AddTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/RemoveTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Groups/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Segments/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/Segments/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Customers/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Devices/Codes/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Devices/Codes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Devices/Codes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Devices/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Devices/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/AcceptTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/CreateEvidenceTextTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/Evidence/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/Evidence/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/Evidence/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Disputes/SubmitEvidenceTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Employees/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Employees/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Events/DisableEventsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Events/EnableEventsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Events/ListEventTypesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Events/SearchEventsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/Activities/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/Activities/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/GetFromGanTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/GetFromNonceTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/LinkCustomerTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/GiftCards/UnlinkCustomerTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/BatchCreateChangesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/BatchGetChangesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/BatchGetCountsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/ChangesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchChangeTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetChangesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetCountsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetAdjustmentTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetPhysicalCountTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/GetAdjustmentTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/GetPhysicalCountTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Inventory/GetTransferTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/DeleteInvoiceAttachmentTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/PublishTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Invoices/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/BreakTypes/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/BreakTypes/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/BreakTypes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/BreakTypes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/BreakTypes/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/BulkPublishScheduledShiftsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/CreateScheduledShiftTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/CreateTimecardTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/DeleteTimecardTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/EmployeeWages/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/EmployeeWages/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/PublishScheduledShiftTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/RetrieveScheduledShiftTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/RetrieveTimecardTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/SearchScheduledShiftsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/SearchTimecardsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/Shifts/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/Shifts/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/Shifts/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/Shifts/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/Shifts/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/UpdateScheduledShiftTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/UpdateTimecardTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CheckoutsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchDeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchUpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributes/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/CustomAttributes/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/Transactions/CaptureTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/Transactions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/Transactions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/Transactions/VoidTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Locations/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Accounts/AccumulatePointsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Accounts/AdjustTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Accounts/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Accounts/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Accounts/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/CalculateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Rewards/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Rewards/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Rewards/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Rewards/RedeemTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/Rewards/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Loyalty/SearchEventsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchDeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchUpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Merchants/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Mobile/AuthorizationCodeTest.cs create mode 100644 src/Square.Test/Unit/MockServer/OAuth/AuthorizeTest.cs create mode 100644 src/Square.Test/Unit/MockServer/OAuth/ObtainTokenTest.cs create mode 100644 src/Square.Test/Unit/MockServer/OAuth/RetrieveTokenStatusTest.cs create mode 100644 src/Square.Test/Unit/MockServer/OAuth/RevokeTokenTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/BatchGetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CalculateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CloneTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchDeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchUpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributes/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributes/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/CustomAttributes/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/PayTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Orders/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/CancelByIdempotencyKeyTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/CompleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payments/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payouts/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payouts/ListEntriesTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Payouts/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Refunds/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Refunds/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Refunds/RefundPaymentTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Sites/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Snippets/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Snippets/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Snippets/UpsertTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/BulkSwapPlanTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/ChangeBillingAnchorDateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/DeleteActionTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/ListEventsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/PauseTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/ResumeTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/SwapPlanTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Subscriptions/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Team/CreateJobTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Team/ListJobsTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Team/RetrieveJobTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Team/UpdateJobTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/BatchCreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/BatchUpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Actions/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Actions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Actions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Actions/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Checkouts/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Checkouts/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Checkouts/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Checkouts/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/DismissTerminalActionTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/DismissTerminalCheckoutTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/DismissTerminalRefundTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Refunds/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Refunds/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Refunds/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Terminal/Refunds/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/CancelTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/ReceiveTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/StartTest.cs create mode 100644 src/Square.Test/Unit/MockServer/TransferOrders/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/V1Transactions/V1ListOrdersTest.cs create mode 100644 src/Square.Test/Unit/MockServer/V1Transactions/V1RetrieveOrderTest.cs create mode 100644 src/Square.Test/Unit/MockServer/V1Transactions/V1UpdateOrderTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/BatchCreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/BatchGetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/BatchUpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/SearchTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Vendors/UpdateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/EventTypes/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/CreateTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/DeleteTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/GetTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/ListTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/TestTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateSignatureKeyTest.cs create mode 100644 src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateTest.cs create mode 100644 src/Square/Core/Public/AdditionalProperties.cs diff --git a/.editorconfig b/.editorconfig index a450a4ea..1e7a0adb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,15 +5,19 @@ resharper_arrange_object_creation_when_type_evident_highlighting = hint resharper_auto_property_can_be_made_get_only_global_highlighting = hint resharper_check_namespace_highlighting = hint resharper_class_never_instantiated_global_highlighting = hint +resharper_class_never_instantiated_local_highlighting = hint resharper_collection_never_updated_global_highlighting = hint resharper_convert_type_check_pattern_to_null_check_highlighting = hint resharper_inconsistent_naming_highlighting = hint resharper_member_can_be_private_global_highlighting = hint +resharper_member_hides_static_from_outer_class_highlighting = hint resharper_not_accessed_field_local_highlighting = hint +resharper_nullable_warning_suppression_is_used_highlighting = suggestion resharper_partial_type_with_single_part_highlighting = hint resharper_prefer_concrete_value_over_default_highlighting = none resharper_private_field_can_be_converted_to_local_variable_highlighting = hint resharper_property_can_be_made_init_only_global_highlighting = hint +resharper_property_can_be_made_init_only_local_highlighting = hint resharper_redundant_name_qualifier_highlighting = none resharper_redundant_using_directive_highlighting = hint resharper_replace_slice_with_range_indexer_highlighting = none @@ -22,9 +26,6 @@ resharper_unused_auto_property_accessor_local_highlighting = hint resharper_unused_member_global_highlighting = hint resharper_unused_type_global_highlighting = hint resharper_use_string_interpolation_highlighting = hint -resharper_property_can_be_made_init_only_local_highlighting = hint -resharper_member_hides_static_from_outer_class_highlighting = hint -resharper_class_never_instantiated_local_highlighting = hint dotnet_diagnostic.CS1591.severity = suggestion [src/**/Types/*.cs] diff --git a/.mock/definition/__package__.yml b/.mock/definition/__package__.yml new file mode 100644 index 00000000..355db187 --- /dev/null +++ b/.mock/definition/__package__.yml @@ -0,0 +1,35513 @@ +types: + AchDetails: + docs: >- + ACH-specific details about `BANK_ACCOUNT` type payments with the + `transfer_type` of `ACH`. + properties: + routing_number: + type: optional> + docs: The routing number for the bank account. + validation: + maxLength: 50 + account_number_suffix: + type: optional> + docs: The last few digits of the bank account number. + validation: + minLength: 1 + maxLength: 4 + account_type: + type: optional> + docs: >- + The type of the bank account performing the transfer. The account type + can be `CHECKING`, + + `SAVINGS`, or `UNKNOWN`. + validation: + maxLength: 50 + source: + openapi: ../default/openapi/openapi.json + AcceptDisputeResponse: + docs: Defines the fields in an `AcceptDispute` response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + dispute: + type: optional + docs: Details about the accepted dispute. + source: + openapi: ../default/openapi/openapi.json + AcceptedPaymentMethods: + properties: + apple_pay: + type: optional> + docs: Whether Apple Pay is accepted at checkout. + google_pay: + type: optional> + docs: Whether Google Pay is accepted at checkout. + cash_app_pay: + type: optional> + docs: Whether Cash App Pay is accepted at checkout. + afterpay_clearpay: + type: optional> + docs: Whether Afterpay/Clearpay is accepted at checkout. + source: + openapi: ../default/openapi/openapi.json + AccumulateLoyaltyPointsResponse: + docs: >- + Represents an + [AccumulateLoyaltyPoints](api-endpoint:Loyalty-AccumulateLoyaltyPoints) + response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + event: + type: optional + docs: >- + The resulting loyalty event. Starting in Square version 2022-08-17, + this field is no longer returned. + events: + type: optional> + docs: >- + The resulting loyalty events. If the purchase qualifies for points, + the `ACCUMULATE_POINTS` event + + is always included. When using the Orders API, the + `ACCUMULATE_PROMOTION_POINTS` event is included + + if the purchase also qualifies for a loyalty promotion. + source: + openapi: ../default/openapi/openapi.json + ActionCancelReason: + enum: + - BUYER_CANCELED + - SELLER_CANCELED + - TIMED_OUT + source: + openapi: ../default/openapi/openapi.json + ActivityType: + enum: + - ADJUSTMENT + - APP_FEE_REFUND + - APP_FEE_REVENUE + - AUTOMATIC_SAVINGS + - AUTOMATIC_SAVINGS_REVERSED + - CHARGE + - DEPOSIT_FEE + - DEPOSIT_FEE_REVERSED + - DISPUTE + - ESCHEATMENT + - FEE + - FREE_PROCESSING + - HOLD_ADJUSTMENT + - INITIAL_BALANCE_CHANGE + - MONEY_TRANSFER + - MONEY_TRANSFER_REVERSAL + - OPEN_DISPUTE + - OTHER + - OTHER_ADJUSTMENT + - PAID_SERVICE_FEE + - PAID_SERVICE_FEE_REFUND + - REDEMPTION_CODE + - REFUND + - RELEASE_ADJUSTMENT + - RESERVE_HOLD + - RESERVE_RELEASE + - RETURNED_PAYOUT + - SQUARE_CAPITAL_PAYMENT + - SQUARE_CAPITAL_REVERSED_PAYMENT + - SUBSCRIPTION_FEE + - SUBSCRIPTION_FEE_PAID_REFUND + - SUBSCRIPTION_FEE_REFUND + - TAX_ON_FEE + - THIRD_PARTY_FEE + - THIRD_PARTY_FEE_REFUND + - PAYOUT + - AUTOMATIC_BITCOIN_CONVERSIONS + - AUTOMATIC_BITCOIN_CONVERSIONS_REVERSED + - CREDIT_CARD_REPAYMENT + - CREDIT_CARD_REPAYMENT_REVERSED + - LOCAL_OFFERS_CASHBACK + - LOCAL_OFFERS_FEE + - PERCENTAGE_PROCESSING_ENROLLMENT + - PERCENTAGE_PROCESSING_DEACTIVATION + - PERCENTAGE_PROCESSING_REPAYMENT + - PERCENTAGE_PROCESSING_REPAYMENT_REVERSED + - PROCESSING_FEE + - PROCESSING_FEE_REFUND + - UNDO_PROCESSING_FEE_REFUND + - GIFT_CARD_LOAD_FEE + - GIFT_CARD_LOAD_FEE_REFUND + - UNDO_GIFT_CARD_LOAD_FEE_REFUND + - BALANCE_FOLDERS_TRANSFER + - BALANCE_FOLDERS_TRANSFER_REVERSED + - GIFT_CARD_POOL_TRANSFER + - GIFT_CARD_POOL_TRANSFER_REVERSED + - SQUARE_PAYROLL_TRANSFER + - SQUARE_PAYROLL_TRANSFER_REVERSED + source: + openapi: ../default/openapi/openapi.json + AddGroupToCustomerResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [AddGroupToCustomer](api-endpoint:Customers-AddGroupToCustomer) endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + AdditionalRecipient: + docs: >- + Represents an additional recipient (other than the merchant) receiving a + portion of this tender. + properties: + location_id: + type: string + docs: >- + The location ID for a recipient (other than the merchant) receiving a + portion of this tender. + validation: + minLength: 1 + maxLength: 50 + description: + type: optional> + docs: The description of the additional recipient. + validation: + maxLength: 100 + amount_money: + type: Money + docs: The amount of money distributed to the recipient. + receivable_id: + type: optional> + docs: >- + The unique ID for the RETIRED `AdditionalRecipientReceivable` object. + This field should be empty for any `AdditionalRecipient` objects + created after the retirement. + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + Address: + docs: >- + Represents a postal address in a country. + + For more information, see [Working with + Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses). + properties: + address_line_1: + type: optional> + docs: >- + The first line of the address. + + + Fields that start with `address_line` provide the address's most + specific + + details, like street number, street name, and building name. They do + *not* + + provide less specific details like city, state/province, or country + (these + + details are provided in other fields). + address_line_2: + type: optional> + docs: The second line of the address, if any. + address_line_3: + type: optional> + docs: The third line of the address, if any. + locality: + type: optional> + docs: >- + The city or town of the address. For a full list of field meanings by + country, see [Working with + Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses). + sublocality: + type: optional> + docs: A civil region within the address's `locality`, if any. + sublocality_2: + type: optional> + docs: A civil region within the address's `sublocality`, if any. + sublocality_3: + type: optional> + docs: A civil region within the address's `sublocality_2`, if any. + administrative_district_level_1: + type: optional> + docs: >- + A civil entity within the address's country. In the US, this + + is the state. For a full list of field meanings by country, see + [Working with + Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses). + administrative_district_level_2: + type: optional> + docs: |- + A civil entity within the address's `administrative_district_level_1`. + In the US, this is the county. + administrative_district_level_3: + type: optional> + docs: |- + A civil entity within the address's `administrative_district_level_2`, + if any. + postal_code: + type: optional> + docs: >- + The address's postal code. For a full list of field meanings by + country, see [Working with + Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses). + country: + type: optional + docs: >- + The address's country, in the two-letter format of ISO 3166. For + example, `US` or `FR`. + + See [Country](#type-country) for possible values + first_name: + type: optional> + docs: Optional first name when it's representing recipient. + last_name: + type: optional> + docs: Optional last name when it's representing recipient. + source: + openapi: ../default/openapi/openapi.json + AdjustLoyaltyPointsResponse: + docs: >- + Represents an + [AdjustLoyaltyPoints](api-endpoint:Loyalty-AdjustLoyaltyPoints) request. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + event: + type: optional + docs: The resulting event data for the adjustment. + source: + openapi: ../default/openapi/openapi.json + AfterpayDetails: + docs: Additional details about Afterpay payments. + properties: + email_address: + type: optional> + docs: Email address on the buyer's Afterpay account. + validation: + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + ApplicationDetails: + docs: Details about the application that took the payment. + properties: + square_product: + type: optional + docs: >- + The Square product, such as Square Point of Sale (POS), + + Square Invoices, or Square Virtual Terminal. + + See [ExternalSquareProduct](#type-externalsquareproduct) for possible + values + application_id: + type: optional> + docs: >- + The Square ID assigned to the application used to take the payment. + + Application developers can use this information to identify payments + that + + their application processed. + + For example, if a developer uses a custom application to process + payments, + + this field contains the application ID from the Developer Dashboard. + + If a seller uses a [Square App + Marketplace](https://developer.squareup.com/docs/app-marketplace) + + application to process payments, the field contains the corresponding + application ID. + source: + openapi: ../default/openapi/openapi.json + ApplicationDetailsExternalSquareProduct: + enum: + - APPOINTMENTS + - ECOMMERCE_API + - INVOICES + - ONLINE_STORE + - OTHER + - RESTAURANTS + - RETAIL + - SQUARE_POS + - TERMINAL_API + - VIRTUAL_TERMINAL + docs: A list of products to return to external callers. + source: + openapi: ../default/openapi/openapi.json + ApplicationType: literal<"TERMINAL_API"> + AppointmentSegment: + docs: Defines an appointment segment of a booking. + properties: + duration_minutes: + type: optional> + docs: The time span in minutes of an appointment segment. + validation: + max: 1500 + service_variation_id: + type: optional> + docs: >- + The ID of the [CatalogItemVariation](entity:CatalogItemVariation) + object representing the service booked in this segment. + validation: + maxLength: 36 + team_member_id: + type: string + docs: >- + The ID of the [TeamMember](entity:TeamMember) object representing the + team member booked in this segment. + validation: + minLength: 1 + maxLength: 32 + service_variation_version: + type: optional> + docs: >- + The current version of the item variation representing the service + booked in this segment. + intermission_minutes: + type: optional + docs: >- + Time between the end of this segment and the beginning of the + subsequent segment. + access: read-only + any_team_member: + type: optional + docs: >- + Whether the customer accepts any team member, instead of a specific + one, to serve this segment. + access: read-only + resource_ids: + type: optional> + docs: >- + The IDs of the seller-accessible resources used for this appointment + segment. + access: read-only + source: + openapi: ../default/openapi/openapi.json + ArchivedState: + enum: + - ARCHIVED_STATE_NOT_ARCHIVED + - ARCHIVED_STATE_ARCHIVED + - ARCHIVED_STATE_ALL + docs: |- + Defines the values for the `archived_state` query expression + used in [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) + to return the archived, not archived or either type of catalog items. + source: + openapi: ../default/openapi/openapi.json + Availability: + docs: >- + Defines an appointment slot that encapsulates the appointment segments, + location and starting time available for booking. + properties: + start_at: + type: optional> + docs: >- + The RFC 3339 timestamp specifying the beginning time of the slot + available for booking. + location_id: + type: optional + docs: The ID of the location available for booking. + validation: + maxLength: 32 + access: read-only + appointment_segments: + type: optional>> + docs: The list of appointment segments available for booking + source: + openapi: ../default/openapi/openapi.json + BankAccount: + docs: >- + Represents a bank account. For more information about + + linking a bank account to a Square account, see + + [Bank Accounts + API](https://developer.squareup.com/docs/bank-accounts-api). + properties: + id: + type: string + docs: The unique, Square-issued identifier for the bank account. + validation: + minLength: 1 + maxLength: 30 + account_number_suffix: + type: string + docs: The last few digits of the account number. + validation: + minLength: 1 + country: + type: Country + docs: |- + The ISO 3166 Alpha-2 country code where the bank account is based. + See [Country](#type-country) for possible values + currency: + type: Currency + docs: >- + The 3-character ISO 4217 currency code indicating the operating + + currency of the bank account. For example, the currency code for US + dollars + + is `USD`. + + See [Currency](#type-currency) for possible values + account_type: + type: BankAccountType + docs: |- + The financial purpose of the associated bank account. + See [BankAccountType](#type-bankaccounttype) for possible values + holder_name: + type: string + docs: |- + Name of the account holder. This name must match the name + on the targeted bank account record. + validation: + minLength: 1 + primary_bank_identification_number: + type: string + docs: >- + Primary identifier for the bank. For more information, see + + [Bank Accounts + API](https://developer.squareup.com/docs/bank-accounts-api). + validation: + maxLength: 40 + secondary_bank_identification_number: + type: optional> + docs: >- + Secondary identifier for the bank. For more information, see + + [Bank Accounts + API](https://developer.squareup.com/docs/bank-accounts-api). + validation: + maxLength: 40 + debit_mandate_reference_id: + type: optional> + docs: >- + Reference identifier that will be displayed to UK bank account owners + + when collecting direct debit authorization. Only required for UK bank + accounts. + reference_id: + type: optional> + docs: >- + Client-provided identifier for linking the banking account to an + entity + + in a third-party system (for example, a bank account number or a user + identifier). + location_id: + type: optional> + docs: The location to which the bank account belongs. + status: + type: BankAccountStatus + docs: |- + Read-only. The current verification status of this BankAccount object. + See [BankAccountStatus](#type-bankaccountstatus) for possible values + creditable: + type: boolean + docs: >- + Indicates whether it is possible for Square to send money to this bank + account. + debitable: + type: boolean + docs: |- + Indicates whether it is possible for Square to take money from this + bank account. + fingerprint: + type: optional> + docs: >- + A Square-assigned, unique identifier for the bank account based on the + + account information. The account fingerprint can be used to compare + account + + entries and determine if the they represent the same real-world bank + account. + version: + type: optional + docs: The current version of the `BankAccount`. + bank_name: + type: optional> + docs: |- + Read only. Name of actual financial institution. + For example "Bank of America". + validation: + maxLength: 100 + source: + openapi: ../default/openapi/openapi.json + BankAccountCreatedEvent: + docs: |- + Published when you link an external bank account to a Square + account in the Seller Dashboard. Square sets the initial status to + `VERIFICATION_IN_PROGRESS` and publishes the event. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents, `"bank_account.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + BankAccountCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"bank_account"`. + id: + type: optional + docs: ID of the affected bank account. + object: + type: optional + docs: An object containing the created bank account. + source: + openapi: ../default/openapi/openapi.json + BankAccountCreatedEventObject: + properties: + bank_account: + type: optional + docs: The created bank account. + source: + openapi: ../default/openapi/openapi.json + BankAccountDisabledEvent: + docs: |- + Published when Square sets the status of a + [BankAccount](entity:BankAccount) to `DISABLED`. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents, `"bank_account.disabled"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was disabled, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + BankAccountDisabledEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"bank_account"`. + id: + type: optional + docs: ID of the affected bank account. + object: + type: optional + docs: An object containing the disabled bank account. + source: + openapi: ../default/openapi/openapi.json + BankAccountDisabledEventObject: + properties: + bank_account: + type: optional + docs: The disabled bank account. + source: + openapi: ../default/openapi/openapi.json + BankAccountPaymentDetails: + docs: Additional details about BANK_ACCOUNT type payments. + properties: + bank_name: + type: optional> + docs: The name of the bank associated with the bank account. + validation: + maxLength: 100 + transfer_type: + type: optional> + docs: The type of the bank transfer. The type can be `ACH` or `UNKNOWN`. + validation: + maxLength: 50 + account_ownership_type: + type: optional> + docs: |- + The ownership type of the bank account performing the transfer. + The type can be `INDIVIDUAL`, `COMPANY`, or `ACCOUNT_TYPE_UNKNOWN`. + validation: + maxLength: 50 + fingerprint: + type: optional> + docs: |- + Uniquely identifies the bank account for this seller and can be used + to determine if payments are from the same bank account. + validation: + maxLength: 255 + country: + type: optional> + docs: >- + The two-letter ISO code representing the country the bank account is + located in. + validation: + minLength: 2 + maxLength: 2 + statement_description: + type: optional> + docs: The statement description as sent to the bank. + validation: + maxLength: 1000 + ach_details: + type: optional + docs: >- + ACH-specific information about the transfer. The information is only + populated + + if the `transfer_type` is `ACH`. + errors: + type: optional>> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + BankAccountStatus: + enum: + - VERIFICATION_IN_PROGRESS + - VERIFIED + - DISABLED + docs: Indicates the current verification status of a `BankAccount` object. + source: + openapi: ../default/openapi/openapi.json + BankAccountType: + enum: + - CHECKING + - SAVINGS + - INVESTMENT + - OTHER + - BUSINESS_CHECKING + docs: Indicates the financial purpose of the bank account. + source: + openapi: ../default/openapi/openapi.json + BankAccountVerifiedEvent: + docs: |- + Published when Square sets the status of a + [BankAccount](entity:BankAccount) to `VERIFIED`. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents, `"bank_account.verified"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was verified, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + BankAccountVerifiedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"bank_account"`. + id: + type: optional + docs: ID of the affected bank account. + object: + type: optional + docs: An object containing the verified bank account. + source: + openapi: ../default/openapi/openapi.json + BankAccountVerifiedEventObject: + properties: + bank_account: + type: optional + docs: The verified bank account. + source: + openapi: ../default/openapi/openapi.json + BatchChangeInventoryRequest: + properties: + idempotency_key: + type: string + docs: >- + A client-supplied, universally unique identifier (UUID) for the + + request. + + + See + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + in the + + [API Development 101](https://developer.squareup.com/docs/buildbasics) + section for more + + information. + validation: + minLength: 1 + maxLength: 128 + changes: + type: optional>> + docs: >- + The set of physical counts and inventory adjustments to be made. + + Changes are applied based on the client-supplied timestamp and may be + sent + + out of order. + ignore_unchanged_counts: + type: optional> + docs: >- + Indicates whether the current physical count should be ignored if + + the quantity is unchanged since the last physical count. Default: + `true`. + source: + openapi: ../default/openapi/openapi.json + BatchChangeInventoryResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + counts: + type: optional> + docs: The current counts for all objects referenced in the request. + changes: + type: optional> + docs: Changes created for the request. + source: + openapi: ../default/openapi/openapi.json + BatchDeleteCatalogObjectsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + deleted_object_ids: + type: optional> + docs: The IDs of all CatalogObjects deleted by this request. + deleted_at: + type: optional + docs: >- + The database + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + of this deletion in RFC 3339 format, e.g., "2016-09-04T23:59:33.123Z". + source: + openapi: ../default/openapi/openapi.json + BatchGetCatalogObjectsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + objects: + type: optional> + docs: A list of [CatalogObject](entity:CatalogObject)s returned. + related_objects: + type: optional> + docs: >- + A list of [CatalogObject](entity:CatalogObject)s referenced by the + object in the `objects` field. + source: + openapi: ../default/openapi/openapi.json + BatchRetrieveInventoryChangesRequest: + properties: + catalog_object_ids: + type: optional>> + docs: |- + The filter to return results by `CatalogObject` ID. + The filter is only applicable when set. The default value is null. + location_ids: + type: optional>> + docs: |- + The filter to return results by `Location` ID. + The filter is only applicable when set. The default value is null. + types: + type: optional>> + docs: >- + The filter to return results by `InventoryChangeType` values other + than `TRANSFER`. + + The default value is `[PHYSICAL_COUNT, ADJUSTMENT]`. + states: + type: optional>> + docs: |- + The filter to return `ADJUSTMENT` query results by + `InventoryState`. This filter is only applied when set. + The default value is null. + updated_after: + type: optional> + docs: |- + The filter to return results with their `calculated_at` value + after the given time as specified in an RFC 3339 timestamp. + The default value is the UNIX epoch of (`1970-01-01T00:00:00Z`). + updated_before: + type: optional> + docs: >- + The filter to return results with their `created_at` or + `calculated_at` value + + strictly before the given time as specified in an RFC 3339 timestamp. + + The default value is the UNIX epoch of (`1970-01-01T00:00:00Z`). + cursor: + type: optional> + docs: >- + 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 the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + limit: + type: optional> + docs: The number of [records](entity:InventoryChange) to return. + validation: + min: 1 + max: 1000 + source: + openapi: ../default/openapi/openapi.json + BatchGetInventoryChangesResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + changes: + type: optional> + docs: |- + The current calculated inventory changes for the requested objects + and locations. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + + this is the final response. + + See the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + source: + openapi: ../default/openapi/openapi.json + BatchGetInventoryCountsRequest: + properties: + catalog_object_ids: + type: optional>> + docs: |- + The filter to return results by `CatalogObject` ID. + The filter is applicable only when set. The default is null. + location_ids: + type: optional>> + docs: |- + The filter to return results by `Location` ID. + This filter is applicable only when set. The default is null. + updated_after: + type: optional> + docs: |- + The filter to return results with their `calculated_at` value + after the given time as specified in an RFC 3339 timestamp. + The default value is the UNIX epoch of (`1970-01-01T00:00:00Z`). + cursor: + type: optional> + docs: >- + 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 the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + states: + type: optional>> + docs: >- + The filter to return results by `InventoryState`. The filter is only + applicable when set. + + Ignored are untracked states of `NONE`, `SOLD`, and `UNLINKED_RETURN`. + + The default is null. + limit: + type: optional> + docs: The number of [records](entity:InventoryCount) to return. + validation: + min: 1 + max: 1000 + source: + openapi: ../default/openapi/openapi.json + BatchGetInventoryCountsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + counts: + type: optional> + docs: |- + The current calculated inventory counts for the requested objects + and locations. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + + this is the final response. + + + See the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + source: + openapi: ../default/openapi/openapi.json + BatchGetOrdersResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `BatchRetrieveOrders` endpoint. + properties: + orders: + type: optional> + docs: >- + The requested orders. This will omit any requested orders that do not + exist. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BatchUpsertCatalogObjectsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + objects: + type: optional> + docs: The created successfully created CatalogObjects. + updated_at: + type: optional + docs: >- + The database + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + of this update in RFC 3339 format, e.g., "2016-09-04T23:59:33.123Z". + id_mappings: + type: optional> + docs: The mapping between client and server IDs for this upsert. + source: + openapi: ../default/openapi/openapi.json + Booking: + docs: >- + Represents a booking as a time-bound service contract for a seller's staff + member to provide a specified service + + at a given location to a requesting customer in one or more appointment + segments. + properties: + id: + type: optional + docs: A unique ID of this object representing a booking. + validation: + maxLength: 36 + access: read-only + version: + type: optional + docs: The revision number for the booking used for optimistic concurrency. + status: + type: optional + docs: >- + The status of the booking, describing where the booking stands with + respect to the booking state machine. + + See [BookingStatus](#type-bookingstatus) for possible values + created_at: + type: optional + docs: The RFC 3339 timestamp specifying the creation time of this booking. + access: read-only + updated_at: + type: optional + docs: >- + The RFC 3339 timestamp specifying the most recent update time of this + booking. + access: read-only + start_at: + type: optional> + docs: The RFC 3339 timestamp specifying the starting time of this booking. + location_id: + type: optional> + docs: >- + The ID of the [Location](entity:Location) object representing the + location where the booked service is provided. Once set when the + booking is created, its value cannot be changed. + validation: + maxLength: 32 + customer_id: + type: optional> + docs: >- + The ID of the [Customer](entity:Customer) object representing the + customer receiving the booked service. + validation: + maxLength: 192 + customer_note: + type: optional> + docs: >- + The free-text field for the customer to supply notes about the + booking. For example, the note can be preferences that cannot be + expressed by supported attributes of a relevant + [CatalogObject](entity:CatalogObject) instance. + validation: + maxLength: 4096 + seller_note: + type: optional> + docs: >- + The free-text field for the seller to supply notes about the booking. + For example, the note can be preferences that cannot be expressed by + supported attributes of a specific + [CatalogObject](entity:CatalogObject) instance. + + This field should not be visible to customers. + validation: + maxLength: 4096 + appointment_segments: + type: optional>> + docs: A list of appointment segments for this booking. + transition_time_minutes: + type: optional + docs: >- + Additional time at the end of a booking. + + Applications should not make this field visible to customers of a + seller. + access: read-only + all_day: + type: optional + docs: Whether the booking is of a full business day. + access: read-only + location_type: + type: optional + docs: >- + The type of location where the booking is held. + + See + [BusinessAppointmentSettingsBookingLocationType](#type-businessappointmentsettingsbookinglocationtype) + for possible values + creator_details: + type: optional + docs: Information about the booking creator. + source: + type: optional + docs: >- + The source of the booking. + + Access to this field requires seller-level permissions. + + See [BookingBookingSource](#type-bookingbookingsource) for possible + values + address: + type: optional
+ docs: Stores a customer address if the location type is `CUSTOMER_LOCATION`. + source: + openapi: ../default/openapi/openapi.json + BookingBookingSource: + enum: + - FIRST_PARTY_MERCHANT + - FIRST_PARTY_BUYER + - THIRD_PARTY_BUYER + - API + docs: Supported sources a booking was created from. + source: + openapi: ../default/openapi/openapi.json + BookingCreatedEvent: + docs: >- + Published when a booking is created. + + + To receive this event with buyer-level permissions, you must have + `APPOINTMENTS_READ` set for the OAuth scope. + + To receive this event with seller-level permissions, you must have + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` set for the OAuth scope. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"booking.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + BookingCreatedEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"booking"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the created booking. + source: + openapi: ../default/openapi/openapi.json + BookingCreatedEventObject: + properties: + booking: + type: optional + docs: The created booking. + source: + openapi: ../default/openapi/openapi.json + BookingCreatorDetails: + docs: Information about a booking creator. + properties: + creator_type: + type: optional + docs: >- + The seller-accessible type of the creator of the booking. + + See + [BookingCreatorDetailsCreatorType](#type-bookingcreatordetailscreatortype) + for possible values + team_member_id: + type: optional + docs: >- + The ID of the team member who created the booking, when the booking + creator is of the `TEAM_MEMBER` type. + + Access to this field requires seller-level permissions. + validation: + maxLength: 32 + access: read-only + customer_id: + type: optional + docs: >- + The ID of the customer who created the booking, when the booking + creator is of the `CUSTOMER` type. + + Access to this field requires seller-level permissions. + validation: + maxLength: 192 + access: read-only + source: + openapi: ../default/openapi/openapi.json + BookingCreatorDetailsCreatorType: + enum: + - TEAM_MEMBER + - CUSTOMER + docs: Supported types of a booking creator. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDefinitionOwnedCreatedEvent: + docs: >- + Published when a booking [custom attribute + definition](entity:CustomAttributeDefinition) + + is created by the subscribing application. Subscribe to this event to be + notified + + when your application creates a booking custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute_definition.owned.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDefinitionOwnedDeletedEvent: + docs: >- + Published when a booking [custom attribute + definition](entity:CustomAttributeDefinition) + + is deleted by the subscribing application. Subscribe to this event to be + notified + + when your application deletes a booking custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute_definition.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDefinitionOwnedUpdatedEvent: + docs: >- + Published when a booking [custom attribute + definition](entity:CustomAttributeDefinition) + + is updated by the subscribing application. Subscribe to this event to be + notified + + when your application updates a booking custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute_definition.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDefinitionVisibleCreatedEvent: + docs: >- + Published when a booking [custom attribute + definition](entity:CustomAttributeDefinition) + + with the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is created. + + An application that subscribes to this event is notified when a booking + custom attribute definition is created + + by any application for which the subscribing application has read access + to the booking custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute_definition.visible.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDefinitionVisibleDeletedEvent: + docs: >- + Published when a booking [custom attribute + definition](entity:CustomAttributeDefinition) + + with the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is deleted. + + An application that subscribes to this event is notified when a booking + custom attribute definition is deleted + + by any application for which the subscribing application has read access + to the booking custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute_definition.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDefinitionVisibleUpdatedEvent: + docs: >- + Published when a booking [custom attribute + definition](entity:CustomAttributeDefinition) + + with the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is updated. + + An application that subscribes to this event is notified when a booking + custom attribute definition is updated + + by any application for which the subscribing application has read access + to the booking custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute_definition.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDeleteRequest: + docs: >- + Represents an individual delete request in a + [BulkDeleteBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkDeleteBookingCustomAttributes) + + request. An individual request contains a booking ID, the custom attribute + to delete, and an optional idempotency key. + properties: + booking_id: + type: string + docs: The ID of the target [booking](entity:Booking). + validation: + minLength: 1 + maxLength: 36 + key: + type: string + docs: >- + The key of the custom attribute to delete. This key must match the + `key` of a + + custom attribute definition in the Square seller account. If the + requesting application is not + + the definition owner, you must use the qualified key. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeDeleteResponse: + docs: >- + Represents a response for an individual upsert request in a + [BulkDeleteBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkDeleteBookingCustomAttributes) + operation. + properties: + booking_id: + type: optional + docs: >- + The ID of the [booking](entity:Booking) associated with the custom + attribute. + errors: + type: optional> + docs: Any errors that occurred while processing the individual request. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeOwnedDeletedEvent: + docs: >- + Published when a booking [custom attribute](entity:CustomAttribute) + + associated with a [custom attribute + definition](entity:CustomAttributeDefinition) that is + + owned by the subscribing application is deleted. + + Subscribe to this event to be notified + + when your application deletes a booking custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeOwnedUpdatedEvent: + docs: >- + Published when a booking [custom attribute](entity:CustomAttribute) + + is updated by the subscribing application. Subscribe to this event to be + notified + + when your application updates a booking custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeUpsertRequest: + docs: >- + Represents an individual upsert request in a + [BulkUpsertBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkUpsertBookingCustomAttributes) + + request. An individual request contains a booking ID, the custom attribute + to create or update, + + and an optional idempotency key. + properties: + booking_id: + type: string + docs: The ID of the target [booking](entity:Booking). + validation: + minLength: 1 + maxLength: 36 + custom_attribute: + type: CustomAttribute + docs: >- + The custom attribute to create or update, with following fields: + + + - `key`. This key must match the `key` of a custom attribute + definition in the Square seller + + account. If the requesting application is not the definition owner, + you must provide the qualified key. + + + - `value`. This value must conform to the `schema` specified by the + definition. + + For more information, see [Value data + types](https://developer.squareup.com/docs/booking-custom-attributes-api/custom-attributes#value-data-types). + + + - `version`. To enable [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control for update operations, include this optional field in the + request and set the + + value to the current version of the custom attribute. + idempotency_key: + type: optional> + docs: >- + A unique identifier for this individual upsert request, used to ensure + idempotency. + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 45 + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeUpsertResponse: + docs: >- + Represents a response for an individual upsert request in a + [BulkUpsertBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkUpsertBookingCustomAttributes) + operation. + properties: + booking_id: + type: optional + docs: >- + The ID of the [booking](entity:Booking) associated with the custom + attribute. + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred while processing the individual request. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeVisibleDeletedEvent: + docs: >- + Published when a booking [custom attribute](entity:CustomAttribute) with + + the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is deleted. + + An application that subscribes to this event is notified when a booking + custom attribute is deleted + + by any application for which the subscribing application has read access + to the booking custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingCustomAttributeVisibleUpdatedEvent: + docs: >- + Published when a booking [custom attribute](entity:CustomAttribute) + + with the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is updated. + + An application that subscribes to this event is notified when a booking + custom attribute is updated + + by any application for which the subscribing application has read access + to the booking custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"booking.custom_attribute.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + BookingStatus: + enum: + - PENDING + - CANCELLED_BY_CUSTOMER + - CANCELLED_BY_SELLER + - DECLINED + - ACCEPTED + - NO_SHOW + docs: Supported booking statuses. + source: + openapi: ../default/openapi/openapi.json + BookingUpdatedEvent: + docs: >- + Published when a booking is updated or cancelled. + + + To receive this event with buyer-level permissions, you must have + `APPOINTMENTS_READ` set for the OAuth scope. + + To receive this event with seller-level permissions, you must have + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` set for the OAuth scope. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"booking.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + BookingUpdatedEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"booking"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the updated booking. + source: + openapi: ../default/openapi/openapi.json + BookingUpdatedEventObject: + properties: + booking: + type: optional + docs: The updated booking. + source: + openapi: ../default/openapi/openapi.json + Break: + docs: A record of a team member's break on a [timecard](entity:Timecard). + properties: + id: + type: optional + docs: The UUID for this object. + start_at: + type: string + docs: >- + RFC 3339; follows the same timezone information as the + [timecard](entity:Timecard). Precision up to + + the minute is respected; seconds are truncated. + validation: + minLength: 1 + end_at: + type: optional> + docs: >- + RFC 3339; follows the same timezone information as the + [timecard](entity:Timecard). Precision up to + + the minute is respected; seconds are truncated. + break_type_id: + type: string + docs: The [BreakType](entity:BreakType) that this break was templated on. + validation: + minLength: 1 + name: + type: string + docs: A human-readable name. + validation: + minLength: 1 + expected_duration: + type: string + docs: |- + Format: RFC-3339 P[n]Y[n]M[n]DT[n]H[n]M[n]S. The expected length of + the break. + + Example for break expected duration of 15 minutes: PT15M + validation: + minLength: 1 + is_paid: + type: boolean + docs: |- + Whether this break counts towards time worked for compensation + purposes. + source: + openapi: ../default/openapi/openapi.json + BreakType: + docs: >- + A template for a type of [break](entity:Break) that can be added to a + + [timecard](entity:Timecard), including the expected duration and paid + status. + properties: + id: + type: optional + docs: The UUID for this object. + validation: + maxLength: 255 + location_id: + type: string + docs: The ID of the business location this type of break applies to. + validation: + minLength: 1 + break_name: + type: string + docs: |- + A human-readable name for this type of break. The name is displayed to + team members in Square products. + validation: + minLength: 1 + expected_duration: + type: string + docs: |- + Format: RFC-3339 P[n]Y[n]M[n]DT[n]H[n]M[n]S. The expected length of + this break. Precision less than minutes is truncated. + + Example for break expected duration of 15 minutes: PT15M + validation: + minLength: 1 + is_paid: + type: boolean + docs: |- + Whether this break counts towards time worked for compensation + purposes. + version: + type: optional + docs: >- + Used for resolving concurrency issues. The request fails if the + version + + provided does not match the server version at the time of the request. + If a value is not + + provided, Square's servers execute a "blind" write; potentially + + overwriting another writer's data. + created_at: + type: optional + docs: A read-only timestamp in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: A read-only timestamp in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + BulkCreateCustomerData: + docs: >- + Defines the customer data provided in individual create requests for a + + [BulkCreateCustomers](api-endpoint:Customers-BulkCreateCustomers) + operation. + properties: + given_name: + type: optional> + docs: >- + The given name (that is, the first name) associated with the customer + profile. + validation: + maxLength: 300 + family_name: + type: optional> + docs: >- + The family name (that is, the last name) associated with the customer + profile. + validation: + maxLength: 300 + company_name: + type: optional> + docs: A business name associated with the customer profile. + validation: + maxLength: 500 + nickname: + type: optional> + docs: A nickname for the customer profile. + validation: + maxLength: 100 + email_address: + type: optional> + docs: The email address associated with the customer profile. + validation: + maxLength: 254 + address: + type: optional
+ docs: >- + The physical address associated with the customer profile. For maximum + length constraints, + + see [Customer + addresses](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#address). + + The `first_name` and `last_name` fields are ignored if they are + present in the request. + phone_number: + type: optional> + docs: >- + The phone number associated with the customer profile. The phone + number must be valid + + and can contain 9–16 digits, with an optional `+` prefix and country + code. For more information, + + see [Customer phone + numbers](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#phone-number). + reference_id: + type: optional> + docs: |- + An optional second ID used to associate the customer profile with an + entity in another system. + validation: + maxLength: 100 + note: + type: optional> + docs: A custom note associated with the customer profile. + birthday: + type: optional> + docs: >- + The birthday associated with the customer profile, in `YYYY-MM-DD` or + `MM-DD` format. + + For example, specify `1998-09-21` for September 21, 1998, or `09-21` + for September 21. + + Birthdays are returned in `YYYY-MM-DD` format, where `YYYY` is the + specified birth year or + + `0000` if a birth year is not specified. + tax_ids: + type: optional + docs: >- + The tax ID associated with the customer profile. This field is + available 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). + source: + openapi: ../default/openapi/openapi.json + BulkCreateCustomersResponse: + docs: >- + Defines the fields included in the response body from the + + [BulkCreateCustomers](api-endpoint:Customers-BulkCreateCustomers) + endpoint. + properties: + responses: + type: optional> + docs: >- + A map of responses that correspond to individual create requests, + represented by + + key-value pairs. + + + Each key is the idempotency key that was provided for a create request + and each value + + is the corresponding response. + + If the request succeeds, the value is the new customer profile. + + If the request fails, the value contains any errors that occurred + during the request. + errors: + type: optional> + docs: Any top-level errors that prevented the bulk operation from running. + source: + openapi: ../default/openapi/openapi.json + BatchCreateTeamMembersResponse: + docs: >- + Represents a response from a bulk create request containing the created + `TeamMember` objects or error messages. + properties: + team_members: + type: optional> + docs: >- + The successfully created `TeamMember` objects. Each key is the + `idempotency_key` that maps to the `CreateTeamMemberRequest`. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BatchCreateVendorsResponse: + docs: >- + Represents an output from a call to + [BulkCreateVendors](api-endpoint:Vendors-BulkCreateVendors). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + responses: + type: optional> + docs: >- + A set of [CreateVendorResponse](entity:CreateVendorResponse) objects + encapsulating successfully created [Vendor](entity:Vendor) + + objects or error responses for failed attempts. The set is represented + by + + a collection of idempotency-key/`Vendor`-object or + idempotency-key/error-object pairs. The idempotency keys correspond to + those specified + + in the input. + source: + openapi: ../default/openapi/openapi.json + BulkDeleteBookingCustomAttributesResponse: + docs: >- + Represents a + [BulkDeleteBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkDeleteBookingCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + delete request. + properties: + values: + type: optional> + docs: >- + A map of responses that correspond to individual delete requests. Each + response has the + + same ID as the corresponding request and contains `booking_id` and + `errors` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BulkDeleteCustomersResponse: + docs: >- + Defines the fields included in the response body from the + + [BulkDeleteCustomers](api-endpoint:Customers-BulkDeleteCustomers) + endpoint. + properties: + responses: + type: optional> + docs: >- + A map of responses that correspond to individual delete requests, + represented by + + key-value pairs. + + + Each key is the customer ID that was specified for a delete request + and each value + + is the corresponding response. + + If the request succeeds, the value is an empty object (`{ }`). + + If the request fails, the value contains any errors that occurred + during the request. + errors: + type: optional> + docs: Any top-level errors that prevented the bulk operation from running. + source: + openapi: ../default/openapi/openapi.json + BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest: + docs: >- + Represents an individual delete request in a + [BulkDeleteLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkDeleteLocationCustomAttributes) + + request. An individual request contains an optional ID of the associated + custom attribute definition + + and optional key of the associated custom attribute definition. + properties: + key: + type: optional + docs: >- + The key of the associated custom attribute definition. + + Represented as a qualified key if the requesting app is not the + definition owner. + validation: + pattern: ^([a-zA-Z0-9_-]+:)?[a-zA-Z0-9_-]{1,60}$ + access: read-only + source: + openapi: ../default/openapi/openapi.json + BulkDeleteLocationCustomAttributesResponse: + docs: >- + Represents a + [BulkDeleteLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkDeleteLocationCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + delete request. + properties: + values: + type: >- + map + docs: >- + A map of responses that correspond to individual delete requests. Each + response has the + + same key as the corresponding request. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeDeleteResponse: + docs: >- + Represents an individual delete response in a + [BulkDeleteLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkDeleteLocationCustomAttributes) + + request. + properties: + location_id: + type: optional + docs: The ID of the location associated with the custom attribute. + errors: + type: optional> + docs: >- + Errors that occurred while processing the individual + LocationCustomAttributeDeleteRequest request + source: + openapi: ../default/openapi/openapi.json + BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest: + docs: >- + Represents an individual delete request in a + [BulkDeleteMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkDeleteMerchantCustomAttributes) + + request. An individual request contains an optional ID of the associated + custom attribute definition + + and optional key of the associated custom attribute definition. + properties: + key: + type: optional + docs: >- + The key of the associated custom attribute definition. + + Represented as a qualified key if the requesting app is not the + definition owner. + validation: + pattern: ^([a-zA-Z0-9_-]+:)?[a-zA-Z0-9_-]{1,60}$ + access: read-only + source: + openapi: ../default/openapi/openapi.json + BulkDeleteMerchantCustomAttributesResponse: + docs: >- + Represents a + [BulkDeleteMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkDeleteMerchantCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + delete request. + properties: + values: + type: >- + map + docs: >- + A map of responses that correspond to individual delete requests. Each + response has the + + same key as the corresponding request. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BulkDeleteMerchantCustomAttributesResponseMerchantCustomAttributeDeleteResponse: + docs: >- + Represents an individual delete response in a + [BulkDeleteMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkDeleteMerchantCustomAttributes) + + request. + properties: + errors: + type: optional> + docs: >- + Errors that occurred while processing the individual + MerchantCustomAttributeDeleteRequest request + source: + openapi: ../default/openapi/openapi.json + BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute: + docs: Represents one delete within the bulk operation. + properties: + key: + type: optional + docs: >- + The key of the custom attribute to delete. This key must match the + key + + of an existing custom attribute definition. + validation: + pattern: ^([a-zA-Z0-9_-]+:)?[a-zA-Z0-9_-]{1,60}$ + minLength: 1 + access: read-only + order_id: + type: string + docs: The ID of the target [order](entity:Order). + validation: + minLength: 1 + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + BulkDeleteOrderCustomAttributesResponse: + docs: Represents a response from deleting one or more order custom attributes. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + values: + type: map + docs: >2- + A map of responses that correspond to individual delete requests. Each response has the same ID + as the corresponding request and contains either a `custom_attribute` + or an `errors` field. + source: + openapi: ../default/openapi/openapi.json + BulkPublishScheduledShiftsData: + docs: >- + Represents options for an individual publish request in a + + [BulkPublishScheduledShifts](api-endpoint:Labor-BulkPublishScheduledShifts) + + operation, provided as the value in a key-value pair. + properties: + version: + type: optional + docs: >- + The current version of the scheduled shift, used to enable [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control. If the provided version doesn't match the server version, the + request fails. + + If omitted, Square executes a blind write, potentially overwriting + data from another publish request. + source: + openapi: ../default/openapi/openapi.json + BulkPublishScheduledShiftsResponse: + docs: >- + Represents a + [BulkPublishScheduledShifts](api-endpoint:Labor-BulkPublishScheduledShifts) + response. + + Either `scheduled_shifts` or `errors` is present in the response. + properties: + responses: + type: optional> + docs: >- + A map of key-value pairs that represent responses for individual + publish requests. + + The order of responses might differ from the order in which the + requests were provided. + + + - Each key is the scheduled shift ID that was specified for a publish + request. + + - Each value is the corresponding response. If the request succeeds, + the value is the + + published scheduled shift. If the request fails, the value is an + `errors` array containing + + any errors that occurred while processing the request. + errors: + type: optional> + docs: >- + Any top-level errors that prevented the bulk operation from + succeeding. + source: + openapi: ../default/openapi/openapi.json + BulkRetrieveBookingsResponse: + docs: Response payload for bulk retrieval of bookings. + properties: + bookings: + type: optional> + docs: >- + Requested bookings returned as a map containing `booking_id` as the + key and `RetrieveBookingResponse` as the value. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BulkRetrieveChannelsRequestConstants: literal<"MAX_BATCH_SIZE"> + BulkRetrieveChannelsResponse: + docs: >- + Defines the fields that are included in the request body for the + + [BulkRetrieveChannels](api-endpoint:Channels-BulkRetrieveChannels) + endpoint. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + responses: + type: optional> + docs: |- + A map of channel IDs to channel responses which tell whether + retrieval for a specific channel is success or not. + Channel response of a success retrieval would contain channel info + whereas channel response of a failed retrieval would have error info. + source: + openapi: ../default/openapi/openapi.json + BulkRetrieveCustomersResponse: + docs: >- + Defines the fields included in the response body from the + + [BulkRetrieveCustomers](api-endpoint:Customers-BulkRetrieveCustomers) + endpoint. + properties: + responses: + type: optional> + docs: >- + A map of responses that correspond to individual retrieve requests, + represented by + + key-value pairs. + + + Each key is the customer ID that was specified for a retrieve request + and each value + + is the corresponding response. + + If the request succeeds, the value is the requested customer profile. + + If the request fails, the value contains any errors that occurred + during the request. + errors: + type: optional> + docs: Any top-level errors that prevented the bulk operation from running. + source: + openapi: ../default/openapi/openapi.json + BulkRetrieveTeamMemberBookingProfilesResponse: + docs: >- + Response payload for the + [BulkRetrieveTeamMemberBookingProfiles](api-endpoint:Bookings-BulkRetrieveTeamMemberBookingProfiles) + endpoint. + properties: + team_member_booking_profiles: + type: optional> + docs: >- + The returned team members' booking profiles, as a map with + `team_member_id` as the key and + [TeamMemberBookingProfile](entity:TeamMemberBookingProfile) the value. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BatchGetVendorsResponse: + docs: >- + Represents an output from a call to + [BulkRetrieveVendors](api-endpoint:Vendors-BulkRetrieveVendors). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + responses: + type: optional> + docs: >- + The set of [RetrieveVendorResponse](entity:RetrieveVendorResponse) + objects encapsulating successfully retrieved [Vendor](entity:Vendor) + + objects or error responses for failed attempts. The set is represented + by + + a collection of `Vendor`-ID/`Vendor`-object or + `Vendor`-ID/error-object pairs. + source: + openapi: ../default/openapi/openapi.json + BulkSwapPlanResponse: + docs: |- + Defines output parameters in a response of the + [BulkSwapPlan](api-endpoint:Subscriptions-BulkSwapPlan) endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + affected_subscriptions: + type: optional + docs: The number of affected subscriptions. + source: + openapi: ../default/openapi/openapi.json + BulkUpdateCustomerData: + docs: >- + Defines the customer data provided in individual update requests for a + + [BulkUpdateCustomers](api-endpoint:Customers-BulkUpdateCustomers) + operation. + properties: + given_name: + type: optional> + docs: >- + The given name (that is, the first name) associated with the customer + profile. + validation: + maxLength: 300 + family_name: + type: optional> + docs: >- + The family name (that is, the last name) associated with the customer + profile. + validation: + maxLength: 300 + company_name: + type: optional> + docs: A business name associated with the customer profile. + validation: + maxLength: 500 + nickname: + type: optional> + docs: A nickname for the customer profile. + validation: + maxLength: 100 + email_address: + type: optional> + docs: The email address associated with the customer profile. + validation: + maxLength: 254 + address: + type: optional
+ docs: >- + The physical address associated with the customer profile. For maximum + length constraints, + + see [Customer + addresses](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#address). + + The `first_name` and `last_name` fields are ignored if they are + present in the request. + phone_number: + type: optional> + docs: >- + The phone number associated with the customer profile. The phone + number must be valid + + and can contain 9–16 digits, with an optional `+` prefix and country + code. For more information, + + see [Customer phone + numbers](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#phone-number). + reference_id: + type: optional> + docs: |- + An optional second ID used to associate the customer profile with an + entity in another system. + validation: + maxLength: 100 + note: + type: optional> + docs: An custom note associates with the customer profile. + birthday: + type: optional> + docs: >- + The birthday associated with the customer profile, in `YYYY-MM-DD` or + `MM-DD` format. + + For example, specify `1998-09-21` for September 21, 1998, or `09-21` + for September 21. + + Birthdays are returned in `YYYY-MM-DD` format, where `YYYY` is the + specified birth year or + + `0000` if a birth year is not specified. + tax_ids: + type: optional + docs: >- + The tax ID associated with the customer profile. This field is + available 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). + version: + type: optional + docs: >- + The current version of the customer profile. + + + As a best practice, you should include this field to enable + + [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control. + source: + openapi: ../default/openapi/openapi.json + BulkUpdateCustomersResponse: + docs: >- + Defines the fields included in the response body from the + + [BulkUpdateCustomers](api-endpoint:Customers-BulkUpdateCustomers) + endpoint. + properties: + responses: + type: optional> + docs: >- + A map of responses that correspond to individual update requests, + represented by + + key-value pairs. + + + Each key is the customer ID that was specified for an update request + and each value + + is the corresponding response. + + If the request succeeds, the value is the updated customer profile. + + If the request fails, the value contains any errors that occurred + during the request. + errors: + type: optional> + docs: Any top-level errors that prevented the bulk operation from running. + source: + openapi: ../default/openapi/openapi.json + BatchUpdateTeamMembersResponse: + docs: >- + Represents a response from a bulk update request containing the updated + `TeamMember` objects or error messages. + properties: + team_members: + type: optional> + docs: >- + The successfully updated `TeamMember` objects. Each key is the + `team_member_id` that maps to the `UpdateTeamMemberRequest`. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BatchUpdateVendorsResponse: + docs: >- + Represents an output from a call to + [BulkUpdateVendors](api-endpoint:Vendors-BulkUpdateVendors). + properties: + errors: + type: optional> + docs: Errors encountered when the request fails. + responses: + type: optional> + docs: >- + A set of [UpdateVendorResponse](entity:UpdateVendorResponse) objects + encapsulating successfully created [Vendor](entity:Vendor) + + objects or error responses for failed attempts. The set is represented + by a collection of `Vendor`-ID/`UpdateVendorResponse`-object or + + `Vendor`-ID/error-object pairs. + source: + openapi: ../default/openapi/openapi.json + BulkUpsertBookingCustomAttributesResponse: + docs: >- + Represents a + [BulkUpsertBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkUpsertBookingCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + upsert request. + properties: + values: + type: optional> + docs: >- + A map of responses that correspond to individual upsert requests. Each + response has the + + same ID as the corresponding request and contains either a + `booking_id` and `custom_attribute` or an `errors` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest: + docs: >- + Represents an individual upsert request in a + [BulkUpsertCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-BulkUpsertCustomerCustomAttributes) + + request. An individual request contains a customer ID, the custom + attribute to create or update, + + and an optional idempotency key. + properties: + customer_id: + type: string + docs: The ID of the target [customer profile](entity:Customer). + validation: + minLength: 1 + custom_attribute: + type: CustomAttribute + docs: >- + The custom attribute to create or update, with following fields: + + + - `key`. This key must match the `key` of a custom attribute + definition in the Square seller + + account. If the requesting application is not the definition owner, + you must provide the qualified key. + + + - `value`. This value must conform to the `schema` specified by the + definition. + + For more information, see [Value data + types](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attributes#value-data-types). + + + - `version`. To enable [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control for update operations, include this optional field in the + request and set the + + value to the current version of the custom attribute. + idempotency_key: + type: optional> + docs: >- + A unique identifier for this individual upsert request, used to ensure + idempotency. + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 45 + source: + openapi: ../default/openapi/openapi.json + BatchUpsertCustomerCustomAttributesResponse: + docs: >- + Represents a + [BulkUpsertCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-BulkUpsertCustomerCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + upsert request. + properties: + values: + type: >- + optional> + docs: >- + A map of responses that correspond to individual upsert requests. Each + response has the + + same ID as the corresponding request and contains either a + `customer_id` and `custom_attribute` or an `errors` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttributeUpsertResponse: + docs: >- + Represents a response for an individual upsert request in a + [BulkUpsertCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-BulkUpsertCustomerCustomAttributes) + operation. + properties: + customer_id: + type: optional + docs: The ID of the customer profile associated with the custom attribute. + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred while processing the individual request. + source: + openapi: ../default/openapi/openapi.json + BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest: + docs: >- + Represents an individual upsert request in a + [BulkUpsertLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkUpsertLocationCustomAttributes) + + request. An individual request contains a location ID, the custom + attribute to create or update, + + and an optional idempotency key. + properties: + location_id: + type: string + docs: The ID of the target [location](entity:Location). + validation: + minLength: 1 + custom_attribute: + type: CustomAttribute + docs: >- + The custom attribute to create or update, with following fields: + + - `key`. This key must match the `key` of a custom attribute + definition in the Square seller + + account. If the requesting application is not the definition owner, + you must provide the qualified key. + + - `value`. This value must conform to the `schema` specified by the + definition. + + For more information, see [Supported data + types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types).. + + - `version`. 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. + + If this is not important for your application, `version` can be set to + -1. + idempotency_key: + type: optional> + docs: >- + A unique identifier for this individual upsert request, used to ensure + idempotency. + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 45 + source: + openapi: ../default/openapi/openapi.json + BulkUpsertLocationCustomAttributesResponse: + docs: >- + Represents a + [BulkUpsertLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkUpsertLocationCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + upsert request. + properties: + values: + type: >- + optional> + docs: >- + A map of responses that correspond to individual upsert requests. Each + response has the + + same ID as the corresponding request and contains either a + `location_id` and `custom_attribute` or an `errors` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeUpsertResponse: + docs: >- + Represents a response for an individual upsert request in a + [BulkUpsertLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkUpsertLocationCustomAttributes) + operation. + properties: + location_id: + type: optional + docs: The ID of the location associated with the custom attribute. + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred while processing the individual request. + source: + openapi: ../default/openapi/openapi.json + BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest: + docs: >- + Represents an individual upsert request in a + [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) + + request. An individual request contains a merchant ID, the custom + attribute to create or update, + + and an optional idempotency key. + properties: + merchant_id: + type: string + docs: The ID of the target [merchant](entity:Merchant). + validation: + minLength: 1 + custom_attribute: + type: CustomAttribute + docs: >- + The custom attribute to create or update, with following fields: + + - `key`. This key must match the `key` of a custom attribute + definition in the Square seller + + account. If the requesting application is not the definition owner, + you must provide the qualified key. + + - `value`. This value must conform to the `schema` specified by the + definition. + + For more information, see [Supported data + types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). + + - 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. + idempotency_key: + type: optional> + docs: >- + A unique identifier for this individual upsert request, used to ensure + idempotency. + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 45 + source: + openapi: ../default/openapi/openapi.json + BulkUpsertMerchantCustomAttributesResponse: + docs: >- + Represents a + [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) + response, + + which contains a map of responses that each corresponds to an individual + upsert request. + properties: + values: + type: >- + optional> + docs: >- + A map of responses that correspond to individual upsert requests. Each + response has the + + same ID as the corresponding request and contains either a + `merchant_id` and `custom_attribute` or an `errors` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeUpsertResponse: + docs: >- + Represents a response for an individual upsert request in a + [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) + operation. + properties: + merchant_id: + type: optional + docs: The ID of the merchant associated with the custom attribute. + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred while processing the individual request. + source: + openapi: ../default/openapi/openapi.json + BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute: + docs: Represents one upsert within the bulk operation. + properties: + custom_attribute: + type: CustomAttribute + docs: >- + The custom attribute to create or update, with the following fields: + + + - `value`. This value must conform to the `schema` specified by the + definition. + + For more information, see [Value data + types](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attributes#value-data-types). + + + - `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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + minLength: 1 + maxLength: 45 + order_id: + type: string + docs: The ID of the target [order](entity:Order). + validation: + minLength: 1 + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + BulkUpsertOrderCustomAttributesResponse: + docs: Represents a response from a bulk upsert of order custom attributes. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + values: + type: map + docs: ' A map of responses that correspond to individual upsert operations for custom attributes.' + source: + openapi: ../default/openapi/openapi.json + BusinessAppointmentSettings: + docs: >- + The service appointment settings, including where and how the service is + provided. + properties: + location_types: + type: >- + optional>> + docs: >- + Types of the location allowed for bookings. + + See + [BusinessAppointmentSettingsBookingLocationType](#type-businessappointmentsettingsbookinglocationtype) + for possible values + alignment_time: + type: optional + docs: >- + The time unit of the service duration for bookings. + + See + [BusinessAppointmentSettingsAlignmentTime](#type-businessappointmentsettingsalignmenttime) + for possible values + min_booking_lead_time_seconds: + type: optional> + docs: >- + The minimum lead time in seconds before a service can be booked. A + booking must be created at least this amount of time before its + starting time. + max_booking_lead_time_seconds: + type: optional> + docs: >- + The maximum lead time in seconds before a service can be booked. A + booking must be created at most this amount of time before its + starting time. + any_team_member_booking_enabled: + type: optional> + docs: >- + Indicates whether a customer can choose from all available time slots + and have a staff member assigned + + automatically (`true`) or not (`false`). + multiple_service_booking_enabled: + type: optional> + docs: >- + Indicates whether a customer can book multiple services in a single + online booking. + max_appointments_per_day_limit_type: + type: optional + docs: >- + Indicates whether the daily appointment limit applies to team members + or to + + business locations. + + See + [BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType](#type-businessappointmentsettingsmaxappointmentsperdaylimittype) + for possible values + max_appointments_per_day_limit: + type: optional> + docs: >- + The maximum number of daily appointments per team member or per + location. + cancellation_window_seconds: + type: optional> + docs: >- + The cut-off time in seconds for allowing clients to cancel or + reschedule an appointment. + cancellation_fee_money: + type: optional + docs: The flat-fee amount charged for a no-show booking. + cancellation_policy: + type: optional + docs: >- + The cancellation policy adopted by the seller. + + See + [BusinessAppointmentSettingsCancellationPolicy](#type-businessappointmentsettingscancellationpolicy) + for possible values + cancellation_policy_text: + type: optional> + docs: The free-form text of the seller's cancellation policy. + validation: + maxLength: 65536 + skip_booking_flow_staff_selection: + type: optional> + docs: >- + Indicates whether customers has an assigned staff member (`true`) or + can select s staff member of their choice (`false`). + source: + openapi: ../default/openapi/openapi.json + BusinessAppointmentSettingsAlignmentTime: + enum: + - SERVICE_DURATION + - QUARTER_HOURLY + - HALF_HOURLY + - HOURLY + docs: Time units of a service duration for bookings. + source: + openapi: ../default/openapi/openapi.json + BusinessAppointmentSettingsBookingLocationType: + enum: + - BUSINESS_LOCATION + - CUSTOMER_LOCATION + - PHONE + docs: Supported types of location where service is provided. + source: + openapi: ../default/openapi/openapi.json + BusinessAppointmentSettingsCancellationPolicy: + enum: + - CANCELLATION_TREATED_AS_NO_SHOW + - CUSTOM_POLICY + docs: The category of the seller’s cancellation policy. + source: + openapi: ../default/openapi/openapi.json + BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType: + enum: + - PER_TEAM_MEMBER + - PER_LOCATION + docs: Types of daily appointment limits. + source: + openapi: ../default/openapi/openapi.json + BusinessBookingProfile: + docs: >- + A seller's business booking profile, including booking policy, appointment + settings, etc. + properties: + seller_id: + type: optional> + docs: The ID of the seller, obtainable using the Merchants API. + validation: + maxLength: 32 + created_at: + type: optional + docs: The RFC 3339 timestamp specifying the booking's creation time. + access: read-only + booking_enabled: + type: optional> + docs: Indicates whether the seller is open for booking. + customer_timezone_choice: + type: optional + docs: >- + The choice of customer's time zone information of a booking. + + The Square online booking site and all notifications to customers uses + either the seller location’s time zone + + or the time zone the customer chooses at booking. + + See + [BusinessBookingProfileCustomerTimezoneChoice](#type-businessbookingprofilecustomertimezonechoice) + for possible values + booking_policy: + type: optional + docs: >- + The policy for the seller to automatically accept booking requests + (`ACCEPT_ALL`) or not (`REQUIRES_ACCEPTANCE`). + + See + [BusinessBookingProfileBookingPolicy](#type-businessbookingprofilebookingpolicy) + for possible values + allow_user_cancel: + type: optional> + docs: >- + Indicates whether customers can cancel or reschedule their own + bookings (`true`) or not (`false`). + business_appointment_settings: + type: optional + docs: Settings for appointment-type bookings. + support_seller_level_writes: + type: optional> + docs: >- + Indicates whether the seller's subscription to Square Appointments + supports creating, updating or canceling an appointment through the + API (`true`) or not (`false`) using seller permission. + source: + openapi: ../default/openapi/openapi.json + BusinessBookingProfileBookingPolicy: + enum: + - ACCEPT_ALL + - REQUIRES_ACCEPTANCE + docs: Policies for accepting bookings. + source: + openapi: ../default/openapi/openapi.json + BusinessBookingProfileCustomerTimezoneChoice: + enum: + - BUSINESS_LOCATION_TIMEZONE + - CUSTOMER_CHOICE + docs: Choices of customer-facing time zone used for bookings. + source: + openapi: ../default/openapi/openapi.json + BusinessHours: + docs: The hours of operation for a location. + properties: + periods: + type: optional>> + docs: >- + The list of time periods during which the business is open. There can + be at most 10 periods per day. + source: + openapi: ../default/openapi/openapi.json + BusinessHoursPeriod: + docs: Represents a period of time during which a business location is open. + properties: + day_of_week: + type: optional + docs: |- + The day of the week for this time period. + See [DayOfWeek](#type-dayofweek) for possible values + start_local_time: + type: optional> + docs: >- + The start time of a business hours period, specified in local time + using partial-time + + RFC 3339 format. For example, `8:30:00` for a period starting at 8:30 + in the morning. + + Note that the seconds value is always :00, but it is appended for + conformance to the RFC. + end_local_time: + type: optional> + docs: >- + The end time of a business hours period, specified in local time using + partial-time + + RFC 3339 format. For example, `21:00:00` for a period ending at 9:00 + in the evening. + + Note that the seconds value is always :00, but it is appended for + conformance to the RFC. + source: + openapi: ../default/openapi/openapi.json + BuyNowPayLaterDetails: + docs: Additional details about a Buy Now Pay Later payment type. + properties: + brand: + type: optional> + docs: |- + The brand used for the Buy Now Pay Later payment. + The brand can be `AFTERPAY`, `CLEARPAY` or `UNKNOWN`. + validation: + maxLength: 50 + afterpay_details: + type: optional + docs: >- + Details about an Afterpay payment. These details are only populated if + the `brand` is + + `AFTERPAY`. + clearpay_details: + type: optional + docs: >- + Details about a Clearpay payment. These details are only populated if + the `brand` is + + `CLEARPAY`. + source: + openapi: ../default/openapi/openapi.json + CalculateLoyaltyPointsResponse: + docs: >- + Represents a + [CalculateLoyaltyPoints](api-endpoint:Loyalty-CalculateLoyaltyPoints) + response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + points: + type: optional + docs: >- + The number of points that the buyer can earn from the base loyalty + program. + promotion_points: + type: optional + docs: >- + The number of points that the buyer can earn from a loyalty promotion. + To be eligible + + to earn promotion points, the purchase must first qualify for program + points. When `order_id` + + is not provided in the request, this value is always 0. + source: + openapi: ../default/openapi/openapi.json + CalculateOrderResponse: + properties: + order: + type: optional + docs: The calculated version of the order provided in the request. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CancelBookingResponse: + properties: + booking: + type: optional + docs: The booking that was cancelled. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CancelInvoiceResponse: + docs: The response returned by the `CancelInvoice` request. + properties: + invoice: + type: optional + docs: The canceled invoice. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + CancelLoyaltyPromotionResponse: + docs: >- + Represents a + [CancelLoyaltyPromotion](api-endpoint:Loyalty-CancelLoyaltyPromotion) + response. + + Either `loyalty_promotion` or `errors` is present in the response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_promotion: + type: optional + docs: The canceled loyalty promotion. + source: + openapi: ../default/openapi/openapi.json + CancelPaymentByIdempotencyKeyResponse: + docs: >- + Defines the response returned by + + [CancelPaymentByIdempotencyKey](api-endpoint:Payments-CancelPaymentByIdempotencyKey). + + On success, `errors` is empty. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CancelPaymentResponse: + docs: >- + Defines the response returned by + [CancelPayment](api-endpoint:Payments-CancelPayment). + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + payment: + type: optional + docs: The successfully canceled `Payment` object. + source: + openapi: ../default/openapi/openapi.json + CancelSubscriptionResponse: + docs: >- + Defines output parameters in a response from the + + [CancelSubscription](api-endpoint:Subscriptions-CancelSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: >- + The specified subscription scheduled for cancellation according to the + action created by the request. + actions: + type: optional> + docs: A list of a single `CANCEL` action scheduled for the subscription. + source: + openapi: ../default/openapi/openapi.json + CancelTerminalActionResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + action: + type: optional + docs: The canceled `TerminalAction` + source: + openapi: ../default/openapi/openapi.json + CancelTerminalCheckoutResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + checkout: + type: optional + docs: The canceled `TerminalCheckout`. + source: + openapi: ../default/openapi/openapi.json + CancelTerminalRefundResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refund: + type: optional + docs: The updated `TerminalRefund`. + source: + openapi: ../default/openapi/openapi.json + CancelTransferOrderResponse: + docs: Response for canceling a transfer order + properties: + transfer_order: + type: optional + docs: The updated transfer order with status changed to CANCELED + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + CaptureTransactionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [CaptureTransaction](api-endpoint:Transactions-CaptureTransaction) + endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + Card: + docs: |- + Represents the payment details of a card to be used for payments. These + details are determined by the payment token generated by Web Payments SDK. + properties: + id: + type: optional + docs: Unique ID for this card. Generated by Square. + validation: + maxLength: 64 + access: read-only + card_brand: + type: optional + docs: |- + The card's brand. + See [CardBrand](#type-cardbrand) for possible values + last_4: + type: optional + docs: The last 4 digits of the card number. + validation: + maxLength: 4 + access: read-only + exp_month: + type: optional> + docs: >- + The expiration month of the associated card as an integer between 1 + and 12. + exp_year: + type: optional> + docs: The four-digit year of the card's expiration date. + cardholder_name: + type: optional> + docs: The name of the cardholder. + validation: + maxLength: 96 + billing_address: + type: optional
+ docs: >- + The billing address for this card. `US` postal codes can be provided + as a 5-digit zip code + + or 9-digit ZIP+4 (example: `12345-6789`). For a full list of field + meanings by country, see + + [Working with + Addresses](https://developer.squareup.com/docs/build-basics/common-data-types/working-with-addresses). + fingerprint: + type: optional + docs: >- + Intended as a Square-assigned identifier, based + + on the card number, to identify the card across multiple locations + within a + + single application. + validation: + maxLength: 255 + access: read-only + customer_id: + type: optional> + docs: >- + **Required** The ID of a [customer](entity:Customer) to be associated + with the card. + merchant_id: + type: optional + docs: The ID of the merchant associated with the card. + access: read-only + reference_id: + type: optional> + docs: >- + An optional user-defined reference ID that associates this card with + + another entity in an external system. For example, a customer ID from + an + + external customer management system. + validation: + maxLength: 128 + enabled: + type: optional + docs: Indicates whether or not a card can be used for payments. + access: read-only + card_type: + type: optional + docs: >- + The type of the card. + + The Card object includes this field only in response to Payments API + calls. + + See [CardType](#type-cardtype) for possible values + prepaid_type: + type: optional + docs: |- + Indicates whether the card is prepaid or not. + See [CardPrepaidType](#type-cardprepaidtype) for possible values + bin: + type: optional + docs: >- + The first six digits of the card number, known as the Bank + Identification Number (BIN). Only the Payments API + + returns this field. + validation: + maxLength: 6 + access: read-only + version: + type: optional + docs: >- + Current version number of the card. Increments with each card update. + Requests to update an + + existing Card object will be rejected unless the version in the + request matches the current + + version for the Card. + card_co_brand: + type: optional + docs: >- + The card's co-brand if available. For example, an Afterpay virtual + card would have a + + co-brand of AFTERPAY. + + See [CardCoBrand](#type-cardcobrand) for possible values + issuer_alert: + type: optional + docs: >- + An alert from the issuing bank about the card status. Alerts can + indicate whether + + future charges to the card are likely to fail. For more information, + see + + [Manage Card on File + Declines](https://developer.squareup.com/docs/cards-api/manage-card-on-file-declines). + + + This field is present only if there's an active issuer alert. + + See [IssuerAlert](#type-issueralert) for possible values + issuer_alert_at: + type: optional + docs: >- + The timestamp of when the current issuer alert was received and + processed, in + + RFC 3339 format. + + + This field is present only if there's an active issuer alert. + access: read-only + hsa_fsa: + type: optional + docs: >- + Indicates whether the card is linked to a Health Savings Account (HSA) + or Flexible + + Spending Account (FSA), based on the card BIN. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CardAutomaticallyUpdatedEvent: + docs: >- + Published when Square automatically updates the expiration date or + + primary account number (PAN) of a [card](entity:Card) or adds or removes + an issuer alert. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"card.automatically_updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CardAutomaticallyUpdatedEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"card"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the automatically updated card. + source: + openapi: ../default/openapi/openapi.json + CardAutomaticallyUpdatedEventObject: + properties: + card: + type: optional + docs: The automatically updated card. + source: + openapi: ../default/openapi/openapi.json + CardBrand: + enum: + - OTHER_BRAND + - VISA + - MASTERCARD + - AMERICAN_EXPRESS + - DISCOVER + - DISCOVER_DINERS + - JCB + - CHINA_UNIONPAY + - SQUARE_GIFT_CARD + - SQUARE_CAPITAL_CARD + - INTERAC + - EFTPOS + - FELICA + - EBT + docs: Indicates a card's brand, such as `VISA` or `MASTERCARD`. + source: + openapi: ../default/openapi/openapi.json + CardCoBrand: + enum: + - UNKNOWN + - AFTERPAY + - CLEARPAY + docs: Indicates the brand for a co-branded card. + source: + openapi: ../default/openapi/openapi.json + CardCreatedEvent: + docs: Published when a [card](entity:Card) is created or imported. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"card.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CardCreatedEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"card"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the created card. + source: + openapi: ../default/openapi/openapi.json + CardCreatedEventObject: + properties: + card: + type: optional + docs: The created card. + source: + openapi: ../default/openapi/openapi.json + CardDisabledEvent: + docs: Published when a [card](entity:Card) is disabled. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"card.disabled"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CardDisabledEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"card"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the disabled card. + source: + openapi: ../default/openapi/openapi.json + CardDisabledEventObject: + properties: + card: + type: optional + docs: The disabled card. + source: + openapi: ../default/openapi/openapi.json + CardForgottenEvent: + docs: Published when a [card](entity:Card) is GDPR forgotten or vaulted. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"card.forgotten"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CardForgottenEventCard: + properties: + id: + type: optional + docs: Unique ID for this card. Generated by Square. + validation: + maxLength: 64 + access: read-only + customer_id: + type: optional> + docs: >- + The ID of a customer created using the Customers API associated with + the card. + enabled: + type: optional> + docs: Indicates whether or not a card can be used for payments. + reference_id: + type: optional> + docs: >- + An optional user-defined reference ID that associates this card with + + another entity in an external system. For example, a customer ID from + an + + external customer management system. + version: + type: optional + docs: >- + Current version number of the card. Increments with each card update. + Requests to update an + + existing Card object will be rejected unless the version in the + request matches the current + + version for the Card. + merchant_id: + type: optional> + docs: The ID of the merchant associated with the card. + source: + openapi: ../default/openapi/openapi.json + CardForgottenEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"card"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the forgotten card. + source: + openapi: ../default/openapi/openapi.json + CardForgottenEventObject: + properties: + card: + type: optional + docs: The forgotten card. + source: + openapi: ../default/openapi/openapi.json + CardIssuerAlert: + type: literal<"ISSUER_ALERT_CARD_CLOSED"> + docs: Indicates the type of issuer alert for a [card on file](entity:Card). + CardPaymentDetails: + docs: >- + Reflects the current status of a card payment. Contains only + non-confidential information. + properties: + status: + type: optional + docs: >- + The card payment's current state. The state can be AUTHORIZED, + CAPTURED, VOIDED, or + + FAILED. + validation: + maxLength: 50 + access: read-only + card: + type: optional + docs: The credit card's non-confidential details. + entry_method: + type: optional + docs: >- + The method used to enter the card's details for the payment. The + method can be + + `KEYED`, `SWIPED`, `EMV`, `ON_FILE`, or `CONTACTLESS`. + validation: + maxLength: 50 + access: read-only + cvv_status: + type: optional + docs: >- + The status code returned from the Card Verification Value (CVV) check. + The code can be + + `CVV_ACCEPTED`, `CVV_REJECTED`, or `CVV_NOT_CHECKED`. + validation: + maxLength: 50 + access: read-only + avs_status: + type: optional + docs: >- + The status code returned from the Address Verification System (AVS) + check. The code can be + + `AVS_ACCEPTED`, `AVS_REJECTED`, or `AVS_NOT_CHECKED`. + validation: + maxLength: 50 + access: read-only + auth_result_code: + type: optional + docs: >- + The status code returned by the card issuer that describes the + payment's + + authorization status. + validation: + maxLength: 10 + access: read-only + application_identifier: + type: optional + docs: >- + For EMV payments, the application ID identifies the EMV application + used for the payment. + validation: + maxLength: 32 + access: read-only + application_name: + type: optional + docs: >- + For EMV payments, the human-readable name of the EMV application used + for the payment. + validation: + maxLength: 16 + access: read-only + application_cryptogram: + type: optional + docs: For EMV payments, the cryptogram generated for the payment. + validation: + maxLength: 16 + access: read-only + verification_method: + type: optional + docs: >- + For EMV payments, the method used to verify the cardholder's identity. + The method can be + + `PIN`, `SIGNATURE`, `PIN_AND_SIGNATURE`, `ON_DEVICE`, or `NONE`. + validation: + maxLength: 50 + access: read-only + verification_results: + type: optional + docs: >- + For EMV payments, the results of the cardholder verification. The + result can be + + `SUCCESS`, `FAILURE`, or `UNKNOWN`. + validation: + maxLength: 50 + access: read-only + statement_description: + type: optional + docs: >- + The statement description sent to the card networks. + + + Note: The actual statement description varies and is likely to be + truncated and appended with + + additional information on a per issuer basis. + validation: + maxLength: 50 + access: read-only + device_details: + type: optional + docs: |- + __Deprecated__: Use `Payment.device_details` instead. + + Details about the device that took the payment. + card_payment_timeline: + type: optional + docs: The timeline for card payments. + refund_requires_card_presence: + type: optional + docs: |- + Whether the card must be physically present for the payment to + be refunded. If set to `true`, the card must be present. + access: read-only + errors: + type: optional> + docs: Information about errors encountered during the request. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CardPaymentTimeline: + docs: The timeline for card payments. + properties: + authorized_at: + type: optional> + docs: The timestamp when the payment was authorized, in RFC 3339 format. + captured_at: + type: optional> + docs: The timestamp when the payment was captured, in RFC 3339 format. + voided_at: + type: optional> + docs: The timestamp when the payment was voided, in RFC 3339 format. + source: + openapi: ../default/openapi/openapi.json + CardPrepaidType: + enum: + - UNKNOWN_PREPAID_TYPE + - NOT_PREPAID + - PREPAID + docs: Indicates a card's prepaid type, such as `NOT_PREPAID` or `PREPAID`. + source: + openapi: ../default/openapi/openapi.json + CardType: + enum: + - UNKNOWN_CARD_TYPE + - CREDIT + - DEBIT + docs: Indicates a card's type, such as `CREDIT` or `DEBIT`. + source: + openapi: ../default/openapi/openapi.json + CardUpdatedEvent: + docs: >- + Published when a [card](entity:Card) is updated by the seller in the + Square Dashboard. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: The type of this event. The value is `"card.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CardUpdatedEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"card"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the updated card. + source: + openapi: ../default/openapi/openapi.json + CardUpdatedEventObject: + properties: + card: + type: optional + docs: The updated card. + source: + openapi: ../default/openapi/openapi.json + CashAppDetails: + docs: >- + Additional details about `WALLET` type payments with the `brand` of + `CASH_APP`. + properties: + buyer_full_name: + type: optional> + docs: The name of the Cash App account holder. + validation: + maxLength: 255 + buyer_country_code: + type: optional> + docs: >- + The country of the Cash App account holder, in ISO 3166-1-alpha-2 + format. + + + For possible values, see [Country](entity:Country). + validation: + minLength: 2 + maxLength: 2 + buyer_cashtag: + type: optional + docs: $Cashtag of the Cash App account holder. + validation: + minLength: 1 + maxLength: 21 + access: read-only + source: + openapi: ../default/openapi/openapi.json + CashDrawerDevice: + properties: + id: + type: optional + docs: The device Square-issued ID + name: + type: optional> + docs: The device merchant-specified name. + source: + openapi: ../default/openapi/openapi.json + CashDrawerEventType: + enum: + - NO_SALE + - CASH_TENDER_PAYMENT + - OTHER_TENDER_PAYMENT + - CASH_TENDER_CANCELLED_PAYMENT + - OTHER_TENDER_CANCELLED_PAYMENT + - CASH_TENDER_REFUND + - OTHER_TENDER_REFUND + - PAID_IN + - PAID_OUT + docs: |- + The types of events on a CashDrawerShift. + Each event type represents an employee action on the actual cash drawer + represented by a CashDrawerShift. + source: + openapi: ../default/openapi/openapi.json + CashDrawerShift: + docs: >- + This model gives the details of a cash drawer shift. + + The cash_payment_money, cash_refund_money, cash_paid_in_money, + + and cash_paid_out_money fields are all computed by summing their + respective + + event types. + properties: + id: + type: optional + docs: The shift unique ID. + state: + type: optional + docs: >- + The shift current state. + + See [CashDrawerShiftState](#type-cashdrawershiftstate) for possible + values + opened_at: + type: optional> + docs: The time when the shift began, in ISO 8601 format. + ended_at: + type: optional> + docs: The time when the shift ended, in ISO 8601 format. + closed_at: + type: optional> + docs: The time when the shift was closed, in ISO 8601 format. + description: + type: optional> + docs: The free-form text description of a cash drawer by an employee. + opened_cash_money: + type: optional + docs: |- + The amount of money in the cash drawer at the start of the shift. + The amount must be greater than or equal to zero. + cash_payment_money: + type: optional + docs: >- + The amount of money added to the cash drawer from cash payments. + + This is computed by summing all events with the types + CASH_TENDER_PAYMENT and + + CASH_TENDER_CANCELED_PAYMENT. The amount is always greater than or + equal to + + zero. + cash_refunds_money: + type: optional + docs: >- + The amount of money removed from the cash drawer from cash refunds. + + It is computed by summing the events of type CASH_TENDER_REFUND. The + amount + + is always greater than or equal to zero. + cash_paid_in_money: + type: optional + docs: >- + The amount of money added to the cash drawer for reasons other than + cash + + payments. It is computed by summing the events of type PAID_IN. The + amount is + + always greater than or equal to zero. + cash_paid_out_money: + type: optional + docs: >- + The amount of money removed from the cash drawer for reasons other + than + + cash refunds. It is computed by summing the events of type PAID_OUT. + The amount + + is always greater than or equal to zero. + expected_cash_money: + type: optional + docs: >- + The amount of money that should be in the cash drawer at the end of + the + + shift, based on the shift's other money amounts. + + This can be negative if employees have not correctly recorded all the + events + + on the cash drawer. + + cash_paid_out_money is a summation of amounts from cash_payment_money + (zero + + or positive), cash_refunds_money (zero or negative), + cash_paid_in_money (zero + + or positive), and cash_paid_out_money (zero or negative) event types. + closed_cash_money: + type: optional + docs: |- + The amount of money found in the cash drawer at the end of the shift + by an auditing employee. The amount should be positive. + device: + type: optional + docs: >- + The device running Square Point of Sale that was connected to the cash + drawer. + created_at: + type: optional + docs: The shift start time in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The shift updated at time in RFC 3339 format. + access: read-only + location_id: + type: optional + docs: The ID of the location the cash drawer shift belongs to. + access: read-only + team_member_ids: + type: optional> + docs: >- + The IDs of all team members that were logged into Square Point of Sale + at any + + point while the cash drawer shift was open. + access: read-only + opening_team_member_id: + type: optional + docs: The ID of the team member that started the cash drawer shift. + access: read-only + ending_team_member_id: + type: optional + docs: The ID of the team member that ended the cash drawer shift. + access: read-only + closing_team_member_id: + type: optional + docs: >- + The ID of the team member that closed the cash drawer shift by + auditing + + the cash drawer contents. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CashDrawerShiftEvent: + properties: + id: + type: optional + docs: The unique ID of the event. + event_type: + type: optional + docs: >- + The type of cash drawer shift event. + + See [CashDrawerEventType](#type-cashdrawereventtype) for possible + values + event_money: + type: optional + docs: >- + The amount of money that was added to or removed from the cash drawer + + in the event. The amount can be positive (for added money) + + or zero (for other tender type payments). The addition or removal of + money can be determined by + + by the event type. + created_at: + type: optional + docs: The event time in RFC 3339 format. + access: read-only + description: + type: optional> + docs: |- + An optional description of the event, entered by the employee that + created the event. + team_member_id: + type: optional + docs: The ID of the team member that created the event. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CashDrawerShiftState: + enum: + - OPEN + - ENDED + - CLOSED + docs: The current state of a cash drawer shift. + source: + openapi: ../default/openapi/openapi.json + CashDrawerShiftSummary: + docs: >- + The summary of a closed cash drawer shift. + + This model contains only the money counted to start a cash drawer shift, + counted + + at the end of the shift, and the amount that should be in the drawer at + shift + + end based on summing all cash drawer shift events. + properties: + id: + type: optional + docs: The shift unique ID. + state: + type: optional + docs: >- + The shift current state. + + See [CashDrawerShiftState](#type-cashdrawershiftstate) for possible + values + opened_at: + type: optional> + docs: The shift start time in ISO 8601 format. + ended_at: + type: optional> + docs: The shift end time in ISO 8601 format. + closed_at: + type: optional> + docs: The shift close time in ISO 8601 format. + description: + type: optional> + docs: An employee free-text description of a cash drawer shift. + opened_cash_money: + type: optional + docs: |- + The amount of money in the cash drawer at the start of the shift. This + must be a positive amount. + expected_cash_money: + type: optional + docs: >- + The amount of money that should be in the cash drawer at the end of + the + + shift, based on the cash drawer events on the shift. + + The amount is correct if all shift employees accurately recorded their + + cash drawer shift events. Unrecorded events and events with the wrong + amount + + result in an incorrect expected_cash_money amount that can be + negative. + closed_cash_money: + type: optional + docs: >- + The amount of money found in the cash drawer at the end of the shift + by + + an auditing employee. The amount must be greater than or equal to + zero. + created_at: + type: optional + docs: The shift start time in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The shift updated at time in RFC 3339 format. + access: read-only + location_id: + type: optional + docs: The ID of the location the cash drawer shift belongs to. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CashPaymentDetails: + docs: >- + Stores details about a cash payment. Contains only non-confidential + information. For more information, see + + [Take Cash + Payments](https://developer.squareup.com/docs/payments-api/take-payments/cash-payments). + properties: + buyer_supplied_money: + type: Money + docs: The amount and currency of the money supplied by the buyer. + change_back_money: + type: optional + docs: |- + The amount of change due back to the buyer. + This read-only field is calculated + from the `amount_money` and `buyer_supplied_money` fields. + source: + openapi: ../default/openapi/openapi.json + CatalogAvailabilityPeriod: + docs: Represents a time period of availability. + properties: + start_local_time: + type: optional> + docs: >- + The start time of an availability period, specified in local time + using partial-time + + RFC 3339 format. For example, `8:30:00` for a period starting at 8:30 + in the morning. + + Note that the seconds value is always :00, but it is appended for + conformance to the RFC. + end_local_time: + type: optional> + docs: >- + The end time of an availability period, specified in local time using + partial-time + + RFC 3339 format. For example, `21:00:00` for a period ending at 9:00 + in the evening. + + Note that the seconds value is always :00, but it is appended for + conformance to the RFC. + day_of_week: + type: optional + docs: |- + The day of the week for this availability period. + See [DayOfWeek](#type-dayofweek) for possible values + source: + openapi: ../default/openapi/openapi.json + CatalogCategory: + docs: A category to which a `CatalogItem` instance belongs. + properties: + name: + type: optional> + docs: >- + The category name. This is a searchable attribute for use in + applicable query filters, and its value length is of Unicode code + points. + validation: + maxLength: 255 + image_ids: + type: optional>> + docs: >- + The IDs of images associated with this `CatalogCategory` instance. + + Currently these images are not displayed by Square, but are free to be + displayed in 3rd party applications. + category_type: + type: optional + docs: >- + The type of the category. + + See [CatalogCategoryType](#type-catalogcategorytype) for possible + values + parent_category: + type: optional + docs: The ID of the parent category of this category instance. + is_top_level: + type: optional> + docs: >- + Indicates whether a category is a top level category, which does not + have any parent_category. + channels: + type: optional>> + docs: >- + A list of IDs representing channels, such as a Square Online site, + where the category can be made visible. + availability_period_ids: + type: optional>> + docs: >- + The IDs of the `CatalogAvailabilityPeriod` objects associated with the + category. + online_visibility: + type: optional> + docs: >- + Indicates whether the category is visible (`true`) or hidden (`false`) + on all of the seller's Square Online sites. + root_category: + type: optional + docs: The top-level category in a category hierarchy. + access: read-only + ecom_seo_data: + type: optional + docs: The SEO data for a seller's Square Online store. + path_to_root: + type: optional>> + docs: >- + The path from the category to its root category. The first node of the + path is the parent of the category + + and the last is the root category. The path is empty if the category + is a root category. + source: + openapi: ../default/openapi/openapi.json + CatalogCategoryType: + enum: + - REGULAR_CATEGORY + - MENU_CATEGORY + - KITCHEN_CATEGORY + docs: Indicates the type of a category. + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinition: + docs: >- + Contains information defining a custom attribute. Custom attributes are + + intended to store additional information about a catalog object or to + associate a + + catalog object with an entity in another system. Do not use custom + attributes + + to store any sensitive information (personally identifiable information, + card details, etc.). + + [Read more about custom + attributes](https://developer.squareup.com/docs/catalog-api/add-custom-attributes) + properties: + type: + type: CatalogCustomAttributeDefinitionType + docs: >- + The type of this custom attribute. Cannot be modified after creation. + + Required. + + See + [CatalogCustomAttributeDefinitionType](#type-catalogcustomattributedefinitiontype) + for possible values + name: + type: string + docs: >2- + The name of this definition for API and seller-facing UI purposes. + The name must be unique within the (merchant, application) pair. + Required. + + May not be empty and may not exceed 255 characters. Can be modified + after creation. + validation: + minLength: 1 + maxLength: 255 + description: + type: optional> + docs: >- + Seller-oriented description of the meaning of this Custom Attribute, + + any constraints that the seller should observe, etc. May be displayed + as a tooltip in Square UIs. + validation: + maxLength: 255 + source_application: + type: optional + docs: |- + __Read only.__ Contains information about the application that + created this custom attribute definition. + allowed_object_types: + docs: >- + The set of `CatalogObject` types that this custom atttribute may be + applied to. + + Currently, only `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, + and `CATEGORY` are allowed. At least one type must be included. + + See [CatalogObjectType](#type-catalogobjecttype) for possible values + type: list + seller_visibility: + type: optional + docs: >- + The visibility of a custom attribute in seller-facing UIs (including + Square Point + + of Sale applications and Square Dashboard). May be modified. + + See + [CatalogCustomAttributeDefinitionSellerVisibility](#type-catalogcustomattributedefinitionsellervisibility) + for possible values + app_visibility: + type: optional + docs: >- + The visibility of a custom attribute to applications other than the + application + + that created the attribute. + + See + [CatalogCustomAttributeDefinitionAppVisibility](#type-catalogcustomattributedefinitionappvisibility) + for possible values + string_config: + type: optional + docs: Optionally, populated when `type` = `STRING`, unset otherwise. + number_config: + type: optional + docs: Optionally, populated when `type` = `NUMBER`, unset otherwise. + selection_config: + type: optional + docs: Populated when `type` is set to `SELECTION`, unset otherwise. + custom_attribute_usage_count: + type: optional + docs: >- + The number of custom attributes that reference this + + custom attribute definition. Set by the server in response to a + ListCatalog + + request with `include_counts` set to `true`. If the actual count is + greater + + than 100, `custom_attribute_usage_count` will be set to `100`. + access: read-only + key: + type: optional> + docs: >- + The name of the desired custom attribute key that can be used to + access + + the custom attribute value on catalog objects. Cannot be modified + after the + + custom attribute definition has been created. + + Must be between 1 and 60 characters, and may only contain the + characters `[a-zA-Z0-9_-]`. + validation: + pattern: ^[a-zA-Z0-9_-]*$ + minLength: 1 + maxLength: 60 + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionAppVisibility: + enum: + - APP_VISIBILITY_HIDDEN + - APP_VISIBILITY_READ_ONLY + - APP_VISIBILITY_READ_WRITE_VALUES + docs: >- + Defines the visibility of a custom attribute to applications other than + their + + creating application. + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionNumberConfig: + properties: + precision: + type: optional> + docs: |- + An integer between 0 and 5 that represents the maximum number of + positions allowed after the decimal in number custom attribute values + For example: + + - if the precision is 0, the quantity can be 1, 2, 3, etc. + - if the precision is 1, the quantity can be 0.1, 0.2, etc. + - if the precision is 2, the quantity can be 0.01, 0.12, etc. + + Default: 5 + validation: + max: 5 + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionSelectionConfig: + docs: >- + Configuration associated with `SELECTION`-type custom attribute + definitions. + properties: + max_allowed_selections: + type: optional> + docs: >- + The maximum number of selections that can be set. The maximum value + for this + + attribute is 100. The default value is 1. The value can be modified, + but changing the value will not + + affect existing custom attribute values on objects. Clients need to + + handle custom attributes with more selected values than allowed by + this limit. + validation: + max: 100 + allowed_selections: + type: >- + optional>> + docs: >- + The set of valid `CatalogCustomAttributeSelections`. Up to a maximum + of 100 + + selections can be defined. Can be modified. + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSelection: + docs: A named selection for this `SELECTION`-type custom attribute definition. + properties: + uid: + type: optional> + docs: Unique ID set by Square. + name: + type: string + docs: Selection name, unique within `allowed_selections`. + validation: + minLength: 1 + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionSellerVisibility: + enum: + - SELLER_VISIBILITY_HIDDEN + - SELLER_VISIBILITY_READ_WRITE_VALUES + docs: |- + Defines the visibility of a custom attribute to sellers in Square + client applications, Square APIs or in Square UIs (including Square Point + of Sale applications and Square Dashboard). + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionStringConfig: + docs: >- + Configuration associated with Custom Attribute Definitions of type + `STRING`. + properties: + enforce_uniqueness: + type: optional> + docs: >- + If true, each Custom Attribute instance associated with this Custom + Attribute + + Definition must have a unique value within the seller's catalog. For + + example, this may be used for a value like a SKU that should not be + + duplicated within a seller's catalog. May not be modified after the + + definition has been created. + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeDefinitionType: + enum: + - STRING + - BOOLEAN + - NUMBER + - SELECTION + docs: Defines the possible types for a custom attribute. + source: + openapi: ../default/openapi/openapi.json + CatalogCustomAttributeValue: + docs: >- + An instance of a custom attribute. Custom attributes can be defined and + + added to `ITEM` and `ITEM_VARIATION` type catalog objects. + + [Read more about custom + attributes](https://developer.squareup.com/docs/catalog-api/add-custom-attributes). + properties: + name: + type: optional> + docs: The name of the custom attribute. + string_value: + type: optional> + docs: >- + The string value of the custom attribute. Populated if `type` = + `STRING`. + custom_attribute_definition_id: + type: optional + docs: >- + The id of the + [CatalogCustomAttributeDefinition](entity:CatalogCustomAttributeDefinition) + this value belongs to. + access: read-only + type: + type: optional + docs: >- + A copy of type from the associated `CatalogCustomAttributeDefinition`. + + See + [CatalogCustomAttributeDefinitionType](#type-catalogcustomattributedefinitiontype) + for possible values + number_value: + type: optional> + docs: >- + Populated if `type` = `NUMBER`. Contains a string + + representation of a decimal number, using a `.` as the decimal + separator. + boolean_value: + type: optional> + docs: A `true` or `false` value. Populated if `type` = `BOOLEAN`. + selection_uid_values: + type: optional>> + docs: >- + One or more choices from `allowed_selections`. Populated if `type` = + `SELECTION`. + key: + type: optional + docs: >- + If the associated `CatalogCustomAttributeDefinition` object is defined + by another application, this key is prefixed by the defining + application ID. + + For example, if the CatalogCustomAttributeDefinition has a key + attribute of "cocoa_brand" and the defining application ID is + "abcd1234", this key is "abcd1234:cocoa_brand" + + when the application making the request is different from the + application defining the custom attribute definition. Otherwise, the + key is simply "cocoa_brand". + access: read-only + source: + openapi: ../default/openapi/openapi.json + CatalogDiscount: + docs: A discount applicable to items. + properties: + name: + type: optional> + docs: >- + The discount name. This is a searchable attribute for use in + applicable query filters, and its value length is of Unicode code + points. + validation: + maxLength: 255 + discount_type: + type: optional + docs: >- + Indicates whether the discount is a fixed amount or percentage, or + entered at the time of sale. + + See [CatalogDiscountType](#type-catalogdiscounttype) for possible + values + percentage: + type: optional> + docs: >- + The percentage of the discount as a string representation of a decimal + number, using a `.` as the decimal + + separator and without a `%` sign. A value of `7.5` corresponds to + `7.5%`. Specify a percentage of `0` if `discount_type` + + is `VARIABLE_PERCENTAGE`. + + + Do not use this field for amount-based or variable discounts. + amount_money: + type: optional + docs: >- + The amount of the discount. Specify an amount of `0` if + `discount_type` is `VARIABLE_AMOUNT`. + + + Do not use this field for percentage-based or variable discounts. + pin_required: + type: optional> + docs: >- + Indicates whether a mobile staff member needs to enter their PIN to + apply the + + discount to a payment in the Square Point of Sale app. + label_color: + type: optional> + docs: >- + The color of the discount display label in the Square Point of Sale + app. This must be a valid hex color code. + modify_tax_basis: + type: optional + docs: >- + Indicates whether this discount should reduce the price used to + calculate tax. + + + Most discounts should use `MODIFY_TAX_BASIS`. However, in some + circumstances taxes must + + be calculated based on an item's price, ignoring a particular + discount. For example, + + in many US jurisdictions, a manufacturer coupon or instant rebate + reduces the price a + + customer pays but does not reduce the sale price used to calculate how + much sales tax is + + due. In this case, the discount representing that manufacturer coupon + should have + + `DO_NOT_MODIFY_TAX_BASIS` for this field. + + + If you are unsure whether you need to use this field, consult your tax + professional. + + See + [CatalogDiscountModifyTaxBasis](#type-catalogdiscountmodifytaxbasis) + for possible values + maximum_amount_money: + type: optional + docs: >- + For a percentage discount, the maximum absolute value of the discount. + For example, if a + + 50% discount has a `maximum_amount_money` of $20, a $100 purchase will + yield a $20 discount, + + not a $50 discount. + source: + openapi: ../default/openapi/openapi.json + CatalogDiscountModifyTaxBasis: + enum: + - MODIFY_TAX_BASIS + - DO_NOT_MODIFY_TAX_BASIS + source: + openapi: ../default/openapi/openapi.json + CatalogDiscountType: + enum: + - FIXED_PERCENTAGE + - FIXED_AMOUNT + - VARIABLE_PERCENTAGE + - VARIABLE_AMOUNT + docs: How to apply a CatalogDiscount to a CatalogItem. + source: + openapi: ../default/openapi/openapi.json + CatalogEcomSeoData: + docs: SEO data for for a seller's Square Online store. + properties: + page_title: + type: optional> + docs: The SEO title used for the Square Online store. + page_description: + type: optional> + docs: The SEO description used for the Square Online store. + permalink: + type: optional> + docs: The SEO permalink used for the Square Online store. + source: + openapi: ../default/openapi/openapi.json + CatalogIdMapping: + docs: >- + A mapping between a temporary client-supplied ID and a permanent + server-generated ID. + + + When calling + [UpsertCatalogObject](api-endpoint:Catalog-UpsertCatalogObject) or + + [BatchUpsertCatalogObjects](api-endpoint:Catalog-BatchUpsertCatalogObjects) + to + + create a [CatalogObject](entity:CatalogObject) instance, you can supply + + a temporary ID for the to-be-created object, especially when the object is + to be referenced + + elsewhere in the same request body. This temporary ID can be any string + unique within + + the call, but must be prefixed by "#". + + + After the request is submitted and the object created, a permanent + server-generated ID is assigned + + to the new object. The permanent ID is unique across the Square catalog. + properties: + client_object_id: + type: optional> + docs: >- + The client-supplied temporary `#`-prefixed ID for a new + `CatalogObject`. + object_id: + type: optional> + docs: The permanent ID for the CatalogObject created by the server. + source: + openapi: ../default/openapi/openapi.json + CatalogImage: + docs: >- + An image file to use in Square catalogs. It can be associated with + + `CatalogItem`, `CatalogItemVariation`, `CatalogCategory`, and + `CatalogModifierList` objects. + + Only the images on items and item variations are exposed in Dashboard. + + Only the first image on an item is displayed in Square Point of Sale + (SPOS). + + Images on items and variations are displayed through Square Online Store. + + Images on other object types are for use by 3rd party application + developers. + properties: + name: + type: optional> + docs: >- + The internal name to identify this image in calls to the Square API. + + This is a searchable attribute for use in applicable query filters + + using the + [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects). + + It is not unique and should not be shown in a buyer facing context. + url: + type: optional> + docs: >- + The URL of this image, generated by Square after an image is uploaded + + using the + [CreateCatalogImage](api-endpoint:Catalog-CreateCatalogImage) + endpoint. + + To modify the image, use the UpdateCatalogImage endpoint. Do not + change the URL field. + caption: + type: optional> + docs: >- + A caption that describes what is shown in the image. Displayed in the + + Square Online Store. This is a searchable attribute for use in + applicable query filters + + using the + [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects). + photo_studio_order_id: + type: optional> + docs: >- + The immutable order ID for this image object created by the Photo + Studio service in Square Online Store. + source: + openapi: ../default/openapi/openapi.json + CatalogInfoResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + limits: + type: optional + docs: Limits that apply to this API. + standard_unit_description_group: + type: optional + docs: Names and abbreviations for standard units. + source: + openapi: ../default/openapi/openapi.json + CatalogInfoResponseLimits: + properties: + batch_upsert_max_objects_per_batch: + type: optional> + docs: >- + The maximum number of objects that may appear within a single batch in + a + + `/v2/catalog/batch-upsert` request. + batch_upsert_max_total_objects: + type: optional> + docs: |- + The maximum number of objects that may appear across all batches in a + `/v2/catalog/batch-upsert` request. + batch_retrieve_max_object_ids: + type: optional> + docs: >- + The maximum number of object IDs that may appear in a + `/v2/catalog/batch-retrieve` + + request. + search_max_page_limit: + type: optional> + docs: |- + The maximum number of results that may be returned in a page of a + `/v2/catalog/search` response. + batch_delete_max_object_ids: + type: optional> + docs: |- + The maximum number of object IDs that may be included in a single + `/v2/catalog/batch-delete` request. + update_item_taxes_max_item_ids: + type: optional> + docs: |- + The maximum number of item IDs that may be included in a single + `/v2/catalog/update-item-taxes` request. + update_item_taxes_max_taxes_to_enable: + type: optional> + docs: >- + The maximum number of tax IDs to be enabled that may be included in a + single + + `/v2/catalog/update-item-taxes` request. + update_item_taxes_max_taxes_to_disable: + type: optional> + docs: >- + The maximum number of tax IDs to be disabled that may be included in a + single + + `/v2/catalog/update-item-taxes` request. + update_item_modifier_lists_max_item_ids: + type: optional> + docs: |- + The maximum number of item IDs that may be included in a single + `/v2/catalog/update-item-modifier-lists` request. + update_item_modifier_lists_max_modifier_lists_to_enable: + type: optional> + docs: >- + The maximum number of modifier list IDs to be enabled that may be + included in + + a single `/v2/catalog/update-item-modifier-lists` request. + update_item_modifier_lists_max_modifier_lists_to_disable: + type: optional> + docs: >- + The maximum number of modifier list IDs to be disabled that may be + included in + + a single `/v2/catalog/update-item-modifier-lists` request. + source: + openapi: ../default/openapi/openapi.json + CatalogItem: + docs: >- + A [CatalogObject](entity:CatalogObject) instance of the `ITEM` type, also + referred to as an item, in the catalog. + properties: + name: + type: optional> + docs: >- + The item's name. This is a searchable attribute for use in applicable + query filters, its value must not be empty, and the length is of + Unicode code points. + validation: + maxLength: 512 + description: + type: optional> + docs: >- + The item's description. This is a searchable attribute for use in + applicable query filters, and its value length is of Unicode code + points. + + + Deprecated at 2022-07-20, this field is planned to retire in 6 months. + You should migrate to use `description_html` to set the description + + of the [CatalogItem](entity:CatalogItem) instance. The `description` + and `description_html` field values are kept in sync. If you try to + + set the both fields, the `description_html` text value overwrites the + `description` value. Updates in one field are also reflected in the + other, + + except for when you use an early version before Square API 2022-07-20 + and `description_html` is set to blank, setting the `description` + value to null + + does not nullify `description_html`. + validation: + maxLength: 4096 + abbreviation: + type: optional> + docs: >- + The text of the item's display label in the Square Point of Sale app. + Only up to the first five characters of the string are used. + + This attribute is searchable, and its value length is of Unicode code + points. + validation: + maxLength: 24 + label_color: + type: optional> + docs: >- + The color of the item's display label in the Square Point of Sale app. + This must be a valid hex color code. + is_taxable: + type: optional> + docs: >- + Indicates whether the item is taxable (`true`) or non-taxable + (`false`). Default is `true`. + category_id: + type: optional> + docs: >- + The ID of the item's category, if any. Deprecated since 2023-12-13. + Use `CatalogItem.categories`, instead. + tax_ids: + type: optional>> + docs: >- + A set of IDs indicating the taxes enabled for + + this item. When updating an item, any taxes listed here will be added + to the item. + + Taxes may also be added to or deleted from an item using + `UpdateItemTaxes`. + modifier_list_info: + type: optional>> + docs: >- + A set of `CatalogItemModifierListInfo` objects + + representing the modifier lists that apply to this item, along with + the overrides and min + + and max limits that are specific to this item. Modifier lists + + may also be added to or deleted from an item using + `UpdateItemModifierLists`. + variations: + type: optional>> + docs: >- + A list of [CatalogItemVariation](entity:CatalogItemVariation) objects + for this item. An item must have + + at least one variation. + product_type: + type: optional + docs: >- + The product type of the item. Once set, the `product_type` value + cannot be modified. + + + Items of the `LEGACY_SQUARE_ONLINE_SERVICE` and + `LEGACY_SQUARE_ONLINE_MEMBERSHIP` product types can be updated + + but cannot be created using the API. + + See [CatalogItemProductType](#type-catalogitemproducttype) for + possible values + skip_modifier_screen: + type: optional> + docs: >- + If `false`, the Square Point of Sale app will present the + `CatalogItem`'s + + details screen immediately, allowing the merchant to choose + `CatalogModifier`s + + before adding the item to the cart. This is the default behavior. + + + If `true`, the Square Point of Sale app will immediately add the item + to the cart with the pre-selected + + modifiers, and merchants can edit modifiers by drilling down onto the + item's details. + + + Third-party clients are encouraged to implement similar behaviors. + item_options: + type: optional>> + docs: |- + List of item options IDs for this item. Used to manage and group item + variations in a specified order. + + Maximum: 6 item options. + ecom_uri: + type: optional> + docs: >- + Deprecated. A URI pointing to a published e-commerce product page for + the Item. + ecom_image_uris: + type: optional>> + docs: >- + Deprecated. A comma-separated list of encoded URIs pointing to a set + of published e-commerce images for the Item. + image_ids: + type: optional>> + docs: |- + The IDs of images associated with this `CatalogItem` instance. + These images will be shown to customers in Square Online Store. + The first image will show up as the icon for this item in POS. + sort_name: + type: optional> + docs: >- + A name to sort the item by. If this name is unspecified, namely, the + `sort_name` field is absent, the regular `name` field is used for + sorting. + + Its value must not be empty. + + + It is currently supported for sellers of the Japanese locale only. + categories: + type: optional>> + docs: The list of categories. + description_html: + type: optional> + docs: >- + The item's description as expressed in valid HTML elements. The length + of this field value, including those of HTML tags, + + is of Unicode points. With application query filters, the text values + of the HTML elements and attributes are searchable. Invalid or + + unsupported HTML elements or attributes are ignored. + + + Supported HTML elements include: + + - `a`: Link. Supports linking to website URLs, email address, and + telephone numbers. + + - `b`, `strong`: Bold text + + - `br`: Line break + + - `code`: Computer code + + - `div`: Section + + - `h1-h6`: Headings + + - `i`, `em`: Italics + + - `li`: List element + + - `ol`: Numbered list + + - `p`: Paragraph + + - `ul`: Bullet list + + - `u`: Underline + + + + Supported HTML attributes include: + + - `align`: Alignment of the text content + + - `href`: Link destination + + - `rel`: Relationship between link's target and source + + - `target`: Place to open the linked document + validation: + maxLength: 65535 + description_plaintext: + type: optional + docs: >- + A server-generated plaintext version of the `description_html` field, + without formatting tags. + validation: + maxLength: 65535 + access: read-only + channels: + type: optional>> + docs: >- + 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. + is_archived: + type: optional> + docs: Indicates whether this item is archived (`true`) or not (`false`). + ecom_seo_data: + type: optional + docs: The SEO data for a seller's Square Online store. + food_and_beverage_details: + type: optional + docs: The food and beverage-specific details for the `FOOD_AND_BEV` item. + reporting_category: + type: optional + docs: The item's reporting category. + is_alcoholic: + type: optional> + docs: Indicates whether this item is alcoholic (`true`) or not (`false`). + source: + openapi: ../default/openapi/openapi.json + CatalogItemFoodAndBeverageDetails: + docs: The food and beverage-specific details of a `FOOD_AND_BEV` item. + properties: + calorie_count: + type: optional> + docs: >- + The calorie count (in the unit of kcal) for the `FOOD_AND_BEV` type of + items. + dietary_preferences: + type: >- + optional>> + docs: The dietary preferences for the `FOOD_AND_BEV` item. + ingredients: + type: optional>> + docs: The ingredients for the `FOOD_AND_BEV` type item. + source: + openapi: ../default/openapi/openapi.json + CatalogItemFoodAndBeverageDetailsDietaryPreference: + docs: >- + Dietary preferences that can be assigned to an `FOOD_AND_BEV` item and its + ingredients. + properties: + type: + type: optional + docs: >- + The dietary preference type. Supported values include `STANDARD` and + `CUSTOM` as specified in + `FoodAndBeverageDetails.DietaryPreferenceType`. + + See [DietaryPreferenceType](#type-dietarypreferencetype) for possible + values + standard_name: + type: >- + optional + docs: >- + The name of the dietary preference from a standard pre-defined list. + This should be null if it's a custom dietary preference. + + See [StandardDietaryPreference](#type-standarddietarypreference) for + possible values + custom_name: + type: optional> + docs: >- + The name of a user-defined custom dietary preference. This should be + null if it's a standard dietary preference. + source: + openapi: ../default/openapi/openapi.json + CatalogItemFoodAndBeverageDetailsDietaryPreferenceStandardDietaryPreference: + enum: + - DAIRY_FREE + - GLUTEN_FREE + - HALAL + - KOSHER + - NUT_FREE + - VEGAN + - VEGETARIAN + docs: >- + Standard dietary preferences for food and beverage items that are + recommended on item creation. + source: + openapi: ../default/openapi/openapi.json + CatalogItemFoodAndBeverageDetailsDietaryPreferenceType: + enum: + - STANDARD + - CUSTOM + docs: >- + The type of dietary preference for the `FOOD_AND_BEV` type of items and + integredients. + source: + openapi: ../default/openapi/openapi.json + CatalogItemFoodAndBeverageDetailsIngredient: + docs: Describes the ingredient used in a `FOOD_AND_BEV` item. + properties: + type: + type: optional + docs: >- + The dietary preference type of the ingredient. Supported values + include `STANDARD` and `CUSTOM` as specified in + `FoodAndBeverageDetails.DietaryPreferenceType`. + + See [DietaryPreferenceType](#type-dietarypreferencetype) for possible + values + standard_name: + type: >- + optional + docs: >- + The name of the ingredient from a standard pre-defined list. This + should be null if it's a custom dietary preference. + + See [StandardIngredient](#type-standardingredient) for possible values + custom_name: + type: optional> + docs: >- + The name of a custom user-defined ingredient. This should be null if + it's a standard dietary preference. + source: + openapi: ../default/openapi/openapi.json + CatalogItemFoodAndBeverageDetailsIngredientStandardIngredient: + enum: + - CELERY + - CRUSTACEANS + - EGGS + - FISH + - GLUTEN + - LUPIN + - MILK + - MOLLUSCS + - MUSTARD + - PEANUTS + - SESAME + - SOY + - SULPHITES + - TREE_NUTS + docs: >- + Standard ingredients for food and beverage items that are recommended on + item creation. + source: + openapi: ../default/openapi/openapi.json + CatalogItemModifierListInfo: + docs: >- + Controls how a modifier list is applied to a specific item. This object + allows for item-specific customization of modifier list behavior + + and provides the ability to override global modifier list settings. + properties: + modifier_list_id: + type: string + docs: >- + The ID of the `CatalogModifierList` controlled by this + `CatalogModifierListInfo`. + validation: + minLength: 1 + modifier_overrides: + type: optional>> + docs: >- + A set of `CatalogModifierOverride` objects that override default + modifier settings for this item. + min_selected_modifiers: + type: optional> + docs: >- + The minimum number of modifiers that must be selected from this + modifier list. + + Values: + + + - 0: No selection is required. + + - -1: Default value, the attribute was not set by the client. When + `max_selected_modifiers` is + + also -1, use the minimum and maximum selection values set on the + `CatalogItemModifierList`. + + - >0: The required minimum modifier selections. This can be larger + than the total `CatalogModifiers` when `allow_quantities` is enabled. + + - < -1: Invalid. Treated as no selection required. + max_selected_modifiers: + type: optional> + docs: >- + The maximum number of modifiers that can be selected. + + Values: + + + - 0: No maximum limit. + + - -1: Default value, the attribute was not set by the client. When + `min_selected_modifiers` is + + also -1, use the minimum and maximum selection values set on the + `CatalogItemModifierList`. + + - >0: The maximum total modifier selections. This can be larger + than the total `CatalogModifiers` when `allow_quantities` is enabled. + + - < -1: Invalid. Treated as no maximum limit. + enabled: + type: optional> + docs: >- + If `true`, enable this `CatalogModifierList`. The default value is + `true`. + ordinal: + type: optional> + docs: >- + The position of this `CatalogItemModifierListInfo` object within the + `modifier_list_info` list applied + + to a `CatalogItem` instance. + allow_quantities: optional + is_conversational: optional + hidden_from_customer_override: optional + source: + openapi: ../default/openapi/openapi.json + CatalogItemOption: + docs: A group of variations for a `CatalogItem`. + properties: + name: + type: optional> + docs: >- + The item option's display name for the seller. Must be unique across + + all item options. This is a searchable attribute for use in applicable + query filters. + display_name: + type: optional> + docs: >- + The item option's display name for the customer. This is a searchable + attribute for use in applicable query filters. + description: + type: optional> + docs: >- + The item option's human-readable description. Displayed in the Square + + Point of Sale app for the seller and in the Online Store or on + receipts for + + the buyer. This is a searchable attribute for use in applicable query + filters. + show_colors: + type: optional> + docs: If true, display colors for entries in `values` when present. + values: + type: optional>> + docs: |- + A list of CatalogObjects containing the + `CatalogItemOptionValue`s for this item. + source: + openapi: ../default/openapi/openapi.json + CatalogItemOptionForItem: + docs: |2- + An option that can be assigned to an item. + For example, a t-shirt item may offer a color option or a size option. + properties: + item_option_id: + type: optional> + docs: >- + The unique id of the item option, used to form the dimensions of the + item option matrix in a specified order. + source: + openapi: ../default/openapi/openapi.json + CatalogItemOptionValue: + docs: |- + An enumerated value that can link a + `CatalogItemVariation` to an item option as one of + its item option values. + properties: + item_option_id: + type: optional> + docs: Unique ID of the associated item option. + name: + type: optional> + docs: >- + Name of this item option value. This is a searchable attribute for use + in applicable query filters. + description: + type: optional> + docs: >- + A human-readable description for the option value. This is a + searchable attribute for use in applicable query filters. + color: + type: optional> + docs: >- + The HTML-supported hex color for the item option (e.g., "#ff8d4e85"). + + Only displayed if `show_colors` is enabled on the parent `ItemOption`. + When + + left unset, `color` defaults to white ("#ffffff") when `show_colors` + is + + enabled on the parent `ItemOption`. + ordinal: + type: optional> + docs: Determines where this option value appears in a list of option values. + source: + openapi: ../default/openapi/openapi.json + CatalogItemOptionValueForItemVariation: + docs: >- + A `CatalogItemOptionValue` links an item variation to an item option as + + an item option value. For example, a t-shirt item may offer a color option + and + + a size option. An item option value would represent each variation of + t-shirt: + + For example, "Color:Red, Size:Small" or "Color:Blue, Size:Medium". + properties: + item_option_id: + type: optional> + docs: The unique id of an item option. + item_option_value_id: + type: optional> + docs: The unique id of the selected value for the item option. + source: + openapi: ../default/openapi/openapi.json + CatalogItemProductType: + enum: + - REGULAR + - GIFT_CARD + - APPOINTMENTS_SERVICE + - FOOD_AND_BEV + - EVENT + - DIGITAL + - DONATION + - LEGACY_SQUARE_ONLINE_SERVICE + - LEGACY_SQUARE_ONLINE_MEMBERSHIP + docs: >- + The type of a CatalogItem. Connect V2 only allows the creation of + `REGULAR` or `APPOINTMENTS_SERVICE` items. + source: + openapi: ../default/openapi/openapi.json + CatalogItemVariation: + docs: >- + An item variation, representing a product for sale, in the Catalog object + model. Each [item](entity:CatalogItem) must have at least one + + item variation and can have at most 250 item variations. + + + An item variation can be sellable, stockable, or both if it has a unit of + measure for its count for the sold number of the variation, the stocked + + number of the variation, or both. For example, when a variation + representing wine is stocked and sold by the bottle, the variation is both + + stockable and sellable. But when a variation of the wine is sold by the + glass, the sold units cannot be used as a measure of the stocked units. + This by-the-glass + + variation is sellable, but not stockable. To accurately keep track of the + wine's inventory count at any time, the sellable count must be + + converted to stockable count. Typically, the seller defines this unit + conversion. For example, 1 bottle equals 5 glasses. The Square API exposes + + the `stockable_conversion` property on the variation to specify the + conversion. Thus, when two glasses of the wine are sold, the sellable + count + + decreases by 2, and the stockable count automatically decreases by 0.4 + bottle according to the conversion. + properties: + item_id: + type: optional> + docs: The ID of the `CatalogItem` associated with this item variation. + name: + type: optional> + docs: >- + The item variation's name. This is a searchable attribute for use in + applicable query filters. + + + Its value has a maximum length of 255 Unicode code points. However, + when the parent [item](entity:CatalogItem) + + uses [item options](entity:CatalogItemOption), this attribute is + auto-generated, read-only, and can be + + longer than 255 Unicode code points. + sku: + type: optional> + docs: >- + The item variation's SKU, if any. This is a searchable attribute for + use in applicable query filters. + upc: + type: optional> + docs: >- + The universal product code (UPC) of the item variation, if any. This + is a searchable attribute for use in applicable query filters. + + + The value of this attribute should be a number of 12-14 digits long. + This restriction is enforced on the Square Seller Dashboard, + + Square Point of Sale or Retail Point of Sale apps, where this + attribute shows in the GTIN field. If a non-compliant UPC value is + assigned + + to this attribute using the API, the value is not editable on the + Seller Dashboard, Square Point of Sale or Retail Point of Sale apps + + unless it is updated to fit the expected format. + ordinal: + type: optional + docs: >- + The order in which this item variation should be displayed. This value + is read-only. On writes, the ordinal + + for each item variation within a parent `CatalogItem` is set according + to the item variations's + + position. On reads, the value is not guaranteed to be sequential or + unique. + access: read-only + pricing_type: + type: optional + docs: >- + Indicates whether the item variation's price is fixed or determined at + the time + + of sale. + + See [CatalogPricingType](#type-catalogpricingtype) for possible values + price_money: + type: optional + docs: The item variation's price, if fixed pricing is used. + location_overrides: + type: optional>> + docs: Per-location price and inventory overrides. + track_inventory: + type: optional> + docs: If `true`, inventory tracking is active for the variation. + inventory_alert_type: + type: optional + docs: >- + Indicates whether the item variation displays an alert when its + inventory quantity is less than or equal + + to its `inventory_alert_threshold`. + + See [InventoryAlertType](#type-inventoryalerttype) for possible values + inventory_alert_threshold: + type: optional> + docs: >- + If the inventory quantity for the variation is less than or equal to + this value and `inventory_alert_type` + + is `LOW_QUANTITY`, the variation displays an alert in the merchant + dashboard. + + + This value is always an integer. + user_data: + type: optional> + docs: >- + Arbitrary user metadata to associate with the item variation. This + attribute value length is of Unicode code points. + validation: + maxLength: 255 + service_duration: + type: optional> + docs: >- + If the `CatalogItem` that owns this item variation is of type + + `APPOINTMENTS_SERVICE`, then this is the duration of the service in + milliseconds. For + + example, a 30 minute appointment would have the value `1800000`, which + is equal to + + 30 (minutes) * 60 (seconds per minute) * 1000 (milliseconds per + second). + available_for_booking: + type: optional> + docs: >- + If the `CatalogItem` that owns this item variation is of type + + `APPOINTMENTS_SERVICE`, a bool representing whether this service is + available for booking. + item_option_values: + type: optional>> + docs: |- + List of item option values associated with this item variation. Listed + in the same order as the item options of the parent item. + measurement_unit_id: + type: optional> + docs: >- + ID of the ‘CatalogMeasurementUnit’ that is used to measure the + quantity + + sold of this item variation. If left unset, the item will be sold in + + whole quantities. + sellable: + type: optional> + docs: >- + Whether this variation can be sold. The inventory count of a sellable + variation indicates + + the number of units available for sale. When a variation is both + stockable and sellable, + + its sellable inventory count can be smaller than or equal to its + stockable count. + stockable: + type: optional> + docs: >- + Whether stock is counted directly on this variation (TRUE) or only on + its components (FALSE). + + When a variation is both stockable and sellable, the inventory count + of a stockable variation keeps track of the number of units of this + variation in stock + + and is not an indicator of the number of units of the variation that + can be sold. + image_ids: + type: optional>> + docs: >- + The IDs of images associated with this `CatalogItemVariation` + instance. + + These images will be shown to customers in Square Online Store. + team_member_ids: + type: optional>> + docs: >- + Tokens of employees that can perform the service represented by this + variation. Only valid for + + variations of type `APPOINTMENTS_SERVICE`. + stockable_conversion: + type: optional + docs: >- + The unit conversion rule, as prescribed by the + [CatalogStockConversion](entity:CatalogStockConversion) type, + + that describes how this non-stockable (i.e., sellable/receivable) item + variation is converted + + to/from the stockable item variation sharing the same parent item. + With the stock conversion, + + you can accurately track inventory when an item variation is sold in + one unit, but stocked in + + another unit. + source: + openapi: ../default/openapi/openapi.json + CatalogMeasurementUnit: + docs: |- + Represents the unit used to measure a `CatalogItemVariation` and + specifies the precision for decimal quantities. + properties: + measurement_unit: + type: optional + docs: >- + Indicates the unit used to measure the quantity of a catalog item + variation. + precision: + type: optional> + docs: >- + An integer between 0 and 5 that represents the maximum number of + + positions allowed after the decimal in quantities measured with this + unit. + + For example: + + + - if the precision is 0, the quantity can be 1, 2, 3, etc. + + - if the precision is 1, the quantity can be 0.1, 0.2, etc. + + - if the precision is 2, the quantity can be 0.01, 0.12, etc. + + + Default: 3 + source: + openapi: ../default/openapi/openapi.json + CatalogModifier: + docs: >- + A modifier that can be applied to items at the time of sale. For example, + a cheese modifier for a burger, or a flavor modifier for a serving of ice + cream. + properties: + name: + type: optional> + docs: >- + The modifier name. This is a searchable attribute for use in + applicable query filters, and its value length is of Unicode code + points. + validation: + maxLength: 255 + price_money: + type: optional + docs: The modifier price. + on_by_default: + type: optional> + docs: >- + When `true`, this modifier is selected by default when displaying the + modifier list. + + This setting can be overridden at the item level using + `CatalogModifierListInfo.modifier_overrides`. + ordinal: + type: optional> + docs: >- + Determines where this `CatalogModifier` appears in the + `CatalogModifierList`. + modifier_list_id: + type: optional> + docs: The ID of the `CatalogModifierList` associated with this modifier. + location_overrides: + type: optional>> + docs: Location-specific price overrides. + image_id: + type: optional> + docs: >- + The ID of the image associated with this `CatalogModifier` instance. + + Currently this image is not displayed by Square, but is free to be + displayed in 3rd party applications. + hidden_online: + type: optional> + docs: >- + When `true`, this modifier is hidden from online ordering channels. + This setting can be overridden at the item level using + `CatalogModifierListInfo.modifier_overrides`. + source: + openapi: ../default/openapi/openapi.json + CatalogModifierList: + docs: >- + A container for a list of modifiers, or a text-based modifier. + + For text-based modifiers, this represents text configuration for an item. + (For example, custom text to print on a t-shirt). + + For non text-based modifiers, this represents a list of modifiers that can + be applied to items at the time of sale. + + (For example, a list of condiments for a hot dog, or a list of ice cream + flavors). + + Each element of the modifier list is a `CatalogObject` instance of the + `MODIFIER` type. + properties: + name: + type: optional> + docs: >- + The name of the `CatalogModifierList` instance. This is a searchable + attribute for use in applicable query filters, and its value length is + of + + Unicode code points. + validation: + maxLength: 255 + ordinal: + type: optional> + docs: >- + The position of this `CatalogModifierList` within a list of + `CatalogModifierList` instances. + selection_type: + type: optional + docs: >- + __Deprecated__: Indicates whether a single (`SINGLE`) modifier or + multiple (`MULTIPLE`) modifiers can be selected. Use + + `min_selected_modifiers` and `max_selected_modifiers` instead. + + See + [CatalogModifierListSelectionType](#type-catalogmodifierlistselectiontype) + for possible values + modifiers: + type: optional>> + docs: >- + A non-empty list of `CatalogModifier` objects to be included in the + `CatalogModifierList`, + + for non text-based modifiers when the `modifier_type` attribute is + `LIST`. Each element of this list + + is a `CatalogObject` instance of the `MODIFIER` type, containing the + following attributes: + + ``` + + { + + "id": "{{catalog_modifier_id}}", + + "type": "MODIFIER", + + "modifier_data": {{a CatalogModifier instance>}} + + } + + ``` + image_ids: + type: optional>> + docs: >- + The IDs of images associated with this `CatalogModifierList` instance. + + Currently these images are not displayed on Square products, but may + be displayed in 3rd-party applications. + allow_quantities: + type: optional> + docs: >- + When `true`, allows multiple quantities of the same modifier to be + selected. + is_conversational: + type: optional> + docs: True if modifiers belonging to this list can be used conversationally. + modifier_type: + type: optional + docs: >- + The type of the modifier. + + + When this `modifier_type` value is `TEXT`, the `CatalogModifierList` + represents a text-based modifier. + + When this `modifier_type` value is `LIST`, the `CatalogModifierList` + contains a list of `CatalogModifier` objects. + + See + [CatalogModifierListModifierType](#type-catalogmodifierlistmodifiertype) + for possible values + max_length: + type: optional> + docs: >- + The maximum length, in Unicode points, of the text string of the + text-based modifier as represented by + + this `CatalogModifierList` object with the `modifier_type` set to + `TEXT`. + text_required: + type: optional> + docs: >- + Whether the text string must be a non-empty string (`true`) or not + (`false`) for a text-based modifier + + as represented by this `CatalogModifierList` object with the + `modifier_type` set to `TEXT`. + internal_name: + type: optional> + docs: >- + A note for internal use by the business. + + + For example, for a text-based modifier applied to a T-shirt item, if + the buyer-supplied text of "Hello, Kitty!" + + is to be printed on the T-shirt, this `internal_name` attribute can be + "Use italic face" as + + an instruction for the business to follow. + + + For non text-based modifiers, this `internal_name` attribute can be + + used to include SKUs, internal codes, or supplemental descriptions for + internal use. + validation: + maxLength: 512 + min_selected_modifiers: + type: optional> + docs: >- + The minimum number of modifiers that must be selected from this list. + The value can be overridden with `CatalogItemModifierListInfo`. + + + Values: + + + - 0: No selection is required. + + - -1: Default value, the attribute was not set by the client. Treated + as no selection required. + + - >0: The required minimum modifier selections. This can be larger + than the total `CatalogModifiers` when `allow_quantities` is enabled. + + - < -1: Invalid. Treated as no selection required. + max_selected_modifiers: + type: optional> + docs: >- + The maximum number of modifiers that must be selected from this list. + The value can be overridden with `CatalogItemModifierListInfo`. + + + Values: + + + - 0: No maximum limit. + + - -1: Default value, the attribute was not set by the client. Treated + as no maximum limit. + + - >0: The maximum total modifier selections. This can be larger + than the total `CatalogModifiers` when `allow_quantities` is enabled. + + - < -1: Invalid. Treated as no maximum limit. + hidden_from_customer: + type: optional> + docs: >- + If `true`, modifiers from this list are hidden from customer receipts. + The default value is `false`. + + This setting can be overridden with + `CatalogItemModifierListInfo.hidden_from_customer_override`. + source: + openapi: ../default/openapi/openapi.json + CatalogModifierListModifierType: + enum: + - LIST + - TEXT + docs: Defines the type of `CatalogModifierList`. + source: + openapi: ../default/openapi/openapi.json + CatalogModifierListSelectionType: + enum: + - SINGLE + - MULTIPLE + docs: Indicates whether a CatalogModifierList supports multiple selections. + source: + openapi: ../default/openapi/openapi.json + CatalogModifierOverride: + docs: >- + Options to control how to override the default behavior of the specified + modifier. + properties: + modifier_id: + type: string + docs: >- + The ID of the `CatalogModifier` whose default behavior is being + overridden. + validation: + minLength: 1 + on_by_default: + type: optional> + docs: '__Deprecated__: Use `on_by_default_override` instead.' + hidden_online_override: optional + on_by_default_override: optional + source: + openapi: ../default/openapi/openapi.json + CatalogObject: + discriminant: type + base-properties: {} + docs: >- + The wrapper object for the catalog entries of a given object type. + + + Depending on the `type` attribute value, a `CatalogObject` instance + assumes a type-specific data to yield the corresponding type of catalog + object. + + + For example, if `type=ITEM`, the `CatalogObject` instance must have the + ITEM-specific data set on the `item_data` attribute. The resulting + `CatalogObject` instance is also a `CatalogItem` instance. + + + In general, if `type=`, the `CatalogObject` instance must + have the ``-specific data set on the `_data` + attribute. The resulting `CatalogObject` instance is also a + `Catalog` instance. + + + For a more detailed discussion of the Catalog data model, please see the + + [Design a + Catalog](https://developer.squareup.com/docs/catalog-api/design-a-catalog) + guide. + union: + ITEM: CatalogObjectItem + IMAGE: CatalogObjectImage + CATEGORY: CatalogObjectCategory + ITEM_VARIATION: CatalogObjectItemVariation + TAX: CatalogObjectTax + DISCOUNT: CatalogObjectDiscount + MODIFIER_LIST: CatalogObjectModifierList + MODIFIER: CatalogObjectModifier + PRICING_RULE: CatalogObjectPricingRule + PRODUCT_SET: CatalogObjectProductSet + TIME_PERIOD: CatalogObjectTimePeriod + MEASUREMENT_UNIT: CatalogObjectMeasurementUnit + SUBSCRIPTION_PLAN_VARIATION: CatalogObjectSubscriptionPlanVariation + ITEM_OPTION: CatalogObjectItemOption + ITEM_OPTION_VAL: CatalogObjectItemOptionValue + CUSTOM_ATTRIBUTE_DEFINITION: CatalogObjectCustomAttributeDefinition + QUICK_AMOUNTS_SETTINGS: CatalogObjectQuickAmountsSettings + SUBSCRIPTION_PLAN: CatalogObjectSubscriptionPlan + AVAILABILITY_PERIOD: CatalogObjectAvailabilityPeriod + source: + openapi: ../default/openapi/openapi.json + CatalogObjectBatch: + docs: A batch of catalog objects. + properties: + objects: + docs: A list of CatalogObjects belonging to this batch. + type: list + source: + openapi: ../default/openapi/openapi.json + CatalogObjectCategory: + docs: >- + A category that can be assigned to an item or a parent category that can + be assigned + + to another category. For example, a clothing category can be assigned to a + t-shirt item or + + be made as the parent category to the pants category. + properties: + id: + type: optional + docs: The ID of the object's category. + ordinal: + type: optional> + docs: The order of the object within the context of the category. + category_data: + type: optional + docs: >- + Structured data for a `CatalogCategory`, set for CatalogObjects of + type `CATEGORY`. + updated_at: + type: optional + docs: >- + Last modification + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + in RFC 3339 format, e.g., `"2016-08-15T23:59:33.123Z"` + + would indicate the UTC time (denoted by `Z`) of August 15, 2016 at + 23:59:33 and 123 milliseconds. + version: + type: optional + docs: >- + The version of the object. When updating an object, the version + supplied + + must match the version in the database, otherwise the write will be + rejected as conflicting. + is_deleted: + type: optional + docs: >- + If `true`, the object has been deleted from the database. Must be + `false` for new objects + + being inserted. When deleted, the `updated_at` field will equal the + deletion time. + custom_attribute_values: + type: optional> + docs: >- + A map (key-value pairs) of application-defined custom attribute + values. The value of a key-value pair + + is a [CatalogCustomAttributeValue](entity:CatalogCustomAttributeValue) + object. The key is the `key` attribute + + value defined in the associated + [CatalogCustomAttributeDefinition](entity:CatalogCustomAttributeDefinition) + + object defined by the application making the request. + + + If the `CatalogCustomAttributeDefinition` object is + + defined by another application, the + `CatalogCustomAttributeDefinition`'s key attribute value is prefixed + by + + the defining application ID. For example, if the + `CatalogCustomAttributeDefinition` has a `key` attribute of + + `"cocoa_brand"` and the defining application ID is `"abcd1234"`, the + key in the map is `"abcd1234:cocoa_brand"` + + if the application making the request is different from the + application defining the custom attribute definition. + + Otherwise, the key used in the map is simply `"cocoa_brand"`. + + + Application-defined custom attributes are set at a global + (location-independent) level. + + Custom attribute values are intended to store additional information + about a catalog object + + or associations with an entity in another system. Do not use custom + attributes + + to store any sensitive information (personally identifiable + information, card details, etc.). + catalog_v1_ids: + type: optional> + docs: >- + The Connect v1 IDs for this object at each location where it is + present, where they + + differ from the object's Connect V2 ID. The field will only be present + for objects that + + have been created or modified by legacy APIs. + present_at_all_locations: + type: optional + docs: >- + If `true`, this object is present at all locations (including future + locations), except where specified in + + the `absent_at_location_ids` field. If `false`, this object is not + present at any locations (including future locations), + + except where specified in the `present_at_location_ids` field. If not + specified, defaults to `true`. + present_at_location_ids: + type: optional> + docs: >- + A list of locations where the object is present, even if + `present_at_all_locations` is `false`. + + This can include locations that are deactivated. + absent_at_location_ids: + type: optional> + docs: >- + A list of locations where the object is not present, even if + `present_at_all_locations` is `true`. + + This can include locations that are deactivated. + image_id: + type: optional + docs: Identifies the `CatalogImage` attached to this `CatalogObject`. + source: + openapi: ../default/openapi/openapi.json + CatalogObjectBase: + properties: + id: + type: string + docs: >- + An identifier to reference this object in the catalog. When a new + `CatalogObject` + + is inserted, the client should set the id to a temporary identifier + starting with + + a "`#`" character. Other objects being inserted or updated within the + same request + + may use this identifier to refer to the new object. + + + When the server receives the new object, it will supply a unique + identifier that + + replaces the temporary identifier for all future references. + validation: + minLength: 1 + updated_at: + type: optional + docs: >- + Last modification + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + in RFC 3339 format, e.g., `"2016-08-15T23:59:33.123Z"` + + would indicate the UTC time (denoted by `Z`) of August 15, 2016 at + 23:59:33 and 123 milliseconds. + access: read-only + version: + type: optional + docs: >- + The version of the object. When updating an object, the version + supplied + + must match the version in the database, otherwise the write will be + rejected as conflicting. + is_deleted: + type: optional + docs: >- + If `true`, the object has been deleted from the database. Must be + `false` for new objects + + being inserted. When deleted, the `updated_at` field will equal the + deletion time. + custom_attribute_values: + type: optional> + docs: >- + A map (key-value pairs) of application-defined custom attribute + values. The value of a key-value pair + + is a [CatalogCustomAttributeValue](entity:CatalogCustomAttributeValue) + object. The key is the `key` attribute + + value defined in the associated + [CatalogCustomAttributeDefinition](entity:CatalogCustomAttributeDefinition) + + object defined by the application making the request. + + + If the `CatalogCustomAttributeDefinition` object is + + defined by another application, the + `CatalogCustomAttributeDefinition`'s key attribute value is prefixed + by + + the defining application ID. For example, if the + `CatalogCustomAttributeDefinition` has a `key` attribute of + + `"cocoa_brand"` and the defining application ID is `"abcd1234"`, the + key in the map is `"abcd1234:cocoa_brand"` + + if the application making the request is different from the + application defining the custom attribute definition. + + Otherwise, the key used in the map is simply `"cocoa_brand"`. + + + Application-defined custom attributes are set at a global + (location-independent) level. + + Custom attribute values are intended to store additional information + about a catalog object + + or associations with an entity in another system. Do not use custom + attributes + + to store any sensitive information (personally identifiable + information, card details, etc.). + catalog_v1_ids: + type: optional> + docs: >- + The Connect v1 IDs for this object at each location where it is + present, where they + + differ from the object's Connect V2 ID. The field will only be present + for objects that + + have been created or modified by legacy APIs. + present_at_all_locations: + type: optional + docs: >- + If `true`, this object is present at all locations (including future + locations), except where specified in + + the `absent_at_location_ids` field. If `false`, this object is not + present at any locations (including future locations), + + except where specified in the `present_at_location_ids` field. If not + specified, defaults to `true`. + present_at_location_ids: + type: optional> + docs: >- + A list of locations where the object is present, even if + `present_at_all_locations` is `false`. + + This can include locations that are deactivated. + absent_at_location_ids: + type: optional> + docs: >- + A list of locations where the object is not present, even if + `present_at_all_locations` is `true`. + + This can include locations that are deactivated. + image_id: + type: optional + docs: Identifies the `CatalogImage` attached to this `CatalogObject`. + source: + openapi: ../default/openapi/openapi.json + CatalogObjectReference: + docs: >- + A reference to a Catalog object at a specific version. In general this is + + used as an entry point into a graph of catalog objects, where the objects + exist + + at a specific version. + properties: + object_id: + type: optional> + docs: The ID of the referenced object. + catalog_version: + type: optional> + docs: The version of the object. + source: + openapi: ../default/openapi/openapi.json + CatalogObjectType: + enum: + - ITEM + - IMAGE + - CATEGORY + - ITEM_VARIATION + - TAX + - DISCOUNT + - MODIFIER_LIST + - MODIFIER + - PRICING_RULE + - PRODUCT_SET + - TIME_PERIOD + - MEASUREMENT_UNIT + - SUBSCRIPTION_PLAN_VARIATION + - ITEM_OPTION + - ITEM_OPTION_VAL + - CUSTOM_ATTRIBUTE_DEFINITION + - QUICK_AMOUNTS_SETTINGS + - SUBSCRIPTION_PLAN + - AVAILABILITY_PERIOD + docs: >- + Possible types of CatalogObjects returned from the catalog, each + + containing type-specific properties in the `*_data` field corresponding to + the specified object type. + source: + openapi: ../default/openapi/openapi.json + CatalogPricingRule: + docs: >- + Defines how discounts are automatically applied to a set of items that + match the pricing rule + + during the active time period. + properties: + name: + type: optional> + docs: |- + User-defined name for the pricing rule. For example, "Buy one get one + free" or "10% off". + time_period_ids: + type: optional>> + docs: >- + A list of unique IDs for the catalog time periods when + + this pricing rule is in effect. If left unset, the pricing rule is + always + + in effect. + discount_id: + type: optional> + docs: |- + Unique ID for the `CatalogDiscount` to take off + the price of all matched items. + match_products_id: + type: optional> + docs: >- + Unique ID for the `CatalogProductSet` that will be matched by this + rule. A match rule + + matches within the entire cart, and can match multiple times. This + field will always be set. + apply_products_id: + type: optional> + docs: >- + __Deprecated__: Please use the `exclude_products_id` field to apply + + an exclude set instead. Exclude sets allow better control over + quantity + + ranges and offer more flexibility for which matched items receive a + discount. + + + `CatalogProductSet` to apply the pricing to. + + An apply rule matches within the subset of the cart that fits the + match rules (the match set). + + An apply rule can only match once in the match set. + + If not supplied, the pricing will be applied to all products in the + match set. + + Other products retain their base price, or a price generated by other + rules. + exclude_products_id: + type: optional> + docs: >- + `CatalogProductSet` to exclude from the pricing rule. + + An exclude rule matches within the subset of the cart that fits the + match rules (the match set). + + An exclude rule can only match once in the match set. + + If not supplied, the pricing will be applied to all products in the + match set. + + Other products retain their base price, or a price generated by other + rules. + valid_from_date: + type: optional> + docs: >- + Represents the date the Pricing Rule is valid from. Represented in RFC + 3339 full-date format (YYYY-MM-DD). + valid_from_local_time: + type: optional> + docs: >- + Represents the local time the pricing rule should be valid from. + Represented in RFC 3339 partial-time format + + (HH:MM:SS). Partial seconds will be truncated. + valid_until_date: + type: optional> + docs: >- + Represents the date the Pricing Rule is valid until. Represented in + RFC 3339 full-date format (YYYY-MM-DD). + valid_until_local_time: + type: optional> + docs: >- + Represents the local time the pricing rule should be valid until. + Represented in RFC 3339 partial-time format + + (HH:MM:SS). Partial seconds will be truncated. + exclude_strategy: + type: optional + docs: >- + If an `exclude_products_id` was given, controls which subset of + matched + + products is excluded from any discounts. + + + Default value: `LEAST_EXPENSIVE` + + See [ExcludeStrategy](#type-excludestrategy) for possible values + minimum_order_subtotal_money: + type: optional + docs: |- + The minimum order subtotal (before discounts or taxes are applied) + that must be met before this rule may be applied. + customer_group_ids_any: + type: optional>> + docs: >- + A list of IDs of customer groups, the members of which are eligible + for discounts specified in this pricing rule. + + Notice that a group ID is generated by the Customers API. + + If this field is not set, the specified discount applies to matched + products sold to anyone whether the buyer + + has a customer profile created or not. If this + `customer_group_ids_any` field is set, the specified discount + + applies only to matched products sold to customers belonging to the + specified customer groups. + source: + openapi: ../default/openapi/openapi.json + CatalogPricingType: + enum: + - FIXED_PRICING + - VARIABLE_PRICING + docs: >- + Indicates whether the price of a CatalogItemVariation should be entered + manually at the time of sale. + source: + openapi: ../default/openapi/openapi.json + CatalogProductSet: + docs: >- + Represents a collection of catalog objects for the purpose of applying a + + `PricingRule`. Including a catalog object will include all of its + subtypes. + + For example, including a category in a product set will include all of its + + items and associated item variations in the product set. Including an item + in + + a product set will also include its item variations. + properties: + name: + type: optional> + docs: |- + User-defined name for the product set. For example, "Clearance Items" + or "Winter Sale Items". + product_ids_any: + type: optional>> + docs: >2- + Unique IDs for any `CatalogObject` included in this product set. Any + number of these catalog objects can be in an order for a pricing rule + to apply. + + + This can be used with `product_ids_all` in a parent + `CatalogProductSet` to + + match groups of products for a bulk discount, such as a discount for + an + + entree and side combo. + + + Only one of `product_ids_all`, `product_ids_any`, or `all_products` + can be set. + + + Max: 500 catalog object IDs. + product_ids_all: + type: optional>> + docs: >- + Unique IDs for any `CatalogObject` included in this product set. + + All objects in this set must be included in an order for a pricing + rule to apply. + + + Only one of `product_ids_all`, `product_ids_any`, or `all_products` + can be set. + + + Max: 500 catalog object IDs. + quantity_exact: + type: optional> + docs: >- + If set, there must be exactly this many items from `products_any` or + `products_all` + + in the cart for the discount to apply. + + + Cannot be combined with either `quantity_min` or `quantity_max`. + quantity_min: + type: optional> + docs: >- + If set, there must be at least this many items from `products_any` or + `products_all` + + in a cart for the discount to apply. See `quantity_exact`. Defaults to + 0 if + + `quantity_exact`, `quantity_min` and `quantity_max` are all + unspecified. + quantity_max: + type: optional> + docs: >- + If set, the pricing rule will apply to a maximum of this many items + from + + `products_any` or `products_all`. + all_products: + type: optional> + docs: >- + If set to `true`, the product set will include every item in the + catalog. + + Only one of `product_ids_all`, `product_ids_any`, or `all_products` + can be set. + source: + openapi: ../default/openapi/openapi.json + CatalogQuery: + docs: >- + A query composed of one or more different types of filters to narrow the + scope of targeted objects when calling the `SearchCatalogObjects` + endpoint. + + + Although a query can have multiple filters, only certain query types can + be combined per call to + [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects). + + Any combination of the following types may be used together: + + - [exact_query](entity:CatalogQueryExact) + + - [prefix_query](entity:CatalogQueryPrefix) + + - [range_query](entity:CatalogQueryRange) + + - [sorted_attribute_query](entity:CatalogQuerySortedAttribute) + + - [text_query](entity:CatalogQueryText) + + + All other query types cannot be combined with any others. + + + When a query filter is based on an attribute, the attribute must be + searchable. + + Searchable attributes are listed as follows, along their parent types that + can be searched for with applicable query filters. + + + Searchable attribute and objects queryable by searchable attributes: + + - `name`: `CatalogItem`, `CatalogItemVariation`, `CatalogCategory`, + `CatalogTax`, `CatalogDiscount`, `CatalogModifier`, `CatalogModifierList`, + `CatalogItemOption`, `CatalogItemOptionValue` + + - `description`: `CatalogItem`, `CatalogItemOptionValue` + + - `abbreviation`: `CatalogItem` + + - `upc`: `CatalogItemVariation` + + - `sku`: `CatalogItemVariation` + + - `caption`: `CatalogImage` + + - `display_name`: `CatalogItemOption` + + + For example, to search for [CatalogItem](entity:CatalogItem) objects by + searchable attributes, you can use + + the `"name"`, `"description"`, or `"abbreviation"` attribute in an + applicable query filter. + properties: + sorted_attribute_query: + type: optional + docs: >- + A query expression to sort returned query result by the given + attribute. + exact_query: + type: optional + docs: >- + An exact query expression to return objects with attribute name and + value + + matching the specified attribute name and value exactly. Value + matching is case insensitive. + set_query: + type: optional + docs: >- + A set query expression to return objects with attribute name and value + + matching the specified attribute name and any of the specified + attribute values exactly. + + Value matching is case insensitive. + prefix_query: + type: optional + docs: >- + A prefix query expression to return objects with attribute values + + that have a prefix matching the specified string value. Value matching + is case insensitive. + range_query: + type: optional + docs: |- + A range query expression to return objects with numeric values + that lie in the specified range. + text_query: + type: optional + docs: >- + A text query expression to return objects whose searchable attributes + contain all of the given + + keywords, irrespective of their order. For example, if a `CatalogItem` + contains custom attribute values of + + `{"name": "t-shirt"}` and `{"description": "Small, Purple"}`, the + query filter of `{"keywords": ["shirt", "sma", "purp"]}` + + returns this item. + items_for_tax_query: + type: optional + docs: >- + A query expression to return items that have any of the specified + taxes (as identified by the corresponding `CatalogTax` object IDs) + enabled. + items_for_modifier_list_query: + type: optional + docs: >- + A query expression to return items that have any of the given modifier + list (as identified by the corresponding `CatalogModifierList`s IDs) + enabled. + items_for_item_options_query: + type: optional + docs: >- + A query expression to return items that contains the specified item + options (as identified the corresponding `CatalogItemOption` IDs). + item_variations_for_item_option_values_query: + type: optional + docs: >- + A query expression to return item variations (of the + [CatalogItemVariation](entity:CatalogItemVariation) type) that + + contain all of the specified `CatalogItemOption` IDs. + source: + openapi: ../default/openapi/openapi.json + CatalogQueryExact: + docs: >- + The query filter to return the search result by exact match of the + specified attribute name and value. + properties: + attribute_name: + type: string + docs: >- + The name of the attribute to be searched. Matching of the attribute + name is exact. + validation: + minLength: 1 + attribute_value: + type: string + docs: >- + The desired value of the search attribute. Matching of the attribute + value is case insensitive and can be partial. + + For example, if a specified value of "sma", objects with the named + attribute value of "Small", "small" are both matched. + source: + openapi: ../default/openapi/openapi.json + CatalogQueryItemVariationsForItemOptionValues: + docs: >- + The query filter to return the item variations containing the specified + item option value IDs. + properties: + item_option_value_ids: + type: optional>> + docs: >- + A set of `CatalogItemOptionValue` IDs to be used to find associated + + `CatalogItemVariation`s. All ItemVariations that contain all of the + given + + Item Option Values (in any order) will be returned. + source: + openapi: ../default/openapi/openapi.json + CatalogQueryItemsForItemOptions: + docs: >- + The query filter to return the items containing the specified item option + IDs. + properties: + item_option_ids: + type: optional>> + docs: >- + A set of `CatalogItemOption` IDs to be used to find associated + + `CatalogItem`s. All Items that contain all of the given Item Options + (in any order) + + will be returned. + source: + openapi: ../default/openapi/openapi.json + CatalogQueryItemsForModifierList: + docs: >- + The query filter to return the items containing the specified modifier + list IDs. + properties: + modifier_list_ids: + docs: >- + A set of `CatalogModifierList` IDs to be used to find associated + `CatalogItem`s. + type: list + source: + openapi: ../default/openapi/openapi.json + CatalogQueryItemsForTax: + docs: The query filter to return the items containing the specified tax IDs. + properties: + tax_ids: + docs: >- + A set of `CatalogTax` IDs to be used to find associated + `CatalogItem`s. + type: list + source: + openapi: ../default/openapi/openapi.json + CatalogQueryPrefix: + docs: >- + The query filter to return the search result whose named attribute values + are prefixed by the specified attribute value. + properties: + attribute_name: + type: string + docs: The name of the attribute to be searched. + validation: + minLength: 1 + attribute_prefix: + type: string + docs: The desired prefix of the search attribute value. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + CatalogQueryRange: + docs: >- + The query filter to return the search result whose named attribute values + fall between the specified range. + properties: + attribute_name: + type: string + docs: The name of the attribute to be searched. + validation: + minLength: 1 + attribute_min_value: + type: optional> + docs: The desired minimum value for the search attribute (inclusive). + attribute_max_value: + type: optional> + docs: The desired maximum value for the search attribute (inclusive). + source: + openapi: ../default/openapi/openapi.json + CatalogQuerySet: + docs: >- + The query filter to return the search result(s) by exact match of the + specified `attribute_name` and any of + + the `attribute_values`. + properties: + attribute_name: + type: string + docs: >- + The name of the attribute to be searched. Matching of the attribute + name is exact. + validation: + minLength: 1 + attribute_values: + docs: >- + The desired values of the search attribute. Matching of the attribute + values is exact and case insensitive. + + A maximum of 250 values may be searched in a request. + type: list + source: + openapi: ../default/openapi/openapi.json + CatalogQuerySortedAttribute: + docs: The query expression to specify the key to sort search results. + properties: + attribute_name: + type: string + docs: The attribute whose value is used as the sort key. + validation: + minLength: 1 + initial_attribute_value: + type: optional> + docs: >- + The first attribute value to be returned by the query. Ascending sorts + will return only + + objects with this value or greater, while descending sorts will return + only objects with this value + + or less. If unset, start at the beginning (for ascending sorts) or end + (for descending sorts). + sort_order: + type: optional + docs: |- + The desired sort order, `"ASC"` (ascending) or `"DESC"` (descending). + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + CatalogQueryText: + docs: >- + The query filter to return the search result whose searchable attribute + values contain all of the specified keywords or tokens, independent of the + token order or case. + properties: + keywords: + docs: >- + A list of 1, 2, or 3 search keywords. Keywords with fewer than 3 + alphanumeric characters are ignored. + type: list + source: + openapi: ../default/openapi/openapi.json + CatalogQuickAmount: + docs: Represents a Quick Amount in the Catalog. + properties: + type: + type: CatalogQuickAmountType + docs: >- + Represents the type of the Quick Amount. + + See [CatalogQuickAmountType](#type-catalogquickamounttype) for + possible values + amount: + type: Money + docs: Represents the actual amount of the Quick Amount with Money type. + score: + type: optional> + docs: >- + Describes the ranking of the Quick Amount provided by machine learning + model, in the range [0, 100]. + + MANUAL type amount will always have score = 100. + ordinal: + type: optional> + docs: The order in which this Quick Amount should be displayed. + source: + openapi: ../default/openapi/openapi.json + CatalogQuickAmountType: + enum: + - QUICK_AMOUNT_TYPE_MANUAL + - QUICK_AMOUNT_TYPE_AUTO + docs: Determines the type of a specific Quick Amount. + source: + openapi: ../default/openapi/openapi.json + CatalogQuickAmountsSettings: + docs: >- + A parent Catalog Object model represents a set of Quick Amounts and the + settings control the amounts. + properties: + option: + type: CatalogQuickAmountsSettingsOption + docs: >- + Represents the option seller currently uses on Quick Amounts. + + See + [CatalogQuickAmountsSettingsOption](#type-catalogquickamountssettingsoption) + for possible values + eligible_for_auto_amounts: + type: optional> + docs: >- + Represents location's eligibility for auto amounts + + The boolean should be consistent with whether there are AUTO amounts + in the `amounts`. + amounts: + type: optional>> + docs: Represents a set of Quick Amounts at this location. + source: + openapi: ../default/openapi/openapi.json + CatalogQuickAmountsSettingsOption: + enum: + - DISABLED + - MANUAL + - AUTO + docs: Determines a seller's option on Quick Amounts feature. + source: + openapi: ../default/openapi/openapi.json + CatalogStockConversion: + docs: >- + Represents the rule of conversion between a stockable + [CatalogItemVariation](entity:CatalogItemVariation) + + and a non-stockable sell-by or receive-by `CatalogItemVariation` that + + share the same underlying stock. + properties: + stockable_item_variation_id: + type: string + docs: >- + References to the stockable + [CatalogItemVariation](entity:CatalogItemVariation) + + for this stock conversion. Selling, receiving or recounting the + non-stockable `CatalogItemVariation` + + defined with a stock conversion results in adjustments of this + stockable `CatalogItemVariation`. + + This immutable field must reference a stockable `CatalogItemVariation` + + that shares the parent [CatalogItem](entity:CatalogItem) of the + converted `CatalogItemVariation.` + validation: + minLength: 1 + stockable_quantity: + type: string + docs: >- + The quantity of the stockable item variation (as identified by + `stockable_item_variation_id`) + + equivalent to the non-stockable item variation quantity (as specified + in `nonstockable_quantity`) + + as defined by this stock conversion. It accepts a decimal number in a + string format that can take + + up to 10 digits before the decimal point and up to 5 digits after the + decimal point. + validation: + minLength: 1 + maxLength: 16 + nonstockable_quantity: + type: string + docs: >- + The converted equivalent quantity of the non-stockable + [CatalogItemVariation](entity:CatalogItemVariation) + + in its measurement unit. The `stockable_quantity` value and this + `nonstockable_quantity` value together + + define the conversion ratio between stockable item variation and the + non-stockable item variation. + + It accepts a decimal number in a string format that can take up to 10 + digits before the decimal point + + and up to 5 digits after the decimal point. + validation: + minLength: 1 + maxLength: 16 + source: + openapi: ../default/openapi/openapi.json + CatalogSubscriptionPlan: + docs: >- + Describes a subscription plan. A subscription plan represents what you + want to sell in a subscription model, and includes references to each of + the associated subscription plan variations. + + For more information, see [Subscription Plans and + Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). + properties: + name: + type: string + docs: The name of the plan. + phases: + type: optional>> + docs: >- + A list of SubscriptionPhase containing the + [SubscriptionPhase](entity:SubscriptionPhase) for this plan. + + This field it required. Not including this field will throw a + REQUIRED_FIELD_MISSING error + subscription_plan_variations: + type: optional>> + docs: The list of subscription plan variations available for this product + eligible_item_ids: + type: optional>> + docs: >- + The list of IDs of `CatalogItems` that are eligible for subscription + by this SubscriptionPlan's variations. + eligible_category_ids: + type: optional>> + docs: >- + The list of IDs of `CatalogCategory` that are eligible for + subscription by this SubscriptionPlan's variations. + all_items: + type: optional> + docs: >- + If true, all items in the merchant's catalog are subscribable by this + SubscriptionPlan. + source: + openapi: ../default/openapi/openapi.json + CatalogSubscriptionPlanVariation: + docs: >- + Describes a subscription plan variation. A subscription plan variation + represents how the subscription for a product or service is sold. + + For more information, see [Subscription Plans and + Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). + properties: + name: + type: string + docs: The name of the plan variation. + phases: + docs: >- + A list containing each [SubscriptionPhase](entity:SubscriptionPhase) + for this plan variation. + type: list + subscription_plan_id: + type: optional> + docs: The id of the subscription plan, if there is one. + monthly_billing_anchor_date: + type: optional> + docs: The day of the month the billing period starts. + can_prorate: + type: optional> + docs: Whether bills for this plan variation can be split for proration. + successor_plan_variation_id: + type: optional> + docs: >- + The ID of a "successor" plan variation to this one. If the field is + set, and this object is disabled at all + + locations, it indicates that this variation is deprecated and the + object identified by the successor ID be used in + + its stead. + source: + openapi: ../default/openapi/openapi.json + CatalogTax: + docs: A tax applicable to an item. + properties: + name: + type: optional> + docs: >- + The tax's name. This is a searchable attribute for use in applicable + query filters, and its value length is of Unicode code points. + validation: + maxLength: 255 + calculation_phase: + type: optional + docs: >- + Whether the tax is calculated based on a payment's subtotal or total. + + See [TaxCalculationPhase](#type-taxcalculationphase) for possible + values + inclusion_type: + type: optional + docs: |- + Whether the tax is `ADDITIVE` or `INCLUSIVE`. + See [TaxInclusionType](#type-taxinclusiontype) for possible values + percentage: + type: optional> + docs: >- + The percentage of the tax in decimal form, using a `'.'` as the + decimal separator and without a `'%'` sign. + + A value of `7.5` corresponds to 7.5%. For a location-specific tax + rate, contact the tax authority of the location or a tax consultant. + applies_to_custom_amounts: + type: optional> + docs: >- + If `true`, the fee applies to custom amounts entered into the Square + Point of Sale + + app that are not associated with a particular `CatalogItem`. + enabled: + type: optional> + docs: >- + A Boolean flag to indicate whether the tax is displayed as enabled + (`true`) in the Square Point of Sale app or not (`false`). + applies_to_product_set_id: + type: optional> + docs: >- + The ID of a `CatalogProductSet` object. If set, the tax is applicable + to all products in the product set. + source: + openapi: ../default/openapi/openapi.json + CatalogTimePeriod: + docs: Represents a time period - either a single period or a repeating period. + properties: + event: + type: optional> + docs: >- + An iCalendar (RFC 5545) + [event](https://tools.ietf.org/html/rfc5545#section-3.6.1), which + + specifies the name, timing, duration and recurrence of this time + period. + + + Example: + + + ``` + + DTSTART:20190707T180000 + + DURATION:P2H + + RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR + + ``` + + + Only `SUMMARY`, `DTSTART`, `DURATION` and `RRULE` fields are + supported. + + `DTSTART` must be in local (unzoned) time format. Note that while + `BEGIN:VEVENT` + + and `END:VEVENT` is not required in the request. The response will + always + + include them. + source: + openapi: ../default/openapi/openapi.json + CatalogV1Id: + docs: >- + A Square API V1 identifier of an item, including the object ID and its + associated location ID. + properties: + catalog_v1_id: + type: optional> + docs: >- + The ID for an object used in the Square API V1, if the object ID + differs from the Square API V2 object ID. + location_id: + type: optional> + docs: The ID of the `Location` this Connect V1 ID is associated with. + source: + openapi: ../default/openapi/openapi.json + CatalogVersionUpdatedEvent: + docs: Published when the catalog is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CatalogVersionUpdatedEventCatalogVersion: + properties: + updated_at: + type: optional + docs: Last modification timestamp in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CatalogVersionUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type. + object: + type: optional + docs: >- + An object containing fields and values relevant to the event. Is + absent if affected object was deleted. + source: + openapi: ../default/openapi/openapi.json + CatalogVersionUpdatedEventObject: + properties: + catalog_version: + type: optional + docs: The version of the object. + source: + openapi: ../default/openapi/openapi.json + CategoryPathToRootNode: + docs: A node in the path from a retrieved category to its root node. + properties: + category_id: + type: optional> + docs: The category's ID. + category_name: + type: optional> + docs: The category's name. + source: + openapi: ../default/openapi/openapi.json + ChangeBillingAnchorDateResponse: + docs: >- + Defines output parameters in a request to the + + [ChangeBillingAnchorDate](api-endpoint:Subscriptions-ChangeBillingAnchorDate) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The specified subscription for updating billing anchor date. + actions: + type: optional> + docs: A list of a single billing anchor date change for the subscription. + source: + openapi: ../default/openapi/openapi.json + ChangeTiming: + enum: + - IMMEDIATE + - END_OF_BILLING_CYCLE + docs: >- + Supported timings when a pending change, as an action, takes place to a + subscription. + source: + openapi: ../default/openapi/openapi.json + Channel: + properties: + id: + type: optional + docs: The channel's unique ID. + access: read-only + merchant_id: + type: optional + docs: The unique ID of the merchant this channel belongs to. + access: read-only + name: + type: optional> + docs: The name of the channel. + version: + type: optional + docs: >- + The version number which is incremented each time an update is made to + the channel. + access: read-only + reference: + type: optional + docs: Represents an entity the channel is associated with. + status: + type: optional + docs: |- + Status of the channel. + See [Status](#type-status) for possible values + created_at: + type: optional + docs: >- + The timestamp for when the channel was created, in RFC 3339 format + (for example, "2016-09-04T23:59:33.123Z"). + + For more information, see [Working with + Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + access: read-only + updated_at: + type: optional + docs: >- + The timestamp for when the channel was last updated, in RFC 3339 + format (for example, "2016-09-04T23:59:33.123Z"). + + For more information, see [Working with + Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + access: read-only + source: + openapi: ../default/openapi/openapi.json + ChannelStatus: + enum: + - ACTIVE + - INACTIVE + source: + openapi: ../default/openapi/openapi.json + ChargeRequestAdditionalRecipient: + docs: >- + Represents an additional recipient (other than the merchant) entitled to a + portion of the tender. + + Support is currently limited to USD, CAD and GBP currencies + properties: + location_id: + type: string + docs: >- + The location ID for a recipient (other than the merchant) receiving a + portion of the tender. + validation: + minLength: 1 + maxLength: 50 + description: + type: string + docs: The description of the additional recipient. + validation: + minLength: 1 + maxLength: 100 + amount_money: + type: Money + docs: The amount of money distributed to the recipient. + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettings: + properties: + location_id: + type: optional> + docs: The ID of the location that these settings apply to. + customer_notes_enabled: + type: optional> + docs: Indicates whether customers are allowed to leave notes at checkout. + policies: + type: optional>> + docs: |- + Policy information is displayed at the bottom of the checkout pages. + You can set a maximum of two policies. + branding: + type: optional + docs: The branding settings for this location. + tipping: + type: optional + docs: The tip settings for this location. + coupons: + type: optional + docs: The coupon settings for this location. + updated_at: + type: optional + docs: |- + The timestamp when the settings were last updated, in RFC 3339 format. + Examples for January 25th, 2020 6:25:34pm Pacific Standard Time: + UTC: 2020-01-26T02:25:34Z + Pacific Standard Time with UTC offset: 2020-01-25T18:25:34-08:00 + access: read-only + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettingsBranding: + properties: + header_type: + type: optional + docs: |- + Show the location logo on the checkout page. + See [HeaderType](#type-headertype) for possible values + button_color: + type: optional> + docs: >- + The HTML-supported hex color for the button on the checkout page (for + example, "#FFFFFF"). + validation: + minLength: 7 + maxLength: 7 + button_shape: + type: optional + docs: |- + The shape of the button on the checkout page. + See [ButtonShape](#type-buttonshape) for possible values + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettingsBrandingButtonShape: + enum: + - SQUARED + - ROUNDED + - PILL + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettingsBrandingHeaderType: + enum: + - BUSINESS_NAME + - FRAMED_LOGO + - FULL_WIDTH_LOGO + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettingsCoupons: + properties: + enabled: + type: optional> + docs: Indicates whether coupons are enabled for this location. + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettingsPolicy: + properties: + uid: + type: optional> + docs: >- + A unique ID to identify the policy when making changes. You must set + the UID for policy updates, but it’s optional when setting new + policies. + title: + type: optional> + docs: >- + The title of the policy. This is required when setting the + description, though you can update it in a different request. + validation: + maxLength: 50 + description: + type: optional> + docs: The description of the policy. + validation: + maxLength: 4096 + source: + openapi: ../default/openapi/openapi.json + CheckoutLocationSettingsTipping: + properties: + percentages: + type: optional>> + docs: >- + Set three custom percentage amounts that buyers can select at + checkout. If Smart Tip is enabled, this only applies to transactions + totaling $10 or more. + smart_tipping_enabled: + type: optional> + docs: >- + Enables Smart Tip Amounts. If Smart Tip Amounts is enabled, tipping + works as follows: + + If a transaction is less than $10, the available tipping options + include No Tip, $1, $2, or $3. + + If a transaction is $10 or more, the available tipping options include + No Tip, 15%, 20%, or 25%. + + You can set custom percentage amounts with the `percentages` field. + default_percent: + type: optional> + docs: >- + Set the pre-selected percentage amounts that appear at checkout. If + Smart Tip is enabled, this only applies to transactions totaling $10 + or more. + smart_tips: + type: optional>> + docs: Show the Smart Tip Amounts for this location. + default_smart_tip: + type: optional + docs: >- + Set the pre-selected whole amount that appears at checkout when Smart + Tip is enabled and the transaction amount is less than $10. + source: + openapi: ../default/openapi/openapi.json + CheckoutMerchantSettings: + properties: + payment_methods: + type: optional + docs: The set of payment methods accepted for the merchant's account. + updated_at: + type: optional + docs: |- + The timestamp when the settings were last updated, in RFC 3339 format. + Examples for January 25th, 2020 6:25:34pm Pacific Standard Time: + UTC: 2020-01-26T02:25:34Z + Pacific Standard Time with UTC offset: 2020-01-25T18:25:34-08:00 + access: read-only + source: + openapi: ../default/openapi/openapi.json + CheckoutMerchantSettingsPaymentMethods: + properties: + apple_pay: optional + google_pay: optional + cash_app: optional + afterpay_clearpay: optional + source: + openapi: ../default/openapi/openapi.json + CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay: + docs: The settings allowed for AfterpayClearpay. + properties: + order_eligibility_range: + type: >- + optional + docs: >- + Afterpay is shown as an option for order totals falling within the + configured range. + item_eligibility_range: + type: >- + optional + docs: >- + Afterpay is shown as an option for item totals falling within the + configured range. + enabled: + type: optional + docs: Indicates whether the payment method is enabled for the account. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CheckoutMerchantSettingsPaymentMethodsAfterpayClearpayEligibilityRange: + docs: A range of purchase price that qualifies. + properties: + min: Money + max: Money + source: + openapi: ../default/openapi/openapi.json + CheckoutMerchantSettingsPaymentMethodsPaymentMethod: + docs: The settings allowed for a payment method. + properties: + enabled: + type: optional> + docs: Indicates whether the payment method is enabled for the account. + source: + openapi: ../default/openapi/openapi.json + CheckoutOptions: + properties: + allow_tipping: + type: optional> + docs: Indicates whether the payment allows tipping. + custom_fields: + type: optional>> + docs: The custom fields requesting information from the buyer. + subscription_plan_id: + type: optional> + docs: >- + The ID of the subscription plan for the buyer to pay and subscribe. + + For more information, see [Subscription Plan + Checkout](https://developer.squareup.com/docs/checkout-api/subscription-plan-checkout). + validation: + maxLength: 255 + redirect_url: + type: optional> + docs: >- + The confirmation page URL to redirect the buyer to after Square + processes the payment. + validation: + maxLength: 2048 + merchant_support_email: + type: optional> + docs: The email address that buyers can use to contact the seller. + validation: + maxLength: 256 + ask_for_shipping_address: + type: optional> + docs: Indicates whether to include the address fields in the payment form. + accepted_payment_methods: + type: optional + docs: The methods allowed for buyers during checkout. + app_fee_money: + type: optional + docs: >- + The amount of money that the developer is taking as a fee for + facilitating the payment on behalf of the seller. + + + The amount cannot be more than 90% of the total amount of the payment. + + + The amount must be specified in the smallest denomination of the + applicable currency (for example, US dollar amounts are specified in + cents). For more information, see [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/common-data-types/working-with-monetary-amounts). + + + The fee currency code must match the currency associated with the + seller that is accepting the payment. The application must be from a + developer account in the same country and using the same currency code + as the seller. For more information about the application fee + scenario, see [Take Payments and Collect + Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). + + + To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth + permission is required. For more information, see + [Permissions](https://developer.squareup.com/docs/payments-api/collect-fees/additional-considerations#permissions). + shipping_fee: + type: optional + docs: >- + The fee associated with shipping to be applied to the `Order` as a + service charge. + enable_coupon: + type: optional> + docs: >- + Indicates whether to include the `Add coupon` section for the buyer to + provide a Square marketing coupon in the payment form. + enable_loyalty: + type: optional> + docs: >- + Indicates whether to include the `REWARDS` section for the buyer to + opt in to loyalty, redeem rewards in the payment form, or both. + source: + openapi: ../default/openapi/openapi.json + CheckoutOptionsPaymentType: + enum: + - CARD_PRESENT + - MANUAL_CARD_ENTRY + - FELICA_ID + - FELICA_QUICPAY + - FELICA_TRANSPORTATION_GROUP + - FELICA_ALL + - PAYPAY + - QR_CODE + source: + openapi: ../default/openapi/openapi.json + ClearpayDetails: + docs: Additional details about Clearpay payments. + properties: + email_address: + type: optional> + docs: Email address on the buyer's Clearpay account. + validation: + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + CloneOrderResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the [CloneOrder](api-endpoint:Orders-CloneOrder) endpoint. + properties: + order: + type: optional + docs: The cloned order. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CollectedData: + properties: + input_text: + type: optional + docs: The buyer's input text. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CompletePaymentResponse: + docs: >- + Defines the response returned + by[CompletePayment](api-endpoint:Payments-CompletePayment). + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + payment: + type: optional + docs: The successfully completed payment. + source: + openapi: ../default/openapi/openapi.json + Component: + docs: The wrapper object for the component entries of a given component type. + properties: + type: + type: ComponentComponentType + docs: >- + The type of this component. Each component type has expected + properties expressed + + in a structured format within its corresponding `*_details` field. + + See [ComponentType](#type-componenttype) for possible values + application_details: + type: optional + docs: >- + Structured data for an `Application`, set for Components of type + `APPLICATION`. + card_reader_details: + type: optional + docs: >- + Structured data for a `CardReader`, set for Components of type + `CARD_READER`. + battery_details: + type: optional + docs: Structured data for a `Battery`, set for Components of type `BATTERY`. + wifi_details: + type: optional + docs: >- + Structured data for a `WiFi` interface, set for Components of type + `WIFI`. + ethernet_details: + type: optional + docs: >- + Structured data for an `Ethernet` interface, set for Components of + type `ETHERNET`. + source: + openapi: ../default/openapi/openapi.json + ComponentComponentType: + enum: + - APPLICATION + - CARD_READER + - BATTERY + - WIFI + - ETHERNET + - PRINTER + docs: An enum for ComponentType. + source: + openapi: ../default/openapi/openapi.json + ConfirmationDecision: + properties: + has_agreed: + type: optional + docs: The buyer's decision to the displayed terms. + access: read-only + source: + openapi: ../default/openapi/openapi.json + ConfirmationOptions: + properties: + title: + type: string + docs: >- + The title text to display in the confirmation screen flow on the + Terminal. + validation: + minLength: 1 + maxLength: 250 + body: + type: string + docs: >- + The agreement details to display in the confirmation flow on the + Terminal. + validation: + minLength: 1 + maxLength: 10000 + agree_button_text: + type: string + docs: >- + The button text to display indicating the customer agrees to the + displayed terms. + validation: + minLength: 1 + maxLength: 250 + disagree_button_text: + type: optional> + docs: >- + The button text to display indicating the customer does not agree to + the displayed terms. + validation: + minLength: 1 + maxLength: 250 + decision: + type: optional + docs: >- + The result of the buyer’s actions when presented with the confirmation + screen. + source: + openapi: ../default/openapi/openapi.json + Coordinates: + docs: Latitude and longitude coordinates. + properties: + latitude: + type: optional> + docs: The latitude of the coordinate expressed in degrees. + longitude: + type: optional> + docs: The longitude of the coordinate expressed in degrees. + source: + openapi: ../default/openapi/openapi.json + Country: + enum: + - ZZ + - AD + - AE + - AF + - AG + - AI + - AL + - AM + - AO + - AQ + - AR + - AS + - AT + - AU + - AW + - AX + - AZ + - BA + - BB + - BD + - BE + - BF + - BG + - BH + - BI + - BJ + - BL + - BM + - BN + - BO + - BQ + - BR + - BS + - BT + - BV + - BW + - BY + - BZ + - CA + - CC + - CD + - CF + - CG + - CH + - CI + - CK + - CL + - CM + - CN + - CO + - CR + - CU + - CV + - CW + - CX + - CY + - CZ + - DE + - DJ + - DK + - DM + - DO + - DZ + - EC + - EE + - EG + - EH + - ER + - ES + - ET + - FI + - FJ + - FK + - FM + - FO + - FR + - GA + - GB + - GD + - GE + - GF + - GG + - GH + - GI + - GL + - GM + - GN + - GP + - GQ + - GR + - GS + - GT + - GU + - GW + - GY + - HK + - HM + - HN + - HR + - HT + - HU + - ID + - IE + - IL + - IM + - IN + - IO + - IQ + - IR + - IS + - IT + - JE + - JM + - JO + - JP + - KE + - KG + - KH + - KI + - KM + - KN + - KP + - KR + - KW + - KY + - KZ + - LA + - LB + - LC + - LI + - LK + - LR + - LS + - LT + - LU + - LV + - LY + - MA + - MC + - MD + - ME + - MF + - MG + - MH + - MK + - ML + - MM + - MN + - MO + - MP + - MQ + - MR + - MS + - MT + - MU + - MV + - MW + - MX + - MY + - MZ + - NA + - NC + - NE + - NF + - NG + - NI + - NL + - 'NO' + - NP + - NR + - NU + - NZ + - OM + - PA + - PE + - PF + - PG + - PH + - PK + - PL + - PM + - PN + - PR + - PS + - PT + - PW + - PY + - QA + - RE + - RO + - RS + - RU + - RW + - SA + - SB + - SC + - SD + - SE + - SG + - SH + - SI + - SJ + - SK + - SL + - SM + - SN + - SO + - SR + - SS + - ST + - SV + - SX + - SY + - SZ + - TC + - TD + - TF + - TG + - TH + - TJ + - TK + - TL + - TM + - TN + - TO + - TR + - TT + - TV + - TW + - TZ + - UA + - UG + - UM + - US + - UY + - UZ + - VA + - VC + - VE + - VG + - VI + - VN + - VU + - WF + - WS + - YE + - YT + - ZA + - ZM + - ZW + docs: >- + Indicates the country associated with another entity, such as a business. + + Values are in [ISO 3166-1-alpha-2 + format](http://www.iso.org/iso/home/standards/country_codes.htm). + source: + openapi: ../default/openapi/openapi.json + CreateBookingCustomAttributeDefinitionResponse: + docs: >- + Represents a + [CreateBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-CreateBookingCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The newly created custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateBookingResponse: + properties: + booking: + type: optional + docs: The booking that was created. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateBreakTypeResponse: + docs: >- + 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. + properties: + break_type: + type: optional + docs: The `BreakType` that was created by the request. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateCardResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [CreateCard](api-endpoint:Cards-CreateCard) endpoint. + + + Note: if there are errors processing the request, the card field will not + be + + present. + properties: + errors: + type: optional> + docs: Errors resulting from the request. + card: + type: optional + docs: The card created by the request. + source: + openapi: ../default/openapi/openapi.json + CreateCatalogImageRequest: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this CreateCatalogImage request. + + Keys can be any valid string but must be unique for every + CreateCatalogImage request. + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 128 + object_id: + type: optional + docs: >- + Unique ID of the `CatalogObject` to attach this `CatalogImage` object + to. Leave this + + field empty to create unattached images, for example if you are + building an integration + + where an image can be attached to catalog items at a later time. + image: + type: CatalogObject + docs: >- + The new `CatalogObject` of the `IMAGE` type, namely, a `CatalogImage` + object, to encapsulate the specified image file. + is_primary: + type: optional + docs: >- + If this is set to `true`, the image created will be the primary, or + first image of the object referenced by `object_id`. + + If the `CatalogObject` already has a primary `CatalogImage`, setting + this field to `true` will replace the primary image. + + If this is set to `false` and you use the Square API version + 2021-12-15 or later, the image id will be appended to the list of + `image_ids` on the object. + + + With Square API version 2021-12-15 or later, the default value is + `false`. Otherwise, the effective default value is `true`. + source: + openapi: ../default/openapi/openapi.json + CreateCatalogImageResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + image: + type: optional + docs: |- + The newly created `CatalogImage` including a Square-generated + URL for the encapsulated image file. + source: + openapi: ../default/openapi/openapi.json + CreateCheckoutResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `CreateCheckout` endpoint. + properties: + checkout: + type: optional + docs: >- + The newly created `checkout` object associated with the provided + idempotency key. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateCustomerCardResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `CreateCustomerCard` endpoint. + + Either `errors` or `card` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + card: + type: optional + docs: The created card on file. + source: + openapi: ../default/openapi/openapi.json + CreateCustomerCustomAttributeDefinitionResponse: + docs: >- + Represents a + [CreateCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-CreateCustomerCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The new custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateCustomerGroupResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [CreateCustomerGroup](api-endpoint:CustomerGroups-CreateCustomerGroup) + endpoint. + + + Either `errors` or `group` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + group: + type: optional + docs: The successfully created customer group. + source: + openapi: ../default/openapi/openapi.json + CreateCustomerResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [CreateCustomer](api-endpoint:Customers-CreateCustomer) + or + + [BulkCreateCustomers](api-endpoint:Customers-BulkCreateCustomers) + endpoint. + + + Either `errors` or `customer` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + customer: + type: optional + docs: The created customer. + source: + openapi: ../default/openapi/openapi.json + CreateDeviceCodeResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + device_code: + type: optional + docs: The created DeviceCode object containing the device code string. + source: + openapi: ../default/openapi/openapi.json + CreateDisputeEvidenceFileRequest: + docs: Defines the parameters for a `CreateDisputeEvidenceFile` request. + properties: + idempotency_key: + type: string + docs: >- + A unique key identifying the request. For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + minLength: 1 + maxLength: 45 + evidence_type: + type: optional + docs: >- + The type of evidence you are uploading. + + See [DisputeEvidenceType](#type-disputeevidencetype) for possible + values + content_type: + type: optional + docs: >- + The MIME type of the uploaded file. + + The type can be image/heic, image/heif, image/jpeg, application/pdf, + image/png, or image/tiff. + validation: + minLength: 1 + maxLength: 40 + source: + openapi: ../default/openapi/openapi.json + CreateDisputeEvidenceFileResponse: + docs: Defines the fields in a `CreateDisputeEvidenceFile` response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + evidence: + type: optional + docs: The metadata of the newly uploaded dispute evidence. + source: + openapi: ../default/openapi/openapi.json + CreateDisputeEvidenceTextResponse: + docs: Defines the fields in a `CreateDisputeEvidenceText` response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + evidence: + type: optional + docs: The newly uploaded dispute evidence metadata. + source: + openapi: ../default/openapi/openapi.json + CreateGiftCardActivityResponse: + docs: >- + A response that contains a `GiftCardActivity` that was created. + + The response might contain a set of `Error` objects if the request + resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card_activity: + type: optional + docs: The gift card activity that was created. + source: + openapi: ../default/openapi/openapi.json + CreateGiftCardResponse: + docs: >- + A response that contains a `GiftCard`. The response might contain a set of + `Error` objects if the request + + resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card: + type: optional + docs: The new gift card. + source: + openapi: ../default/openapi/openapi.json + CreateInvoiceAttachmentRequestData: + docs: >- + Represents a + [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) + request. + properties: + idempotency_key: + type: optional + docs: >- + A unique string that identifies the `CreateInvoiceAttachment` request. + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 128 + description: + type: optional + docs: The description of the attachment to display on the invoice. + validation: + maxLength: 128 + source: + openapi: ../default/openapi/openapi.json + CreateInvoiceAttachmentResponse: + docs: >- + Represents a + [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) + response. + properties: + attachment: + type: optional + docs: Metadata about the attachment that was added to the invoice. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + CreateInvoiceResponse: + docs: The response returned by the `CreateInvoice` request. + properties: + invoice: + type: optional + docs: The newly created invoice. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + CreateJobResponse: + docs: >- + Represents a [CreateJob](api-endpoint:Team-CreateJob) response. Either + `job` or `errors` + + is present in the response. + properties: + job: + type: optional + docs: The new job. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateLocationCustomAttributeDefinitionResponse: + docs: >- + Represents a + [CreateLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-CreateLocationCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The new custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateLocationResponse: + docs: >- + The response object returned by the + [CreateLocation](api-endpoint:Locations-CreateLocation) endpoint. + properties: + errors: + type: optional> + docs: >- + Information about + [errors](https://developer.squareup.com/docs/build-basics/handling-errors) + encountered during the request. + location: + type: optional + docs: The newly created `Location` object. + source: + openapi: ../default/openapi/openapi.json + CreateLoyaltyAccountResponse: + docs: A response that includes loyalty account created. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_account: + type: optional + docs: The newly created loyalty account. + source: + openapi: ../default/openapi/openapi.json + CreateLoyaltyPromotionResponse: + docs: >- + Represents a + [CreateLoyaltyPromotion](api-endpoint:Loyalty-CreateLoyaltyPromotion) + response. + + Either `loyalty_promotion` or `errors` is present in the response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_promotion: + type: optional + docs: The new loyalty promotion. + source: + openapi: ../default/openapi/openapi.json + CreateLoyaltyRewardResponse: + docs: A response that includes the loyalty reward created. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + reward: + type: optional + docs: The loyalty reward created. + source: + openapi: ../default/openapi/openapi.json + CreateMerchantCustomAttributeDefinitionResponse: + docs: >- + Represents a + [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The new custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateMobileAuthorizationCodeResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `CreateMobileAuthorizationCode` endpoint. + properties: + authorization_code: + type: optional + docs: >- + The generated authorization code that connects a mobile application + instance + + to a Square account. + validation: + maxLength: 191 + expires_at: + type: optional + docs: >- + The timestamp when `authorization_code` expires, in + + [RFC 3339](https://tools.ietf.org/html/rfc3339) format (for example, + "2016-09-04T23:59:33.123Z"). + validation: + minLength: 20 + maxLength: 48 + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateOrderCustomAttributeDefinitionResponse: + docs: Represents a response from creating an order custom attribute definition. + properties: + custom_attribute_definition: + type: optional + docs: The new custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateOrderRequest: + properties: + order: + type: optional + docs: >- + The order to create. If this field is set, the only other top-level + field that can be + + set is the `idempotency_key`. + idempotency_key: + type: optional + docs: >- + A value you specify that uniquely identifies this + + order among orders you have created. + + + If you are unsure whether a particular order was created successfully, + + you can try it again with the same idempotency key without + + worrying about creating duplicate orders. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + CreateOrderResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `CreateOrder` endpoint. + + Either `errors` or `order` is present in a given response, but never both. + properties: + order: + type: optional + docs: The newly created order. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreatePaymentLinkResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + payment_link: + type: optional + docs: The created payment link. + related_resources: + type: optional + docs: The list of related objects. + source: + openapi: ../default/openapi/openapi.json + CreatePaymentResponse: + docs: >- + Defines the response returned by + [CreatePayment](api-endpoint:Payments-CreatePayment). + + + If there are errors processing the request, the `payment` field might not + be + + present, or it might be present with a status of `FAILED`. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + payment: + type: optional + docs: The newly created payment. + source: + openapi: ../default/openapi/openapi.json + CreateScheduledShiftResponse: + docs: >- + Represents a + [CreateScheduledShift](api-endpoint:Labor-CreateScheduledShift) response. + + Either `scheduled_shift` or `errors` is present in the response. + properties: + scheduled_shift: + type: optional + docs: >- + The new scheduled shift. To make the shift public, call + + [PublishScheduledShift](api-endpoint:Labor-PublishScheduledShift) or + + [BulkPublishScheduledShifts](api-endpoint:Labor-BulkPublishScheduledShifts). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateShiftResponse: + docs: |- + The response to a request to create a `Shift`. The response contains + the created `Shift` object and might contain a set of `Error` objects if + the request resulted in errors. + properties: + shift: + type: optional + docs: The `Shift` that was created on the request. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateSubscriptionResponse: + docs: >- + Defines output parameters in a response from the + + [CreateSubscription](api-endpoint:Subscriptions-CreateSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: >- + The newly created subscription. + + + For more information, see + + [Subscription + object](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#subscription-object). + source: + openapi: ../default/openapi/openapi.json + CreateTeamMemberRequest: + docs: Represents a create request for a `TeamMember` object. + properties: + idempotency_key: + type: optional + docs: >- + A unique string that identifies this `CreateTeamMember` request. + + Keys can be any valid string, but must be unique for every request. + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + + + The minimum length is 1 and the maximum length is 45. + team_member: + type: optional + docs: >- + **Required** The data used to create the `TeamMember` object. If you + include `wage_setting`, you must provide + + `job_id` for each job assignment. To get job IDs, call + [ListJobs](api-endpoint:Team-ListJobs). + source: + openapi: ../default/openapi/openapi.json + CreateTeamMemberResponse: + docs: >- + Represents a response from a create request containing the created + `TeamMember` object or error messages. + properties: + team_member: + type: optional + docs: The successfully created `TeamMember` object. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateTerminalActionResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + action: + type: optional + docs: The created `TerminalAction` + source: + openapi: ../default/openapi/openapi.json + CreateTerminalCheckoutResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + checkout: + type: optional + docs: The created `TerminalCheckout`. + source: + openapi: ../default/openapi/openapi.json + CreateTerminalRefundResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refund: + type: optional + docs: The created `TerminalRefund`. + source: + openapi: ../default/openapi/openapi.json + CreateTimecardResponse: + docs: >- + The response to a request to create a `Timecard`. The response contains + + the created `Timecard` object and might contain a set of `Error` objects + if + + the request resulted in errors. + properties: + timecard: + type: optional + docs: The `Timecard` that was created on the request. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + CreateTransferOrderData: + docs: >- + Data for creating a new transfer order to move + [CatalogItemVariation](entity:CatalogItemVariation)s + + between [Location](entity:Location)s. Used with the + [CreateTransferOrder](api-endpoint:TransferOrders-CreateTransferOrder) + + endpoint. + properties: + source_location_id: + type: string + docs: >- + The source [Location](entity:Location) that will send the items. Must + be an active location + + in your Square account with sufficient inventory of the requested + items. + validation: + minLength: 1 + maxLength: 64 + destination_location_id: + type: string + docs: >- + The destination [Location](entity:Location) that will receive the + items. Must be an active location + + in your Square account + validation: + minLength: 1 + maxLength: 64 + expected_at: + type: optional> + docs: >- + Expected transfer date in RFC 3339 format (e.g. + "2023-10-01T12:00:00Z"). + notes: + type: optional> + docs: Optional notes about the transfer + validation: + maxLength: 4096 + tracking_number: + type: optional> + docs: Optional shipment tracking number + validation: + maxLength: 64 + created_by_team_member_id: + type: optional> + docs: >- + ID of the [TeamMember](entity:TeamMember) creating this transfer + order. Used for tracking + + and auditing purposes. + validation: + maxLength: 64 + line_items: + type: optional>> + docs: >- + List of [CatalogItemVariation](entity:CatalogItemVariation)s to + transfer, including quantities + source: + openapi: ../default/openapi/openapi.json + CreateTransferOrderLineData: + docs: >- + Data for creating a new transfer order line item. Each line item specifies + a + + [CatalogItemVariation](entity:CatalogItemVariation) and quantity to + transfer. + properties: + item_variation_id: + type: string + docs: >- + ID of the [CatalogItemVariation](entity:CatalogItemVariation) to + transfer. Must reference a valid + + item variation in the [Catalog](api:Catalog). The item variation must + be: + + - Active and available for sale + + - Enabled for inventory tracking + + - Available at the source location + validation: + minLength: 1 + maxLength: 64 + quantity_ordered: + type: string + docs: Total quantity ordered + validation: + pattern: ^(0|[1-9]\d*)(\.\d{1,4})?$ + minLength: 1 + maxLength: 16 + source: + openapi: ../default/openapi/openapi.json + CreateTransferOrderResponse: + docs: Response for creating a transfer order. + properties: + transfer_order: + type: optional + docs: The created transfer order + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + CreateVendorResponse: + docs: >- + Represents an output from a call to + [CreateVendor](api-endpoint:Vendors-CreateVendor). + properties: + errors: + type: optional> + docs: Errors encountered when the request fails. + vendor: + type: optional + docs: The successfully created [Vendor](entity:Vendor) object. + source: + openapi: ../default/openapi/openapi.json + CreateWebhookSubscriptionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [CreateWebhookSubscription](api-endpoint:WebhookSubscriptions-CreateWebhookSubscription) + endpoint. + + + Note: if there are errors processing the request, the + [Subscription](entity:WebhookSubscription) will not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + subscription: + type: optional + docs: The new [Subscription](entity:WebhookSubscription). + source: + openapi: ../default/openapi/openapi.json + Currency: + enum: + - UNKNOWN_CURRENCY + - AED + - AFN + - ALL + - AMD + - ANG + - AOA + - ARS + - AUD + - AWG + - AZN + - BAM + - BBD + - BDT + - BGN + - BHD + - BIF + - BMD + - BND + - BOB + - BOV + - BRL + - BSD + - BTN + - BWP + - BYR + - BZD + - CAD + - CDF + - CHE + - CHF + - CHW + - CLF + - CLP + - CNY + - COP + - COU + - CRC + - CUC + - CUP + - CVE + - CZK + - DJF + - DKK + - DOP + - DZD + - EGP + - ERN + - ETB + - EUR + - FJD + - FKP + - GBP + - GEL + - GHS + - GIP + - GMD + - GNF + - GTQ + - GYD + - HKD + - HNL + - HRK + - HTG + - HUF + - IDR + - ILS + - INR + - IQD + - IRR + - ISK + - JMD + - JOD + - JPY + - KES + - KGS + - KHR + - KMF + - KPW + - KRW + - KWD + - KYD + - KZT + - LAK + - LBP + - LKR + - LRD + - LSL + - LTL + - LVL + - LYD + - MAD + - MDL + - MGA + - MKD + - MMK + - MNT + - MOP + - MRO + - MUR + - MVR + - MWK + - MXN + - MXV + - MYR + - MZN + - NAD + - NGN + - NIO + - NOK + - NPR + - NZD + - OMR + - PAB + - PEN + - PGK + - PHP + - PKR + - PLN + - PYG + - QAR + - RON + - RSD + - RUB + - RWF + - SAR + - SBD + - SCR + - SDG + - SEK + - SGD + - SHP + - SLL + - SLE + - SOS + - SRD + - SSP + - STD + - SVC + - SYP + - SZL + - THB + - TJS + - TMT + - TND + - TOP + - TRY + - TTD + - TWD + - TZS + - UAH + - UGX + - USD + - USN + - USS + - UYI + - UYU + - UZS + - VEF + - VND + - VUV + - WST + - XAF + - XAG + - XAU + - XBA + - XBB + - XBC + - XBD + - XCD + - XDR + - XOF + - XPD + - XPF + - XPT + - XTS + - XXX + - YER + - ZAR + - ZMK + - ZMW + - BTC + - XUS + docs: >- + Indicates the associated currency for an amount of money. Values + correspond + + to [ISO 4217](https://wikipedia.org/wiki/ISO_4217). + source: + openapi: ../default/openapi/openapi.json + CustomAttribute: + docs: |- + A custom attribute value. Each custom attribute value has a corresponding + `CustomAttributeDefinition` object. + properties: + key: + type: optional> + docs: >- + The identifier + + of the custom attribute definition and its corresponding custom + attributes. This value + + can be a simple key, which is the key that is provided when the custom + attribute definition + + is created, or a qualified key, if the requesting + + application is not the definition owner. The qualified key consists of + the application ID + + of the custom attribute definition owner + + followed by the simple key that was provided when the definition was + created. It has the + + format application_id:simple key. + + + The value for a simple key can contain up to 60 alphanumeric + characters, periods (.), + + underscores (_), and hyphens (-). + validation: + pattern: ^([a-zA-Z0-9\._-]+:)?[a-zA-Z0-9\._-]{1,60}$ + minLength: 1 + value: + type: optional> + docs: >- + The value assigned to the custom attribute. It is validated against + the custom + + attribute definition's schema on write operations. For more + information about custom + + attribute values, + + see [Custom Attributes + Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). + version: + type: optional + docs: >- + Read only. The current version of the custom attribute. This field is + incremented when the custom attribute is changed. + + When updating an existing custom attribute value, you can provide this + field + + and specify the current version of the custom attribute to enable + + [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency). + + This field can also be used to enforce strong consistency for reads. + For more information about strong consistency for reads, + + see [Custom Attributes + Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). + visibility: + type: optional + docs: >- + A copy of the `visibility` field value for the associated custom + attribute definition. + + See + [CustomAttributeDefinitionVisibility](#type-customattributedefinitionvisibility) + for possible values + definition: + type: optional + docs: >- + A copy of the associated custom attribute definition object. This + field is only set when + + the optional field is specified on the request. + updated_at: + type: optional + docs: >- + The timestamp that indicates when the custom attribute was created or + was most recently + + updated, in RFC 3339 format. + access: read-only + created_at: + type: optional + docs: >- + The timestamp that indicates when the custom attribute was created, in + RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CustomAttributeDefinition: + docs: >- + Represents a definition for custom attribute values. A custom attribute + definition + + specifies the key, visibility, schema, and other properties for a custom + attribute. + properties: + key: + type: optional> + docs: >- + The identifier + + of the custom attribute definition and its corresponding custom + attributes. This value + + can be a simple key, which is the key that is provided when the custom + attribute definition + + is created, or a qualified key, if the requesting + + application is not the definition owner. The qualified key consists of + the application ID + + of the custom attribute definition owner + + followed by the simple key that was provided when the definition was + created. It has the + + format application_id:simple key. + + + The value for a simple key can contain up to 60 alphanumeric + characters, periods (.), + + underscores (_), and hyphens (-). + + + This field can not be changed + + after the custom attribute definition is created. This field is + required when creating + + a definition and must be unique per application, seller, and resource + type. + validation: + pattern: ^([a-zA-Z0-9\._-]+:)?[a-zA-Z0-9\._-]{1,60}$ + minLength: 1 + schema: + type: optional>> + docs: >- + The JSON schema for the custom attribute definition, which determines + the data type of the corresponding custom attributes. For more + information, + + see [Custom Attributes + Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). + This field is required when creating a definition. + name: + type: optional> + docs: >- + The name of the custom attribute definition for API and seller-facing + UI purposes. The name must + + be unique within the seller and application pair. This field is + required if the + + `visibility` field is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + validation: + maxLength: 255 + description: + type: optional> + docs: >- + Seller-oriented description of the custom attribute definition, + including any constraints + + that the seller should observe. May be displayed as a tooltip in + Square UIs. This field is + + required if the `visibility` field is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + validation: + maxLength: 255 + visibility: + type: optional + docs: >- + Specifies how the custom attribute definition and its values should be + shared with + + the seller and other applications. If no value is specified, the value + defaults to `VISIBILITY_HIDDEN`. + + See [Visibility](#type-visibility) for possible values + version: + type: optional + docs: >- + Read only. The current version of the custom attribute definition. + + The value is incremented each time the custom attribute definition is + updated. + + When updating a custom attribute definition, you can provide this + field + + and specify the current version of the custom attribute definition to + enable + + [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency). + + + On writes, this field must be set to the latest version. Stale writes + are rejected. + + + This field can also be used to enforce strong consistency for reads. + For more information about strong consistency for reads, + + see [Custom Attributes + Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). + updated_at: + type: optional + docs: >- + The timestamp that indicates when the custom attribute definition was + created or most recently updated, + + in RFC 3339 format. + access: read-only + created_at: + type: optional + docs: >- + The timestamp that indicates when the custom attribute definition was + created, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CustomAttributeDefinitionEventData: + docs: |- + Represents an object in the CustomAttributeDefinition event notification + payload that contains the affected custom attribute definition. + properties: + type: + type: optional> + docs: >- + The type of the event data object. The value is + `"custom_attribute_definition"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the custom attribute definition. + source: + openapi: ../default/openapi/openapi.json + CustomAttributeDefinitionEventDataObject: + properties: + custom_attribute_definition: + type: optional + docs: The custom attribute definition. + source: + openapi: ../default/openapi/openapi.json + CustomAttributeDefinitionVisibility: + enum: + - VISIBILITY_HIDDEN + - VISIBILITY_READ_ONLY + - VISIBILITY_READ_WRITE_VALUES + docs: >- + The level of permission that a seller or other applications requires to + + view this custom attribute definition. + + The `Visibility` field controls who can read and write the custom + attribute values + + and custom attribute definition. + source: + openapi: ../default/openapi/openapi.json + CustomAttributeEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"custom_attribute"`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the event data object. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the custom attribute. + source: + openapi: ../default/openapi/openapi.json + CustomAttributeEventDataObject: + properties: + custom_attribute: + type: optional + docs: The custom attribute. + source: + openapi: ../default/openapi/openapi.json + CustomAttributeFilter: + docs: |- + Supported custom attribute query expressions for calling the + [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) + endpoint to search for items or item variations. + properties: + custom_attribute_definition_id: + type: optional> + docs: >- + A query expression to filter items or item variations by matching + their custom attributes' + + `custom_attribute_definition_id` property value against the the + specified id. + + Exactly one of `custom_attribute_definition_id` or `key` must be + specified. + key: + type: optional> + docs: >- + A query expression to filter items or item variations by matching + their custom attributes' + + `key` property value against the specified key. + + Exactly one of `custom_attribute_definition_id` or `key` must be + specified. + string_filter: + type: optional> + docs: >- + A query expression to filter items or item variations by matching + their custom attributes' + + `string_value` property value against the specified text. + + Exactly one of `string_filter`, `number_filter`, + `selection_uids_filter`, or `bool_filter` must be specified. + number_filter: + type: optional + docs: >- + A query expression to filter items or item variations with their + custom attributes + + containing a number value within the specified range. + + Exactly one of `string_filter`, `number_filter`, + `selection_uids_filter`, or `bool_filter` must be specified. + selection_uids_filter: + type: optional>> + docs: >- + A query expression to filter items or item variations by matching + their custom attributes' + + `selection_uid_values` values against the specified selection uids. + + Exactly one of `string_filter`, `number_filter`, + `selection_uids_filter`, or `bool_filter` must be specified. + bool_filter: + type: optional> + docs: >- + A query expression to filter items or item variations by matching + their custom attributes' + + `boolean_value` property values against the specified Boolean + expression. + + Exactly one of `string_filter`, `number_filter`, + `selection_uids_filter`, or `bool_filter` must be specified. + source: + openapi: ../default/openapi/openapi.json + CustomField: + docs: >- + Describes a custom form field to add to the checkout page to collect more + information from buyers during checkout. + + For more information, + + see [Specify checkout + options](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations#specify-checkout-options-1). + properties: + title: + type: string + docs: The title of the custom field. + validation: + minLength: 1 + maxLength: 50 + source: + openapi: ../default/openapi/openapi.json + Customer: + docs: >- + Represents a Square customer profile in the Customer Directory of a Square + seller. + properties: + id: + type: optional + docs: >- + A unique Square-assigned ID for the customer profile. + + + If you need this ID for an API request, use the ID returned when you + created the customer profile or call the + [SearchCustomers](api-endpoint:Customers-SearchCustomers) + + or [ListCustomers](api-endpoint:Customers-ListCustomers) endpoint. + created_at: + type: optional + docs: >- + The timestamp when the customer profile was created, in RFC 3339 + format. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp when the customer profile was last updated, in RFC 3339 + format. + access: read-only + given_name: + type: optional> + docs: >- + The given name (that is, the first name) associated with the customer + profile. + family_name: + type: optional> + docs: >- + The family name (that is, the last name) associated with the customer + profile. + nickname: + type: optional> + docs: A nickname for the customer profile. + company_name: + type: optional> + docs: A business name associated with the customer profile. + email_address: + type: optional> + docs: The email address associated with the customer profile. + address: + type: optional
+ docs: The physical address associated with the customer profile. + phone_number: + type: optional> + docs: The phone number associated with the customer profile. + birthday: + type: optional> + docs: >- + The birthday associated with the customer profile, in `YYYY-MM-DD` + format. For example, `1998-09-21` + + represents September 21, 1998, and `0000-09-21` represents September + 21 (without a birth year). + reference_id: + type: optional> + docs: |- + An optional second ID used to associate the customer profile with an + entity in another system. + note: + type: optional> + docs: A custom note associated with the customer profile. + preferences: + type: optional + docs: Represents general customer preferences. + creation_source: + type: optional + docs: >- + The method used to create the customer profile. + + See [CustomerCreationSource](#type-customercreationsource) for + possible values + group_ids: + type: optional>> + docs: >- + The IDs of [customer groups](entity:CustomerGroup) the customer + belongs to. + segment_ids: + type: optional>> + docs: >- + The IDs of [customer segments](entity:CustomerSegment) the customer + belongs to. + version: + type: optional + docs: >- + 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. + tax_ids: + type: optional + docs: >- + 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). + source: + openapi: ../default/openapi/openapi.json + CustomerAddressFilter: + docs: >- + The customer address filter. This filter is used in a + [CustomerCustomAttributeFilterValue](entity:CustomerCustomAttributeFilterValue) + filter when + + searching by an `Address`-type custom attribute. + properties: + postal_code: + type: optional + docs: The postal code to search for. Only an `exact` match is supported. + country: + type: optional + docs: |- + The country code to search for. + See [Country](#type-country) for possible values + source: + openapi: ../default/openapi/openapi.json + CustomerCreatedEvent: + docs: >- + Published when a [customer](entity:Customer) is created. Subscribe to this + event to track customer profiles affected by a merge operation. + + For more information, see [Use Customer + Webhooks](https://developer.squareup.com/docs/customers-api/use-the-api/customer-webhooks). + + + The `customer` object in the event notification does not include the + `segment_ids` field. + properties: + merchant_id: + type: optional> + docs: The ID of the seller associated with the event. + type: + type: optional> + docs: The type of event. For this object, the value is `customer.created`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CustomerCreatedEventData: + docs: The data associated with the event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `customer`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the new customer. + validation: + maxLength: 192 + object: + type: optional + docs: An object that contains the new customer. + source: + openapi: ../default/openapi/openapi.json + CustomerCreatedEventEventContext: + docs: Information about the change that triggered the event. + properties: + merge: + type: optional + docs: Information about the merge operation associated with the event. + source: + openapi: ../default/openapi/openapi.json + CustomerCreatedEventEventContextMerge: + docs: >- + Information about a merge operation, which creates a new customer using + aggregated properties from two or more existing customers. + properties: + from_customer_ids: + type: optional>> + docs: The IDs of the existing customers that were merged and then deleted. + to_customer_id: + type: optional> + docs: The ID of the new customer created by the merge. + source: + openapi: ../default/openapi/openapi.json + CustomerCreatedEventObject: + docs: An object that contains the customer associated with the event. + properties: + customer: + type: optional + docs: The new customer. + event_context: + type: optional + docs: >- + Information about the change that triggered the event. This field is + returned only if the customer is created by a merge operation. + source: + openapi: ../default/openapi/openapi.json + CustomerCreationSource: + enum: + - OTHER + - APPOINTMENTS + - COUPON + - DELETION_RECOVERY + - DIRECTORY + - EGIFTING + - EMAIL_COLLECTION + - FEEDBACK + - IMPORT + - INVOICES + - LOYALTY + - MARKETING + - MERGE + - ONLINE_STORE + - INSTANT_PROFILE + - TERMINAL + - THIRD_PARTY + - THIRD_PARTY_IMPORT + - UNMERGE_RECOVERY + docs: Indicates the method used to create the customer profile. + source: + openapi: ../default/openapi/openapi.json + CustomerCreationSourceFilter: + docs: >- + The creation source filter. + + + If one or more creation sources are set, customer profiles are included + in, + + or excluded from, the result if they match at least one of the filter + criteria. + properties: + values: + type: optional>> + docs: >- + The list of creation sources used as filtering criteria. + + See [CustomerCreationSource](#type-customercreationsource) for + possible values + rule: + type: optional + docs: >- + Indicates whether a customer profile matching the filter criteria + + should be included in the result or excluded from the result. + + + Default: `INCLUDE`. + + See [CustomerInclusionExclusion](#type-customerinclusionexclusion) for + possible values + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionCreatedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + is created by the subscribing application. + + + This event is replaced by + + [customer.custom_attribute_definition.owned.created](webhook:customer.custom_attribute_definition.owned.created). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionCreatedPublicEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to all applications is created. A notification is sent + when any application creates a custom + + attribute definition whose `visibility` is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + + + This event is replaced by + + [customer.custom_attribute_definition.visible.created](webhook:customer.custom_attribute_definition.visible.created), + + which applies to custom attribute definitions that are visible to the + subscribing application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.public.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionDeletedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + created by the subscribing application is deleted. A custom attribute + definition can only be deleted by + + the application that created it. + + + This event is replaced by + + [customer.custom_attribute_definition.owned.deleted](webhook:customer.custom_attribute_definition.owned.deleted). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionDeletedPublicEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to all applications is deleted. A notification is sent + when any application deletes a custom + + attribute definition whose `visibility` is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + + + This event is replaced by + + [customer.custom_attribute_definition.visible.deleted](webhook:customer.custom_attribute_definition.visible.deleted), + + which applies to custom attribute definitions that are visible to the + subscribing application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.public.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionOwnedCreatedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + is created by the subscribing application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.owned.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionOwnedDeletedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + created by the subscribing application is deleted. A custom attribute + definition can only be deleted by + + the application that created it. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionOwnedUpdatedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + created by the subscribing application is updated. A custom attribute + definition can only be updated by + + the application that created it. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionUpdatedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + created by the subscribing application is updated. A custom attribute + definition can only be updated by + + the application that created it. + + + This event is replaced by + + [customer.custom_attribute_definition.owned.updated](webhook:customer.custom_attribute_definition.owned.updated). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionUpdatedPublicEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to all applications is updated. A notification is sent + when any application updates a custom + + attribute definition whose `visibility` is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + + + This event is replaced by + + [customer.custom_attribute_definition.visible.updated](webhook:customer.custom_attribute_definition.visible.updated), + + which applies to custom attribute definitions that are visible to the + subscribing application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.public.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionVisibleCreatedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is created. A notification + is sent when your application + + creates a custom attribute definition or another application creates a + custom attribute definition whose + + `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.visible.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionVisibleDeletedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is deleted. A custom + attribute definition can only be deleted + + by the application that created it. A notification is sent when your + application deletes a custom attribute + + definition or when another application deletes a custom attribute + definition whose `visibility` is + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDefinitionVisibleUpdatedEvent: + docs: >- + Published when a customer [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is updated. A custom + attribute definition can only be updated + + by the application that created it. A notification is sent when your + application updates a custom + + attribute definition or when another application updates a custom + attribute definition whose `visibility` is + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute_definition.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDeletedEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) owned + by the + + subscribing application is deleted. Custom attributes are owned by the + application that created the + + corresponding [custom attribute + definition](entity:CustomAttributeDefinition). Custom attributes whose + + `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be deleted by any + application. + + + This event is replaced by + + [customer.custom_attribute.owned.deleted](webhook:customer.custom_attribute.owned.deleted). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeDeletedPublicEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) that + is visible + + to all applications is deleted. A notification is sent when any + application deletes a custom attribute + + whose `visibility` is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + + + This event is replaced by + + [customer.custom_attribute.visible.deleted](webhook:customer.custom_attribute.visible.deleted), + + which applies to custom attributes that are visible to the subscribing + application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.public.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeFilter: + docs: >- + The custom attribute filter. Use this filter in a set of [custom attribute + filters](entity:CustomerCustomAttributeFilters) to search + + based on the value or last updated date of a customer-related [custom + attribute](entity:CustomAttribute). + properties: + key: + type: string + docs: >- + The `key` of the [custom attribute](entity:CustomAttribute) to filter + by. The key is the identifier of the custom attribute + + (and the corresponding custom attribute definition) and can be + retrieved using the [Customer Custom Attributes + API](api:CustomerCustomAttributes). + filter: + type: optional + docs: >- + A filter that corresponds to the data type of the target custom + attribute. For example, provide the `phone` filter to + + search based on the value of a `PhoneNumber`-type custom attribute. + The data type is specified by the schema field of the custom attribute + definition, + + which can be retrieved using the [Customer Custom Attributes + API](api:CustomerCustomAttributes). + + + You must provide this `filter` field, the `updated_at` field, or both. + updated_at: + type: optional + docs: >- + The date range for when the custom attribute was last updated. The + date range can include `start_at`, `end_at`, or + + both. Range boundaries are inclusive. Dates are specified as RFC 3339 + timestamps. + + + You must provide this `updated_at` field, the `filter` field, or both. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeFilterValue: + docs: >- + A type-specific filter used in a [custom attribute + filter](entity:CustomerCustomAttributeFilter) to search based on the + value + + of a customer-related [custom attribute](entity:CustomAttribute). + properties: + email: + type: optional + docs: >- + A filter for a query based on the value of an `Email`-type custom + attribute. This filter is case-insensitive and can + + include `exact` or `fuzzy`, but not both. + + + For an `exact` match, provide the complete email address. + + + For a `fuzzy` match, provide a query expression containing one or more + query tokens to match against the email address. Square removes + + any punctuation (including periods (.), underscores (_), and the @ + symbol) and tokenizes the email addresses on spaces. A match is found + + if a tokenized email address contains all the tokens in the search + query, irrespective of the token order. For example, `Steven gmail` + + matches steven.jones@gmail.com and mygmail@stevensbakery.com. + phone: + type: optional + docs: >- + A filter for a query based on the value of a `PhoneNumber`-type custom + attribute. This filter is case-insensitive and + + can include `exact` or `fuzzy`, but not both. + + + For an `exact` match, provide the complete phone number. This is + always an E.164-compliant phone number that starts + + with the + sign followed by the country code and subscriber number. + For example, the format for a US phone number is +12061112222. + + + For a `fuzzy` match, provide a query expression containing one or more + query tokens to match against the phone number. + + Square removes any punctuation and tokenizes the expression on spaces. + A match is found if a tokenized phone number contains + + all the tokens in the search query, irrespective of the token order. + For example, `415 123 45` is tokenized to `415`, `123`, and `45`, + + which matches +14151234567 and +12345674158, but does not match + +1234156780. Similarly, the expression `415` matches + + +14151234567, +12345674158, and +1234156780. + text: + type: optional + docs: >- + A filter for a query based on the value of a `String`-type custom + attribute. This filter is case-insensitive and + + can include `exact` or `fuzzy`, but not both. + + + For an `exact` match, provide the complete string. + + + For a `fuzzy` match, provide a query expression containing one or more + query tokens in any order that contain complete words + + to match against the string. Square tokenizes the expression using a + grammar-based tokenizer. For example, the expressions `quick brown`, + + `brown quick`, and `quick fox` match "The quick brown fox jumps over + the lazy dog". However, `quick foxes` and `qui` do not match. + selection: + type: optional + docs: >- + A filter for a query based on the display name for a `Selection`-type + custom attribute value. This filter is case-sensitive + + and can contain `any`, `all`, or both. The `none` condition is not + supported. + + + Provide the display name of each item that you want to search for. To + find the display names for the selection, use the + + [Customer Custom Attributes API](api:CustomerCustomAttributes) to + retrieve the corresponding custom attribute definition + + and then check the `schema.items.names` field. For more information, + see + + [Search based on + selection](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#custom-attribute-value-filter-selection). + + + Note that when a `Selection`-type custom attribute is assigned to a + customer profile, the custom attribute value is a list of one + + or more UUIDs (sourced from the `schema.items.enum` field) that map to + the item names. These UUIDs are unique per seller. + date: + type: optional + docs: >- + A filter for a query based on the value of a `Date`-type custom + attribute. + + + Provide a date range for this filter using `start_at`, `end_at`, or + both. Range boundaries are inclusive. Dates can be specified + + in `YYYY-MM-DD` format or as RFC 3339 timestamps. + number: + type: optional + docs: >- + A filter for a query based on the value of a `Number`-type custom + attribute, which can be an integer or a decimal with up to + + 5 digits of precision. + + + Provide a numerical range for this filter using `start_at`, `end_at`, + or both. Range boundaries are inclusive. Numbers are specified + + as decimals or integers. The absolute value of range boundaries must + not exceed `(2^63-1)/10^5`, or 92233720368547. + boolean: + type: optional> + docs: >- + A filter for a query based on the value of a `Boolean`-type custom + attribute. + address: + type: optional + docs: >- + A filter for a query based on the value of an `Address`-type custom + attribute. The filter can include `postal_code`, `country`, or both. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeFilters: + docs: >- + The custom attribute filters in a set of [customer + filters](entity:CustomerFilter) used in a search query. Use this filter + + to search based on [custom attributes](entity:CustomAttribute) that are + assigned to customer profiles. For more information, see + + [Search by custom + attribute](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#search-by-custom-attribute). + properties: + filters: + type: optional>> + docs: >- + The custom attribute filters. Each filter must specify `key` and + include the `filter` field with a type-specific filter, + + the `updated_at` field, or both. The provided keys must be unique + within the list of custom attribute filters. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeOwnedDeletedEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) owned + by the + + subscribing application is deleted. Custom attributes are owned by the + application that created the + + corresponding [custom attribute + definition](entity:CustomAttributeDefinition). Custom attributes whose + + `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be deleted by any + application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeOwnedUpdatedEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) owned + by the + + subscribing application is created or updated. Custom attributes are owned + by the application that created + + the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). Custom attributes whose + + `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be created or updated + by any application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeUpdatedEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) owned + by the + + subscribing application is created or updated. Custom attributes are owned + by the application that created + + the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). Custom attributes whose + + `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be created or updated + by any application. + + + This event is replaced by + + [customer.custom_attribute.owned.updated](webhook:customer.custom_attribute.owned.updated). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeUpdatedPublicEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) that + is visible + + to all applications is created or updated. A notification is sent when any + application creates or updates + + a custom attribute whose `visibility` is `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES`. + + + This event is replaced by + + [customer.custom_attribute.visible.updated](webhook:customer.custom_attribute.visible.updated), + + which applies to custom attributes that are visible to the subscribing + application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.public.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeVisibleDeletedEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) that + is visible to the + + subscribing application is deleted. A notification is sent when: + + - Your application deletes a custom attribute owned by your application, + regardless of the `visibility` setting. + + - Any application deletes a custom attribute whose `visibility` is + `VISIBILITY_READ_ONLY` + + or `VISIBILITY_READ_WRITE_VALUES`. + + + Custom attributes set to `VISIBILITY_READ_WRITE_VALUES` can be deleted by + any application, but those set to + + `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be deleted by the + owner. Custom attributes are owned + + by the application that created the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerCustomAttributeVisibleUpdatedEvent: + docs: >- + Published when a customer [custom attribute](entity:CustomAttribute) that + is visible to the + + subscribing application is created or updated. A notification is sent + when: + + - Your application creates or updates a custom attribute owned by your + application, regardless of the `visibility` setting. + + - Any application creates or updates a custom attribute whose `visibility` + is `VISIBILITY_READ_ONLY` + + or `VISIBILITY_READ_WRITE_VALUES`. + + + Custom attributes set to `VISIBILITY_READ_WRITE_VALUES` can be created or + updated by any application, but those set to + + `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be created or + updated by the owner. Custom attributes are owned + + by the application that created the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"customer.custom_attribute.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + CustomerDeletedEvent: + docs: >- + Published when a [customer](entity:Customer) is deleted. For more + information, see [Use Customer + Webhooks](https://developer.squareup.com/docs/customers-api/use-the-api/customer-webhooks). + + + The `customer` object in the event notification does not include the + following fields: `group_ids` and `segment_ids`. + properties: + merchant_id: + type: optional> + docs: The ID of the seller associated with the event. + type: + type: optional> + docs: The type of event. For this object, the value is `customer.deleted`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CustomerDeletedEventData: + docs: The data associated with the event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `customer`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the deleted customer. + validation: + maxLength: 192 + object: + type: optional + docs: An object that contains the deleted customer. + source: + openapi: ../default/openapi/openapi.json + CustomerDeletedEventEventContext: + docs: Information about the change that triggered the event. + properties: + merge: + type: optional + docs: Information about the merge operation associated with the event. + source: + openapi: ../default/openapi/openapi.json + CustomerDeletedEventEventContextMerge: + docs: >- + Information about a merge operation, which creates a new customer using + aggregated properties from two or more existing customers. + properties: + from_customer_ids: + type: optional>> + docs: The IDs of the existing customers that were merged and then deleted. + to_customer_id: + type: optional> + docs: The ID of the new customer created by the merge. + source: + openapi: ../default/openapi/openapi.json + CustomerDeletedEventObject: + docs: An object that contains the customer associated with the event. + properties: + customer: + type: optional + docs: The deleted customer. + event_context: + type: optional + docs: >- + Information about the change that triggered the event. This field is + returned only if the customer is deleted by a merge operation. + source: + openapi: ../default/openapi/openapi.json + CustomerDetails: + docs: Details about the customer making the payment. + properties: + customer_initiated: + type: optional> + docs: Indicates whether the customer initiated the payment. + seller_keyed_in: + type: optional> + docs: >- + Indicates that the seller keyed in payment details on behalf of the + customer. + + This is used to flag a payment as Mail Order / Telephone Order (MOTO). + source: + openapi: ../default/openapi/openapi.json + CustomerFilter: + docs: >- + Represents the filtering criteria in a [search + query](entity:CustomerQuery) that defines how to filter + + customer profiles returned in + [SearchCustomers](api-endpoint:Customers-SearchCustomers) results. + properties: + creation_source: + type: optional + docs: A filter to select customers based on their creation source. + created_at: + type: optional + docs: A filter to select customers based on when they were created. + updated_at: + type: optional + docs: A filter to select customers based on when they were last updated. + email_address: + type: optional + docs: >- + A filter to [select customers by their email + address](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#search-by-email-address) + + visible to the seller. + + This filter is case-insensitive. + + + For [exact + matching](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#exact-search-by-email-address), + this + + filter causes the search to return customer profiles + + whose `email_address` field value are identical to the email address + provided + + in the query. + + + For [fuzzy + matching](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#fuzzy-search-by-email-address), + + this filter causes the search to return customer profiles + + whose `email_address` field value has a token-wise partial match + against the filtering + + expression in the query. For example, with `Steven gmail` provided in + a search + + query, the search returns customers whose email address is + `steven.johnson@gmail.com` + + or `mygmail@stevensbakery.com`. Square removes any punctuation + (including periods (.), + + underscores (_), and the @ symbol) and tokenizes the email addresses + on spaces. A match is + + found if a tokenized email address contains all the tokens in the + search query, + + irrespective of the token order. + phone_number: + type: optional + docs: >- + A filter to [select customers by their phone + numbers](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#search-by-phone-number) + + visible to the seller. + + + For [exact + matching](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#exact-search-by-phone-number), + + this filter returns customers whose phone number matches the specified + query expression. The number in the query must be of an + + E.164-compliant form. In particular, it must include the leading `+` + sign followed by a country code and then a subscriber number. + + For example, the standard E.164 form of a US phone number is + `+12062223333` and an E.164-compliant variation is `+1 (206) + 222-3333`. + + To match the query expression, stored customer phone numbers are + converted to the standard E.164 form. + + + For [fuzzy + matching](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#fuzzy-search-by-phone-number), + + this filter returns customers whose phone number matches the token or + tokens provided in the query expression. For example, with `415` + + provided in a search query, the search returns customers with the + phone numbers `+1-415-212-1200`, `+1-212-415-1234`, and `+1 (551) + 234-1567`. + + Similarly, a search query of `415 123` returns customers with the + phone numbers `+1-212-415-1234` and `+1 (551) 234-1567` but not + + `+1-212-415-1200`. A match is found if a tokenized phone number + contains all the tokens in the search query, irrespective of the token + order. + reference_id: + type: optional + docs: >- + A filter to [select customers by their reference + IDs](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#search-by-reference-id). + + This filter is case-insensitive. + + + [Exact + matching](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#exact-search-by-reference-id) + + of a customer's reference ID against a query's reference ID is + evaluated as an + + exact match between two strings, character by character in the given + order. + + + [Fuzzy + matching](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#fuzzy-search-by-reference-id) + + of stored reference IDs against queried reference IDs works + + exactly the same as fuzzy matching on email addresses. + Non-alphanumeric characters + + are replaced by spaces to tokenize stored and queried reference IDs. A + match is found + + if a tokenized stored reference ID contains all tokens specified in + any order in the query. For example, + + a query of `NYC M` matches customer profiles with the `reference_id` + value of `NYC_M_35_JOHNSON` + + and `NYC_27_MURRAY`. + group_ids: + type: optional + docs: >- + A filter to select customers based on the + [groups](entity:CustomerGroup) they belong to. + + Group membership is controlled by sellers and developers. + + + The `group_ids` filter has the following syntax: + + ``` + + "group_ids": { + + "any": ["{group_a_id}", "{group_b_id}", ...], + + "all": ["{group_1_id}", "{group_2_id}", ...], + + "none": ["{group_i_id}", "{group_ii_id}", ...] + + } + + ``` + + + You can use any combination of the `any`, `all`, and `none` fields in + the filter. + + With `any`, the search returns customers in groups `a` or `b` or any + other group specified in the list. + + With `all`, the search returns customers in groups `1` and `2` and all + other groups specified in the list. + + With `none`, the search returns customers not in groups `i` or `ii` or + any other group specified in the list. + + + If any of the search conditions are not met, including when an invalid + or non-existent group ID is provided, + + the result is an empty object (`{}`). + custom_attribute: + type: optional + docs: >- + A filter to select customers based on one or more custom attributes. + + This filter can contain up to 10 custom attribute filters. Each custom + attribute filter specifies filtering criteria for a target custom + + attribute. If multiple custom attribute filters are provided, they are + combined as an `AND` operation. + + + To be valid for a search, the custom attributes must be visible to the + requesting application. For more information, including example + queries, + + see [Search by custom + attribute](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#search-by-custom-attribute). + + + Square returns matching customer profiles, which do not contain custom + attributes. To retrieve customer-related custom attributes, + + use the [Customer Custom Attributes + API](api:CustomerCustomAttributes). For example, you can call + + [RetrieveCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-RetrieveCustomerCustomAttribute) + using a customer ID from the result set. + segment_ids: + type: optional + docs: >2- + A filter to select customers based on the [segments](entity:CustomerSegment) they belong to. + Segment membership is dynamic and adjusts automatically based on + whether customers meet the segment criteria. + + + You can provide up to three segment IDs in the filter, using any + combination of the `all`, `any`, and `none` fields. + + For the following example, the results include customers who belong to + both segment A and segment B but do not belong to segment C. + + + ``` + + "segment_ids": { + + "all": ["{segment_A_id}", "{segment_B_id}"], + + "none": ["{segment_C_id}"] + + } + + ``` + + + If an invalid or non-existent segment ID is provided in the filter, + Square stops processing the request + + and returns a `400 BAD_REQUEST` error that includes the segment ID. + source: + openapi: ../default/openapi/openapi.json + CustomerGroup: + docs: >- + Represents a group of customer profiles. + + + Customer groups can be created, be modified, and have their membership + defined using + + the Customers API or within the Customer Directory in the Square Seller + Dashboard or Point of Sale. + properties: + id: + type: optional + docs: A unique Square-generated ID for the customer group. + validation: + maxLength: 255 + access: read-only + name: + type: string + docs: The name of the customer group. + created_at: + type: optional + docs: The timestamp when the customer group was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp when the customer group was last updated, in RFC 3339 + format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CustomerInclusionExclusion: + enum: + - INCLUDE + - EXCLUDE + docs: |- + Indicates whether customers should be included in, or excluded from, + the result set when they match the filtering criteria. + source: + openapi: ../default/openapi/openapi.json + CustomerPreferences: + docs: Represents communication preferences for the customer profile. + properties: + email_unsubscribed: + type: optional> + docs: >- + Indicates whether the customer has unsubscribed from marketing + campaign emails. A value of `true` means that the customer chose to + opt out of email marketing from the current Square seller or from all + Square sellers. This value is read-only from the Customers API. + source: + openapi: ../default/openapi/openapi.json + CustomerQuery: + docs: >- + Represents filtering and sorting criteria for a + [SearchCustomers](api-endpoint:Customers-SearchCustomers) request. + properties: + filter: + type: optional + docs: >- + The filtering criteria for the search query. A query can contain + multiple filters in any combination. + + Multiple filters are combined as `AND` statements. + + + __Note:__ Combining multiple filters as `OR` statements is not + supported. Instead, send multiple single-filter + + searches and join the result sets. + sort: + type: optional + docs: |- + Sorting criteria for query results. The default behavior is to sort + customers alphabetically by `given_name` and `family_name`. + source: + openapi: ../default/openapi/openapi.json + CustomerSegment: + docs: >- + Represents a group of customer profiles that match one or more predefined + filter criteria. + + + Segments (also known as Smart Groups) are defined and created within the + Customer Directory in the + + Square Seller Dashboard or Point of Sale. + properties: + id: + type: optional + docs: A unique Square-generated ID for the segment. + validation: + maxLength: 255 + access: read-only + name: + type: optional + docs: The name of the segment. + access: read-only + created_at: + type: optional + docs: The timestamp when the segment was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp when the segment was last updated, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CustomerSort: + docs: >- + Represents the sorting criteria in a [search query](entity:CustomerQuery) + that defines how to sort + + customer profiles returned in + [SearchCustomers](api-endpoint:Customers-SearchCustomers) results. + properties: + field: + type: optional + docs: >- + Indicates the fields to use as the sort key, which is either the + default set of fields or `created_at`. + + + The default value is `DEFAULT`. + + See [CustomerSortField](#type-customersortfield) for possible values + order: + type: optional + docs: >- + Indicates the order in which results should be sorted based on the + + sort field value. Strings use standard alphabetic comparison + + to determine order. Strings representing numbers are sorted as + strings. + + + The default value is `ASC`. + + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + CustomerSortField: + enum: + - DEFAULT + - CREATED_AT + docs: >- + Specifies customer attributes as the sort key to customer profiles + returned from a search. + source: + openapi: ../default/openapi/openapi.json + CustomerTaxIds: + docs: >- + Represents the tax ID associated with a [customer + profile](entity:Customer). The corresponding `tax_ids` field is available + 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). + properties: + eu_vat: + type: optional> + docs: >- + The EU VAT identification number for the customer. For example, + `IE3426675K`. The ID can contain alphanumeric characters only. + validation: + maxLength: 20 + source: + openapi: ../default/openapi/openapi.json + CustomerTextFilter: + docs: >- + A filter to select customers based on exact or fuzzy matching of + + customer attributes against a specified query. Depending on the customer + attributes, + + the filter can be case-sensitive. This filter can be exact or fuzzy, but + it cannot be both. + properties: + exact: + type: optional> + docs: >- + Use the exact filter to select customers whose attributes match + exactly the specified query. + fuzzy: + type: optional> + docs: >- + Use the fuzzy filter to select customers whose attributes match the + specified query + + in a fuzzy manner. When the fuzzy option is used, search queries are + tokenized, and then + + each query token must be matched somewhere in the searched attribute. + For single token queries, + + this is effectively the same behavior as a partial match operation. + source: + openapi: ../default/openapi/openapi.json + CustomerUpdatedEvent: + docs: >- + Published when a [customer](entity:Customer) is updated. For more + information, see [Use Customer + Webhooks](https://developer.squareup.com/docs/customers-api/use-the-api/customer-webhooks). + + + Updates to the 'segment_ids' customer field does not invoke a + `customer.updated` event. In addition, the `customer` object in the event + notification does not include this field. + properties: + merchant_id: + type: optional> + docs: The ID of the seller associated with the event. + type: + type: optional> + docs: The type of event. For this object, the value is `customer.updated`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + CustomerUpdatedEventData: + docs: The data associated with the event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `customer`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the updated customer. + validation: + maxLength: 192 + object: + type: optional + docs: An object that contains the updated customer. + source: + openapi: ../default/openapi/openapi.json + CustomerUpdatedEventObject: + docs: An object that contains the customer associated with the event. + properties: + customer: + type: optional + docs: The updated customer. + source: + openapi: ../default/openapi/openapi.json + DataCollectionOptions: + properties: + title: + type: string + docs: The title text to display in the data collection flow on the Terminal. + validation: + minLength: 1 + maxLength: 250 + body: + type: string + docs: >- + The body text to display under the title in the data collection screen + flow on the + + Terminal. + validation: + minLength: 1 + maxLength: 10000 + input_type: + type: DataCollectionOptionsInputType + docs: |- + Represents the type of the input text. + See [InputType](#type-inputtype) for possible values + collected_data: + type: optional + docs: The buyer’s input text from the data collection screen. + source: + openapi: ../default/openapi/openapi.json + DataCollectionOptionsInputType: + enum: + - EMAIL + - PHONE_NUMBER + docs: Describes the input type of the data. + source: + openapi: ../default/openapi/openapi.json + DateRange: + docs: |- + A range defined by two dates. Used for filtering a query for Connect v2 + objects that have date properties. + properties: + start_date: + type: optional> + docs: >- + A string in `YYYY-MM-DD` format, such as `2017-10-31`, per the ISO + 8601 + + extended format for calendar dates. + + The beginning of a date range (inclusive). + end_date: + type: optional> + docs: >- + A string in `YYYY-MM-DD` format, such as `2017-10-31`, per the ISO + 8601 + + extended format for calendar dates. + + The end of a date range (inclusive). + source: + openapi: ../default/openapi/openapi.json + DayOfWeek: + enum: + - SUN + - MON + - TUE + - WED + - THU + - FRI + - SAT + docs: Indicates the specific day of the week. + source: + openapi: ../default/openapi/openapi.json + DeleteBookingCustomAttributeDefinitionResponse: + docs: >- + Represents a + [DeleteBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-DeleteBookingCustomAttributeDefinition) + response + + containing error messages when errors occurred during the request. The + successful response does not contain any payload. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteBookingCustomAttributeResponse: + docs: >- + Represents a + [DeleteBookingCustomAttribute](api-endpoint:BookingCustomAttributes-DeleteBookingCustomAttribute) + response. + + Either an empty object `{}` (for a successful deletion) or `errors` is + present in the response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteBreakTypeResponse: + docs: >- + The response to a request to delete a `BreakType`. The response might + contain a set + + of `Error` objects if the request resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteCatalogObjectResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + deleted_object_ids: + type: optional> + docs: >- + The IDs of all catalog objects deleted by this request. + + Multiple IDs may be returned when associated objects are also deleted, + for example + + a catalog item variation will be deleted (and its ID included in this + field) + + when its parent catalog item is deleted. + deleted_at: + type: optional + docs: >- + The database + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + of this deletion in RFC 3339 format, e.g., `2016-09-04T23:59:33.123Z`. + source: + openapi: ../default/openapi/openapi.json + DeleteCustomerCardResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `DeleteCustomerCard` endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteCustomerCustomAttributeDefinitionResponse: + docs: >- + Represents a response from a delete request containing error messages if + there are any. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteCustomerCustomAttributeResponse: + docs: >- + Represents a + [DeleteCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-DeleteCustomerCustomAttribute) + response. + + Either an empty object `{}` (for a successful deletion) or `errors` is + present in the response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteCustomerGroupResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [DeleteCustomerGroup](api-endpoint:CustomerGroups-DeleteCustomerGroup) + endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteCustomerResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `DeleteCustomer` endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteDisputeEvidenceResponse: + docs: Defines the fields in a `DeleteDisputeEvidence` response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteInvoiceAttachmentResponse: + docs: >- + Represents a + [DeleteInvoiceAttachment](api-endpoint:Invoices-DeleteInvoiceAttachment) + response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteInvoiceResponse: + docs: Describes a `DeleteInvoice` response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteLocationCustomAttributeDefinitionResponse: + docs: >- + Represents a response from a delete request containing error messages if + there are any. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteLocationCustomAttributeResponse: + docs: >- + Represents a + [DeleteLocationCustomAttribute](api-endpoint:LocationCustomAttributes-DeleteLocationCustomAttribute) + response. + + Either an empty object `{}` (for a successful deletion) or `errors` is + present in the response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteLoyaltyRewardResponse: + docs: A response returned by the API call. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteMerchantCustomAttributeDefinitionResponse: + docs: >- + Represents a response from a delete request containing error messages if + there are any. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteMerchantCustomAttributeResponse: + docs: >- + Represents a + [DeleteMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-DeleteMerchantCustomAttribute) + response. + + Either an empty object `{}` (for a successful deletion) or `errors` is + present in the response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteOrderCustomAttributeDefinitionResponse: + docs: Represents a response from deleting an order custom attribute definition. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteOrderCustomAttributeResponse: + docs: Represents a response from deleting an order custom attribute. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeletePaymentLinkResponse: + properties: + errors: optional> + id: + type: optional + docs: The ID of the link that is deleted. + cancelled_order_id: + type: optional + docs: >- + The ID of the order that is canceled. When a payment link is deleted, + Square updates the + + the `state` (of the order that the checkout link created) to CANCELED. + source: + openapi: ../default/openapi/openapi.json + DeleteShiftResponse: + docs: >- + The response to a request to delete a `Shift`. The response might contain + a set of + + `Error` objects if the request resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteSnippetResponse: + docs: Represents a `DeleteSnippet` response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteSubscriptionActionResponse: + docs: >- + Defines output parameters in a response of the + [DeleteSubscriptionAction](api-endpoint:Subscriptions-DeleteSubscriptionAction) + + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The subscription that has the specified action deleted. + source: + openapi: ../default/openapi/openapi.json + DeleteTimecardResponse: + docs: >- + The response to a request to delete a `Timecard`. The response might + contain a set of + + `Error` objects if the request resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + DeleteTransferOrderResponse: + docs: Response for deleting a transfer order + properties: + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + DeleteWebhookSubscriptionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [DeleteWebhookSubscription](api-endpoint:WebhookSubscriptions-DeleteWebhookSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + Destination: + docs: Information about the destination against which the payout was made. + properties: + type: + type: optional + docs: |- + Type of the destination such as a bank account or debit card. + See [DestinationType](#type-destinationtype) for possible values + id: + type: optional + docs: >- + Square issued unique ID (also known as the instrument ID) associated + with this destination. + source: + openapi: ../default/openapi/openapi.json + DestinationDetails: + docs: Details about a refund's destination. + properties: + card_details: + type: optional + docs: >- + Details about a card refund. Only populated if the destination_type is + `CARD`. + cash_details: + type: optional + docs: >- + Details about a cash refund. Only populated if the destination_type is + `CASH`. + external_details: + type: optional + docs: >- + Details about an external refund. Only populated if the + destination_type is `EXTERNAL`. + source: + openapi: ../default/openapi/openapi.json + DestinationDetailsCardRefundDetails: + properties: + card: + type: optional + docs: The card's non-confidential details. + entry_method: + type: optional> + docs: >- + The method used to enter the card's details for the refund. The method + can be + + `KEYED`, `SWIPED`, `EMV`, `ON_FILE`, or `CONTACTLESS`. + validation: + maxLength: 50 + auth_result_code: + type: optional> + docs: >- + The authorization code provided by the issuer when a refund is + approved. + validation: + maxLength: 10 + source: + openapi: ../default/openapi/openapi.json + DestinationDetailsCashRefundDetails: + docs: >- + Stores details about a cash refund. Contains only non-confidential + information. + properties: + seller_supplied_money: + type: Money + docs: The amount and currency of the money supplied by the seller. + change_back_money: + type: optional + docs: |- + The amount of change due back to the seller. + This read-only field is calculated + from the `amount_money` and `seller_supplied_money` fields. + source: + openapi: ../default/openapi/openapi.json + DestinationDetailsExternalRefundDetails: + docs: >- + Stores details about an external refund. Contains only non-confidential + information. + properties: + type: + type: string + docs: >- + The type of external refund the seller paid to the buyer. It can be + one of the + + following: + + - CHECK - Refunded using a physical check. + + - BANK_TRANSFER - Refunded using external bank transfer. + + - OTHER\_GIFT\_CARD - Refunded using a non-Square gift card. + + - CRYPTO - Refunded using a crypto currency. + + - SQUARE_CASH - Refunded using Square Cash App. + + - SOCIAL - Refunded using peer-to-peer payment applications. + + - EXTERNAL - A third-party application gathered this refund outside of + Square. + + - EMONEY - Refunded using an E-money provider. + + - CARD - A credit or debit card that Square does not support. + + - STORED_BALANCE - Use for house accounts, store credit, and so forth. + + - FOOD_VOUCHER - Restaurant voucher provided by employers to employees + to pay for meals + + - OTHER - A type not listed here. + validation: + maxLength: 50 + source: + type: string + docs: |- + A description of the external refund source. For example, + "Food Delivery Service". + validation: + maxLength: 255 + source_id: + type: optional> + docs: An ID to associate the refund to its originating source. + validation: + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + DestinationType: + enum: + - BANK_ACCOUNT + - CARD + - SQUARE_BALANCE + - SQUARE_STORED_BALANCE + docs: List of possible destinations against which a payout can be made. + source: + openapi: ../default/openapi/openapi.json + Device: + properties: + id: + type: optional + docs: >- + A synthetic identifier for the device. The identifier includes a + standardized prefix and + + is otherwise an opaque id generated from key device fields. + access: read-only + attributes: + type: DeviceAttributes + docs: A collection of DeviceAttributes representing the device. + components: + type: optional>> + docs: A list of components applicable to the device. + status: + type: optional + docs: The current status of the device. + source: + openapi: ../default/openapi/openapi.json + DeviceAttributes: + properties: + type: + type: DeviceAttributesDeviceType + docs: |- + The device type. + See [DeviceType](#type-devicetype) for possible values + manufacturer: + type: string + docs: The maker of the device. + model: + type: optional> + docs: The specific model of the device. + name: + type: optional> + docs: A seller-specified name for the device. + manufacturers_id: + type: optional> + docs: >- + The manufacturer-supplied identifier for the device (where available). + In many cases, + + this identifier will be a serial number. + updated_at: + type: optional + docs: >- + The RFC 3339-formatted value of the most recent update to the device + information. + + (Could represent any field update on the device.) + access: read-only + version: + type: optional + docs: The current version of software installed on the device. + merchant_token: + type: optional> + docs: The merchant_token identifying the merchant controlling the device. + source: + openapi: ../default/openapi/openapi.json + DeviceAttributesDeviceType: + enum: + - TERMINAL + - HANDHELD + docs: An enum identifier of the device type. + source: + openapi: ../default/openapi/openapi.json + DeviceCheckoutOptions: + properties: + device_id: + type: string + docs: >- + The unique ID of the device intended for this `TerminalCheckout`. + + A list of `DeviceCode` objects can be retrieved from the + /v2/devices/codes endpoint. + + Match a `DeviceCode.device_id` value with `device_id` to get the + associated device code. + skip_receipt_screen: + type: optional> + docs: Instructs the device to skip the receipt screen. Defaults to false. + collect_signature: + type: optional> + docs: >- + Indicates that signature collection is desired during checkout. + Defaults to false. + tip_settings: + type: optional + docs: Tip-specific settings. + show_itemized_cart: + type: optional> + docs: >- + Show the itemization screen prior to taking a payment. This field is + only meaningful when the + + checkout includes an order ID. Defaults to true. + source: + openapi: ../default/openapi/openapi.json + DeviceCode: + properties: + id: + type: optional + docs: The unique id for this device code. + access: read-only + name: + type: optional> + docs: An optional user-defined name for the device code. + validation: + maxLength: 128 + code: + type: optional + docs: The unique code that can be used to login. + access: read-only + device_id: + type: optional + docs: >- + The unique id of the device that used this code. Populated when the + device is paired up. + access: read-only + product_type: + type: ProductType + docs: The targeting product type of the device code. + location_id: + type: optional> + docs: The location assigned to this code. + validation: + maxLength: 50 + status: + type: optional + docs: |- + The pairing status of the device code. + See [DeviceCodeStatus](#type-devicecodestatus) for possible values + pair_by: + type: optional + docs: >- + When this DeviceCode will expire and no longer login. Timestamp in RFC + 3339 format. + access: read-only + created_at: + type: optional + docs: When this DeviceCode was created. Timestamp in RFC 3339 format. + access: read-only + status_changed_at: + type: optional + docs: >- + When this DeviceCode's status was last changed. Timestamp in RFC 3339 + format. + access: read-only + paired_at: + type: optional + docs: When this DeviceCode was paired. Timestamp in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + DeviceCodePairedEvent: + docs: |- + Published when a Square Terminal has been paired with a + Terminal API client and the device_id of the paired Square Terminal is + available. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents, `"device.code.paired"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DeviceCodePairedEventData: + properties: + type: + type: optional> + docs: Name of the paired object’s type, `"device_code"`. + id: + type: optional + docs: ID of the paired device code. + object: + type: optional + docs: An object containing the paired device code. + source: + openapi: ../default/openapi/openapi.json + DeviceCodePairedEventObject: + properties: + device_code: + type: optional + docs: The created terminal checkout + source: + openapi: ../default/openapi/openapi.json + DeviceCodeStatus: + enum: + - UNKNOWN + - UNPAIRED + - PAIRED + - EXPIRED + docs: DeviceCode.Status enum. + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsApplicationDetails: + properties: + application_type: + type: optional + docs: |- + The type of application. + See [ApplicationType](#type-applicationtype) for possible values + version: + type: optional + docs: The version of the application. + session_location: + type: optional> + docs: The location_id of the session for the application. + device_code_id: + type: optional> + docs: The id of the device code that was used to log in to the device. + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsBatteryDetails: + properties: + visible_percent: + type: optional> + docs: The battery charge percentage as displayed on the device. + external_power: + type: optional + docs: |- + The status of external_power. + See [ExternalPower](#type-externalpower) for possible values + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsCardReaderDetails: + properties: + version: + type: optional + docs: The version of the card reader. + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsEthernetDetails: + properties: + active: + type: optional> + docs: >- + A boolean to represent whether the Ethernet interface is currently + active. + ip_address_v4: + type: optional> + docs: The string representation of the device’s IPv4 address. + mac_address: + type: optional> + docs: The mac address of the device in this network. + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsExternalPower: + enum: + - AVAILABLE_CHARGING + - AVAILABLE_NOT_IN_USE + - UNAVAILABLE + - AVAILABLE_INSUFFICIENT + docs: An enum for ExternalPower. + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsMeasurement: + docs: A value qualified by unit of measure. + properties: + value: + type: optional> + docs: Value of measure. + source: + openapi: ../default/openapi/openapi.json + DeviceComponentDetailsWiFiDetails: + properties: + active: + type: optional> + docs: A boolean to represent whether the WiFI interface is currently active. + ssid: + type: optional> + docs: The name of the connected WIFI network. + ip_address_v4: + type: optional> + docs: The string representation of the device’s IPv4 address. + secure_connection: + type: optional> + docs: >- + The security protocol for a secure connection (e.g. WPA2). None + provided if the connection + + is unsecured. + signal_strength: + type: optional + docs: A representation of signal strength of the WIFI network connection. + mac_address: + type: optional> + docs: The mac address of the device in this network. + source: + openapi: ../default/openapi/openapi.json + DeviceCreatedEvent: + docs: Published when a Device is created. + properties: + merchant_id: + type: optional> + docs: The merchant the newly created device belongs to. + type: + type: optional> + docs: The type of event this represents. The value is `"device.created"`. + event_id: + type: optional> + docs: A UUID that uniquely identifies this device creation event. + created_at: + type: optional + docs: >- + The time when the device creation event was first created, in RFC 3339 + format. + access: read-only + data: + type: optional + docs: The metadata associated with the device creation event. + source: + openapi: ../default/openapi/openapi.json + DeviceCreatedEventData: + properties: + type: + type: optional> + docs: The type of the event data object. The value is `"device"`. + id: + type: optional + docs: The ID of the device. + object: + type: optional + docs: An object containing the created device. + source: + openapi: ../default/openapi/openapi.json + DeviceCreatedEventObject: + properties: + device: + type: optional + docs: The created device. + source: + openapi: ../default/openapi/openapi.json + DeviceDetails: + docs: Details about the device that took the payment. + properties: + device_id: + type: optional> + docs: The Square-issued ID of the device. + validation: + maxLength: 255 + device_installation_id: + type: optional> + docs: The Square-issued installation ID for the device. + validation: + maxLength: 255 + device_name: + type: optional> + docs: The name of the device set by the seller. + validation: + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + DeviceMetadata: + properties: + battery_percentage: + type: optional> + docs: The Terminal’s remaining battery percentage, between 1-100. + charging_state: + type: optional> + docs: |- + The current charging state of the Terminal. + Options: `CHARGING`, `NOT_CHARGING` + location_id: + type: optional> + docs: >- + The ID of the Square seller business location associated with the + Terminal. + merchant_id: + type: optional> + docs: >- + The ID of the Square merchant account that is currently signed-in to + the Terminal. + network_connection_type: + type: optional> + docs: |- + The Terminal’s current network connection type. + Options: `WIFI`, `ETHERNET` + payment_region: + type: optional> + docs: The country in which the Terminal is authorized to take payments. + serial_number: + type: optional> + docs: >- + The unique identifier assigned to the Terminal, which can be found on + the lower back + + of the device. + os_version: + type: optional> + docs: The current version of the Terminal’s operating system. + app_version: + type: optional> + docs: The current version of the application running on the Terminal. + wifi_network_name: + type: optional> + docs: The name of the Wi-Fi network to which the Terminal is connected. + wifi_network_strength: + type: optional> + docs: |- + The signal strength of the Wi-FI network connection. + Options: `POOR`, `FAIR`, `GOOD`, `EXCELLENT` + ip_address: + type: optional> + docs: The IP address of the Terminal. + source: + openapi: ../default/openapi/openapi.json + DeviceStatus: + properties: + category: + type: optional + docs: |- + Category of the device status. + See [Category](#type-category) for possible values + source: + openapi: ../default/openapi/openapi.json + DeviceStatusCategory: + enum: + - AVAILABLE + - NEEDS_ATTENTION + - OFFLINE + source: + openapi: ../default/openapi/openapi.json + DigitalWalletDetails: + docs: >- + Additional details about `WALLET` type payments. Contains only + non-confidential information. + properties: + status: + type: optional> + docs: >- + The status of the `WALLET` payment. The status can be `AUTHORIZED`, + `CAPTURED`, `VOIDED`, or + + `FAILED`. + validation: + maxLength: 50 + brand: + type: optional> + docs: >- + The brand used for the `WALLET` payment. The brand can be `CASH_APP`, + `PAYPAY`, `ALIPAY`, + + `RAKUTEN_PAY`, `AU_PAY`, `D_BARAI`, `MERPAY`, `WECHAT_PAY` or + `UNKNOWN`. + validation: + maxLength: 50 + cash_app_details: + type: optional + docs: Brand-specific details for payments with the `brand` of `CASH_APP`. + source: + openapi: ../default/openapi/openapi.json + DisableCardResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [DisableCard](api-endpoint:Cards-DisableCard) endpoint. + + + Note: if there are errors processing the request, the card field will not + be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + card: + type: optional + docs: The retrieved card. + source: + openapi: ../default/openapi/openapi.json + DisableEventsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [DisableEvents](api-endpoint:Events-DisableEvents) + endpoint. + + + Note: if there are errors processing the request, the events field will + not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + DismissTerminalActionResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + action: + type: optional + docs: Current state of the action to be dismissed. + source: + openapi: ../default/openapi/openapi.json + DismissTerminalCheckoutResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + checkout: + type: optional + docs: Current state of the checkout to be dismissed. + source: + openapi: ../default/openapi/openapi.json + DismissTerminalRefundResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + refund: + type: optional + docs: Current state of the refund to be dismissed. + source: + openapi: ../default/openapi/openapi.json + Dispute: + docs: >- + Represents a + [dispute](https://developer.squareup.com/docs/disputes-api/overview) a + cardholder initiated with their bank. + properties: + dispute_id: + type: optional> + docs: The unique ID for this `Dispute`, generated by Square. + validation: + minLength: 1 + maxLength: 40 + id: + type: optional + docs: The unique ID for this `Dispute`, generated by Square. + validation: + minLength: 1 + maxLength: 40 + amount_money: + type: optional + docs: >- + The disputed amount, which can be less than the total transaction + amount. + + For instance, if multiple items were purchased but the cardholder only + initiates a dispute over some of the items. + reason: + type: optional + docs: |- + The reason why the cardholder initiated the dispute. + See [DisputeReason](#type-disputereason) for possible values + state: + type: optional + docs: |- + The current state of this dispute. + See [DisputeState](#type-disputestate) for possible values + due_at: + type: optional> + docs: >- + The deadline by which the seller must respond to the dispute, in [RFC + 3339 + format](https://developer.squareup.com/docs/build-basics/common-data-types/working-with-dates). + validation: + minLength: 1 + maxLength: 40 + disputed_payment: + type: optional + docs: The payment challenged in this dispute. + evidence_ids: + type: optional>> + docs: The IDs of the evidence associated with the dispute. + card_brand: + type: optional + docs: |- + The card brand used in the disputed payment. + See [CardBrand](#type-cardbrand) for possible values + created_at: + type: optional + docs: The timestamp when the dispute was created, in RFC 3339 format. + validation: + minLength: 1 + maxLength: 40 + access: read-only + updated_at: + type: optional + docs: The timestamp when the dispute was last updated, in RFC 3339 format. + validation: + minLength: 1 + maxLength: 40 + access: read-only + brand_dispute_id: + type: optional> + docs: >- + The ID of the dispute in the card brand system, generated by the card + brand. + validation: + minLength: 1 + maxLength: 40 + reported_date: + type: optional> + docs: The timestamp when the dispute was reported, in RFC 3339 format. + validation: + minLength: 1 + maxLength: 40 + reported_at: + type: optional> + docs: The timestamp when the dispute was reported, in RFC 3339 format. + validation: + minLength: 1 + maxLength: 40 + version: + type: optional + docs: The current version of the `Dispute`. + location_id: + type: optional> + docs: The ID of the location where the dispute originated. + validation: + minLength: 1 + maxLength: 40 + source: + openapi: ../default/openapi/openapi.json + DisputeCreatedEvent: + docs: Published when a [Dispute](entity:Dispute) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeCreatedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidence: + properties: + evidence_id: + type: optional> + docs: The Square-generated ID of the evidence. + validation: + minLength: 1 + maxLength: 40 + id: + type: optional + docs: The Square-generated ID of the evidence. + validation: + minLength: 1 + maxLength: 40 + dispute_id: + type: optional> + docs: The ID of the dispute the evidence is associated with. + validation: + minLength: 1 + maxLength: 40 + evidence_file: + type: optional + docs: Image, PDF, TXT + evidence_text: + type: optional> + docs: Raw text + validation: + minLength: 1 + maxLength: 500 + uploaded_at: + type: optional> + docs: The time when the evidence was uploaded, in RFC 3339 format. + validation: + minLength: 1 + maxLength: 40 + evidence_type: + type: optional + docs: >- + The type of the evidence. + + See [DisputeEvidenceType](#type-disputeevidencetype) for possible + values + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceAddedEvent: + docs: >- + Published when evidence is added to a [Dispute](entity:Dispute) + + from the Disputes Dashboard in the Seller Dashboard, the Square Point of + Sale app, + + or by calling either + [CreateDisputeEvidenceFile](api-endpoint:Disputes-CreateDisputeEvidenceFile) + or + [CreateDisputeEvidenceText](api-endpoint:Disputes-CreateDisputeEvidenceText). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceAddedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceAddedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceCreatedEvent: + docs: >- + Published when evidence is added to a [Dispute](entity:Dispute) + + from the Disputes Dashboard in the Seller Dashboard, the Square Point of + Sale app, + + or by calling either + [CreateDisputeEvidenceFile](api-endpoint:Disputes-CreateDisputeEvidenceFile) + or + [CreateDisputeEvidenceText](api-endpoint:Disputes-CreateDisputeEvidenceText). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceCreatedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceDeletedEvent: + docs: >- + Published when evidence is removed from a [Dispute](entity:Dispute) + + from the Disputes Dashboard in the Seller Dashboard, the Square Point of + Sale app, + + or by calling + [DeleteDisputeEvidence](api-endpoint:Disputes-DeleteDisputeEvidence). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceDeletedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceDeletedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceFile: + docs: A file to be uploaded as dispute evidence. + properties: + filename: + type: optional> + docs: >- + The file name including the file extension. For example: + "receipt.tiff". + validation: + minLength: 1 + maxLength: 40 + filetype: + type: optional> + docs: >- + Dispute evidence files must be application/pdf, image/heic, + image/heif, image/jpeg, image/png, or image/tiff formats. + validation: + minLength: 1 + maxLength: 40 + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceRemovedEvent: + docs: >- + Published when evidence is removed from a [Dispute](entity:Dispute) + + from the Disputes Dashboard in the Seller Dashboard, the Square Point of + Sale app, + + or by calling + [DeleteDisputeEvidence](api-endpoint:Disputes-DeleteDisputeEvidence). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceRemovedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceRemovedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputeEvidenceType: + enum: + - GENERIC_EVIDENCE + - ONLINE_OR_APP_ACCESS_LOG + - AUTHORIZATION_DOCUMENTATION + - CANCELLATION_OR_REFUND_DOCUMENTATION + - CARDHOLDER_COMMUNICATION + - CARDHOLDER_INFORMATION + - PURCHASE_ACKNOWLEDGEMENT + - DUPLICATE_CHARGE_DOCUMENTATION + - PRODUCT_OR_SERVICE_DESCRIPTION + - RECEIPT + - SERVICE_RECEIVED_DOCUMENTATION + - PROOF_OF_DELIVERY_DOCUMENTATION + - RELATED_TRANSACTION_DOCUMENTATION + - REBUTTAL_EXPLANATION + - TRACKING_NUMBER + docs: The type of the dispute evidence. + source: + openapi: ../default/openapi/openapi.json + DisputeReason: + enum: + - AMOUNT_DIFFERS + - CANCELLED + - DUPLICATE + - NO_KNOWLEDGE + - NOT_AS_DESCRIBED + - NOT_RECEIVED + - PAID_BY_OTHER_MEANS + - CUSTOMER_REQUESTS_CREDIT + - EMV_LIABILITY_SHIFT + docs: |- + The list of possible reasons why a cardholder might initiate a + dispute with their bank. + source: + openapi: ../default/openapi/openapi.json + DisputeState: + enum: + - INQUIRY_EVIDENCE_REQUIRED + - INQUIRY_PROCESSING + - INQUIRY_CLOSED + - EVIDENCE_REQUIRED + - PROCESSING + - WON + - LOST + - ACCEPTED + docs: The list of possible dispute states. + source: + openapi: ../default/openapi/openapi.json + DisputeStateChangedEvent: + docs: >- + Published when the state of a [Dispute](entity:Dispute) changes. + + This includes the dispute resolution (WON, LOST) reported by the bank. The + event + + data includes details of what changed. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeStateChangedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeStateChangedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputeStateUpdatedEvent: + docs: >- + Published when the state of a [Dispute](entity:Dispute) changes. + + This includes the dispute resolution (WON, LOST) reported by the bank. The + event + + data includes details of what changed. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + DisputeStateUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected dispute's type. + id: + type: optional + docs: ID of the affected dispute. + object: + type: optional + docs: An object containing fields and values relevant to the event. + source: + openapi: ../default/openapi/openapi.json + DisputeStateUpdatedEventObject: + properties: + object: + type: optional + docs: The dispute object. + source: + openapi: ../default/openapi/openapi.json + DisputedPayment: + docs: The payment the cardholder disputed. + properties: + payment_id: + type: optional> + docs: Square-generated unique ID of the payment being disputed. + validation: + minLength: 1 + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + EcomVisibility: + enum: + - UNINDEXED + - UNAVAILABLE + - HIDDEN + - VISIBLE + docs: Determines item visibility in Ecom (Online Store) and Online Checkout. + source: + openapi: ../default/openapi/openapi.json + Employee: + docs: >- + An employee object that is used by the external API. + + + DEPRECATED at version 2020-08-26. Replaced by + [TeamMember](entity:TeamMember). + properties: + id: + type: optional + docs: UUID for this object. + first_name: + type: optional> + docs: The employee's first name. + last_name: + type: optional> + docs: The employee's last name. + email: + type: optional> + docs: The employee's email address + phone_number: + type: optional> + docs: The employee's phone number in E.164 format, i.e. "+12125554250" + location_ids: + type: optional>> + docs: A list of location IDs where this employee has access to. + status: + type: optional + docs: |- + Specifies the status of the employees being fetched. + See [EmployeeStatus](#type-employeestatus) for possible values + is_owner: + type: optional> + docs: |- + Whether this employee is the owner of the merchant. Each merchant + has one owner employee, and that employee has full authority over + the account. + created_at: + type: optional + docs: A read-only timestamp in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: A read-only timestamp in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + EmployeeStatus: + enum: + - ACTIVE + - INACTIVE + docs: >- + The status of the Employee being retrieved. + + + DEPRECATED at version 2020-08-26. Replaced by + [TeamMemberStatus](entity:TeamMemberStatus). + source: + openapi: ../default/openapi/openapi.json + EmployeeWage: + docs: >- + The hourly wage rate that an employee earns on a `Shift` for doing the job + specified by the `title` property of this object. Deprecated at version + 2020-08-26. Use [TeamMemberWage](entity:TeamMemberWage). + properties: + id: + type: optional + docs: The UUID for this object. + employee_id: + type: optional> + docs: The `Employee` that this wage is assigned to. + title: + type: optional> + docs: The job title that this wage relates to. + hourly_rate: + type: optional + docs: |- + Can be a custom-set hourly wage or the calculated effective hourly + wage based on the annual wage and hours worked per week. + source: + openapi: ../default/openapi/openapi.json + EnableEventsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [EnableEvents](api-endpoint:Events-EnableEvents) + endpoint. + + + Note: if there are errors processing the request, the events field will + not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + Error: + docs: >- + Represents an error encountered during a request to the Connect API. + + + See [Handling + errors](https://developer.squareup.com/docs/build-basics/handling-errors) + for more information. + properties: + category: + type: ErrorCategory + docs: |- + The high-level category for the error. + See [ErrorCategory](#type-errorcategory) for possible values + code: + type: ErrorCode + docs: |- + The specific code of the error. + See [ErrorCode](#type-errorcode) for possible values + detail: + type: optional + docs: A human-readable description of the error for debugging purposes. + field: + type: optional + docs: |- + The name of the field provided in the original request (if any) that + the error pertains to. + source: + openapi: ../default/openapi/openapi.json + ErrorCategory: + enum: + - API_ERROR + - AUTHENTICATION_ERROR + - INVALID_REQUEST_ERROR + - RATE_LIMIT_ERROR + - PAYMENT_METHOD_ERROR + - REFUND_ERROR + - MERCHANT_SUBSCRIPTION_ERROR + - EXTERNAL_VENDOR_ERROR + docs: |- + Indicates which high-level category of error has occurred during a + request to the Connect API. + source: + openapi: ../default/openapi/openapi.json + ErrorCode: + enum: + - INTERNAL_SERVER_ERROR + - UNAUTHORIZED + - ACCESS_TOKEN_EXPIRED + - ACCESS_TOKEN_REVOKED + - CLIENT_DISABLED + - FORBIDDEN + - INSUFFICIENT_SCOPES + - APPLICATION_DISABLED + - V1_APPLICATION + - V1_ACCESS_TOKEN + - CARD_PROCESSING_NOT_ENABLED + - MERCHANT_SUBSCRIPTION_NOT_FOUND + - BAD_REQUEST + - MISSING_REQUIRED_PARAMETER + - INCORRECT_TYPE + - INVALID_TIME + - INVALID_TIME_RANGE + - INVALID_VALUE + - INVALID_CURSOR + - UNKNOWN_QUERY_PARAMETER + - CONFLICTING_PARAMETERS + - EXPECTED_JSON_BODY + - INVALID_SORT_ORDER + - VALUE_REGEX_MISMATCH + - VALUE_TOO_SHORT + - VALUE_TOO_LONG + - VALUE_TOO_LOW + - VALUE_TOO_HIGH + - VALUE_EMPTY + - ARRAY_LENGTH_TOO_LONG + - ARRAY_LENGTH_TOO_SHORT + - ARRAY_EMPTY + - EXPECTED_BOOLEAN + - EXPECTED_INTEGER + - EXPECTED_FLOAT + - EXPECTED_STRING + - EXPECTED_OBJECT + - EXPECTED_ARRAY + - EXPECTED_MAP + - EXPECTED_BASE64_ENCODED_BYTE_ARRAY + - INVALID_ARRAY_VALUE + - INVALID_ENUM_VALUE + - INVALID_CONTENT_TYPE + - INVALID_FORM_VALUE + - CUSTOMER_NOT_FOUND + - ONE_INSTRUMENT_EXPECTED + - NO_FIELDS_SET + - TOO_MANY_MAP_ENTRIES + - MAP_KEY_LENGTH_TOO_SHORT + - MAP_KEY_LENGTH_TOO_LONG + - CUSTOMER_MISSING_NAME + - CUSTOMER_MISSING_EMAIL + - INVALID_PAUSE_LENGTH + - INVALID_DATE + - UNSUPPORTED_COUNTRY + - UNSUPPORTED_CURRENCY + - APPLE_TTP_PIN_TOKEN + - CARD_EXPIRED + - INVALID_EXPIRATION + - INVALID_EXPIRATION_YEAR + - INVALID_EXPIRATION_DATE + - UNSUPPORTED_CARD_BRAND + - UNSUPPORTED_ENTRY_METHOD + - INVALID_ENCRYPTED_CARD + - INVALID_CARD + - PAYMENT_AMOUNT_MISMATCH + - GENERIC_DECLINE + - CVV_FAILURE + - ADDRESS_VERIFICATION_FAILURE + - INVALID_ACCOUNT + - CURRENCY_MISMATCH + - INSUFFICIENT_FUNDS + - INSUFFICIENT_PERMISSIONS + - CARDHOLDER_INSUFFICIENT_PERMISSIONS + - INVALID_LOCATION + - TRANSACTION_LIMIT + - VOICE_FAILURE + - PAN_FAILURE + - EXPIRATION_FAILURE + - CARD_NOT_SUPPORTED + - READER_DECLINED + - INVALID_PIN + - MISSING_PIN + - MISSING_ACCOUNT_TYPE + - INVALID_POSTAL_CODE + - INVALID_FEES + - MANUALLY_ENTERED_PAYMENT_NOT_SUPPORTED + - PAYMENT_LIMIT_EXCEEDED + - GIFT_CARD_AVAILABLE_AMOUNT + - ACCOUNT_UNUSABLE + - BUYER_REFUSED_PAYMENT + - DELAYED_TRANSACTION_EXPIRED + - DELAYED_TRANSACTION_CANCELED + - DELAYED_TRANSACTION_CAPTURED + - DELAYED_TRANSACTION_FAILED + - CARD_TOKEN_EXPIRED + - CARD_TOKEN_USED + - AMOUNT_TOO_HIGH + - UNSUPPORTED_INSTRUMENT_TYPE + - REFUND_AMOUNT_INVALID + - REFUND_ALREADY_PENDING + - PAYMENT_NOT_REFUNDABLE + - PAYMENT_NOT_REFUNDABLE_DUE_TO_DISPUTE + - REFUND_ERROR_PAYMENT_NEEDS_COMPLETION + - REFUND_DECLINED + - INSUFFICIENT_PERMISSIONS_FOR_REFUND + - INVALID_CARD_DATA + - SOURCE_USED + - SOURCE_EXPIRED + - UNSUPPORTED_LOYALTY_REWARD_TIER + - LOCATION_MISMATCH + - ORDER_UNPAID_NOT_RETURNABLE + - IDEMPOTENCY_KEY_REUSED + - UNEXPECTED_VALUE + - SANDBOX_NOT_SUPPORTED + - INVALID_EMAIL_ADDRESS + - INVALID_PHONE_NUMBER + - CHECKOUT_EXPIRED + - BAD_CERTIFICATE + - INVALID_SQUARE_VERSION_FORMAT + - API_VERSION_INCOMPATIBLE + - CARD_PRESENCE_REQUIRED + - UNSUPPORTED_SOURCE_TYPE + - CARD_MISMATCH + - PLAID_ERROR + - PLAID_ERROR_ITEM_LOGIN_REQUIRED + - PLAID_ERROR_RATE_LIMIT + - CARD_DECLINED + - VERIFY_CVV_FAILURE + - VERIFY_AVS_FAILURE + - CARD_DECLINED_CALL_ISSUER + - CARD_DECLINED_VERIFICATION_REQUIRED + - BAD_EXPIRATION + - CHIP_INSERTION_REQUIRED + - ALLOWABLE_PIN_TRIES_EXCEEDED + - RESERVATION_DECLINED + - UNKNOWN_BODY_PARAMETER + - NOT_FOUND + - APPLE_PAYMENT_PROCESSING_CERTIFICATE_HASH_NOT_FOUND + - METHOD_NOT_ALLOWED + - NOT_ACCEPTABLE + - REQUEST_TIMEOUT + - CONFLICT + - GONE + - REQUEST_ENTITY_TOO_LARGE + - UNSUPPORTED_MEDIA_TYPE + - UNPROCESSABLE_ENTITY + - RATE_LIMITED + - NOT_IMPLEMENTED + - BAD_GATEWAY + - SERVICE_UNAVAILABLE + - TEMPORARY_ERROR + - GATEWAY_TIMEOUT + docs: |- + Indicates the specific error that occurred during a request to a + Square API. + source: + openapi: ../default/openapi/openapi.json + Event: + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + EventData: + properties: + type: + type: optional> + docs: The name of the affected object’s type. + id: + type: optional + docs: The ID of the affected object. + deleted: + type: optional> + docs: >- + This is true if the affected object has been deleted; otherwise, it's + absent. + object: + type: optional>> + docs: >- + An object containing fields and values relevant to the event. It is + absent if the affected object has been deleted. + source: + openapi: ../default/openapi/openapi.json + EventMetadata: + docs: Contains metadata about a particular [Event](entity:Event). + properties: + event_id: + type: optional> + docs: A unique ID for the event. + api_version: + type: optional> + docs: >- + The API version of the event. This corresponds to the default API + version of the developer application at the time when the event was + created. + source: + openapi: ../default/openapi/openapi.json + EventTypeMetadata: + docs: Contains the metadata of a webhook event type. + properties: + event_type: + type: optional + docs: The event type. + access: read-only + api_version_introduced: + type: optional + docs: The API version at which the event type was introduced. + access: read-only + release_status: + type: optional + docs: The release status of the event type. + access: read-only + source: + openapi: ../default/openapi/openapi.json + ExcludeStrategy: + enum: + - LEAST_EXPENSIVE + - MOST_EXPENSIVE + docs: |- + Indicates which products matched by a CatalogPricingRule + will be excluded if the pricing rule uses an exclude set. + source: + openapi: ../default/openapi/openapi.json + ExternalPaymentDetails: + docs: >- + Stores details about an external payment. Contains only non-confidential + information. + + For more information, see + + [Take External + Payments](https://developer.squareup.com/docs/payments-api/take-payments/external-payments). + properties: + type: + type: string + docs: >- + The type of external payment the seller received. It can be one of the + following: + + - CHECK - Paid using a physical check. + + - BANK_TRANSFER - Paid using external bank transfer. + + - OTHER\_GIFT\_CARD - Paid using a non-Square gift card. + + - CRYPTO - Paid using a crypto currency. + + - SQUARE_CASH - Paid using Square Cash App. + + - SOCIAL - Paid using peer-to-peer payment applications. + + - EXTERNAL - A third-party application gathered this payment outside + of Square. + + - EMONEY - Paid using an E-money provider. + + - CARD - A credit or debit card that Square does not support. + + - STORED_BALANCE - Use for house accounts, store credit, and so forth. + + - FOOD_VOUCHER - Restaurant voucher provided by employers to employees + to pay for meals + + - OTHER - A type not listed here. + validation: + maxLength: 50 + source: + type: string + docs: |- + A description of the external payment source. For example, + "Food Delivery Service". + validation: + maxLength: 255 + source_id: + type: optional> + docs: An ID to associate the payment to its originating source. + validation: + maxLength: 255 + source_fee_money: + type: optional + docs: |- + The fees paid to the source. The `amount_money` minus this field is + the net amount seller receives. + source: + openapi: ../default/openapi/openapi.json + FilterValue: + docs: >- + A filter to select resources based on an exact field value. For any given + + value, the value can only be in one property. Depending on the field, + either + + all properties can be set or only a subset will be available. + + + Refer to the documentation of the field. + properties: + all: + type: optional>> + docs: A list of terms that must be present on the field of the resource. + any: + type: optional>> + docs: |- + A list of terms where at least one of them must be present on the + field of the resource. + none: + type: optional>> + docs: A list of terms that must not be present on the field the resource + source: + openapi: ../default/openapi/openapi.json + FloatNumberRange: + docs: Specifies a decimal number range. + properties: + start_at: + type: optional> + docs: A decimal value indicating where the range starts. + end_at: + type: optional> + docs: A decimal value indicating where the range ends. + source: + openapi: ../default/openapi/openapi.json + Fulfillment: + docs: >- + Contains details about how to fulfill this order. + + Orders can only be created with at most one fulfillment using the API. + + However, orders returned by the Orders API might contain multiple + fulfillments because sellers can create multiple fulfillments using Square + products such as Square Online. + properties: + uid: + type: optional> + docs: A unique ID that identifies the fulfillment only within this order. + validation: + maxLength: 60 + type: + type: optional + docs: |- + The type of the fulfillment. + See [FulfillmentType](#type-fulfillmenttype) for possible values + state: + type: optional + docs: |- + The state of the fulfillment. + See [FulfillmentState](#type-fulfillmentstate) for possible values + line_item_application: + type: optional + docs: >- + Describes what order line items this fulfillment applies to. + + It can be `ALL` or `ENTRY_LIST` with a supplied list of fulfillment + entries. + + See + [FulfillmentFulfillmentLineItemApplication](#type-fulfillmentfulfillmentlineitemapplication) + for possible values + entries: + type: optional> + docs: >- + A list of entries pertaining to the fulfillment of an order. Each + entry must reference + + a valid `uid` for an order line item in the `line_item_uid` field, as + well as a `quantity` to + + fulfill. + + + Multiple entries can reference the same line item `uid`, as long as + the total quantity among + + all fulfillment entries referencing a single line item does not exceed + the quantity of the + + order's line item itself. + + + An order cannot be marked as `COMPLETED` before all fulfillments are + `COMPLETED`, + + `CANCELED`, or `FAILED`. Fulfillments can be created and completed + independently + + before order completion. + access: read-only + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this fulfillment. Metadata fields + are intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + pickup_details: + type: optional + docs: >- + Contains details for a pickup fulfillment. These details are required + when the fulfillment + + type is `PICKUP`. + shipment_details: + type: optional + docs: >- + Contains details for a shipment fulfillment. These details are + required when the fulfillment type + + is `SHIPMENT`. + + + A shipment fulfillment's relationship to fulfillment `state`: + + `PROPOSED`: A shipment is requested. + + `RESERVED`: Fulfillment in progress. Shipment processing. + + `PREPARED`: Shipment packaged. Shipping label created. + + `COMPLETED`: Package has been shipped. + + `CANCELED`: Shipment has been canceled. + + `FAILED`: Shipment has failed. + delivery_details: + type: optional + docs: Describes delivery details of an order fulfillment. + source: + openapi: ../default/openapi/openapi.json + FulfillmentDeliveryDetails: + docs: Describes delivery details of an order fulfillment. + properties: + recipient: + type: optional + docs: The contact information for the person to receive the fulfillment. + schedule_type: + type: >- + optional + docs: >- + Indicates the fulfillment delivery schedule type. If `SCHEDULED`, then + + `deliver_at` is required. If `ASAP`, then `prep_time_duration` is + required. The default is `SCHEDULED`. + + See + [OrderFulfillmentDeliveryDetailsScheduleType](#type-orderfulfillmentdeliverydetailsscheduletype) + for possible values + placed_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was placed. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + + + Must be in RFC 3339 timestamp format, e.g., + "2016-09-04T23:59:33.123Z". + access: read-only + deliver_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + that represents the start of the delivery period. + + When the fulfillment `schedule_type` is `ASAP`, the field is + automatically + + set to the current time plus the `prep_time_duration`. + + Otherwise, the application can set this field while the fulfillment + `state` is + + `PROPOSED`, `RESERVED`, or `PREPARED` (any time before the + + terminal state such as `COMPLETED`, `CANCELED`, and `FAILED`). + + + The timestamp must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + prep_time_duration: + type: optional> + docs: |- + The duration of time it takes to prepare and deliver this fulfillment. + The duration must be in RFC 3339 format (for example, "P1W3D"). + delivery_window_duration: + type: optional> + docs: >- + The time period after `deliver_at` in which to deliver the order. + + Applications can set this field when the fulfillment `state` is + + `PROPOSED`, `RESERVED`, or `PREPARED` (any time before the terminal + state + + such as `COMPLETED`, `CANCELED`, and `FAILED`). + + + The duration must be in RFC 3339 format (for example, "P1W3D"). + note: + type: optional> + docs: >- + Provides additional instructions about the delivery fulfillment. + + It is displayed in the Square Point of Sale application and set by the + API. + validation: + maxLength: 550 + completed_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicates when the seller completed the fulfillment. + + This field is automatically set when fulfillment `state` changes to + `COMPLETED`. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + in_progress_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicates when the seller started processing the fulfillment. + + This field is automatically set when the fulfillment `state` changes + to `RESERVED`. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + access: read-only + rejected_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was rejected. This field is + + automatically set when the fulfillment `state` changes to `FAILED`. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + access: read-only + ready_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the seller marked the fulfillment as ready for + + courier pickup. This field is automatically set when the fulfillment + `state` changes + + to PREPARED. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + access: read-only + delivered_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was delivered to the recipient. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + access: read-only + canceled_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was canceled. This field is + automatically + + set when the fulfillment `state` changes to `CANCELED`. + + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + access: read-only + cancel_reason: + type: optional> + docs: 'The delivery cancellation reason. Max length: 100 characters.' + validation: + maxLength: 100 + courier_pickup_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when an order can be picked up by the courier for delivery. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + courier_pickup_window_duration: + type: optional> + docs: >- + The time period after `courier_pickup_at` in which the courier should + pick up the order. + + The duration must be in RFC 3339 format (for example, "P1W3D"). + is_no_contact_delivery: + type: optional> + docs: Whether the delivery is preferred to be no contact. + dropoff_notes: + type: optional> + docs: >- + A note to provide additional instructions about how to deliver the + order. + validation: + maxLength: 550 + courier_provider_name: + type: optional> + docs: The name of the courier provider. + validation: + maxLength: 255 + courier_support_phone_number: + type: optional> + docs: The support phone number of the courier. + validation: + maxLength: 17 + square_delivery_id: + type: optional> + docs: The identifier for the delivery created by Square. + validation: + maxLength: 50 + external_delivery_id: + type: optional> + docs: >- + The identifier for the delivery created by the third-party courier + service. + validation: + maxLength: 50 + managed_delivery: + type: optional> + docs: >- + The flag to indicate the delivery is managed by a third party (ie + DoorDash), which means + + we may not receive all recipient information for PII purposes. + source: + openapi: ../default/openapi/openapi.json + FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType: + enum: + - SCHEDULED + - ASAP + docs: The schedule type of the delivery fulfillment. + source: + openapi: ../default/openapi/openapi.json + FulfillmentFulfillmentEntry: + docs: >- + Links an order line item to a fulfillment. Each entry must reference + + a valid `uid` for an order line item in the `line_item_uid` field, as well + as a `quantity` to + + fulfill. + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the fulfillment entry only within this + order. + validation: + maxLength: 60 + line_item_uid: + type: string + docs: The `uid` from the order line item. + validation: + minLength: 1 + quantity: + type: string + docs: >- + The quantity of the line item being fulfilled, formatted as a decimal + number. + + For example, `"3"`. + + + Fulfillments for line items with a `quantity_unit` can have + non-integer quantities. + + For example, `"1.70000"`. + validation: + minLength: 1 + maxLength: 12 + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this fulfillment entry. Metadata + fields are intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + source: + openapi: ../default/openapi/openapi.json + FulfillmentFulfillmentLineItemApplication: + enum: + - ALL + - ENTRY_LIST + docs: >- + The `line_item_application` describes what order line items this + fulfillment applies + + to. It can be `ALL` or `ENTRY_LIST` with a supplied list of fulfillment + entries. + source: + openapi: ../default/openapi/openapi.json + FulfillmentPickupDetails: + docs: Contains details necessary to fulfill a pickup order. + properties: + recipient: + type: optional + docs: >- + Information about the person to pick up this fulfillment from a + physical + + location. + expires_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when this fulfillment expires if it is not marked in + progress. The timestamp must be + + in RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). The + expiration time can only be set + + up to 7 days in the future. If `expires_at` is not set, any new + payments attached to the order + + are automatically completed. + auto_complete_duration: + type: optional> + docs: >- + The duration of time after which an in progress pickup fulfillment is + automatically moved + + to the `COMPLETED` state. The duration must be in RFC 3339 format (for + example, "P1W3D"). + + + If not set, this pickup fulfillment remains in progress until it is + canceled or completed. + schedule_type: + type: optional + docs: >- + The schedule type of the pickup fulfillment. Defaults to `SCHEDULED`. + + See + [FulfillmentPickupDetailsScheduleType](#type-fulfillmentpickupdetailsscheduletype) + for possible values + pickup_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + that represents the start of the pickup window. Must be in RFC 3339 + timestamp format, e.g., + + "2016-09-04T23:59:33.123Z". + + + For fulfillments with the schedule type `ASAP`, this is automatically + set + + to the current time plus the expected duration to prepare the + fulfillment. + pickup_window_duration: + type: optional> + docs: >- + The window of time in which the order should be picked up after the + `pickup_at` timestamp. + + Must be in RFC 3339 duration format, e.g., "P1W3D". Can be used as an + + informational guideline for merchants. + prep_time_duration: + type: optional> + docs: |- + The duration of time it takes to prepare this fulfillment. + The duration must be in RFC 3339 format (for example, "P1W3D"). + note: + type: optional> + docs: >- + A note to provide additional instructions about the pickup + + fulfillment displayed in the Square Point of Sale application and set + by the API. + validation: + maxLength: 500 + placed_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was placed. The timestamp must be in + RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + accepted_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was marked in progress. The timestamp + must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + rejected_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was rejected. The timestamp must be in + RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + ready_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment is marked as ready for pickup. The + timestamp must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + expired_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment expired. The timestamp must be in RFC + 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + picked_up_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was picked up by the recipient. The + timestamp must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + canceled_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the fulfillment was canceled. The timestamp must be in + RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + cancel_reason: + type: optional> + docs: >- + A description of why the pickup was canceled. The maximum length: 100 + characters. + validation: + maxLength: 100 + is_curbside_pickup: + type: optional> + docs: >- + If set to `true`, indicates that this pickup order is for curbside + pickup, not in-store pickup. + curbside_pickup_details: + type: optional + docs: >- + Specific details for curbside pickup. These details can only be + populated if `is_curbside_pickup` is set to `true`. + source: + openapi: ../default/openapi/openapi.json + FulfillmentPickupDetailsCurbsidePickupDetails: + docs: Specific details for curbside pickup. + properties: + curbside_details: + type: optional> + docs: >- + Specific details for curbside pickup, such as parking number and + vehicle model. + validation: + maxLength: 250 + buyer_arrived_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the buyer arrived and is waiting for pickup. The + timestamp must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + source: + openapi: ../default/openapi/openapi.json + FulfillmentPickupDetailsScheduleType: + enum: + - SCHEDULED + - ASAP + docs: The schedule type of the pickup fulfillment. + source: + openapi: ../default/openapi/openapi.json + FulfillmentRecipient: + docs: Information about the fulfillment recipient. + properties: + customer_id: + type: optional> + docs: >- + The ID of the customer associated with the fulfillment. + + + If `customer_id` is provided, the fulfillment recipient's + `display_name`, + + `email_address`, and `phone_number` are automatically populated from + the + + targeted customer profile. If these fields are set in the request, the + request + + values override the information from the customer profile. If the + + targeted customer profile does not contain the necessary information + and + + these fields are left unset, the request results in an error. + validation: + maxLength: 191 + display_name: + type: optional> + docs: >- + The display name of the fulfillment recipient. This field is required. + + + If provided, the display name overrides the corresponding customer + profile value + + indicated by `customer_id`. + validation: + maxLength: 255 + email_address: + type: optional> + docs: >- + The email address of the fulfillment recipient. + + + If provided, the email address overrides the corresponding customer + profile value + + indicated by `customer_id`. + validation: + maxLength: 255 + phone_number: + type: optional> + docs: >- + The phone number of the fulfillment recipient. This field is required. + + + If provided, the phone number overrides the corresponding customer + profile value + + indicated by `customer_id`. + validation: + maxLength: 17 + address: + type: optional
+ docs: >- + The address of the fulfillment recipient. This field is required. + + + If provided, the address overrides the corresponding customer profile + value + + indicated by `customer_id`. + source: + openapi: ../default/openapi/openapi.json + FulfillmentShipmentDetails: + docs: Contains the details necessary to fulfill a shipment order. + properties: + recipient: + type: optional + docs: Information about the person to receive this shipment fulfillment. + carrier: + type: optional> + docs: >- + The shipping carrier being used to ship this fulfillment (such as UPS, + FedEx, or USPS). + validation: + maxLength: 50 + shipping_note: + type: optional> + docs: A note with additional information for the shipping carrier. + validation: + maxLength: 500 + shipping_type: + type: optional> + docs: >- + A description of the type of shipping product purchased from the + carrier + + (such as First Class, Priority, or Express). + validation: + maxLength: 50 + tracking_number: + type: optional> + docs: >- + The reference number provided by the carrier to track the shipment's + progress. + validation: + maxLength: 100 + tracking_url: + type: optional> + docs: A link to the tracking webpage on the carrier's website. + validation: + maxLength: 2000 + placed_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the shipment was requested. The timestamp must be in + RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + in_progress_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when this fulfillment was moved to the `RESERVED` state, + which indicates that preparation + + of this shipment has begun. The timestamp must be in RFC 3339 format + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + packaged_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when this fulfillment was moved to the `PREPARED` state, + which indicates that the + + fulfillment is packaged. The timestamp must be in RFC 3339 format (for + example, "2016-09-04T23:59:33.123Z"). + access: read-only + expected_shipped_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the shipment is expected to be delivered to the + shipping carrier. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + shipped_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when this fulfillment was moved to the `COMPLETED` state, + which indicates that + + the fulfillment has been given to the shipping carrier. The timestamp + must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + canceled_at: + type: optional> + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating the shipment was canceled. + + The timestamp must be in RFC 3339 format (for example, + "2016-09-04T23:59:33.123Z"). + cancel_reason: + type: optional> + docs: A description of why the shipment was canceled. + validation: + maxLength: 100 + failed_at: + type: optional + docs: >- + The + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + + indicating when the shipment failed to be completed. The timestamp + must be in RFC 3339 format + + (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + failure_reason: + type: optional> + docs: A description of why the shipment failed to be completed. + validation: + maxLength: 100 + source: + openapi: ../default/openapi/openapi.json + FulfillmentState: + enum: + - PROPOSED + - RESERVED + - PREPARED + - COMPLETED + - CANCELED + - FAILED + docs: The current state of this fulfillment. + source: + openapi: ../default/openapi/openapi.json + FulfillmentType: + enum: + - PICKUP + - SHIPMENT + - DELIVERY + docs: The type of fulfillment. + source: + openapi: ../default/openapi/openapi.json + GetBankAccountByV1IdResponse: + docs: Response object returned by GetBankAccountByV1Id. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + bank_account: + type: optional + docs: The requested `BankAccount` object. + source: + openapi: ../default/openapi/openapi.json + GetBankAccountResponse: + docs: Response object returned by `GetBankAccount`. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + bank_account: + type: optional + docs: The requested `BankAccount` object. + source: + openapi: ../default/openapi/openapi.json + GetBreakTypeResponse: + docs: >- + The response to a request to get a `BreakType`. The response contains + + the requested `BreakType` objects and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + break_type: + type: optional + docs: The response object. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetDeviceCodeResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + device_code: + type: optional + docs: The queried DeviceCode. + source: + openapi: ../default/openapi/openapi.json + GetDeviceResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + device: + type: optional + docs: The requested `Device`. + source: + openapi: ../default/openapi/openapi.json + GetEmployeeWageResponse: + docs: >- + A response to a request to get an `EmployeeWage`. The response contains + + the requested `EmployeeWage` objects and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + employee_wage: + type: optional + docs: The requested `EmployeeWage` object. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetInvoiceResponse: + docs: Describes a `GetInvoice` response. + properties: + invoice: + type: optional + docs: The invoice requested. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + GetPaymentRefundResponse: + docs: >- + Defines the response returned by + [GetRefund](api-endpoint:Refunds-GetPaymentRefund). + + + Note: If there are errors processing the request, the refund field might + not be + + present or it might be present in a FAILED state. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refund: + type: optional + docs: The requested `PaymentRefund`. + source: + openapi: ../default/openapi/openapi.json + GetPaymentResponse: + docs: >- + Defines the response returned by + [GetPayment](api-endpoint:Payments-GetPayment). + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + payment: + type: optional + docs: The requested `Payment`. + source: + openapi: ../default/openapi/openapi.json + GetPayoutResponse: + properties: + payout: + type: optional + docs: The requested payout. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + GetShiftResponse: + docs: |- + A response to a request to get a `Shift`. The response contains + the requested `Shift` object and might contain a set of `Error` objects if + the request resulted in errors. + properties: + shift: + type: optional + docs: The requested `Shift`. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetTeamMemberWageResponse: + docs: >- + A response to a request to get a `TeamMemberWage`. The response contains + + the requested `TeamMemberWage` objects and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + team_member_wage: + type: optional + docs: The requested `TeamMemberWage` object. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetTerminalActionResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + action: + type: optional + docs: The requested `TerminalAction` + source: + openapi: ../default/openapi/openapi.json + GetTerminalCheckoutResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + checkout: + type: optional + docs: The requested `TerminalCheckout`. + source: + openapi: ../default/openapi/openapi.json + GetTerminalRefundResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refund: + type: optional + docs: The requested `Refund`. + source: + openapi: ../default/openapi/openapi.json + GiftCard: + docs: Represents a Square gift card. + properties: + id: + type: optional + docs: The Square-assigned ID of the gift card. + access: read-only + type: + type: GiftCardType + docs: |- + The gift card type. + See [Type](#type-type) for possible values + gan_source: + type: optional + docs: >- + The source that generated the gift card account number (GAN). The + default value is `SQUARE`. + + See [GANSource](#type-gansource) for possible values + state: + type: optional + docs: |- + The current gift card state. + See [Status](#type-status) for possible values + balance_money: + type: optional + docs: >- + The current gift card balance. This balance is always greater than or + equal to zero. + gan: + type: optional> + docs: >- + The gift card account number (GAN). Buyers can use the GAN to make + purchases or check + + the gift card balance. + created_at: + type: optional + docs: >- + The timestamp when the gift card was created, in RFC 3339 format. + + In the case of a digital gift card, it is the time when you create a + card + + (using the Square Point of Sale application, Seller Dashboard, or Gift + Cards API). + + In the case of a plastic gift card, it is the time when Square + associates the card with the + + seller at the time of activation. + access: read-only + customer_ids: + type: optional> + docs: >- + The IDs of the [customer profiles](entity:Customer) to whom this gift + card is linked. + access: read-only + source: + openapi: ../default/openapi/openapi.json + GiftCardActivity: + docs: >- + Represents an action performed on a [gift card](entity:GiftCard) that + affects its state or balance. + + A gift card activity contains information about a specific activity type. + For example, a `REDEEM` activity + + includes a `redeem_activity_details` field that contains information about + the redemption. + properties: + id: + type: optional + docs: The Square-assigned ID of the gift card activity. + access: read-only + type: + type: GiftCardActivityType + docs: |- + The type of gift card activity. + See [Type](#type-type) for possible values + location_id: + type: string + docs: >- + The ID of the [business location](entity:Location) where the activity + occurred. + created_at: + type: optional + docs: >- + The timestamp when the gift card activity was created, in RFC 3339 + format. + access: read-only + gift_card_id: + type: optional> + docs: >- + The gift card ID. When creating a gift card activity, `gift_card_id` + is not required if + + `gift_card_gan` is specified. + gift_card_gan: + type: optional> + docs: >- + The gift card account number (GAN). When creating a gift card + activity, `gift_card_gan` + + is not required if `gift_card_id` is specified. + gift_card_balance_money: + type: optional + docs: The final balance on the gift card after the action is completed. + load_activity_details: + type: optional + docs: >- + Additional details about a `LOAD` activity, which is used to reload + money onto a gift card. + activate_activity_details: + type: optional + docs: >- + Additional details about an `ACTIVATE` activity, which is used to + activate a gift card with + + an initial balance. + redeem_activity_details: + type: optional + docs: >- + Additional details about a `REDEEM` activity, which is used to redeem + a gift card for a purchase. + + + For applications that process payments using the Square Payments API, + Square creates a `REDEEM` activity that + + updates the gift card balance after the corresponding + [CreatePayment](api-endpoint:Payments-CreatePayment) + + request is completed. Applications that use a custom payment + processing system must call + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + to create the `REDEEM` activity. + clear_balance_activity_details: + type: optional + docs: >- + Additional details about a `CLEAR_BALANCE` activity, which is used to + set the balance of a gift card to zero. + deactivate_activity_details: + type: optional + docs: >- + Additional details about a `DEACTIVATE` activity, which is used to + deactivate a gift card. + adjust_increment_activity_details: + type: optional + docs: >- + Additional details about an `ADJUST_INCREMENT` activity, which is used + to add money to a gift card + + outside of a typical `ACTIVATE`, `LOAD`, or `REFUND` activity flow. + adjust_decrement_activity_details: + type: optional + docs: >- + Additional details about an `ADJUST_DECREMENT` activity, which is used + to deduct money from a gift + + card outside of a typical `REDEEM` activity flow. + refund_activity_details: + type: optional + docs: >- + Additional details about a `REFUND` activity, which is used to add + money to a gift card when + + refunding a payment. + + + For applications that refund payments to a gift card using the Square + Refunds API, Square automatically + + creates a `REFUND` activity that updates the gift card balance after a + [RefundPayment](api-endpoint:Refunds-RefundPayment) + + request is completed. Applications that use a custom processing system + must call + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + to create the `REFUND` activity. + unlinked_activity_refund_activity_details: + type: optional + docs: >- + Additional details about an `UNLINKED_ACTIVITY_REFUND` activity. This + activity is used to add money + + to a gift card when refunding a payment that was processed using a + custom payment processing system + + and not linked to the gift card. + import_activity_details: + type: optional + docs: >- + Additional details about an `IMPORT` activity, which Square uses to + import a third-party + + gift card with a balance. + block_activity_details: + type: optional + docs: >- + Additional details about a `BLOCK` activity, which Square uses to + temporarily block a gift card. + unblock_activity_details: + type: optional + docs: >- + Additional details about an `UNBLOCK` activity, which Square uses to + unblock a gift card. + import_reversal_activity_details: + type: optional + docs: >- + Additional details about an `IMPORT_REVERSAL` activity, which Square + uses to reverse the + + import of a third-party gift card. + transfer_balance_to_activity_details: + type: optional + docs: >- + Additional details about a `TRANSFER_BALANCE_TO` activity, which + Square uses to add money to + + a gift card as the result of a transfer from another gift card. + transfer_balance_from_activity_details: + type: optional + docs: >- + Additional details about a `TRANSFER_BALANCE_FROM` activity, which + Square uses to deduct money from + + a gift as the result of a transfer to another gift card. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityActivate: + docs: >- + Represents details about an `ACTIVATE` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: optional + docs: >- + The amount added to the gift card. This value is a positive integer. + + + Applications that use a custom order processing system must specify + this amount in the + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + order_id: + type: optional> + docs: >- + The ID of the [order](entity:Order) that contains the `GIFT_CARD` line + item. + + + Applications that use the Square Orders API to process orders must + specify the order ID + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + line_item_uid: + type: optional> + docs: >- + The UID of the `GIFT_CARD` line item in the order that represents the + gift card purchase. + + + Applications that use the Square Orders API to process orders must + specify the line item UID + + in the + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + reference_id: + type: optional> + docs: >- + A client-specified ID that associates the gift card activity with an + entity in another system. + + + Applications that use a custom order processing system can use this + field to track information + + related to an order or payment. + buyer_payment_instrument_ids: + type: optional>> + docs: >- + The payment instrument IDs used to process the gift card purchase, + such as a credit card ID + + or bank account ID. + + + Applications that use a custom order processing system must specify + payment instrument IDs in + + the + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + + Square uses this information to perform compliance checks. + + + For applications that use the Square Orders API to process payments, + Square has the necessary + + instrument IDs to perform compliance checks. + + + Each buyer payment instrument ID can contain a maximum of 255 + characters. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityAdjustDecrement: + docs: >- + Represents details about an `ADJUST_DECREMENT` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: Money + docs: >- + The amount deducted from the gift card balance. This value is a + positive integer. + reason: + type: GiftCardActivityAdjustDecrementReason + docs: |- + The reason the gift card balance was adjusted. + See [Reason](#type-reason) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityAdjustDecrementReason: + enum: + - SUSPICIOUS_ACTIVITY + - BALANCE_ACCIDENTALLY_INCREASED + - SUPPORT_ISSUE + - PURCHASE_WAS_REFUNDED + docs: >- + Indicates the reason for deducting money from a [gift + card](entity:GiftCard). + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityAdjustIncrement: + docs: >- + Represents details about an `ADJUST_INCREMENT` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: Money + docs: >- + The amount added to the gift card balance. This value is a positive + integer. + reason: + type: GiftCardActivityAdjustIncrementReason + docs: |- + The reason the gift card balance was adjusted. + See [Reason](#type-reason) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityAdjustIncrementReason: + enum: + - COMPLIMENTARY + - SUPPORT_ISSUE + - TRANSACTION_VOIDED + docs: Indicates the reason for adding money to a [gift card](entity:GiftCard). + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityBlock: + docs: >- + Represents details about a `BLOCK` [gift card activity + type](entity:GiftCardActivityType). + properties: + reason: + type: GiftCardActivityBlockReason + docs: |- + The reason the gift card was blocked. + See [Reason](#type-reason) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityBlockReason: + type: literal<"CHARGEBACK_BLOCK"> + docs: Indicates the reason for blocking a [gift card](entity:GiftCard). + GiftCardActivityClearBalance: + docs: >- + Represents details about a `CLEAR_BALANCE` [gift card activity + type](entity:GiftCardActivityType). + properties: + reason: + type: GiftCardActivityClearBalanceReason + docs: |- + The reason the gift card balance was cleared. + See [Reason](#type-reason) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityClearBalanceReason: + enum: + - SUSPICIOUS_ACTIVITY + - REUSE_GIFTCARD + - UNKNOWN_REASON + docs: >- + Indicates the reason for clearing the balance of a [gift + card](entity:GiftCard). + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityCreatedEvent: + docs: Published when a [gift card activity](entity:GiftCardActivity) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `gift_card.activity.created`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityCreatedEventData: + docs: Represents the data associated with a `gift_card.activity.created` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `gift_card_activity`. + id: + type: optional + docs: The ID of the new gift card activity. + object: + type: optional + docs: An object that contains the new gift card activity. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityCreatedEventObject: + docs: |- + An object that contains the gift card activity associated with a + `gift_card.activity.created` event. + properties: + gift_card_activity: + type: optional + docs: The new gift card activity. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityDeactivate: + docs: >- + Represents details about a `DEACTIVATE` [gift card activity + type](entity:GiftCardActivityType). + properties: + reason: + type: GiftCardActivityDeactivateReason + docs: |- + The reason the gift card was deactivated. + See [Reason](#type-reason) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityDeactivateReason: + enum: + - SUSPICIOUS_ACTIVITY + - UNKNOWN_REASON + - CHARGEBACK_DEACTIVATE + docs: Indicates the reason for deactivating a [gift card](entity:GiftCard). + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityImport: + docs: >- + Represents details about an `IMPORT` [gift card activity + type](entity:GiftCardActivityType). + + This activity type is used when Square imports a third-party gift card, in + which case the + + `gan_source` of the gift card is set to `OTHER`. + properties: + amount_money: + type: Money + docs: The balance amount on the imported gift card. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityImportReversal: + docs: >- + Represents details about an `IMPORT_REVERSAL` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: Money + docs: |- + The amount of money cleared from the third-party gift card when + the import was reversed. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityLoad: + docs: >- + Represents details about a `LOAD` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: optional + docs: >- + The amount added to the gift card. This value is a positive integer. + + + Applications that use a custom order processing system must specify + this amount in the + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + order_id: + type: optional> + docs: >- + The ID of the [order](entity:Order) that contains the `GIFT_CARD` line + item. + + + Applications that use the Square Orders API to process orders must + specify the order ID in the + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + line_item_uid: + type: optional> + docs: >- + The UID of the `GIFT_CARD` line item in the order that represents the + additional funds for the gift card. + + + Applications that use the Square Orders API to process orders must + specify the line item UID + + in the + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + reference_id: + type: optional> + docs: >- + A client-specified ID that associates the gift card activity with an + entity in another system. + + + Applications that use a custom order processing system can use this + field to track information related to + + an order or payment. + buyer_payment_instrument_ids: + type: optional>> + docs: >- + The payment instrument IDs used to process the order for the + additional funds, such as a credit card ID + + or bank account ID. + + + Applications that use a custom order processing system must specify + payment instrument IDs in + + the + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + + Square uses this information to perform compliance checks. + + + For applications that use the Square Orders API to process payments, + Square has the necessary + + instrument IDs to perform compliance checks. + + + Each buyer payment instrument ID can contain a maximum of 255 + characters. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityRedeem: + docs: >- + Represents details about a `REDEEM` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: Money + docs: >- + The amount deducted from the gift card for the redemption. This value + is a positive integer. + + + Applications that use a custom payment processing system must specify + this amount in the + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + request. + payment_id: + type: optional + docs: >- + The ID of the payment that represents the gift card redemption. Square + populates this field + + if the payment was processed by Square. + access: read-only + reference_id: + type: optional> + docs: >- + A client-specified ID that associates the gift card activity with an + entity in another system. + + + Applications that use a custom payment processing system can use this + field to track information + + related to an order or payment. + status: + type: optional + docs: >- + The status of the gift card redemption. Gift cards redeemed from + Square Point of Sale or the + + Square Seller Dashboard use a two-state process: `PENDING` + + to `COMPLETED` or `PENDING` to `CANCELED`. Gift cards redeemed using + the Gift Card Activities API + + always have a `COMPLETED` status. + + See [Status](#type-status) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityRedeemStatus: + enum: + - PENDING + - COMPLETED + - CANCELED + docs: >- + Indicates the status of a [gift card](entity:GiftCard) redemption. This + status is relevant only for + + redemptions made from Square products (such as Square Point of Sale) + because Square products use a + + two-state process. Gift cards redeemed using the Gift Card Activities API + always have a `COMPLETED` status. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityRefund: + docs: >- + Represents details about a `REFUND` [gift card activity + type](entity:GiftCardActivityType). + properties: + redeem_activity_id: + type: optional> + docs: >- + The ID of the refunded `REDEEM` gift card activity. Square populates + this field if the + + `payment_id` in the corresponding + [RefundPayment](api-endpoint:Refunds-RefundPayment) request + + represents a gift card redemption. + + + For applications that use a custom payment processing system, this + field is required when creating + + a `REFUND` activity. The provided `REDEEM` activity ID must be linked + to the same gift card. + amount_money: + type: optional + docs: >- + The amount added to the gift card for the refund. This value is a + positive integer. + + + This field is required when creating a `REFUND` activity. The amount + can represent a full or partial refund. + reference_id: + type: optional> + docs: >- + A client-specified ID that associates the gift card activity with an + entity in another system. + payment_id: + type: optional + docs: >- + The ID of the refunded payment. Square populates this field if the + refund is for a + + payment processed by Square. This field matches the `payment_id` in + the corresponding + + [RefundPayment](api-endpoint:Refunds-RefundPayment) request. + access: read-only + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityTransferBalanceFrom: + docs: >- + Represents details about a `TRANSFER_BALANCE_FROM` [gift card activity + type](entity:GiftCardActivityType). + properties: + transfer_to_gift_card_id: + type: string + docs: The ID of the gift card to which the specified amount was transferred. + amount_money: + type: Money + docs: >- + The amount deducted from the gift card for the transfer. This value is + a positive integer. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityTransferBalanceTo: + docs: >- + Represents details about a `TRANSFER_BALANCE_TO` [gift card activity + type](entity:GiftCardActivityType). + properties: + transfer_from_gift_card_id: + type: string + docs: >- + The ID of the gift card from which the specified amount was + transferred. + amount_money: + type: Money + docs: >- + The amount added to the gift card balance for the transfer. This value + is a positive integer. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityType: + enum: + - ACTIVATE + - LOAD + - REDEEM + - CLEAR_BALANCE + - DEACTIVATE + - ADJUST_INCREMENT + - ADJUST_DECREMENT + - REFUND + - UNLINKED_ACTIVITY_REFUND + - IMPORT + - BLOCK + - UNBLOCK + - IMPORT_REVERSAL + - TRANSFER_BALANCE_FROM + - TRANSFER_BALANCE_TO + docs: Indicates the type of [gift card activity](entity:GiftCardActivity). + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityUnblock: + docs: >- + Represents details about an `UNBLOCK` [gift card activity + type](entity:GiftCardActivityType). + properties: + reason: + type: GiftCardActivityUnblockReason + docs: |- + The reason the gift card was unblocked. + See [Reason](#type-reason) for possible values + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityUnblockReason: + type: literal<"CHARGEBACK_UNBLOCK"> + docs: Indicates the reason for unblocking a [gift card](entity:GiftCard). + GiftCardActivityUnlinkedActivityRefund: + docs: >- + Represents details about an `UNLINKED_ACTIVITY_REFUND` [gift card activity + type](entity:GiftCardActivityType). + properties: + amount_money: + type: Money + docs: >- + The amount added to the gift card for the refund. This value is a + positive integer. + reference_id: + type: optional> + docs: >- + A client-specified ID that associates the gift card activity with an + entity in another system. + payment_id: + type: optional + docs: >- + The ID of the refunded payment. This field is not used starting in + Square version 2022-06-16. + access: read-only + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityUpdatedEvent: + docs: >- + Published when a [gift card activity](entity:GiftCardActivity) is + updated. + + Subscribe to this event to be notified about the following changes: + + - An update to the `REDEEM` activity for a gift card redemption made from + a Square product (such as Square Point of Sale). + + These redemptions are initially assigned a `PENDING` state, but then + change to a `COMPLETED` or `CANCELED` state. + + - An update to the `IMPORT` activity for an imported gift card when the + balance is later adjusted by Square. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `gift_card.activity.updated`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityUpdatedEventData: + docs: The data associated with a `gift_card.activity.updated` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `gift_card_activity`. + id: + type: optional + docs: The ID of the updated gift card activity. + object: + type: optional + docs: An object that contains the updated gift card activity. + source: + openapi: ../default/openapi/openapi.json + GiftCardActivityUpdatedEventObject: + docs: |- + An object that contains the gift card activity associated with a + `gift_card.activity.updated` event. + properties: + gift_card_activity: + type: optional + docs: The updated gift card activity. + source: + openapi: ../default/openapi/openapi.json + GiftCardCreatedEvent: + docs: Published when a [gift card](entity:GiftCard) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: The type of event. For this event, the value is `gift_card.created`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + GiftCardCreatedEventData: + docs: The data associated with a `gift_card.created` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `gift_card`. + id: + type: optional + docs: The ID of the new gift card. + object: + type: optional + docs: An object that contains the new gift card. + source: + openapi: ../default/openapi/openapi.json + GiftCardCreatedEventObject: + docs: >- + An object that contains the gift card associated with a + `gift_card.created` event. + properties: + gift_card: + type: optional + docs: The new gift card. + source: + openapi: ../default/openapi/openapi.json + GiftCardCustomerLinkedEvent: + docs: >- + Published when a [customer](entity:Customer) is linked to a [gift + card](entity:GiftCard). + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `gift_card.customer_linked`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + GiftCardCustomerLinkedEventData: + docs: The data associated with a `gift_card.customer_linked` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `gift_card`. + id: + type: optional + docs: The ID of the updated gift card. + object: + type: optional + docs: >- + An object that contains the updated gift card and the ID of the linked + customer. + source: + openapi: ../default/openapi/openapi.json + GiftCardCustomerLinkedEventObject: + docs: |- + An object that contains the gift card and customer ID associated with a + `gift_card.customer_linked` event. + properties: + gift_card: + type: optional + docs: The gift card with the updated `customer_ids` field. + linked_customer_id: + type: optional> + docs: The ID of the linked [customer](entity:Customer). + source: + openapi: ../default/openapi/openapi.json + GiftCardCustomerUnlinkedEvent: + docs: >- + Published when a [customer](entity:Customer) is unlinked from a [gift + card](entity:GiftCard). + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `gift_card.customer_unlinked`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + GiftCardCustomerUnlinkedEventData: + docs: The data associated with a `gift_card.customer_unlinked` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `gift_card`. + id: + type: optional + docs: The ID of the updated gift card. + object: + type: optional + docs: >- + An object that contains the updated gift card and the ID of the + unlinked customer. + source: + openapi: ../default/openapi/openapi.json + GiftCardCustomerUnlinkedEventObject: + docs: >- + An object that contains the gift card and the customer ID associated with + a + + `gift_card.customer_linked` event. + properties: + gift_card: + type: optional + docs: |- + The gift card with the updated `customer_ids` field. + The field is removed if the gift card is not linked to any customers. + unlinked_customer_id: + type: optional> + docs: The ID of the unlinked [customer](entity:Customer). + source: + openapi: ../default/openapi/openapi.json + GiftCardGanSource: + enum: + - SQUARE + - OTHER + docs: |- + Indicates the source that generated the gift card + account number (GAN). + source: + openapi: ../default/openapi/openapi.json + GiftCardStatus: + enum: + - ACTIVE + - DEACTIVATED + - BLOCKED + - PENDING + docs: Indicates the gift card state. + source: + openapi: ../default/openapi/openapi.json + GiftCardType: + enum: + - PHYSICAL + - DIGITAL + docs: Indicates the gift card type. + source: + openapi: ../default/openapi/openapi.json + GiftCardUpdatedEvent: + docs: |- + Published when a [gift card](entity:GiftCard) is updated. This includes + changes to the state, balance, and customer association. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. For this event, the value is + `gift_card.updated`. + event_id: + type: optional> + docs: >- + The unique ID of the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + GiftCardUpdatedEventData: + docs: The data associated with a `gift_card.updated` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `gift_card`. + id: + type: optional + docs: The ID of the updated gift card. + object: + type: optional + docs: An object that contains the updated gift card. + source: + openapi: ../default/openapi/openapi.json + GiftCardUpdatedEventObject: + docs: >- + An object that contains the gift card associated with a + `gift_card.updated` event. + properties: + gift_card: + type: optional + docs: >- + The gift card with the updated `balance_money`, `state`, or + `customer_ids` field. + + Some events can affect both `balance_money` and `state`. + source: + openapi: ../default/openapi/openapi.json + InventoryAdjustment: + docs: |- + Represents a change in state or quantity of product inventory at a + particular time and location. + properties: + id: + type: optional + docs: |- + A unique ID generated by Square for the + `InventoryAdjustment`. + validation: + maxLength: 100 + reference_id: + type: optional> + docs: |- + An optional ID provided by the application to tie the + `InventoryAdjustment` to an external + system. + validation: + maxLength: 255 + from_state: + type: optional + docs: |- + The [inventory state](entity:InventoryState) of the related quantity + of items before the adjustment. + See [InventoryState](#type-inventorystate) for possible values + to_state: + type: optional + docs: |- + The [inventory state](entity:InventoryState) of the related quantity + of items after the adjustment. + See [InventoryState](#type-inventorystate) for possible values + location_id: + type: optional> + docs: >- + The Square-generated ID of the [Location](entity:Location) where the + related + + quantity of items is being tracked. + validation: + maxLength: 100 + catalog_object_id: + type: optional> + docs: |- + The Square-generated ID of the + [CatalogObject](entity:CatalogObject) being tracked. + validation: + maxLength: 100 + catalog_object_type: + type: optional> + docs: >- + The [type](entity:CatalogObjectType) of the + [CatalogObject](entity:CatalogObject) being tracked. + + + The Inventory API supports setting and reading the + `"catalog_object_type": "ITEM_VARIATION"` field value. + + In addition, it can also read the `"catalog_object_type": "ITEM"` + field value that is set by the Square Restaurants app. + validation: + maxLength: 14 + quantity: + type: optional> + docs: |- + The number of items affected by the adjustment as a decimal string. + Can support up to 5 digits after the decimal point. + validation: + maxLength: 26 + total_price_money: + type: optional + docs: |- + The total price paid for goods associated with the + adjustment. Present if and only if `to_state` is `SOLD`. Always + non-negative. + occurred_at: + type: optional> + docs: >- + A client-generated RFC 3339-formatted timestamp that indicates when + + the inventory adjustment took place. For inventory adjustment updates, + the `occurred_at` + + timestamp cannot be older than 24 hours or in the future relative to + the + + time of the request. + validation: + maxLength: 34 + created_at: + type: optional + docs: >- + An RFC 3339-formatted timestamp that indicates when the inventory + adjustment is received. + validation: + maxLength: 34 + access: read-only + source: + type: optional + docs: |- + Information about the application that caused the + inventory adjustment. + employee_id: + type: optional> + docs: >- + The Square-generated ID of the [Employee](entity:Employee) responsible + for the + + inventory adjustment. + validation: + maxLength: 100 + team_member_id: + type: optional> + docs: >- + The Square-generated ID of the [Team Member](entity:TeamMember) + responsible for the + + inventory adjustment. + validation: + maxLength: 100 + transaction_id: + type: optional + docs: |- + The Square-generated ID of the [Transaction](entity:Transaction) that + caused the adjustment. Only relevant for payment-related state + transitions. + validation: + maxLength: 255 + access: read-only + refund_id: + type: optional + docs: |- + The Square-generated ID of the [Refund](entity:Refund) that + caused the adjustment. Only relevant for refund-related state + transitions. + validation: + maxLength: 255 + access: read-only + purchase_order_id: + type: optional + docs: >- + The Square-generated ID of the purchase order that caused the + + adjustment. Only relevant for state transitions from the Square for + Retail + + app. + validation: + maxLength: 100 + access: read-only + goods_receipt_id: + type: optional + docs: >- + The Square-generated ID of the goods receipt that caused the + + adjustment. Only relevant for state transitions from the Square for + Retail + + app. + validation: + maxLength: 100 + access: read-only + adjustment_group: + type: optional + docs: >- + An adjustment group bundling the related adjustments of item + variations through stock conversions in a single inventory event. + source: + openapi: ../default/openapi/openapi.json + InventoryAdjustmentGroup: + properties: + id: + type: optional + docs: |- + A unique ID generated by Square for the + `InventoryAdjustmentGroup`. + validation: + maxLength: 100 + access: read-only + root_adjustment_id: + type: optional + docs: The inventory adjustment of the composed variation. + validation: + maxLength: 100 + access: read-only + from_state: + type: optional + docs: >- + Representative `from_state` for adjustments within the group. For + example, for a group adjustment from `IN_STOCK` to `SOLD`, + + there can be two component adjustments in the group: one from + `IN_STOCK`to `COMPOSED` and the other one from `COMPOSED` to `SOLD`. + + Here, the representative `from_state` for the + `InventoryAdjustmentGroup` is `IN_STOCK`. + + See [InventoryState](#type-inventorystate) for possible values + to_state: + type: optional + docs: >- + Representative `to_state` for adjustments within group. For example, + for a group adjustment from `IN_STOCK` to `SOLD`, + + the two component adjustments in the group can be from `IN_STOCK` to + `COMPOSED` and from `COMPOSED` to `SOLD`. + + Here, the representative `to_state` of the `InventoryAdjustmentGroup` + is `SOLD`. + + See [InventoryState](#type-inventorystate) for possible values + source: + openapi: ../default/openapi/openapi.json + InventoryAlertType: + enum: + - NONE + - LOW_QUANTITY + docs: >- + Indicates whether Square should alert the merchant when the inventory + quantity of a CatalogItemVariation is low. + source: + openapi: ../default/openapi/openapi.json + InventoryChange: + docs: |- + Represents a single physical count, inventory, adjustment, or transfer + that is part of the history of inventory changes for a particular + [CatalogObject](entity:CatalogObject) instance. + properties: + type: + type: optional + docs: >- + Indicates how the inventory change is applied. See + + [InventoryChangeType](entity:InventoryChangeType) for all possible + values. + + See [InventoryChangeType](#type-inventorychangetype) for possible + values + physical_count: + type: optional + docs: |- + Contains details about the physical count when `type` is + `PHYSICAL_COUNT`, and is unset for all other change types. + adjustment: + type: optional + docs: |- + Contains details about the inventory adjustment when `type` is + `ADJUSTMENT`, and is unset for all other change types. + transfer: + type: optional + docs: >- + Contains details about the inventory transfer when `type` is + + `TRANSFER`, and is unset for all other change types. + + + _Note:_ An [InventoryTransfer](entity:InventoryTransfer) object can + only be set in the input to the + + [BatchChangeInventory](api-endpoint:Inventory-BatchChangeInventory) + endpoint when the seller has an active Retail Plus subscription. + measurement_unit: + type: optional + docs: >- + The [CatalogMeasurementUnit](entity:CatalogMeasurementUnit) object + representing the catalog measurement unit associated with the + inventory change. + measurement_unit_id: + type: optional + docs: >- + The ID of the [CatalogMeasurementUnit](entity:CatalogMeasurementUnit) + object representing the catalog measurement unit associated with the + inventory change. + access: read-only + source: + openapi: ../default/openapi/openapi.json + InventoryChangeType: + enum: + - PHYSICAL_COUNT + - ADJUSTMENT + - TRANSFER + docs: >- + Indicates how the inventory change was applied to a tracked product + quantity. + source: + openapi: ../default/openapi/openapi.json + InventoryCount: + docs: >- + Represents Square-estimated quantity of items in a particular state at a + + particular seller location based on the known history of physical counts + and + + inventory adjustments. + properties: + catalog_object_id: + type: optional> + docs: |- + The Square-generated ID of the + [CatalogObject](entity:CatalogObject) being tracked. + validation: + maxLength: 100 + catalog_object_type: + type: optional> + docs: >- + The [type](entity:CatalogObjectType) of the + [CatalogObject](entity:CatalogObject) being tracked. + + + The Inventory API supports setting and reading the + `"catalog_object_type": "ITEM_VARIATION"` field value. + + In addition, it can also read the `"catalog_object_type": "ITEM"` + field value that is set by the Square Restaurants app. + validation: + maxLength: 14 + state: + type: optional + docs: |- + The current [inventory state](entity:InventoryState) for the related + quantity of items. + See [InventoryState](#type-inventorystate) for possible values + location_id: + type: optional> + docs: >- + The Square-generated ID of the [Location](entity:Location) where the + related + + quantity of items is being tracked. + validation: + maxLength: 100 + quantity: + type: optional> + docs: >- + The number of items affected by the estimated count as a decimal + string. + + Can support up to 5 digits after the decimal point. + validation: + maxLength: 26 + calculated_at: + type: optional + docs: >- + An RFC 3339-formatted timestamp that indicates when the most recent + physical count or adjustment affecting + + the estimated count is received. + validation: + maxLength: 34 + access: read-only + is_estimated: + type: optional + docs: >- + Whether the inventory count is for composed variation (TRUE) or not + (FALSE). If true, the inventory count will not be present in the + response of + + any of these endpoints: + [BatchChangeInventory](api-endpoint:Inventory-BatchChangeInventory), + + [BatchRetrieveInventoryChanges](api-endpoint:Inventory-BatchRetrieveInventoryChanges), + + [BatchRetrieveInventoryCounts](api-endpoint:Inventory-BatchRetrieveInventoryCounts), + and + + [RetrieveInventoryChanges](api-endpoint:Inventory-RetrieveInventoryChanges). + access: read-only + source: + openapi: ../default/openapi/openapi.json + InventoryCountUpdatedEvent: + docs: |- + Published when the quantity is updated for a + [CatalogItemVariation](entity:CatalogItemVariation). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InventoryCountUpdatedEventData: + properties: + type: + type: optional> + docs: >- + Name of the affected object’s type. For this event, the value is + `inventory_counts`. + id: + type: optional + docs: ID of the affected object. + object: + type: optional + docs: >- + An object containing fields and values relevant to the event. Is + absent if affected object was deleted. + source: + openapi: ../default/openapi/openapi.json + InventoryCountUpdatedEventObject: + properties: + inventory_counts: + type: optional>> + docs: The inventory counts. + source: + openapi: ../default/openapi/openapi.json + InventoryPhysicalCount: + docs: >- + Represents the quantity of an item variation that is physically present + + at a specific location, verified by a seller or a seller's employee. For + example, + + a physical count might come from an employee counting the item variations + on + + hand or from syncing with an external system. + properties: + id: + type: optional + docs: |- + A unique Square-generated ID for the + [InventoryPhysicalCount](entity:InventoryPhysicalCount). + validation: + maxLength: 100 + reference_id: + type: optional> + docs: |- + An optional ID provided by the application to tie the + [InventoryPhysicalCount](entity:InventoryPhysicalCount) to an external + system. + validation: + maxLength: 255 + catalog_object_id: + type: optional> + docs: |- + The Square-generated ID of the + [CatalogObject](entity:CatalogObject) being tracked. + validation: + maxLength: 100 + catalog_object_type: + type: optional> + docs: >- + The [type](entity:CatalogObjectType) of the + [CatalogObject](entity:CatalogObject) being tracked. + + + The Inventory API supports setting and reading the + `"catalog_object_type": "ITEM_VARIATION"` field value. + + In addition, it can also read the `"catalog_object_type": "ITEM"` + field value that is set by the Square Restaurants app. + validation: + maxLength: 14 + state: + type: optional + docs: |- + The current [inventory state](entity:InventoryState) for the related + quantity of items. + See [InventoryState](#type-inventorystate) for possible values + location_id: + type: optional> + docs: >- + The Square-generated ID of the [Location](entity:Location) where the + related + + quantity of items is being tracked. + validation: + maxLength: 100 + quantity: + type: optional> + docs: >- + The number of items affected by the physical count as a decimal + string. + + The number can support up to 5 digits after the decimal point. + validation: + maxLength: 26 + source: + type: optional + docs: |- + Information about the application with which the + physical count is submitted. + employee_id: + type: optional> + docs: >- + The Square-generated ID of the [Employee](entity:Employee) responsible + for the + + physical count. + validation: + maxLength: 100 + team_member_id: + type: optional> + docs: >- + The Square-generated ID of the [Team Member](entity:TeamMember) + responsible for the + + physical count. + validation: + maxLength: 100 + occurred_at: + type: optional> + docs: >- + A client-generated RFC 3339-formatted timestamp that indicates when + + the physical count was examined. For physical count updates, the + `occurred_at` + + timestamp cannot be older than 24 hours or in the future relative to + the + + time of the request. + validation: + maxLength: 34 + created_at: + type: optional + docs: >- + An RFC 3339-formatted timestamp that indicates when the physical count + is received. + validation: + maxLength: 34 + access: read-only + source: + openapi: ../default/openapi/openapi.json + InventoryState: + enum: + - CUSTOM + - IN_STOCK + - SOLD + - RETURNED_BY_CUSTOMER + - RESERVED_FOR_SALE + - SOLD_ONLINE + - ORDERED_FROM_VENDOR + - RECEIVED_FROM_VENDOR + - IN_TRANSIT_TO + - NONE + - WASTE + - UNLINKED_RETURN + - COMPOSED + - DECOMPOSED + - SUPPORTED_BY_NEWER_VERSION + - IN_TRANSIT + docs: Indicates the state of a tracked item quantity in the lifecycle of goods. + source: + openapi: ../default/openapi/openapi.json + InventoryTransfer: + docs: |- + Represents the transfer of a quantity of product inventory at a + particular time from one location to another. + properties: + id: + type: optional + docs: |- + A unique ID generated by Square for the + `InventoryTransfer`. + validation: + maxLength: 100 + reference_id: + type: optional> + docs: |- + An optional ID provided by the application to tie the + `InventoryTransfer` to an external system. + validation: + maxLength: 255 + state: + type: optional + docs: |- + The [inventory state](entity:InventoryState) for the quantity of + items being transferred. + See [InventoryState](#type-inventorystate) for possible values + from_location_id: + type: optional> + docs: >- + The Square-generated ID of the [Location](entity:Location) where the + related + + quantity of items was tracked before the transfer. + validation: + maxLength: 100 + to_location_id: + type: optional> + docs: >- + The Square-generated ID of the [Location](entity:Location) where the + related + + quantity of items was tracked after the transfer. + validation: + maxLength: 100 + catalog_object_id: + type: optional> + docs: |- + The Square-generated ID of the + [CatalogObject](entity:CatalogObject) being tracked. + validation: + maxLength: 100 + catalog_object_type: + type: optional> + docs: >- + The [type](entity:CatalogObjectType) of the + [CatalogObject](entity:CatalogObject) being tracked. + + + The Inventory API supports setting and reading the + `"catalog_object_type": "ITEM_VARIATION"` field value. + + In addition, it can also read the `"catalog_object_type": "ITEM"` + field value that is set by the Square Restaurants app. + validation: + maxLength: 14 + quantity: + type: optional> + docs: |- + The number of items affected by the transfer as a decimal string. + Can support up to 5 digits after the decimal point. + validation: + maxLength: 26 + occurred_at: + type: optional> + docs: >- + A client-generated RFC 3339-formatted timestamp that indicates when + + the transfer took place. For write actions, the `occurred_at` + timestamp + + cannot be older than 24 hours or in the future relative to the time of + the + + request. + validation: + maxLength: 34 + created_at: + type: optional + docs: |- + An RFC 3339-formatted timestamp that indicates when Square + received the transfer request. + validation: + maxLength: 34 + access: read-only + source: + type: optional + docs: |- + Information about the application that initiated the + inventory transfer. + employee_id: + type: optional> + docs: >- + The Square-generated ID of the [Employee](entity:Employee) responsible + for the + + inventory transfer. + validation: + maxLength: 100 + team_member_id: + type: optional> + docs: >- + The Square-generated ID of the [Team Member](entity:TeamMember) + responsible for the + + inventory transfer. + validation: + maxLength: 100 + source: + openapi: ../default/openapi/openapi.json + Invoice: + docs: >- + Stores information about an invoice. You use the Invoices API to create + and manage + + invoices. For more information, see [Invoices API + Overview](https://developer.squareup.com/docs/invoices-api/overview). + properties: + id: + type: optional + docs: The Square-assigned ID of the invoice. + access: read-only + version: + type: optional + docs: >- + The Square-assigned version number, which is incremented each time an + update is committed to the invoice. + location_id: + type: optional> + docs: >- + The ID of the location that this invoice is associated with. + + + If specified in a `CreateInvoice` request, the value must match the + `location_id` of the associated order. + validation: + minLength: 1 + maxLength: 255 + order_id: + type: optional> + docs: >- + The ID of the [order](entity:Order) for which the invoice is created. + + This field is required when creating an invoice, and the order must be + in the `OPEN` state. + + + To view the line items and other information for the associated order, + call the + + [RetrieveOrder](api-endpoint:Orders-RetrieveOrder) endpoint using the + order ID. + validation: + minLength: 1 + maxLength: 255 + primary_recipient: + type: optional + docs: >- + The customer who receives the invoice. This customer data is displayed + on the invoice and used by Square to deliver the invoice. + + + This field is required to publish an invoice, and it must specify the + `customer_id`. + payment_requests: + type: optional>> + docs: >- + The payment schedule for the invoice, represented by one or more + payment requests that + + define payment settings, such as amount due and due date. An invoice + supports the following payment request combinations: + + - One balance + + - One deposit with one balance + + - 2–12 installments + + - One deposit with 2–12 installments + + + This field is required when creating an invoice. It must contain at + least one payment request. + + All payment requests for the invoice must equal the total order + amount. For more information, see + + [Configuring payment + requests](https://developer.squareup.com/docs/invoices-api/create-publish-invoices#payment-requests). + + + Adding `INSTALLMENT` payment requests to an invoice requires an + + [Invoices Plus + subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription). + delivery_method: + type: optional + docs: >- + The delivery method that Square uses to send the invoice, reminders, + and receipts to + + the customer. After the invoice is published, Square processes the + invoice based on the delivery + + method and payment request settings, either immediately or on the + `scheduled_at` date, if specified. + + For example, Square might send the invoice or receipt for an automatic + payment. For invoices with + + automatic payments, this field must be set to `EMAIL`. + + + One of the following is required when creating an invoice: + + - (Recommended) This `delivery_method` field. To configure an + automatic payment, the + + `automatic_payment_source` field of the payment request is also + required. + + - The deprecated `request_method` field of the payment request. Note + that `invoice` + + objects returned in responses do not include `request_method`. + + See [InvoiceDeliveryMethod](#type-invoicedeliverymethod) for possible + values + invoice_number: + type: optional> + docs: >- + A user-friendly invoice number that is displayed on the invoice. The + value is unique within a location. + + If not provided when creating an invoice, Square assigns a value. + + It increments from 1 and is padded with zeros making it 7 characters + long + + (for example, 0000001 and 0000002). + validation: + minLength: 1 + maxLength: 191 + title: + type: optional> + docs: The title of the invoice, which is displayed on the invoice. + validation: + minLength: 1 + maxLength: 255 + description: + type: optional> + docs: The description of the invoice, which is displayed on the invoice. + validation: + minLength: 1 + maxLength: 65536 + scheduled_at: + type: optional> + docs: >- + The timestamp when the invoice is scheduled for processing, in RFC + 3339 format. + + After the invoice is published, Square processes the invoice on the + specified date, + + according to the delivery method and payment request settings. + + + If the field is not set, Square processes the invoice immediately + after it is published. + public_url: + type: optional + docs: >- + A temporary link to the Square-hosted payment page where the customer + can pay the + + invoice. If the link expires, customers can provide the email address + or phone number + + associated with the invoice and request a new link directly from the + expired payment page. + + + This field is added after the invoice is published and reaches the + scheduled date + + (if one is defined). + access: read-only + next_payment_amount_money: + type: optional + docs: >- + The current amount due for the invoice. In addition to the + + amount due on the next payment request, this includes any overdue + payment amounts. + status: + type: optional + docs: |- + The status of the invoice. + See [InvoiceStatus](#type-invoicestatus) for possible values + timezone: + type: optional + docs: >- + The time zone used to interpret calendar dates on the invoice, such as + `due_date`. + + When an invoice is created, this field is set to the `timezone` + specified for the seller + + location. The value cannot be changed. + + + For example, a payment `due_date` of 2021-03-09 with a `timezone` of + America/Los\_Angeles + + becomes overdue at midnight on March 9 in America/Los\_Angeles (which + equals a UTC timestamp + + of 2021-03-10T08:00:00Z). + access: read-only + created_at: + type: optional + docs: The timestamp when the invoice was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp when the invoice was last updated, in RFC 3339 format. + access: read-only + accepted_payment_methods: + type: optional + docs: >- + The payment methods that customers can use to pay the invoice on the + Square-hosted + + invoice page. This setting is independent of any automatic payment + requests for the invoice. + + + This field is required when creating an invoice and must set at least + one payment method to `true`. + custom_fields: + type: optional>> + docs: >- + Additional seller-defined fields that are displayed on the invoice. + For more information, see + + [Custom + fields](https://developer.squareup.com/docs/invoices-api/overview#custom-fields). + + + Adding custom fields to an invoice requires an + + [Invoices Plus + subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription). + + + Max: 2 custom fields + subscription_id: + type: optional + docs: >- + The ID of the [subscription](entity:Subscription) associated with the + invoice. + + This field is present only on subscription billing invoices. + access: read-only + sale_or_service_date: + type: optional> + docs: >- + The date of the sale or the date that the service is rendered, in + `YYYY-MM-DD` format. + + This field can be used to specify a past or future date which is + displayed on the invoice. + payment_conditions: + type: optional> + docs: >- + **France only.** The payment terms and conditions that are displayed + on the invoice. For more information, + + see [Payment + conditions](https://developer.squareup.com/docs/invoices-api/overview#payment-conditions). + + + For countries other than France, Square returns an + `INVALID_REQUEST_ERROR` with a `BAD_REQUEST` code and + + "Payment conditions are not supported for this location's country" + detail if this field is included in `CreateInvoice` or `UpdateInvoice` + requests. + validation: + minLength: 1 + maxLength: 2000 + store_payment_method_enabled: + type: optional> + docs: >- + Indicates whether to allow a customer to save a credit or debit card + as a card on file or a bank transfer as a + + bank account on file. If `true`, Square displays a __Save my card on + file__ or __Save my bank on file__ checkbox on the + + invoice payment page. Stored payment information can be used for + future automatic payments. The default value is `false`. + attachments: + type: optional> + docs: >- + Metadata about the attachments on the invoice. Invoice attachments are + managed using the + + [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) + and + [DeleteInvoiceAttachment](api-endpoint:Invoices-DeleteInvoiceAttachment) + endpoints. + access: read-only + creator_team_member_id: + type: optional + docs: >- + The ID of the [team member](entity:TeamMember) who created the + invoice. + + This field is present only on invoices created in the Square Dashboard + or Square Invoices app by a logged-in team member. + access: read-only + source: + openapi: ../default/openapi/openapi.json + InvoiceAcceptedPaymentMethods: + docs: >- + The payment methods that customers can use to pay an + [invoice](entity:Invoice) on the Square-hosted invoice payment page. + properties: + card: + type: optional> + docs: >- + Indicates whether credit card or debit card payments are accepted. The + default value is `false`. + square_gift_card: + type: optional> + docs: >- + Indicates whether Square gift card payments are accepted. The default + value is `false`. + bank_account: + type: optional> + docs: >- + Indicates whether ACH bank transfer payments are accepted. The default + value is `false`. + buy_now_pay_later: + type: optional> + docs: >- + Indicates whether Afterpay (also known as Clearpay) payments are + accepted. The default value is `false`. + + + This option is allowed only for invoices that have a single payment + request of the `BALANCE` type. This payment method is + + supported if the seller account accepts Afterpay payments and the + seller location is in a country where Afterpay + + invoice payments are supported. As a best practice, consider enabling + an additional payment method when allowing + + `buy_now_pay_later` payments. For more information, including detailed + requirements and processing limits, see + + [Buy Now Pay Later payments with + Afterpay](https://developer.squareup.com/docs/invoices-api/overview#buy-now-pay-later). + cash_app_pay: + type: optional> + docs: >- + Indicates whether Cash App payments are accepted. The default value is + `false`. + + + This payment method is supported only for seller + [locations](entity:Location) in the United States. + source: + openapi: ../default/openapi/openapi.json + InvoiceAttachment: + docs: Represents a file attached to an [invoice](entity:Invoice). + properties: + id: + type: optional + docs: The Square-assigned ID of the attachment. + access: read-only + filename: + type: optional + docs: The file name of the attachment, which is displayed on the invoice. + access: read-only + description: + type: optional + docs: |- + The description of the attachment, which is displayed on the invoice. + This field maps to the seller-defined **Message** field. + access: read-only + filesize: + type: optional + docs: The file size of the attachment in bytes. + access: read-only + hash: + type: optional + docs: The MD5 hash that was generated from the file contents. + access: read-only + mime_type: + type: optional + docs: >- + The mime type of the attachment. + + The following mime types are supported: + + image/gif, image/jpeg, image/png, image/tiff, image/bmp, + application/pdf. + access: read-only + uploaded_at: + type: optional + docs: The timestamp when the attachment was uploaded, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + InvoiceAutomaticPaymentSource: + enum: + - NONE + - CARD_ON_FILE + - BANK_ON_FILE + docs: >- + Indicates the automatic payment method for an [invoice payment + request](entity:InvoicePaymentRequest). + source: + openapi: ../default/openapi/openapi.json + InvoiceCanceledEvent: + docs: Published when an [Invoice](entity:Invoice) is canceled. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.canceled"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoiceCanceledEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: An object containing the canceled invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceCanceledEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceCreatedEvent: + docs: Published when an [Invoice](entity:Invoice) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoiceCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: An object containing the created invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceCreatedEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceCustomField: + docs: >- + An additional seller-defined and customer-facing field to include on the + invoice. For more information, + + see [Custom + fields](https://developer.squareup.com/docs/invoices-api/overview#custom-fields). + + + Adding custom fields to an invoice requires an + + [Invoices Plus + subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription). + properties: + label: + type: optional> + docs: >- + The label or title of the custom field. This field is required for a + custom field. + validation: + maxLength: 30 + value: + type: optional> + docs: The text of the custom field. If omitted, only the label is rendered. + validation: + maxLength: 2000 + placement: + type: optional + docs: >- + The location of the custom field on the invoice. This field is + required for a custom field. + + See [InvoiceCustomFieldPlacement](#type-invoicecustomfieldplacement) + for possible values + source: + openapi: ../default/openapi/openapi.json + InvoiceCustomFieldPlacement: + enum: + - ABOVE_LINE_ITEMS + - BELOW_LINE_ITEMS + docs: >- + Indicates where to render a custom field on the Square-hosted invoice page + and in emailed or PDF + + copies of the invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceDeletedEvent: + docs: Published when a draft [Invoice](entity:Invoice) is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoiceDeletedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + deleted: + type: optional> + docs: Indicates that the invoice was deleted. + source: + openapi: ../default/openapi/openapi.json + InvoiceDeliveryMethod: + enum: + - EMAIL + - SHARE_MANUALLY + - SMS + docs: >- + Indicates how Square delivers the [invoice](entity:Invoice) to the + customer. + source: + openapi: ../default/openapi/openapi.json + InvoiceFilter: + docs: Describes query filters to apply. + properties: + location_ids: + docs: |- + Limits the search to the specified locations. A location is required. + In the current implementation, only one location can be specified. + type: list + customer_ids: + type: optional>> + docs: >- + Limits the search to the specified customers, within the specified + locations. + + Specifying a customer is optional. In the current implementation, + + a maximum of one customer can be specified. + source: + openapi: ../default/openapi/openapi.json + InvoicePaymentMadeEvent: + docs: >- + Published when a payment that is associated with an + [invoice](entity:Invoice) is completed. + + For more information about invoice payments, see [Pay an + invoice](https://developer.squareup.com/docs/invoices-api/pay-refund-invoices#pay-invoice). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.payment_made"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoicePaymentMadeEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: An object containing the invoice that was paid. + source: + openapi: ../default/openapi/openapi.json + InvoicePaymentMadeEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + InvoicePaymentReminder: + docs: >- + Describes a payment request reminder (automatic notification) that Square + sends + + to the customer. You configure a reminder relative to the payment request + + `due_date`. + properties: + uid: + type: optional + docs: |- + A Square-assigned ID that uniquely identifies the reminder within the + `InvoicePaymentRequest`. + access: read-only + relative_scheduled_days: + type: optional> + docs: >- + The number of days before (a negative number) or after (a positive + number) + + the payment request `due_date` when the reminder is sent. For example, + -3 indicates that + + the reminder should be sent 3 days before the payment request + `due_date`. + validation: + min: -32767 + max: 32767 + message: + type: optional> + docs: The reminder message. + validation: + minLength: 1 + maxLength: 1000 + status: + type: optional + docs: >- + The status of the reminder. + + See [InvoicePaymentReminderStatus](#type-invoicepaymentreminderstatus) + for possible values + sent_at: + type: optional + docs: If sent, the timestamp when the reminder was sent, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + InvoicePaymentReminderStatus: + enum: + - PENDING + - NOT_APPLICABLE + - SENT + docs: The status of a payment request reminder. + source: + openapi: ../default/openapi/openapi.json + InvoicePaymentRequest: + docs: >- + Represents a payment request for an [invoice](entity:Invoice). Invoices + can specify a maximum + + of 13 payment requests, with up to 12 `INSTALLMENT` request types. For + more information, + + see [Configuring payment + requests](https://developer.squareup.com/docs/invoices-api/create-publish-invoices#payment-requests). + + + Adding `INSTALLMENT` payment requests to an invoice requires an + + [Invoices Plus + subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription). + properties: + uid: + type: optional> + docs: >- + The Square-generated ID of the payment request in an + [invoice](entity:Invoice). + validation: + minLength: 1 + maxLength: 255 + request_method: + type: optional + docs: >- + Indicates how Square processes the payment request. DEPRECATED at + version 2021-01-21. Replaced by the + + `Invoice.delivery_method` and + `InvoicePaymentRequest.automatic_payment_source` fields. + + + One of the following is required when creating an invoice: + + - (Recommended) The `delivery_method` field of the invoice. To + configure an automatic payment, the + + `automatic_payment_source` field of the payment request is also + required. + + - This `request_method` field. Note that `invoice` objects returned in + responses do not include `request_method`. + + See [InvoiceRequestMethod](#type-invoicerequestmethod) for possible + values + request_type: + type: optional + docs: >- + Identifies the payment request type. This type defines how the payment + request amount is determined. + + This field is required to create a payment request. + + See [InvoiceRequestType](#type-invoicerequesttype) for possible values + due_date: + type: optional> + docs: >- + The due date (in the invoice's time zone) for the payment request, in + `YYYY-MM-DD` format. This field + + is required to create a payment request. If an + `automatic_payment_source` is defined for the request, Square + + charges the payment source on this date. + + + After this date, the invoice becomes overdue. For example, a payment + `due_date` of 2021-03-09 with a `timezone` + + of America/Los\_Angeles becomes overdue at midnight on March 9 in + America/Los\_Angeles (which equals a UTC + + timestamp of 2021-03-10T08:00:00Z). + fixed_amount_requested_money: + type: optional + docs: >- + If the payment request specifies `DEPOSIT` or `INSTALLMENT` as the + `request_type`, + + this indicates the request amount. + + You cannot specify this when `request_type` is `BALANCE` or when the + + payment request includes the `percentage_requested` field. + percentage_requested: + type: optional> + docs: >- + Specifies the amount for the payment request in percentage: + + + - When the payment `request_type` is `DEPOSIT`, it is the percentage + of the order's total amount. + + - When the payment `request_type` is `INSTALLMENT`, it is the + percentage of the order's total less + + the deposit, if requested. The sum of the `percentage_requested` in + all installment + + payment requests must be equal to 100. + + + You cannot specify this when the payment `request_type` is `BALANCE` + or when the + + payment request specifies the `fixed_amount_requested_money` field. + tipping_enabled: + type: optional> + docs: >- + If set to true, the Square-hosted invoice page (the `public_url` field + of the invoice) + + provides a place for the customer to pay a tip. + + + This field is allowed only on the final payment request + + and the payment `request_type` must be `BALANCE` or `INSTALLMENT`. + automatic_payment_source: + type: optional + docs: >- + The payment method for an automatic payment. + + + The default value is `NONE`. + + See + [InvoiceAutomaticPaymentSource](#type-invoiceautomaticpaymentsource) + for possible values + card_id: + type: optional> + docs: >- + The ID of the credit or debit card on file to charge for the payment + request. To get the cards on file for a customer, + + call [ListCards](api-endpoint:Cards-ListCards) and include the + `customer_id` of the invoice recipient. + validation: + minLength: 1 + maxLength: 255 + reminders: + type: optional>> + docs: A list of one or more reminders to send for the payment request. + computed_amount_money: + type: optional + docs: >- + The amount of the payment request, computed using the order amount and + information from the various payment + + request fields (`request_type`, `fixed_amount_requested_money`, and + `percentage_requested`). + total_completed_amount_money: + type: optional + docs: >- + The amount of money already paid for the specific payment request. + + This amount might include a rounding adjustment if the most recent + invoice payment + + was in cash in a currency that rounds cash payments (such as, `CAD` or + `AUD`). + rounding_adjustment_included_money: + type: optional + docs: >- + If the most recent payment was a cash payment + + in a currency that rounds cash payments (such as, `CAD` or `AUD`) and + the payment + + is rounded from `computed_amount_money` in the payment request, then + this + + field specifies the rounding adjustment applied. This amount + + might be negative. + source: + openapi: ../default/openapi/openapi.json + InvoicePublishedEvent: + docs: >- + Published when an [Invoice](entity:Invoice) transitions from a draft to a + non-draft status. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.published"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoicePublishedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: An object containing the published invoice. + source: + openapi: ../default/openapi/openapi.json + InvoicePublishedEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceQuery: + docs: Describes query criteria for searching invoices. + properties: + filter: + type: InvoiceFilter + docs: >- + Query filters to apply in searching invoices. + + For more information, see [Search for + invoices](https://developer.squareup.com/docs/invoices-api/retrieve-list-search-invoices#search-invoices). + sort: + type: optional + docs: Describes the sort order for the search result. + source: + openapi: ../default/openapi/openapi.json + InvoiceRecipient: + docs: >- + Represents a snapshot of customer data. This object stores customer data + that is displayed on the invoice + + and that Square uses to deliver the invoice. + + + When you provide a customer ID for a draft invoice, Square retrieves the + associated customer profile and populates + + the remaining `InvoiceRecipient` fields. You cannot update these fields + after the invoice is published. + + Square updates the customer ID in response to a merge operation, but does + not update other fields. + properties: + customer_id: + type: optional> + docs: |- + The ID of the customer. This is the customer profile ID that + you provide when creating a draft invoice. + validation: + minLength: 1 + maxLength: 255 + given_name: + type: optional + docs: The recipient's given (that is, first) name. + access: read-only + family_name: + type: optional + docs: The recipient's family (that is, last) name. + access: read-only + email_address: + type: optional + docs: The recipient's email address. + access: read-only + address: + type: optional
+ docs: The recipient's physical address. + phone_number: + type: optional + docs: The recipient's phone number. + access: read-only + company_name: + type: optional + docs: The name of the recipient's company. + access: read-only + tax_ids: + type: optional + docs: >- + The recipient's tax IDs. The country of the seller account determines + whether this field + + is available for the customer. For more information, see [Invoice + recipient tax + IDs](https://developer.squareup.com/docs/invoices-api/overview#recipient-tax-ids). + source: + openapi: ../default/openapi/openapi.json + InvoiceRecipientTaxIds: + docs: >- + Represents the tax IDs for an invoice recipient. The country of the seller + account determines + + whether the corresponding `tax_ids` field is available for the customer. + For more information, + + see [Invoice recipient tax + IDs](https://developer.squareup.com/docs/invoices-api/overview#recipient-tax-ids). + properties: + eu_vat: + type: optional + docs: >- + The EU VAT identification number for the invoice recipient. For + example, `IE3426675K`. + access: read-only + source: + openapi: ../default/openapi/openapi.json + InvoiceRefundedEvent: + docs: >- + Published when a refund is applied toward a payment of an + [invoice](entity:Invoice). + + For more information about invoice refunds, see [Refund an + invoice](https://developer.squareup.com/docs/invoices-api/pay-refund-invoices#refund-invoice). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.refunded"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoiceRefundedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: An object containing the refunded invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceRefundedEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceRequestMethod: + enum: + - EMAIL + - CHARGE_CARD_ON_FILE + - SHARE_MANUALLY + - CHARGE_BANK_ON_FILE + - SMS + - SMS_CHARGE_CARD_ON_FILE + - SMS_CHARGE_BANK_ON_FILE + docs: >- + Specifies the action for Square to take for processing the invoice. For + example, + + email the invoice, charge a customer's card on file, or do nothing. + DEPRECATED at + + version 2021-01-21. The corresponding `request_method` field is replaced + by the + + `Invoice.delivery_method` and + `InvoicePaymentRequest.automatic_payment_source` fields. + source: + openapi: ../default/openapi/openapi.json + InvoiceRequestType: + enum: + - BALANCE + - DEPOSIT + - INSTALLMENT + docs: >- + Indicates the type of the payment request. For more information, see + + [Configuring payment + requests](https://developer.squareup.com/docs/invoices-api/create-publish-invoices#payment-requests). + source: + openapi: ../default/openapi/openapi.json + InvoiceScheduledChargeFailedEvent: + docs: >- + Published when an automatic scheduled payment for an + [Invoice](entity:Invoice) has failed. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: >- + The type of event this represents, + `"invoice.scheduled_charge_failed"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoiceScheduledChargeFailedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: >- + An object containing the invoice that experienced the failed scheduled + charge. + source: + openapi: ../default/openapi/openapi.json + InvoiceScheduledChargeFailedEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceSort: + docs: Identifies the sort field and sort order. + properties: + field: + type: InvoiceSortField + docs: |- + The field to use for sorting. + See [InvoiceSortField](#type-invoicesortfield) for possible values + order: + type: optional + docs: |- + The order to use for sorting the results. + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + InvoiceSortField: + type: literal<"INVOICE_SORT_DATE"> + docs: The field to use for sorting. + InvoiceStatus: + enum: + - DRAFT + - UNPAID + - SCHEDULED + - PARTIALLY_PAID + - PAID + - PARTIALLY_REFUNDED + - REFUNDED + - CANCELED + - FAILED + - PAYMENT_PENDING + docs: Indicates the status of an [invoice](entity:Invoice). + source: + openapi: ../default/openapi/openapi.json + InvoiceUpdatedEvent: + docs: Published when an [Invoice](entity:Invoice) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"invoice.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + InvoiceUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"invoice"`. + id: + type: optional + docs: ID of the affected invoice. + object: + type: optional + docs: An object containing the updated invoice. + source: + openapi: ../default/openapi/openapi.json + InvoiceUpdatedEventObject: + properties: + invoice: + type: optional + docs: The related invoice. + source: + openapi: ../default/openapi/openapi.json + ItemVariationLocationOverrides: + docs: >- + Price and inventory alerting overrides for a `CatalogItemVariation` at a + specific `Location`. + properties: + location_id: + type: optional> + docs: >- + The ID of the `Location`. This can include locations that are + deactivated. + price_money: + type: optional + docs: >- + The price of the `CatalogItemVariation` at the given `Location`, or + blank for variable pricing. + pricing_type: + type: optional + docs: >- + The pricing type (fixed or variable) for the `CatalogItemVariation` at + the given `Location`. + + See [CatalogPricingType](#type-catalogpricingtype) for possible values + track_inventory: + type: optional> + docs: >- + If `true`, inventory tracking is active for the `CatalogItemVariation` + at this `Location`. + inventory_alert_type: + type: optional + docs: >- + Indicates whether the `CatalogItemVariation` displays an alert when + its inventory + + quantity is less than or equal to its `inventory_alert_threshold`. + + See [InventoryAlertType](#type-inventoryalerttype) for possible values + inventory_alert_threshold: + type: optional> + docs: >- + If the inventory quantity for the variation is less than or equal to + this value and `inventory_alert_type` + + is `LOW_QUANTITY`, the variation displays an alert in the merchant + dashboard. + + + This value is always an integer. + sold_out: + type: optional + docs: >- + Indicates whether the overridden item variation is sold out at the + specified location. + + + When inventory tracking is enabled on the item variation either + globally or at the specified location, + + the item variation is automatically marked as sold out when its + inventory count reaches zero. The seller + + can manually set the item variation as sold out even when the + inventory count is greater than zero. + + Attempts by an application to set this attribute are ignored. + Regardless how the sold-out status is set, + + applications should treat its inventory count as zero when this + attribute value is `true`. + access: read-only + sold_out_valid_until: + type: optional + docs: >- + The seller-assigned timestamp, of the RFC 3339 format, to indicate + when this sold-out variation + + becomes available again at the specified location. Attempts by an + application to set this attribute are ignored. + + When the current time is later than this attribute value, the affected + item variation is no longer sold out. + access: read-only + source: + openapi: ../default/openapi/openapi.json + Job: + docs: >- + Represents a job that can be assigned to [team + members](entity:TeamMember). This object defines the + + job's title and tip eligibility. Compensation is defined in a [job + assignment](entity:JobAssignment) + + in a team member's wage setting. + properties: + id: + type: optional + docs: >- + **Read only** The unique Square-assigned ID of the job. If you need a + job ID for an API request, + + call [ListJobs](api-endpoint:Team-ListJobs) or use the ID returned + when you created the job. + + You can also get job IDs from a team member's wage setting. + title: + type: optional> + docs: The title of the job. + validation: + maxLength: 150 + is_tip_eligible: + type: optional> + docs: Indicates whether team members can earn tips for the job. + created_at: + type: optional + docs: The timestamp when the job was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp when the job was last updated, in RFC 3339 format. + access: read-only + version: + type: optional + docs: >- + **Read only** The current version of the job. Include this field in + `UpdateJob` requests to enable + + [optimistic + concurrency](https://developer.squareup.com/docs/working-with-apis/optimistic-concurrency) + + control and avoid overwrites from concurrent requests. Requests fail + if the provided version doesn't + + match the server version at the time of the request. + source: + openapi: ../default/openapi/openapi.json + JobAssignment: + docs: >- + Represents a job assigned to a [team member](entity:TeamMember), including + the compensation the team + + member earns for the job. Job assignments are listed in the team member's + [wage setting](entity:WageSetting). + properties: + job_title: + type: optional> + docs: The title of the job. + pay_type: + type: JobAssignmentPayType + docs: >- + The current pay type for the job assignment used to + + calculate the pay amount in a pay period. + + See [JobAssignmentPayType](#type-jobassignmentpaytype) for possible + values + hourly_rate: + type: optional + docs: >- + The hourly pay rate of the job. For `SALARY` pay types, Square + calculates the hourly rate based on + + `annual_rate` and `weekly_hours`. + annual_rate: + type: optional + docs: >- + The total pay amount for a 12-month period on the job. Set if the job + `PayType` is `SALARY`. + weekly_hours: + type: optional> + docs: >- + The planned hours per week for the job. Set if the job `PayType` is + `SALARY`. + job_id: + type: optional> + docs: The ID of the [job](entity:Job). + source: + openapi: ../default/openapi/openapi.json + JobAssignmentPayType: + enum: + - NONE + - HOURLY + - SALARY + docs: Enumerates the possible pay types that a job can be assigned. + source: + openapi: ../default/openapi/openapi.json + JobCreatedEvent: + docs: Published when a Job is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"job.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + JobCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"job"`. + id: + type: optional + docs: ID of the created job. + object: + type: optional + docs: An object containing the created job. + source: + openapi: ../default/openapi/openapi.json + JobCreatedEventObject: + properties: + job: + type: optional + docs: The created job. + source: + openapi: ../default/openapi/openapi.json + JobUpdatedEvent: + docs: Published when a Job is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"job.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + JobUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"job"`. + id: + type: optional + docs: ID of the updated job. + object: + type: optional + docs: An object containing the updated job. + source: + openapi: ../default/openapi/openapi.json + JobUpdatedEventObject: + properties: + job: + type: optional + docs: The updated job. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftCreatedEvent: + docs: Published when a [ScheduledShift](entity:ScheduledShift) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + location_id: + type: optional> + docs: The ID of the location associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.scheduled_shift.created`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftCreatedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `scheduled_shift`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the affected `ScheduledShift`. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the affected `ScheduledShift`. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftCreatedEventObject: + properties: + ScheduledShift: + type: optional + docs: The new `ScheduledShift`. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftDeletedEvent: + docs: Published when a [ScheduledShift](entity:ScheduledShift) is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + location_id: + type: optional> + docs: The ID of the location associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.scheduled_shift.deleted`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftDeletedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `scheduled_shift`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the affected `ScheduledShift`. + validation: + maxLength: 255 + deleted: + type: optional> + docs: Is true if the affected object was deleted. Otherwise absent. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftPublishedEvent: + docs: Published when a [ScheduledShift](entity:ScheduledShift) is published. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + location_id: + type: optional> + docs: The ID of the location associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.scheduled_shift.published`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftPublishedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `scheduled_shift`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the affected `ScheduledShift`. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the affected `ScheduledShift`. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftPublishedEventObject: + properties: + ScheduledShift: + type: optional + docs: The published `ScheduledShift`. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftUpdatedEvent: + docs: Published when a [ScheduledShift](entity:ScheduledShift) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + location_id: + type: optional> + docs: The ID of the location associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.scheduled_shift.updated`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftUpdatedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `scheduled_shift`. + validation: + maxLength: 50 + id: + type: optional + docs: The ID of the affected `ScheduledShift`. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the affected `ScheduledShift`. + source: + openapi: ../default/openapi/openapi.json + LaborScheduledShiftUpdatedEventObject: + properties: + ScheduledShift: + type: optional + docs: The updated `ScheduledShift`. + source: + openapi: ../default/openapi/openapi.json + LaborShiftCreatedEvent: + docs: >- + Published when a worker starts a [Shift](entity:Shift). + + + Deprecated at Square API version 2025-05-21. Replaced by + `labor.timecard.created`. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + type: + type: optional> + docs: The type of event. For this event, the value is `labor.shift.created`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborShiftCreatedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `shift`. + id: + type: optional + docs: The ID of the affected `Shift`. + object: + type: optional + docs: An object containing the affected `Shift`. + source: + openapi: ../default/openapi/openapi.json + LaborShiftCreatedEventObject: + properties: + shift: + type: optional + docs: The new `Shift`. + source: + openapi: ../default/openapi/openapi.json + LaborShiftDeletedEvent: + docs: >- + Published when a [Shift](entity:Shift) is deleted. + + + Deprecated at Square API version 2025-05-21. Replaced by + `labor.timecard.deleted`. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + type: + type: optional> + docs: The type of event. For this event, the value is `labor.shift.deleted`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborShiftDeletedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `shift`. + id: + type: optional + docs: The ID of the affected `Shift`. + deleted: + type: optional> + docs: Is true if the affected object was deleted. Otherwise absent. + source: + openapi: ../default/openapi/openapi.json + LaborShiftUpdatedEvent: + docs: >- + Published when a [Shift](entity:Shift) is updated. + + + Deprecated at Square API version 2025-05-21. Replaced by + `labor.timecard.updated`. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + type: + type: optional> + docs: The type of event. For this event, the value is `labor.shift.updated`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborShiftUpdatedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `shift`. + id: + type: optional + docs: ID of the affected `Shift`. + object: + type: optional + docs: An object containing the affected `Shift`. + source: + openapi: ../default/openapi/openapi.json + LaborShiftUpdatedEventObject: + properties: + shift: + type: optional + docs: The updated `Shift`. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardCreatedEvent: + docs: Published when a worker starts a [Timecard](entity:Timecard). + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.timecard.created`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardCreatedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `timecard`. + id: + type: optional + docs: The ID of the affected `Timecard`. + object: + type: optional + docs: An object containing the affected `Timecard`. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardCreatedEventObject: + properties: + timecard: + type: optional + docs: The new `Timecard`. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardDeletedEvent: + docs: Published when a [Timecard](entity:Timecard) is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.timecard.deleted`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardDeletedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `timecard`. + id: + type: optional + docs: The ID of the affected `Timecard`. + deleted: + type: optional> + docs: Is true if the affected object was deleted. Otherwise absent. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardUpdatedEvent: + docs: Published when a [Timecard](entity:Timecard) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the merchant associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `labor.timecard.updated`. + event_id: + type: optional> + docs: The unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardUpdatedEventData: + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `timecard`. + id: + type: optional + docs: The ID of the affected `Timecard`. + object: + type: optional + docs: An object containing the affected `Timecard`. + source: + openapi: ../default/openapi/openapi.json + LaborTimecardUpdatedEventObject: + properties: + timecard: + type: optional + docs: The updated `Timecard`. + source: + openapi: ../default/openapi/openapi.json + LinkCustomerToGiftCardResponse: + docs: >- + A response that contains the linked `GiftCard` object. If the request + resulted in errors, + + the response contains a set of `Error` objects. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card: + type: optional + docs: >- + The gift card with the ID of the linked customer listed in the + `customer_ids` field. + source: + openapi: ../default/openapi/openapi.json + ListBankAccountsResponse: + docs: Response object returned by ListBankAccounts. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + bank_accounts: + type: optional> + docs: List of BankAccounts associated with this account. + cursor: + type: optional + docs: >- + When a response is truncated, it includes a cursor that you can + + use in a subsequent request to fetch next set of bank accounts. + + If empty, this is the final response. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + source: + openapi: ../default/openapi/openapi.json + ListBookingCustomAttributeDefinitionsResponse: + docs: >- + Represents a + [ListBookingCustomAttributeDefinitions](api-endpoint:BookingCustomAttributes-ListBookingCustomAttributeDefinitions) + response. + + Either `custom_attribute_definitions`, an empty object, or `errors` is + present in the response. + + If additional results are available, the `cursor` field is also present + along with `custom_attribute_definitions`. + properties: + custom_attribute_definitions: + type: optional> + docs: >- + The retrieved custom attribute definitions. If no custom attribute + definitions are found, + + Square returns an empty object (`{}`). + cursor: + type: optional + docs: >- + The cursor to provide in your next call to this endpoint to retrieve + the next page of + + results for your original request. This field is present only if the + request succeeded and + + additional results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListBookingCustomAttributesResponse: + docs: >- + Represents a + [ListBookingCustomAttributes](api-endpoint:BookingCustomAttributes-ListBookingCustomAttributes) + response. + + Either `custom_attributes`, an empty object, or `errors` is present in the + response. If additional + + results are available, the `cursor` field is also present along with + `custom_attributes`. + properties: + custom_attributes: + type: optional> + docs: >- + The retrieved custom attributes. If `with_definitions` was set to + `true` in the request, + + the custom attribute definition is returned in the `definition` field + of each custom attribute. + + + If no custom attributes are found, Square returns an empty object + (`{}`). + cursor: + type: optional + docs: >- + The cursor to use in your next call to this endpoint to retrieve the + next page of results + + for your original request. This field is present only if the request + succeeded and additional + + results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListBookingsResponse: + properties: + bookings: + type: optional> + docs: The list of targeted bookings. + cursor: + type: optional + docs: >- + The pagination cursor to be used in the subsequent request to get the + next page of the results. Stop retrieving the next page of the results + when the cursor is not set. + validation: + maxLength: 65536 + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListBreakTypesResponse: + docs: >- + 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. + properties: + break_types: + type: optional> + docs: ' A page of `BreakType` results.' + cursor: + type: optional + docs: |- + The value supplied in the subsequent request to fetch the next page + of `BreakType` results. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListCardsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [ListCards](api-endpoint:Cards-ListCards) endpoint. + + + Note: if there are errors processing the request, the card field will not + be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + cards: + type: optional> + docs: The requested list of `Card`s. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + source: + openapi: ../default/openapi/openapi.json + ListCashDrawerShiftEventsResponse: + properties: + cursor: + type: optional + docs: |- + Opaque cursor for fetching the next page. Cursor is not present in + the last page of results. + errors: + type: optional> + docs: Any errors that occurred during the request. + cash_drawer_shift_events: + type: optional> + docs: |- + All of the events (payments, refunds, etc.) for a cash drawer during + the shift. + source: + openapi: ../default/openapi/openapi.json + ListCashDrawerShiftsResponse: + properties: + cursor: + type: optional + docs: |- + Opaque cursor for fetching the next page of results. Cursor is not + present in the last page of results. + errors: + type: optional> + docs: Any errors that occurred during the request. + cash_drawer_shifts: + type: optional> + docs: |- + A collection of CashDrawerShiftSummary objects for shifts that match + the query. + source: + openapi: ../default/openapi/openapi.json + ListCatalogResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + this is the final response. + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + objects: + type: optional> + docs: The CatalogObjects returned. + source: + openapi: ../default/openapi/openapi.json + ListChannelsRequestConstants: literal<"MAX_PAGE_SIZE"> + ListChannelsResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + channels: + type: optional> + docs: List of requested Channel. + cursor: + type: optional + docs: The token required to retrieve the next page of results. + source: + openapi: ../default/openapi/openapi.json + ListCustomerCustomAttributeDefinitionsResponse: + docs: >- + Represents a + [ListCustomerCustomAttributeDefinitions](api-endpoint:CustomerCustomAttributes-ListCustomerCustomAttributeDefinitions) + response. + + Either `custom_attribute_definitions`, an empty object, or `errors` is + present in the response. + + If additional results are available, the `cursor` field is also present + along with `custom_attribute_definitions`. + properties: + custom_attribute_definitions: + type: optional> + docs: >- + The retrieved custom attribute definitions. If no custom attribute + definitions are found, + + Square returns an empty object (`{}`). + cursor: + type: optional + docs: >- + The cursor to provide in your next call to this endpoint to retrieve + the next page of + + results for your original request. This field is present only if the + request succeeded and + + additional results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListCustomerCustomAttributesResponse: + docs: >- + Represents a + [ListCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-ListCustomerCustomAttributes) + response. + + Either `custom_attributes`, an empty object, or `errors` is present in the + response. If additional + + results are available, the `cursor` field is also present along with + `custom_attributes`. + properties: + custom_attributes: + type: optional> + docs: >- + The retrieved custom attributes. If `with_definitions` was set to + `true` in the request, + + the custom attribute definition is returned in the `definition` field + of each custom attribute. + + + If no custom attributes are found, Square returns an empty object + (`{}`). + cursor: + type: optional + docs: >- + The cursor to use in your next call to this endpoint to retrieve the + next page of results + + for your original request. This field is present only if the request + succeeded and additional + + results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListCustomerGroupsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [ListCustomerGroups](api-endpoint:CustomerGroups-ListCustomerGroups) + endpoint. + + + Either `errors` or `groups` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + groups: + type: optional> + docs: A list of customer groups belonging to the current seller. + cursor: + type: optional + docs: >- + A pagination cursor to retrieve the next set of results for your + + original query to the endpoint. This value is present only if the + request + + succeeded and additional results are available. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListCustomerSegmentsResponse: + docs: >- + Defines the fields that are included in the response body for requests to + the `ListCustomerSegments` endpoint. + + + Either `errors` or `segments` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + segments: + type: optional> + docs: >- + The list of customer segments belonging to the associated Square + account. + cursor: + type: optional + docs: >- + A pagination cursor to be used in subsequent calls to + `ListCustomerSegments` + + to retrieve the next set of query results. The cursor is only present + if the request succeeded and + + additional results are available. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListCustomersResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the `ListCustomers` endpoint. + + + Either `errors` or `customers` is present in a given response (never + both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + customers: + type: optional> + docs: >- + The customer profiles associated with the Square account or an empty + object (`{}`) if none are found. + + Only customer profiles with public information (`given_name`, + `family_name`, `company_name`, `email_address`, or + + `phone_number`) are included in the response. + cursor: + type: optional + docs: >- + A pagination cursor to retrieve the next set of results for the + + original query. A cursor is only present if the request succeeded and + additional results + + are available. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + count: + type: optional + docs: >- + The total count of customers associated with the Square account. Only + customer profiles with public information + + (`given_name`, `family_name`, `company_name`, `email_address`, or + `phone_number`) are counted. This field is present + + only if `count` is set to `true` in the request. + source: + openapi: ../default/openapi/openapi.json + ListDeviceCodesResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + device_codes: + type: optional> + docs: The queried DeviceCode. + cursor: + type: optional + docs: >- + A pagination cursor to retrieve the next set of results for your + + original query to the endpoint. This value is present only if the + request + + succeeded and additional results are available. + + + See [Paginating + results](https://developer.squareup.com/docs/working-with-apis/pagination) + for more information. + source: + openapi: ../default/openapi/openapi.json + ListDevicesResponse: + properties: + errors: + type: optional> + docs: Information about errors that occurred during the request. + devices: + type: optional> + docs: The requested list of `Device` objects. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + source: + openapi: ../default/openapi/openapi.json + ListDisputeEvidenceResponse: + docs: Defines the fields in a `ListDisputeEvidence` response. + properties: + evidence: + type: optional> + docs: The list of evidence previously uploaded to the specified dispute. + errors: + type: optional> + docs: Information about errors encountered during the request. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. + + If unset, this is the final response. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListDisputesResponse: + docs: Defines fields in a `ListDisputes` response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + disputes: + type: optional> + docs: The list of disputes. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. + + If unset, this is the final response. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListEmployeeWagesResponse: + docs: >- + The response to a request for a set of `EmployeeWage` objects. The + response contains + + a set of `EmployeeWage` objects. + properties: + employee_wages: + type: optional> + docs: A page of `EmployeeWage` results. + cursor: + type: optional + docs: |- + The value supplied in the subsequent request to fetch the next page + of `EmployeeWage` results. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListEmployeesResponse: + properties: + employees: optional> + cursor: + type: optional + docs: The token to be used to retrieve the next page of results. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListEventTypesResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [ListEventTypes](api-endpoint:Events-ListEventTypes) + endpoint. + + + Note: if there are errors processing the request, the event types field + will not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + event_types: + type: optional> + docs: The list of event types. + metadata: + type: optional> + docs: >- + Contains the metadata of an event type. For more information, see + [EventTypeMetadata](entity:EventTypeMetadata). + source: + openapi: ../default/openapi/openapi.json + ListGiftCardActivitiesResponse: + docs: >- + A response that contains a list of `GiftCardActivity` objects. If the + request resulted in errors, + + the response contains a set of `Error` objects. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card_activities: + type: optional> + docs: >- + The requested gift card activities or an empty object if none are + found. + cursor: + type: optional + docs: >- + When a response is truncated, it includes a cursor that you can use in + a + + subsequent request to retrieve the next set of activities. If a cursor + is not present, this is + + the final response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + source: + openapi: ../default/openapi/openapi.json + ListGiftCardsResponse: + docs: >- + A response that contains a list of `GiftCard` objects. If the request + resulted in errors, + + the response contains a set of `Error` objects. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_cards: + type: optional> + docs: The requested gift cards or an empty object if none are found. + cursor: + type: optional + docs: >- + When a response is truncated, it includes a cursor that you can use in + a + + subsequent request to retrieve the next set of gift cards. If a cursor + is not present, this is + + the final response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + source: + openapi: ../default/openapi/openapi.json + ListInvoicesResponse: + docs: Describes a `ListInvoice` response. + properties: + invoices: + type: optional> + docs: The invoices retrieved. + cursor: + type: optional + docs: >- + When a response is truncated, it includes a cursor that you can use in + a + + subsequent request to retrieve the next set of invoices. If empty, + this is the final + + response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + ListJobsResponse: + docs: >- + Represents a [ListJobs](api-endpoint:Team-ListJobs) response. Either + `jobs` or `errors` + + is present in the response. If additional results are available, the + `cursor` field is also present. + properties: + jobs: + type: optional> + docs: The retrieved jobs. A single paged response contains up to 100 jobs. + cursor: + type: optional + docs: >- + An opaque cursor used to retrieve the next page of results. This field + is present only + + if the request succeeded and additional results are available. For + more information, see + + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListLocationBookingProfilesResponse: + properties: + location_booking_profiles: + type: optional> + docs: The list of a seller's location booking profiles. + cursor: + type: optional + docs: >- + The pagination cursor to be used in the subsequent request to get the + next page of the results. Stop retrieving the next page of the results + when the cursor is not set. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListLocationCustomAttributeDefinitionsResponse: + docs: >- + Represents a + [ListLocationCustomAttributeDefinitions](api-endpoint:LocationCustomAttributes-ListLocationCustomAttributeDefinitions) + response. + + Either `custom_attribute_definitions`, an empty object, or `errors` is + present in the response. + + If additional results are available, the `cursor` field is also present + along with `custom_attribute_definitions`. + properties: + custom_attribute_definitions: + type: optional> + docs: >- + The retrieved custom attribute definitions. If no custom attribute + definitions are found, + + Square returns an empty object (`{}`). + cursor: + type: optional + docs: >- + The cursor to provide in your next call to this endpoint to retrieve + the next page of + + results for your original request. This field is present only if the + request succeeded and + + additional results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListLocationCustomAttributesResponse: + docs: >- + Represents a + [ListLocationCustomAttributes](api-endpoint:LocationCustomAttributes-ListLocationCustomAttributes) + response. + + Either `custom_attributes`, an empty object, or `errors` is present in the + response. If additional + + results are available, the `cursor` field is also present along with + `custom_attributes`. + properties: + custom_attributes: + type: optional> + docs: >- + The retrieved custom attributes. If `with_definitions` was set to + `true` in the request, + + the custom attribute definition is returned in the `definition` field + of each custom attribute. + + If no custom attributes are found, Square returns an empty object + (`{}`). + cursor: + type: optional + docs: >- + The cursor to use in your next call to this endpoint to retrieve the + next page of results + + for your original request. This field is present only if the request + succeeded and additional + + results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListLocationsResponse: + docs: >- + Defines the fields that are included in the response body of a request + + to the [ListLocations](api-endpoint:Locations-ListLocations) endpoint. + + + Either `errors` or `locations` is present in a given response (never + both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + locations: + type: optional> + docs: The business locations. + source: + openapi: ../default/openapi/openapi.json + ListLoyaltyProgramsResponse: + docs: A response that contains all loyalty programs. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + programs: + type: optional> + docs: A list of `LoyaltyProgram` for the merchant. + source: + openapi: ../default/openapi/openapi.json + ListLoyaltyPromotionsResponse: + docs: >- + Represents a + [ListLoyaltyPromotions](api-endpoint:Loyalty-ListLoyaltyPromotions) + response. + + One of `loyalty_promotions`, an empty object, or `errors` is present in + the response. + + If additional results are available, the `cursor` field is also present + along with `loyalty_promotions`. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_promotions: + type: optional> + docs: The retrieved loyalty promotions. + cursor: + type: optional + docs: >- + The cursor to use in your next call to this endpoint to retrieve the + next page of results + + for your original request. This field is present only if the request + succeeded and additional + + results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListMerchantCustomAttributeDefinitionsResponse: + docs: >- + Represents a + [ListMerchantCustomAttributeDefinitions](api-endpoint:MerchantCustomAttributes-ListMerchantCustomAttributeDefinitions) + response. + + Either `custom_attribute_definitions`, an empty object, or `errors` is + present in the response. + + If additional results are available, the `cursor` field is also present + along with `custom_attribute_definitions`. + properties: + custom_attribute_definitions: + type: optional> + docs: >- + The retrieved custom attribute definitions. If no custom attribute + definitions are found, + + Square returns an empty object (`{}`). + cursor: + type: optional + docs: >- + The cursor to provide in your next call to this endpoint to retrieve + the next page of + + results for your original request. This field is present only if the + request succeeded and + + additional results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListMerchantCustomAttributesResponse: + docs: >- + Represents a + [ListMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-ListMerchantCustomAttributes) + response. + + Either `custom_attributes`, an empty object, or `errors` is present in the + response. If additional + + results are available, the `cursor` field is also present along with + `custom_attributes`. + properties: + custom_attributes: + type: optional> + docs: >- + The retrieved custom attributes. If `with_definitions` was set to + `true` in the request, + + the custom attribute definition is returned in the `definition` field + of each custom attribute. + + If no custom attributes are found, Square returns an empty object + (`{}`). + cursor: + type: optional + docs: >- + The cursor to use in your next call to this endpoint to retrieve the + next page of results + + for your original request. This field is present only if the request + succeeded and additional + + results are available. For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListMerchantsResponse: + docs: >- + The response object returned by the + [ListMerchant](api-endpoint:Merchants-ListMerchants) endpoint. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + merchant: + type: optional> + docs: The requested `Merchant` entities. + cursor: + type: optional + docs: >- + If the response is truncated, the cursor to use in next request to + fetch next set of objects. + source: + openapi: ../default/openapi/openapi.json + ListOrderCustomAttributeDefinitionsResponse: + docs: Represents a response from listing order custom attribute definitions. + properties: + custom_attribute_definitions: + docs: >- + The retrieved custom attribute definitions. If no custom attribute + definitions are found, Square returns an empty object (`{}`). + type: list + cursor: + type: optional + docs: >- + The cursor to provide in your next call to this endpoint to retrieve + the next page of results for your original request. + + This field is present only if the request succeeded and additional + results are available. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + validation: + minLength: 1 + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListOrderCustomAttributesResponse: + docs: Represents a response from listing order custom attributes. + properties: + custom_attributes: + type: optional> + docs: >- + The retrieved custom attributes. If no custom attribute are found, + Square returns an empty object (`{}`). + cursor: + type: optional + docs: >- + The cursor to provide in your next call to this endpoint to retrieve + the next page of results for your original request. + + This field is present only if the request succeeded and additional + results are available. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + validation: + minLength: 1 + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListPaymentLinksResponse: + properties: + errors: + type: optional> + docs: Errors that occurred during the request. + payment_links: + type: optional> + docs: The list of payment links. + cursor: + type: optional + docs: >2- + When a response is truncated, it includes a cursor that you can use in a subsequent request + to retrieve the next set of gift cards. If a cursor is not present, + this is the final response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListPaymentRefundsRequestSortField: + enum: + - CREATED_AT + - UPDATED_AT + source: + openapi: ../default/openapi/openapi.json + ListPaymentRefundsResponse: + docs: >- + Defines the response returned by + [ListPaymentRefunds](api-endpoint:Refunds-ListPaymentRefunds). + + + Either `errors` or `refunds` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refunds: + type: optional> + docs: The list of requested refunds. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListPaymentsRequestSortField: + enum: + - CREATED_AT + - OFFLINE_CREATED_AT + - UPDATED_AT + source: + openapi: ../default/openapi/openapi.json + ListPaymentsResponse: + docs: >- + Defines the response returned by + [ListPayments](api-endpoint:Payments-ListPayments). + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + payments: + type: optional> + docs: The requested list of payments. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListPayoutEntriesResponse: + docs: The response to retrieve payout records entries. + properties: + payout_entries: + type: optional> + docs: >- + The requested list of payout entries, ordered with the given or + default sort order. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + this is the final response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + ListPayoutsResponse: + docs: The response to retrieve payout records entries. + properties: + payouts: + type: optional> + docs: The requested list of payouts. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + this is the final response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + ListSitesResponse: + docs: >- + Represents a `ListSites` response. The response can include either `sites` + or `errors`. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + sites: + type: optional> + docs: The sites that belong to the seller. + source: + openapi: ../default/openapi/openapi.json + ListSubscriptionEventsResponse: + docs: >- + Defines output parameters in a response from the + + [ListSubscriptionEvents](api-endpoint:Subscriptions-ListSubscriptionEvents). + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription_events: + type: optional> + docs: The retrieved subscription events. + cursor: + type: optional + docs: >- + When the total number of resulting subscription events exceeds the + limit of a paged response, + + the response includes a cursor for you to use in a subsequent request + to fetch the next set of events. + + If the cursor is unset, the response contains the last page of the + results. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListTeamMemberBookingProfilesResponse: + properties: + team_member_booking_profiles: + type: optional> + docs: >- + The list of team member booking profiles. The results are returned in + the ascending order of the time + + when the team member booking profiles were last updated. Multiple + booking profiles updated at the same time + + are further sorted in the ascending order of their IDs. + cursor: + type: optional + docs: >- + The pagination cursor to be used in the subsequent request to get the + next page of the results. Stop retrieving the next page of the results + when the cursor is not set. + validation: + maxLength: 65536 + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListTeamMemberWagesResponse: + docs: >- + The response to a request for a set of `TeamMemberWage` objects. The + response contains + + a set of `TeamMemberWage` objects. + properties: + team_member_wages: + type: optional> + docs: A page of `TeamMemberWage` results. + cursor: + type: optional + docs: |- + The value supplied in the subsequent request to fetch the next page + of `TeamMemberWage` results. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ListTransactionsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [ListTransactions](api-endpoint:Transactions-ListTransactions) endpoint. + + + One of `errors` or `transactions` is present in a given response (never + both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + transactions: + type: optional> + docs: An array of transactions that match your query. + cursor: + type: optional + docs: >- + A pagination cursor for retrieving the next set of results, + + if any remain. Provide this value as the `cursor` parameter in a + subsequent + + request to this endpoint. + + + See [Paginating + results](https://developer.squareup.com/docs/working-with-apis/pagination) + for more information. + source: + openapi: ../default/openapi/openapi.json + ListWebhookEventTypesResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [ListWebhookEventTypes](api-endpoint:WebhookSubscriptions-ListWebhookEventTypes) + endpoint. + + + Note: if there are errors processing the request, the event types field + will not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + event_types: + type: optional> + docs: The list of event types. + metadata: + type: optional> + docs: >- + Contains the metadata of a webhook event type. For more information, + see [EventTypeMetadata](entity:EventTypeMetadata). + source: + openapi: ../default/openapi/openapi.json + ListWebhookSubscriptionsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [ListWebhookSubscriptions](api-endpoint:WebhookSubscriptions-ListWebhookSubscriptions) + endpoint. + + + Note: if there are errors processing the request, the subscriptions field + will not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + subscriptions: + type: optional> + docs: The requested list of [Subscription](entity:WebhookSubscription)s. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + ListWorkweekConfigsResponse: + docs: >- + The response to a request for a set of `WorkweekConfig` objects. The + response contains + + the requested `WorkweekConfig` objects and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + workweek_configs: + type: optional> + docs: A page of `WorkweekConfig` results. + cursor: + type: optional + docs: |- + The value supplied in the subsequent request to fetch the next page of + `WorkweekConfig` results. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + Location: + docs: >- + Represents one of a business' + [locations](https://developer.squareup.com/docs/locations-api). + properties: + id: + type: optional + docs: >- + A short generated string of letters and numbers that uniquely + identifies this location instance. + validation: + maxLength: 32 + access: read-only + name: + type: optional> + docs: |- + The name of the location. + This information appears in the Seller Dashboard as the nickname. + A location name must be unique within a seller account. + validation: + maxLength: 255 + address: + type: optional
+ docs: The physical address of the location. + timezone: + type: optional> + docs: |- + The [IANA time zone](https://www.iana.org/time-zones) identifier for + the time zone of the location. For example, `America/Los_Angeles`. + validation: + maxLength: 30 + capabilities: + type: optional> + docs: >- + The Square features that are enabled for the location. + + See [LocationCapability](entity:LocationCapability) for possible + values. + + See [LocationCapability](#type-locationcapability) for possible values + access: read-only + status: + type: optional + docs: |- + The status of the location. + See [LocationStatus](#type-locationstatus) for possible values + created_at: + type: optional + docs: >- + The time when the location was created, in RFC 3339 format. + + For more information, see [Working with + Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + validation: + minLength: 20 + maxLength: 25 + access: read-only + merchant_id: + type: optional + docs: The ID of the merchant that owns the location. + validation: + maxLength: 32 + access: read-only + country: + type: optional + docs: >- + The country of the location, in the two-letter format of ISO 3166. For + example, `US` or `JP`. + + + See [Country](entity:Country) for possible values. + + See [Country](#type-country) for possible values + language_code: + type: optional> + docs: >- + The language associated with the location, in + + [BCP 47 format](https://tools.ietf.org/html/bcp47#appendix-A). + + For more information, see [Language + Preferences](https://developer.squareup.com/docs/build-basics/general-considerations/language-preferences). + validation: + minLength: 2 + maxLength: 5 + currency: + type: optional + docs: >- + The currency used for all transactions at this location, + + in ISO 4217 format. For example, the currency code for US dollars is + `USD`. + + See [Currency](entity:Currency) for possible values. + + See [Currency](#type-currency) for possible values + phone_number: + type: optional> + docs: The phone number of the location. For example, `+1 855-700-6000`. + validation: + maxLength: 17 + business_name: + type: optional> + docs: >- + The name of the location's overall business. This name is present on + receipts and other customer-facing branding, and can be changed no + more than three times in a twelve-month period. + validation: + maxLength: 255 + type: + type: optional + docs: |- + The type of the location. + See [LocationType](#type-locationtype) for possible values + website_url: + type: optional> + docs: The website URL of the location. For example, `https://squareup.com`. + validation: + maxLength: 255 + business_hours: + type: optional + docs: The hours of operation for the location. + business_email: + type: optional> + docs: >- + The email address of the location. This can be unique to the location + and is not always the email address for the business owner or + administrator. + validation: + maxLength: 255 + description: + type: optional> + docs: The description of the location. For example, `Main Street location`. + validation: + maxLength: 1024 + twitter_username: + type: optional> + docs: >- + The Twitter username of the location without the '@' symbol. For + example, `Square`. + validation: + minLength: 1 + maxLength: 15 + instagram_username: + type: optional> + docs: >- + The Instagram username of the location without the '@' symbol. For + example, `square`. + validation: + minLength: 1 + maxLength: 30 + facebook_url: + type: optional> + docs: >- + The Facebook profile URL of the location. The URL should begin with + 'facebook.com/'. For example, `https://www.facebook.com/square`. + validation: + maxLength: 255 + coordinates: + type: optional + docs: The physical coordinates (latitude and longitude) of the location. + logo_url: + type: optional + docs: >- + The URL of the logo image for the location. When configured in the + Seller + + Dashboard (Receipts section), the logo appears on transactions (such + as receipts and invoices) that Square generates on behalf of the + seller. + + This image should have a roughly square (1:1) aspect ratio and should + be at least 200x200 pixels. + validation: + maxLength: 255 + access: read-only + pos_background_url: + type: optional + docs: The URL of the Point of Sale background image for the location. + validation: + maxLength: 255 + access: read-only + mcc: + type: optional> + docs: >- + A four-digit number that describes the kind of goods or services sold + at the location. + + The [merchant category code + (MCC)](https://developer.squareup.com/docs/locations-api#initialize-a-merchant-category-code) + of the location as standardized by ISO 18245. + + For example, `5045`, for a location that sells computer goods and + software. + validation: + minLength: 4 + maxLength: 4 + full_format_logo_url: + type: optional + docs: >- + The URL of a full-format logo image for the location. When configured + in the Seller + + Dashboard (Receipts section), the logo appears on transactions (such + as receipts and invoices) that Square generates on behalf of the + seller. + + This image can be wider than it is tall and should be at least + 1280x648 pixels. + access: read-only + tax_ids: + type: optional + docs: The tax IDs for this location. + source: + openapi: ../default/openapi/openapi.json + LocationBookingProfile: + docs: >- + The booking profile of a seller's location, including the location's ID + and whether the location is enabled for online booking. + properties: + location_id: + type: optional> + docs: The ID of the [location](entity:Location). + booking_site_url: + type: optional> + docs: Url for the online booking site for this location. + online_booking_enabled: + type: optional> + docs: Indicates whether the location is enabled for online booking. + source: + openapi: ../default/openapi/openapi.json + LocationCapability: + enum: + - CREDIT_CARD_PROCESSING + - AUTOMATIC_TRANSFERS + - UNLINKED_REFUNDS + docs: The capabilities a location might have. + source: + openapi: ../default/openapi/openapi.json + LocationCreatedEvent: + docs: Published when a [Location](entity:Location) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the [Location](entity:Location) associated with the event. + type: + type: optional> + docs: The type of event this represents, `"location.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LocationCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"location"`. + id: + type: optional + docs: ID of the updated [Location](entity:Location). + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeDefinitionOwnedCreatedEvent: + docs: >- + Published when a location [custom attribute + definition](entity:CustomAttributeDefinition) + + is created by the subscribing application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute_definition.owned.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeDefinitionOwnedDeletedEvent: + docs: >- + Published when a location [custom attribute + definition](entity:CustomAttributeDefinition) + + created by the subscribing application is deleted. A custom attribute + definition can only be deleted by + + the application that created it. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute_definition.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeDefinitionOwnedUpdatedEvent: + docs: >- + Published when a location [custom attribute + definition](entity:CustomAttributeDefinition) + + created by the subscribing application is updated. A custom attribute + definition can only be updated + + by the application that created it. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute_definition.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeDefinitionVisibleCreatedEvent: + docs: >- + Published when a location [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is created. A notification + is sent when your application + + creates a custom attribute definition or another application creates a + custom attribute definition whose + + `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute_definition.visible.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeDefinitionVisibleDeletedEvent: + docs: >- + Published when a location [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is deleted. A custom + attribute definition can only + + be deleted by the application that created it. A notification is sent when + your application deletes + + a custom attribute definition or when another application deletes a custom + attribute definition whose + + `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute_definition.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeDefinitionVisibleUpdatedEvent: + docs: >- + Published when a location [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is updated. A custom + attribute definition can only be updated + + by the application that created it. A notification is sent when your + application updates a custom attribute + + definition or when another application updates a custom attribute + definition whose `visibility` is + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute_definition.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeOwnedDeletedEvent: + docs: >- + Published when a location [custom attribute](entity:CustomAttribute) + + owned by the subscribing application is deleted. Custom attributes are + owned by the + + application that created the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). + + Custom attributes whose `visibility` is `VISIBILITY_READ_WRITE_VALUES` can + be deleted by any application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeOwnedUpdatedEvent: + docs: >- + Published when a location [custom attribute](entity:CustomAttribute) owned + by the + + subscribing application is created or updated. Custom attributes are owned + by the application that created + + the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). Custom attributes whose + + `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be created or updated + by any application. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeVisibleDeletedEvent: + docs: >- + Published when a location [custom attribute](entity:CustomAttribute) that + is visible to the + + subscribing application is deleted. A notification is sent when: + + - Your application deletes a custom attribute owned by your application, + regardless of the `visibility` setting. + + - Any application deletes a custom attribute whose `visibility` is + `VISIBILITY_READ_ONLY` + + or `VISIBILITY_READ_WRITE_VALUES`. + + + Custom attributes set to `VISIBILITY_READ_WRITE_VALUES` can be deleted by + any application, but those set to + + `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be deleted by the + owner. Custom attributes are owned + + by the application that created the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationCustomAttributeVisibleUpdatedEvent: + docs: >- + Published when a location [custom attribute](entity:CustomAttribute) that + is visible + + to the subscribing application is created or updated. A notification is + sent when: + + - Your application creates or updates a custom attribute owned by your + application, regardless of the `visibility` setting. + + - Any application creates or updates a custom attribute whose `visibility` + is `VISIBILITY_READ_ONLY` + + or `VISIBILITY_READ_WRITE_VALUES`. + + + Custom attributes set to `VISIBILITY_READ_WRITE_VALUES` can be created or + updated by any application, but those set to + + `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be created or + updated by the owner. Custom attributes are owned + + by the application that created the corresponding [custom attribute + definition](entity:CustomAttributeDefinition). + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"location.custom_attribute.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + LocationSettingsUpdatedEvent: + docs: Published when online checkout location settings are updated + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: >- + The type of event this represents, + `"online_checkout.location_settings.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LocationSettingsUpdatedEventData: + properties: + type: + type: optional> + docs: >- + Name of the updated object’s type, + `"online_checkout.location_settings"`. + id: + type: optional + docs: ID of the updated location settings. + object: + type: optional + docs: An object containing the updated location settings. + source: + openapi: ../default/openapi/openapi.json + LocationSettingsUpdatedEventObject: + properties: + location_settings: + type: optional + docs: The updated location settings. + source: + openapi: ../default/openapi/openapi.json + LocationStatus: + enum: + - ACTIVE + - INACTIVE + docs: A location's status. + source: + openapi: ../default/openapi/openapi.json + LocationType: + enum: + - PHYSICAL + - MOBILE + docs: A location's type. + source: + openapi: ../default/openapi/openapi.json + LocationUpdatedEvent: + docs: Published when a [Location](entity:Location) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the [Location](entity:Location) associated with the event. + type: + type: optional> + docs: The type of event this represents, `"location.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LocationUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"location"`. + id: + type: optional + docs: ID of the updated [Location](entity:Location). + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccount: + docs: >- + Describes a loyalty account in a [loyalty program](entity:LoyaltyProgram). + For more information, see + + [Create and Retrieve Loyalty + Accounts](https://developer.squareup.com/docs/loyalty-api/loyalty-accounts). + properties: + id: + type: optional + docs: The Square-assigned ID of the loyalty account. + validation: + maxLength: 36 + access: read-only + program_id: + type: string + docs: >- + The Square-assigned ID of the [loyalty program](entity:LoyaltyProgram) + to which the account belongs. + validation: + minLength: 1 + maxLength: 36 + balance: + type: optional + docs: >- + The available point balance in the loyalty account. If points are + scheduled to expire, they are listed in the `expiring_point_deadlines` + field. + + + Your application should be able to handle loyalty accounts that have a + negative point balance (`balance` is less than 0). This might occur if + a seller makes a manual adjustment or as a result of a refund or + exchange. + access: read-only + lifetime_points: + type: optional + docs: The total points accrued during the lifetime of the account. + access: read-only + customer_id: + type: optional> + docs: >- + The Square-assigned ID of the [customer](entity:Customer) that is + associated with the account. + enrolled_at: + type: optional> + docs: >- + The timestamp when the buyer joined the loyalty program, in RFC 3339 + format. This field is used to display the **Enrolled On** or **Member + Since** date in first-party Square products. + + + If this field is not set in a `CreateLoyaltyAccount` request, Square + populates it after the buyer's first action on their account + + (when `AccumulateLoyaltyPoints` or `CreateLoyaltyReward` is called). + In first-party flows, Square populates the field when the buyer agrees + to the terms of service on Square Point of Sale. + + + If this field is set in a `CreateLoyaltyAccount` request, it is meant + to be used when there is a loyalty migration from another system and + into Square. + + In that case, the timestamp can reflect when the buyer originally + enrolled in the previous system. It may represent a current or past + date, but cannot be set in the future. + + Note: Setting this field in this scenario does not, by itself, impact + the first-party enrollment flow on Square Point of Sale. + created_at: + type: optional + docs: >- + The timestamp when the loyalty account was created, in RFC 3339 + format. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp when the loyalty account was last updated, in RFC 3339 + format. + access: read-only + mapping: + type: optional + docs: >- + The mapping that associates the loyalty account with a buyer. + Currently, + + a loyalty account can only be mapped to a buyer by phone number. + + + To create a loyalty account, you must specify the `mapping` field, + with the buyer's phone number + + in the `phone_number` field. + expiring_point_deadlines: + type: optional>> + docs: >- + The schedule for when points expire in the loyalty account balance. + This field is present only if the account has points that are + scheduled to expire. + + + The total number of points in this field equals the number of points + in the `balance` field. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountCreatedEvent: + docs: Published when a [loyalty account](entity:LoyaltyAccount) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.account.created`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountCreatedEventData: + docs: The data associated with a `loyalty.account.created` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_account`. + id: + type: optional + docs: The ID of the affected loyalty account. + object: + type: optional + docs: An object that contains the new loyalty account. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountCreatedEventObject: + properties: + loyalty_account: + type: optional + docs: The loyalty account that was created. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountDeletedEvent: + docs: Published when a [loyalty account](entity:LoyaltyAccount) is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.account.deleted`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountDeletedEventData: + docs: The data associated with a `loyalty.account.deleted` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_account`. + id: + type: optional + docs: The ID of the affected loyalty account. + object: + type: optional + docs: An object that contains the loyalty account that was deleted. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountDeletedEventObject: + properties: + loyalty_account: + type: optional + docs: The loyalty account that was deleted. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountExpiringPointDeadline: + docs: >- + Represents a set of points for a loyalty account that are scheduled to + expire on a specific date. + properties: + points: + type: integer + docs: >- + The number of points scheduled to expire at the `expires_at` + timestamp. + expires_at: + type: string + docs: >- + The timestamp of when the points are scheduled to expire, in RFC 3339 + format. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountMapping: + docs: >- + Represents the mapping that associates a loyalty account with a buyer. + + + Currently, a loyalty account can only be mapped to a buyer by phone + number. For more information, see + + [Loyalty Overview](https://developer.squareup.com/docs/loyalty/overview). + properties: + id: + type: optional + docs: The Square-assigned ID of the mapping. + validation: + maxLength: 36 + access: read-only + created_at: + type: optional + docs: The timestamp when the mapping was created, in RFC 3339 format. + access: read-only + phone_number: + type: optional> + docs: >- + The phone number of the buyer, in E.164 format. For example, + "+14155551111". + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountMappingType: + type: literal<"PHONE"> + docs: The type of mapping. + LoyaltyAccountUpdatedEvent: + docs: Published when a [loyalty account](entity:LoyaltyAccount) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.account.updated`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountUpdatedEventData: + docs: The data associated with a `loyalty.account.updated` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_account`. + id: + type: optional + docs: The ID of the affected loyalty account. + object: + type: optional + docs: An object that contains the loyalty account that was updated. + source: + openapi: ../default/openapi/openapi.json + LoyaltyAccountUpdatedEventObject: + properties: + loyalty_account: + type: optional + docs: The loyalty account that was updated. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEvent: + docs: >- + Provides information about a loyalty event. + + For more information, see [Search for Balance-Changing Loyalty + Events](https://developer.squareup.com/docs/loyalty-api/loyalty-events). + properties: + id: + type: optional + docs: The Square-assigned ID of the loyalty event. + validation: + minLength: 1 + access: read-only + type: + type: LoyaltyEventType + docs: |- + The type of the loyalty event. + See [LoyaltyEventType](#type-loyaltyeventtype) for possible values + created_at: + type: optional + docs: The timestamp when the event was created, in RFC 3339 format. + validation: + minLength: 1 + access: read-only + accumulate_points: + type: optional + docs: Provides metadata when the event `type` is `ACCUMULATE_POINTS`. + create_reward: + type: optional + docs: Provides metadata when the event `type` is `CREATE_REWARD`. + redeem_reward: + type: optional + docs: Provides metadata when the event `type` is `REDEEM_REWARD`. + delete_reward: + type: optional + docs: Provides metadata when the event `type` is `DELETE_REWARD`. + adjust_points: + type: optional + docs: Provides metadata when the event `type` is `ADJUST_POINTS`. + loyalty_account_id: + type: optional + docs: >- + The ID of the [loyalty account](entity:LoyaltyAccount) associated with + the event. + validation: + minLength: 1 + maxLength: 36 + access: read-only + location_id: + type: optional + docs: The ID of the [location](entity:Location) where the event occurred. + access: read-only + source: + type: LoyaltyEventSource + docs: |- + Defines whether the event was generated by the Square Point of Sale. + See [LoyaltyEventSource](#type-loyaltyeventsource) for possible values + expire_points: + type: optional + docs: Provides metadata when the event `type` is `EXPIRE_POINTS`. + other_event: + type: optional + docs: Provides metadata when the event `type` is `OTHER`. + accumulate_promotion_points: + type: optional + docs: >- + Provides metadata when the event `type` is + `ACCUMULATE_PROMOTION_POINTS`. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventAccumulatePoints: + docs: Provides metadata when the event `type` is `ACCUMULATE_POINTS`. + properties: + loyalty_program_id: + type: optional + docs: The ID of the [loyalty program](entity:LoyaltyProgram). + validation: + maxLength: 36 + access: read-only + points: + type: optional> + docs: The number of points accumulated by the event. + validation: + min: 1 + order_id: + type: optional> + docs: >- + The ID of the [order](entity:Order) for which the buyer accumulated + the points. + + This field is returned only if the Orders API is used to process + orders. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventAccumulatePromotionPoints: + docs: Provides metadata when the event `type` is `ACCUMULATE_PROMOTION_POINTS`. + properties: + loyalty_program_id: + type: optional + docs: >- + The Square-assigned ID of the [loyalty + program](entity:LoyaltyProgram). + validation: + maxLength: 36 + access: read-only + loyalty_promotion_id: + type: optional + docs: >- + The Square-assigned ID of the [loyalty + promotion](entity:LoyaltyPromotion). + validation: + minLength: 1 + maxLength: 255 + access: read-only + points: + type: optional + docs: The number of points earned by the event. + access: read-only + order_id: + type: optional + docs: >- + The ID of the [order](entity:Order) for which the buyer earned the + promotion points. + + Only applications that use the Orders API to process orders can + trigger this event. + validation: + minLength: 1 + access: read-only + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventAdjustPoints: + docs: Provides metadata when the event `type` is `ADJUST_POINTS`. + properties: + loyalty_program_id: + type: optional + docs: >- + The Square-assigned ID of the [loyalty + program](entity:LoyaltyProgram). + validation: + maxLength: 36 + access: read-only + points: + type: integer + docs: The number of points added or removed. + reason: + type: optional> + docs: The reason for the adjustment of points. + validation: + maxLength: 3500 + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventCreateReward: + docs: Provides metadata when the event `type` is `CREATE_REWARD`. + properties: + loyalty_program_id: + type: optional + docs: The ID of the [loyalty program](entity:LoyaltyProgram). + validation: + minLength: 1 + maxLength: 36 + access: read-only + reward_id: + type: optional + docs: >- + The Square-assigned ID of the created [loyalty + reward](entity:LoyaltyReward). + + This field is returned only if the event source is `LOYALTY_API`. + validation: + maxLength: 36 + access: read-only + points: + type: optional + docs: The loyalty points used to create the reward. + access: read-only + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventCreatedEvent: + docs: Published when a [loyalty event](entity:LoyaltyEvent) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.event.created`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventCreatedEventData: + docs: The data associated with a `loyalty.event.created` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_event`. + id: + type: optional + docs: ID of the affected loyalty event. + object: + type: optional + docs: An object that contains the new loyalty event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventCreatedEventObject: + properties: + loyalty_event: + type: optional + docs: The loyalty event that was created. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventDateTimeFilter: + docs: Filter events by date time range. + properties: + created_at: + type: TimeRange + docs: The `created_at` date time range used to filter the result. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventDeleteReward: + docs: Provides metadata when the event `type` is `DELETE_REWARD`. + properties: + loyalty_program_id: + type: optional + docs: The ID of the [loyalty program](entity:LoyaltyProgram). + validation: + minLength: 1 + maxLength: 36 + access: read-only + reward_id: + type: optional + docs: |- + The ID of the deleted [loyalty reward](entity:LoyaltyReward). + This field is returned only if the event source is `LOYALTY_API`. + validation: + maxLength: 36 + access: read-only + points: + type: optional + docs: The number of points returned to the loyalty account. + access: read-only + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventExpirePoints: + docs: Provides metadata when the event `type` is `EXPIRE_POINTS`. + properties: + loyalty_program_id: + type: optional + docs: >- + The Square-assigned ID of the [loyalty + program](entity:LoyaltyProgram). + validation: + minLength: 1 + maxLength: 36 + access: read-only + points: + type: integer + docs: The number of points expired. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventFilter: + docs: |- + The filtering criteria. If the request specifies multiple filters, + the endpoint uses a logical AND to evaluate them. + properties: + loyalty_account_filter: + type: optional + docs: Filter events by loyalty account. + type_filter: + type: optional + docs: Filter events by event type. + date_time_filter: + type: optional + docs: |- + Filter events by date time range. + For each range, the start time is inclusive and the end time + is exclusive. + location_filter: + type: optional + docs: Filter events by location. + order_filter: + type: optional + docs: Filter events by the order associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventLocationFilter: + docs: Filter events by location. + properties: + location_ids: + docs: |- + The [location](entity:Location) IDs for loyalty events to query. + If multiple values are specified, the endpoint uses + a logical OR to combine them. + type: list + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventLoyaltyAccountFilter: + docs: Filter events by loyalty account. + properties: + loyalty_account_id: + type: string + docs: >- + The ID of the [loyalty account](entity:LoyaltyAccount) associated with + loyalty events. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventOrderFilter: + docs: Filter events by the order associated with the event. + properties: + order_id: + type: string + docs: The ID of the [order](entity:Order) associated with the event. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventOther: + docs: Provides metadata when the event `type` is `OTHER`. + properties: + loyalty_program_id: + type: optional + docs: >- + The Square-assigned ID of the [loyalty + program](entity:LoyaltyProgram). + validation: + minLength: 1 + maxLength: 36 + access: read-only + points: + type: integer + docs: The number of points added or removed. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventQuery: + docs: Represents a query used to search for loyalty events. + properties: + filter: + type: optional + docs: The query filter criteria. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventRedeemReward: + docs: Provides metadata when the event `type` is `REDEEM_REWARD`. + properties: + loyalty_program_id: + type: optional + docs: The ID of the [loyalty program](entity:LoyaltyProgram). + validation: + minLength: 1 + maxLength: 36 + access: read-only + reward_id: + type: optional + docs: |- + The ID of the redeemed [loyalty reward](entity:LoyaltyReward). + This field is returned only if the event source is `LOYALTY_API`. + validation: + maxLength: 36 + access: read-only + order_id: + type: optional + docs: >- + The ID of the [order](entity:Order) that redeemed the reward. + + This field is returned only if the Orders API is used to process + orders. + access: read-only + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventSource: + enum: + - SQUARE + - LOYALTY_API + docs: Defines whether the event was generated by the Square Point of Sale. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventType: + enum: + - ACCUMULATE_POINTS + - CREATE_REWARD + - REDEEM_REWARD + - DELETE_REWARD + - ADJUST_POINTS + - EXPIRE_POINTS + - OTHER + - ACCUMULATE_PROMOTION_POINTS + docs: The type of the loyalty event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyEventTypeFilter: + docs: Filter events by event type. + properties: + types: + docs: |- + The loyalty event types used to filter the result. + If multiple values are specified, the endpoint uses a + logical OR to combine them. + See [LoyaltyEventType](#type-loyaltyeventtype) for possible values + type: list + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgram: + docs: >- + Represents a Square loyalty program. Loyalty programs define how buyers + can earn points and redeem points for rewards. + + Square sellers can have only one loyalty program, which is created and + managed from the Seller Dashboard. + + For more information, see [Loyalty Program + Overview](https://developer.squareup.com/docs/loyalty/overview). + properties: + id: + type: optional + docs: |- + The Square-assigned ID of the loyalty program. Updates to + the loyalty program do not modify the identifier. + validation: + maxLength: 36 + access: read-only + status: + type: optional + docs: >- + Whether the program is currently active. + + See [LoyaltyProgramStatus](#type-loyaltyprogramstatus) for possible + values + reward_tiers: + type: optional>> + docs: The list of rewards for buyers, sorted by ascending points. + expiration_policy: + type: optional + docs: If present, details for how points expire. + terminology: + type: optional + docs: A cosmetic name for the “points” currency. + location_ids: + type: optional>> + docs: The [locations](entity:Location) at which the program is active. + created_at: + type: optional + docs: The timestamp when the program was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp when the reward was last updated, in RFC 3339 format. + access: read-only + accrual_rules: + type: optional>> + docs: >- + Defines how buyers can earn loyalty points from the base loyalty + program. + + To check for associated [loyalty promotions](entity:LoyaltyPromotion) + that enable + + buyers to earn extra points, call + [ListLoyaltyPromotions](api-endpoint:Loyalty-ListLoyaltyPromotions). + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRule: + docs: >- + Represents an accrual rule, which defines how buyers can earn points from + the base [loyalty program](entity:LoyaltyProgram). + properties: + accrual_type: + type: LoyaltyProgramAccrualRuleType + docs: >- + The type of the accrual rule that defines how buyers can earn points. + + See + [LoyaltyProgramAccrualRuleType](#type-loyaltyprogramaccrualruletype) + for possible values + points: + type: optional> + docs: |- + The number of points that + buyers earn based on the `accrual_type`. + validation: + min: 1 + visit_data: + type: optional + docs: Additional data for rules with the `VISIT` accrual type. + spend_data: + type: optional + docs: Additional data for rules with the `SPEND` accrual type. + item_variation_data: + type: optional + docs: Additional data for rules with the `ITEM_VARIATION` accrual type. + category_data: + type: optional + docs: Additional data for rules with the `CATEGORY` accrual type. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRuleCategoryData: + docs: Represents additional data for rules with the `CATEGORY` accrual type. + properties: + category_id: + type: string + docs: >- + The ID of the `CATEGORY` [catalog object](entity:CatalogObject) that + buyers can purchase to earn + + points. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRuleItemVariationData: + docs: >- + Represents additional data for rules with the `ITEM_VARIATION` accrual + type. + properties: + item_variation_id: + type: string + docs: >- + The ID of the `ITEM_VARIATION` [catalog object](entity:CatalogObject) + that buyers can purchase to earn + + points. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRuleSpendData: + docs: Represents additional data for rules with the `SPEND` accrual type. + properties: + amount_money: + type: Money + docs: >- + The amount that buyers must spend to earn points. + + For example, given an "Earn 1 point for every $10 spent" accrual rule, + a buyer who spends $105 earns 10 points. + excluded_category_ids: + type: optional>> + docs: >- + The IDs of any `CATEGORY` catalog objects that are excluded from + points accrual. + + + You can use the + [BatchRetrieveCatalogObjects](api-endpoint:Catalog-BatchRetrieveCatalogObjects) + + endpoint to retrieve information about the excluded categories. + excluded_item_variation_ids: + type: optional>> + docs: >- + The IDs of any `ITEM_VARIATION` catalog objects that are excluded from + points accrual. + + + You can use the + [BatchRetrieveCatalogObjects](api-endpoint:Catalog-BatchRetrieveCatalogObjects) + + endpoint to retrieve information about the excluded item variations. + tax_mode: + type: LoyaltyProgramAccrualRuleTaxMode + docs: >- + Indicates how taxes should be treated when calculating the purchase + amount used for points accrual. + + See + [LoyaltyProgramAccrualRuleTaxMode](#type-loyaltyprogramaccrualruletaxmode) + for possible values + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRuleTaxMode: + enum: + - BEFORE_TAX + - AFTER_TAX + docs: >- + Indicates how taxes should be treated when calculating the purchase amount + used for loyalty points accrual. + + This setting applies only to `SPEND` accrual rules or `VISIT` accrual + rules that have a minimum spend requirement. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRuleType: + enum: + - VISIT + - SPEND + - ITEM_VARIATION + - CATEGORY + docs: The type of the accrual rule that defines how buyers can earn points. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramAccrualRuleVisitData: + docs: Represents additional data for rules with the `VISIT` accrual type. + properties: + minimum_amount_money: + type: optional + docs: The minimum purchase required during the visit to quality for points. + tax_mode: + type: LoyaltyProgramAccrualRuleTaxMode + docs: >- + Indicates how taxes should be treated when calculating the purchase + amount to determine whether the visit qualifies for points. + + This setting applies only if `minimum_amount_money` is specified. + + See + [LoyaltyProgramAccrualRuleTaxMode](#type-loyaltyprogramaccrualruletaxmode) + for possible values + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramCreatedEvent: + docs: Published when a [loyalty program](entity:LoyaltyProgram) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.program.created`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramCreatedEventData: + docs: The data associated with a `loyalty.program.created` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_program`. + id: + type: optional + docs: The ID of the created loyalty program. + object: + type: optional + docs: An object that contains the loyalty program that was created. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramCreatedEventObject: + docs: >- + An object that contains the loyalty program associated with a + `loyalty.program.created` event. + properties: + loyalty_program: + type: optional + docs: The loyalty program that was created. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramExpirationPolicy: + docs: Describes when the loyalty program expires. + properties: + expiration_duration: + type: string + docs: >- + The number of months before points expire, in `P[n]M` RFC 3339 + duration format. For example, a value of `P12M` represents a duration + of 12 months. + + Points are valid through the last day of the month in which they are + scheduled to expire. For example, with a `P12M` duration, points + earned on July 6, 2020 expire on August 1, 2021. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramRewardTier: + docs: >- + Represents a reward tier in a loyalty program. A reward tier defines how + buyers can redeem points for a reward, such as the number of points + required and the value and scope of the discount. A loyalty program can + offer multiple reward tiers. + properties: + id: + type: optional + docs: The Square-assigned ID of the reward tier. + validation: + maxLength: 36 + access: read-only + points: + type: integer + docs: The points exchanged for the reward tier. + validation: + min: 1 + name: + type: optional + docs: The name of the reward tier. + access: read-only + created_at: + type: optional + docs: The timestamp when the reward tier was created, in RFC 3339 format. + access: read-only + pricing_rule_reference: + type: CatalogObjectReference + docs: >- + A reference to the specific version of a `PRICING_RULE` catalog object + that contains information about the reward tier discount. + + + Use `object_id` and `catalog_version` with the + [RetrieveCatalogObject](api-endpoint:Catalog-RetrieveCatalogObject) + endpoint + + to get discount details. Make sure to set `include_related_objects` to + true in the request to retrieve all catalog objects + + that define the discount. For more information, see [Getting discount + details for a reward + tier](https://developer.squareup.com/docs/loyalty-api/loyalty-rewards#get-discount-details). + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramStatus: + enum: + - INACTIVE + - ACTIVE + docs: Indicates whether the program is currently active. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramTerminology: + docs: Represents the naming used for loyalty points. + properties: + one: + type: string + docs: A singular unit for a point (for example, 1 point is called 1 star). + validation: + minLength: 1 + other: + type: string + docs: A plural unit for point (for example, 10 points is called 10 stars). + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramUpdatedEvent: + docs: Published when a [loyalty program](entity:LoyaltyProgram) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.program.updated`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramUpdatedEventData: + docs: The data associated with a `loyalty.program.updated` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_program`. + id: + type: optional + docs: The ID of the affected loyalty program. + object: + type: optional + docs: An object that contains the loyalty program that was updated. + source: + openapi: ../default/openapi/openapi.json + LoyaltyProgramUpdatedEventObject: + docs: >- + An object that contains the loyalty program associated with a + `loyalty.program.updated` event. + properties: + loyalty_program: + type: optional + docs: The loyalty program that was updated. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotion: + docs: >- + Represents a promotion for a [loyalty program](entity:LoyaltyProgram). + Loyalty promotions enable buyers + + to earn extra points on top of those earned from the base program. + + + A loyalty program can have a maximum of 10 loyalty promotions with an + `ACTIVE` or `SCHEDULED` status. + properties: + id: + type: optional + docs: The Square-assigned ID of the promotion. + validation: + minLength: 1 + maxLength: 255 + access: read-only + name: + type: string + docs: The name of the promotion. + validation: + minLength: 1 + maxLength: 70 + incentive: + type: LoyaltyPromotionIncentive + docs: >- + The points incentive for the promotion. This field defines whether + promotion points + + are earned by multiplying base program points or by adding a specified + number of points. + available_time: + type: LoyaltyPromotionAvailableTimeData + docs: >- + The scheduling information that defines when purchases can qualify to + earn points from an `ACTIVE` promotion. + trigger_limit: + type: optional + docs: >- + The number of times a buyer can earn promotion points during a + specified interval. + + If not specified, buyers can trigger the promotion an unlimited number + of times. + status: + type: optional + docs: >- + The current status of the promotion. + + See [LoyaltyPromotionStatus](#type-loyaltypromotionstatus) for + possible values + created_at: + type: optional + docs: The timestamp of when the promotion was created, in RFC 3339 format. + access: read-only + canceled_at: + type: optional + docs: The timestamp of when the promotion was canceled, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp when the promotion was last updated, in RFC 3339 format. + access: read-only + loyalty_program_id: + type: optional + docs: >- + The ID of the [loyalty program](entity:LoyaltyProgram) associated with + the promotion. + access: read-only + minimum_spend_amount_money: + type: optional + docs: >- + The minimum purchase amount required to earn promotion points. If + specified, this amount is positive. + qualifying_item_variation_ids: + type: optional>> + docs: >- + The IDs of any qualifying `ITEM_VARIATION` [catalog + objects](entity:CatalogObject). If specified, + + the purchase must include at least one of these items to qualify for + the promotion. + + + This option is valid only if the base loyalty program uses a `VISIT` + or `SPEND` accrual rule. + + With `SPEND` accrual rules, make sure that qualifying promotional + items are not excluded. + + + You can specify `qualifying_item_variation_ids` or + `qualifying_category_ids` for a given promotion, but not both. + qualifying_category_ids: + type: optional>> + docs: >- + The IDs of any qualifying `CATEGORY` [catalog + objects](entity:CatalogObject). If specified, + + the purchase must include at least one item from one of these + categories to qualify for the promotion. + + + This option is valid only if the base loyalty program uses a `VISIT` + or `SPEND` accrual rule. + + With `SPEND` accrual rules, make sure that qualifying promotional + items are not excluded. + + + You can specify `qualifying_category_ids` or + `qualifying_item_variation_ids` for a promotion, but not both. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionAvailableTimeData: + docs: >- + Represents scheduling information that determines when purchases can + qualify to earn points + + from a [loyalty promotion](entity:LoyaltyPromotion). + properties: + start_date: + type: optional + docs: >- + The date that the promotion starts, in `YYYY-MM-DD` format. Square + populates this field + + based on the provided `time_periods`. + access: read-only + end_date: + type: optional + docs: >- + The date that the promotion ends, in `YYYY-MM-DD` format. Square + populates this field + + based on the provided `time_periods`. If an end date is not specified, + an `ACTIVE` promotion + + remains available until it is canceled. + access: read-only + time_periods: + docs: >- + A list of [iCalendar (RFC 5545) + events](https://tools.ietf.org/html/rfc5545#section-3.6.1) + + (`VEVENT`). Each event represents an available time period per day or + days of the week. + + A day can have a maximum of one available time period. + + + Only `DTSTART`, `DURATION`, and `RRULE` are supported. `DTSTART` and + `DURATION` are required and + + timestamps must be in local (unzoned) time format. Include `RRULE` to + specify recurring promotions, + + an end date (using the `UNTIL` keyword), or both. For more + information, see + + [Available + time](https://developer.squareup.com/docs/loyalty-api/loyalty-promotions#available-time). + + + Note that `BEGIN:VEVENT` and `END:VEVENT` are optional in a + `CreateLoyaltyPromotion` request + + but are always included in the response. + type: list + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionCreatedEvent: + docs: Published when a [loyalty promotion](entity:LoyaltyPromotion) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.promotion.created`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionCreatedEventData: + docs: The data associated with a `loyalty.promotion.created` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_promotion`. + id: + type: optional + docs: The ID of the affected loyalty promotion. + object: + type: optional + docs: An object that contains the loyalty promotion that was created. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionCreatedEventObject: + docs: >- + An object that contains the loyalty promotion associated with a + `loyalty.promotion.created` event. + properties: + loyalty_promotion: + type: optional + docs: The loyalty promotion that was created. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionIncentive: + docs: >- + Represents how points for a [loyalty promotion](entity:LoyaltyPromotion) + are calculated, + + either by multiplying the points earned from the base program or by adding + a specified number + + of points to the points earned from the base program. + properties: + type: + type: LoyaltyPromotionIncentiveType + docs: >- + The type of points incentive. + + See + [LoyaltyPromotionIncentiveType](#type-loyaltypromotionincentivetype) + for possible values + points_multiplier_data: + type: optional + docs: Additional data for a `POINTS_MULTIPLIER` incentive type. + points_addition_data: + type: optional + docs: Additional data for a `POINTS_ADDITION` incentive type. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionIncentivePointsAdditionData: + docs: >- + Represents the metadata for a `POINTS_ADDITION` type of [loyalty promotion + incentive](entity:LoyaltyPromotionIncentive). + properties: + points_addition: + type: integer + docs: >- + The number of additional points to earn each time the promotion is + triggered. For example, + + suppose a purchase qualifies for 5 points from the base loyalty + program. If the purchase also + + qualifies for a `POINTS_ADDITION` promotion incentive with a + `points_addition` of 3, the buyer + + earns a total of 8 points (5 program points + 3 promotion points = 8 + points). + validation: + min: 1 + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionIncentivePointsMultiplierData: + docs: >- + Represents the metadata for a `POINTS_MULTIPLIER` type of [loyalty + promotion incentive](entity:LoyaltyPromotionIncentive). + properties: + points_multiplier: + type: optional> + docs: >- + The multiplier used to calculate the number of points earned each time + the promotion + + is triggered. For example, suppose a purchase qualifies for 5 points + from the base loyalty program. + + If the purchase also qualifies for a `POINTS_MULTIPLIER` promotion + incentive with a `points_multiplier` + + of 3, the buyer earns a total of 15 points (5 program points x 3 + promotion multiplier = 15 points). + + + DEPRECATED at version 2023-08-16. Replaced by the `multiplier` field. + + + One of the following is required when specifying a points multiplier: + + - (Recommended) The `multiplier` field. + + - This deprecated `points_multiplier` field. If provided in the + request, Square also returns `multiplier` + + with the equivalent value. + validation: + min: 2 + max: 10 + multiplier: + type: optional> + docs: >- + The multiplier used to calculate the number of points earned each time + the promotion is triggered, + + specified as a string representation of a decimal. Square supports + multipliers up to 10x, with three + + point precision for decimal multipliers. For example, suppose a + purchase qualifies for 4 points from the + + base loyalty program. If the purchase also qualifies for a + `POINTS_MULTIPLIER` promotion incentive with a + + `multiplier` of "1.5", the buyer earns a total of 6 points (4 program + points x 1.5 promotion multiplier = 6 points). + + Fractional points are dropped. + + + One of the following is required when specifying a points multiplier: + + - (Recommended) This `multiplier` field. + + - The deprecated `points_multiplier` field. If provided in the + request, Square also returns `multiplier` + + with the equivalent value. + validation: + maxLength: 5 + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionIncentiveType: + enum: + - POINTS_MULTIPLIER + - POINTS_ADDITION + docs: >- + Indicates the type of points incentive for a [loyalty + promotion](entity:LoyaltyPromotion), + + which is used to determine how buyers can earn points from the promotion. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionStatus: + enum: + - ACTIVE + - ENDED + - CANCELED + - SCHEDULED + docs: Indicates the status of a [loyalty promotion](entity:LoyaltyPromotion). + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionTriggerLimit: + docs: >- + Represents the number of times a buyer can earn points during a [loyalty + promotion](entity:LoyaltyPromotion). + + If this field is not set, buyers can trigger the promotion an unlimited + number of times to earn points during + + the time that the promotion is available. + + + A purchase that is disqualified from earning points because of this limit + might qualify for another active promotion. + properties: + times: + type: integer + docs: >- + The maximum number of times a buyer can trigger the promotion during + the specified `interval`. + validation: + min: 1 + max: 30 + interval: + type: optional + docs: >- + The time period the limit applies to. + + See + [LoyaltyPromotionTriggerLimitInterval](#type-loyaltypromotiontriggerlimitinterval) + for possible values + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionTriggerLimitInterval: + enum: + - ALL_TIME + - DAY + docs: >- + Indicates the time period that the [trigger + limit](entity:LoyaltyPromotionTriggerLimit) applies to, + + which is used to determine the number of times a buyer can earn points for + a [loyalty promotion](entity:LoyaltyPromotion). + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionUpdatedEvent: + docs: >- + Published when a [loyalty promotion](entity:LoyaltyPromotion) is updated. + This event is + + invoked only when a loyalty promotion is canceled. + properties: + merchant_id: + type: optional> + docs: The ID of the Square seller associated with the event. + type: + type: optional> + docs: >- + The type of event. For this event, the value is + `loyalty.promotion.updated`. + event_id: + type: optional> + docs: >- + The unique ID for the event, which is used for + + [idempotency + support](https://developer.squareup.com/docs/webhooks/step4manage#webhooks-best-practices). + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionUpdatedEventData: + docs: The data associated with a `loyalty.promotion.updated` event. + properties: + type: + type: optional> + docs: >- + The type of object affected by the event. For this event, the value is + `loyalty_promotion`. + id: + type: optional + docs: The ID of the affected loyalty promotion. + object: + type: optional + docs: An object that contains the loyalty promotion that was updated. + source: + openapi: ../default/openapi/openapi.json + LoyaltyPromotionUpdatedEventObject: + docs: >- + An object that contains the loyalty promotion associated with a + `loyalty.promotion.updated` event. + properties: + loyalty_promotion: + type: optional + docs: The loyalty promotion that was updated. + source: + openapi: ../default/openapi/openapi.json + LoyaltyReward: + docs: >- + Represents a contract to redeem loyalty points for a [reward + tier](entity:LoyaltyProgramRewardTier) discount. Loyalty rewards can be in + an ISSUED, REDEEMED, or DELETED state. + + For more information, see [Manage loyalty + rewards](https://developer.squareup.com/docs/loyalty-api/loyalty-rewards). + properties: + id: + type: optional + docs: The Square-assigned ID of the loyalty reward. + validation: + maxLength: 36 + access: read-only + status: + type: optional + docs: >- + The status of a loyalty reward. + + See [LoyaltyRewardStatus](#type-loyaltyrewardstatus) for possible + values + loyalty_account_id: + type: string + docs: >- + The Square-assigned ID of the [loyalty account](entity:LoyaltyAccount) + to which the reward belongs. + validation: + minLength: 1 + maxLength: 36 + reward_tier_id: + type: string + docs: >- + The Square-assigned ID of the [reward + tier](entity:LoyaltyProgramRewardTier) used to create the reward. + validation: + minLength: 1 + maxLength: 36 + points: + type: optional + docs: The number of loyalty points used for the reward. + validation: + min: 1 + access: read-only + order_id: + type: optional> + docs: >- + The Square-assigned ID of the [order](entity:Order) to which the + reward is attached. + created_at: + type: optional + docs: The timestamp when the reward was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp when the reward was last updated, in RFC 3339 format. + access: read-only + redeemed_at: + type: optional + docs: The timestamp when the reward was redeemed, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + LoyaltyRewardStatus: + enum: + - ISSUED + - REDEEMED + - DELETED + docs: The status of the loyalty reward. + source: + openapi: ../default/openapi/openapi.json + MeasurementUnit: + docs: >- + Represents a unit of measurement to use with a quantity, such as ounces + + or inches. Exactly one of the following fields are required: + `custom_unit`, + + `area_unit`, `length_unit`, `volume_unit`, and `weight_unit`. + properties: + custom_unit: + type: optional + docs: >- + A custom unit of measurement defined by the seller using the Point of + Sale + + app or ad-hoc as an order line item. + area_unit: + type: optional + docs: >- + Represents a standard area unit. + + See [MeasurementUnitArea](#type-measurementunitarea) for possible + values + length_unit: + type: optional + docs: >- + Represents a standard length unit. + + See [MeasurementUnitLength](#type-measurementunitlength) for possible + values + volume_unit: + type: optional + docs: >- + Represents a standard volume unit. + + See [MeasurementUnitVolume](#type-measurementunitvolume) for possible + values + weight_unit: + type: optional + docs: >- + Represents a standard unit of weight or mass. + + See [MeasurementUnitWeight](#type-measurementunitweight) for possible + values + generic_unit: + type: optional + docs: >- + Reserved for API integrations that lack the ability to specify a real + measurement unit + + See [MeasurementUnitGeneric](#type-measurementunitgeneric) for + possible values + time_unit: + type: optional + docs: >- + Represents a standard unit of time. + + See [MeasurementUnitTime](#type-measurementunittime) for possible + values + type: + type: optional + docs: >- + Represents the type of the measurement unit. + + See [MeasurementUnitUnitType](#type-measurementunitunittype) for + possible values + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitArea: + enum: + - IMPERIAL_ACRE + - IMPERIAL_SQUARE_INCH + - IMPERIAL_SQUARE_FOOT + - IMPERIAL_SQUARE_YARD + - IMPERIAL_SQUARE_MILE + - METRIC_SQUARE_CENTIMETER + - METRIC_SQUARE_METER + - METRIC_SQUARE_KILOMETER + docs: Unit of area used to measure a quantity. + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitCustom: + docs: The information needed to define a custom unit, provided by the seller. + properties: + name: + type: string + docs: The name of the custom unit, for example "bushel". + abbreviation: + type: string + docs: >- + The abbreviation of the custom unit, such as "bsh" (bushel). This + appears + + in the cart for the Point of Sale app, and in reports. + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitGeneric: literal<"UNIT"> + MeasurementUnitLength: + enum: + - IMPERIAL_INCH + - IMPERIAL_FOOT + - IMPERIAL_YARD + - IMPERIAL_MILE + - METRIC_MILLIMETER + - METRIC_CENTIMETER + - METRIC_METER + - METRIC_KILOMETER + docs: The unit of length used to measure a quantity. + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitTime: + enum: + - GENERIC_MILLISECOND + - GENERIC_SECOND + - GENERIC_MINUTE + - GENERIC_HOUR + - GENERIC_DAY + docs: Unit of time used to measure a quantity (a duration). + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitUnitType: + enum: + - TYPE_CUSTOM + - TYPE_AREA + - TYPE_LENGTH + - TYPE_VOLUME + - TYPE_WEIGHT + - TYPE_GENERIC + docs: >- + Describes the type of this unit and indicates which field contains the + unit information. This is an ‘open’ enum. + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitVolume: + enum: + - GENERIC_FLUID_OUNCE + - GENERIC_SHOT + - GENERIC_CUP + - GENERIC_PINT + - GENERIC_QUART + - GENERIC_GALLON + - IMPERIAL_CUBIC_INCH + - IMPERIAL_CUBIC_FOOT + - IMPERIAL_CUBIC_YARD + - METRIC_MILLILITER + - METRIC_LITER + docs: The unit of volume used to measure a quantity. + source: + openapi: ../default/openapi/openapi.json + MeasurementUnitWeight: + enum: + - IMPERIAL_WEIGHT_OUNCE + - IMPERIAL_POUND + - IMPERIAL_STONE + - METRIC_MILLIGRAM + - METRIC_GRAM + - METRIC_KILOGRAM + docs: Unit of weight used to measure a quantity. + source: + openapi: ../default/openapi/openapi.json + Merchant: + docs: Represents a business that sells with Square. + properties: + id: + type: optional + docs: The Square-issued ID of the merchant. + business_name: + type: optional> + docs: The name of the merchant's overall business. + country: + type: Country + docs: >- + The country code associated with the merchant, in the two-letter + format of ISO 3166. For example, `US` or `JP`. + + See [Country](#type-country) for possible values + language_code: + type: optional> + docs: >- + The code indicating the [language + preferences](https://developer.squareup.com/docs/build-basics/general-considerations/language-preferences) + of the merchant, in [BCP 47 + format](https://tools.ietf.org/html/bcp47#appendix-A). For example, + `en-US` or `fr-CA`. + currency: + type: optional + docs: >- + The currency associated with the merchant, in ISO 4217 format. For + example, the currency code for US dollars is `USD`. + + See [Currency](#type-currency) for possible values + status: + type: optional + docs: |- + The merchant's status. + See [MerchantStatus](#type-merchantstatus) for possible values + main_location_id: + type: optional> + docs: >- + The ID of the [main + `Location`](https://developer.squareup.com/docs/locations-api#about-the-main-location) + for this merchant. + created_at: + type: optional + docs: |- + The time when the merchant was created, in RFC 3339 format. + For more information, see [Working with Dates](https://developer.squareup.com/docs/build-basics/working-with-dates). + access: read-only + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeDefinitionOwnedCreatedEvent: + docs: >- + Published when a merchant [custom attribute + definition](entity:CustomAttributeDefinition) + + is created by the subscribing application. Subscribe to this event to be + notified + + when your application creates a merchant custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute_definition.owned.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeDefinitionOwnedDeletedEvent: + docs: >- + Published when a merchant [custom attribute + definition](entity:CustomAttributeDefinition) + + is deleted by the subscribing application. Subscribe to this event to be + notified + + when your application deletes a merchant custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute_definition.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeDefinitionOwnedUpdatedEvent: + docs: >- + Published when a merchant [custom attribute + definition](entity:CustomAttributeDefinition) + + is updated by the subscribing application. Subscribe to this event to be + notified + + when your application updates a merchant custom attribute definition. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute_definition.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeDefinitionVisibleCreatedEvent: + docs: >- + Published when a merchant [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is created. A notification + is sent when your application + + creates a custom attribute definition or another application creates a + custom attribute definition whose + + `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute_definition.visible.created"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeDefinitionVisibleDeletedEvent: + docs: >- + Published when a merchant [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is deleted. A notification + is sent when your application + + deletes a custom attribute definition or another application deletes a + custom attribute definition whose + + `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute_definition.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeDefinitionVisibleUpdatedEvent: + docs: >- + Published when a merchant [custom attribute + definition](entity:CustomAttributeDefinition) + + that is visible to the subscribing application is updated. A notification + is sent when your application + + updates a custom attribute definition or another application updates a + custom attribute definition whose + + `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute_definition.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeOwnedDeletedEvent: + docs: >- + Published when a merchant [custom attribute](entity:CustomAttribute) + + associated with a [custom attribute + definition](entity:CustomAttributeDefinition) that is + + owned by the subscribing application is deleted. Subscribe to this event + to be notified + + when your application deletes a merchant custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeOwnedUpdatedEvent: + docs: >- + Published when a merchant [custom attribute](entity:CustomAttribute) + + associated with a [custom attribute + definition](entity:CustomAttributeDefinition) that is + + owned by the subscribing application is updated. Subscribe to this event + to be notified + + when your application updates a merchant custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeVisibleDeletedEvent: + docs: >- + Published when a merchant [custom attribute](entity:CustomAttribute) with + + the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is deleted. + + An application that subscribes to this event is notified when a merchant + custom attribute is deleted + + by any application for which the subscribing application has read access + to the merchant custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantCustomAttributeVisibleUpdatedEvent: + docs: >- + Published when a merchant [custom attribute](entity:CustomAttribute) with + + the `visibility` field set to `VISIBILITY_READ_ONLY` or + `VISIBILITY_READ_WRITE_VALUES` is updated. + + An application that subscribes to this event is notified when a merchant + custom attribute is updated + + by any application for which the subscribing application has read access + to the merchant custom attribute. + properties: + merchant_id: + type: optional> + docs: >- + The ID of the seller associated with the event that triggered the + event notification. + type: + type: optional> + docs: >- + The type of this event. The value is + `"merchant.custom_attribute.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event notification. + created_at: + type: optional + docs: >- + The timestamp that indicates when the event notification was created, + in RFC 3339 format. + access: read-only + data: + type: optional + docs: >- + The data associated with the event that triggered the event + notification. + source: + openapi: ../default/openapi/openapi.json + MerchantSettingsUpdatedEvent: + docs: Published when online checkout merchant settings are updated + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: >- + The type of event this represents, + `"online_checkout.merchant_settings.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + MerchantSettingsUpdatedEventData: + properties: + type: + type: optional> + docs: >- + Name of the updated object’s type, + `"online_checkout.merchant_settings"`. + id: + type: optional + docs: ID of the updated merchant settings. + object: + type: optional + docs: An object containing the updated merchant settings. + source: + openapi: ../default/openapi/openapi.json + MerchantSettingsUpdatedEventObject: + properties: + merchant_settings: + type: optional + docs: The updated merchant settings. + source: + openapi: ../default/openapi/openapi.json + MerchantStatus: + enum: + - ACTIVE + - INACTIVE + source: + openapi: ../default/openapi/openapi.json + ModifierLocationOverrides: + docs: >- + Location-specific overrides for specified properties of a + `CatalogModifier` object. + properties: + location_id: + type: optional> + docs: >- + The ID of the `Location` object representing the location. This can + include a deactivated location. + price_money: + type: optional + docs: >- + The overridden price at the specified location. If this is + unspecified, the modifier price is not overridden. + + The modifier becomes free of charge at the specified location, when + this `price_money` field is set to 0. + sold_out: + type: optional + docs: >- + Indicates whether the modifier is sold out at the specified location + or not. As an example, for cheese (modifier) burger (item), when the + modifier is sold out, it is the cheese, but not the burger, that is + sold out. + + The seller can manually set this sold out status. Attempts by an + application to set this attribute are ignored. + access: read-only + source: + openapi: ../default/openapi/openapi.json + Money: + docs: >- + Represents an amount of money. `Money` fields can be signed or unsigned. + + Fields that do not explicitly define whether they are signed or unsigned + are + + considered unsigned and can only hold positive amounts. For signed fields, + the + + sign of the value indicates the purpose of the money transfer. See + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts) + + for more information. + properties: + amount: + type: optional> + docs: >- + The amount of money, in the smallest denomination of the currency + + indicated by `currency`. For example, when `currency` is `USD`, + `amount` is + + in cents. Monetary amounts can be positive or negative. See the + specific + + field description to determine the meaning of the sign in a particular + case. + currency: + type: optional + docs: >- + The type of currency, in __ISO 4217 format__. For example, the + currency + + code for US dollars is `USD`. + + + See [Currency](entity:Currency) for possible values. + + See [Currency](#type-currency) for possible values + source: + openapi: ../default/openapi/openapi.json + OauthAuthorizationRevokedEvent: + docs: >- + Published when a merchant/application revokes all access tokens and + refresh tokens granted to an application. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"oauth.authorization.revoked"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OauthAuthorizationRevokedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"revocation"`. + id: + type: optional + docs: Not applicable, revocation is not an object + object: + type: optional + docs: An object containing information about revocation event. + source: + openapi: ../default/openapi/openapi.json + OauthAuthorizationRevokedEventObject: + properties: + revocation: + type: optional + docs: The revocation event. + source: + openapi: ../default/openapi/openapi.json + OauthAuthorizationRevokedEventRevocationObject: + properties: + revoked_at: + type: optional> + docs: Timestamp of when the revocation event occurred, in RFC 3339 format. + revoker_type: + type: optional + docs: >- + Type of client that performed the revocation, either APPLICATION, + MERCHANT, or SQUARE. + + See + [OauthAuthorizationRevokedEventRevokerType](#type-oauthauthorizationrevokedeventrevokertype) + for possible values + source: + openapi: ../default/openapi/openapi.json + OauthAuthorizationRevokedEventRevokerType: + enum: + - APPLICATION + - MERCHANT + - SQUARE + docs: Defines the possible types for the revoking client. + source: + openapi: ../default/openapi/openapi.json + ObtainTokenResponse: + docs: Represents an [ObtainToken](api-endpoint:OAuth-ObtainToken) response. + properties: + access_token: + type: optional + docs: >- + An OAuth access token used to authorize Square API requests on behalf + of the seller. + + Include this token as a bearer token in the `Authorization` header of + your API requests. + + + OAuth access tokens expire in 30 days (except `short_lived` access + tokens). You should call + + `ObtainToken` and provide the returned `refresh_token` to get a new + access token well before + + the current one expires. For more information, see [OAuth API: + Walkthrough](https://developer.squareup.com/docs/oauth-api/walkthrough). + validation: + minLength: 2 + maxLength: 1024 + token_type: + type: optional + docs: The type of access token. This value is always `bearer`. + validation: + minLength: 2 + maxLength: 10 + expires_at: + type: optional + docs: >- + The timestamp of when the `access_token` expires, in [ISO + 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format. + validation: + minLength: 20 + maxLength: 48 + merchant_id: + type: optional + docs: >- + The ID of the authorizing [merchant](entity:Merchant) (seller), which + represents a business. + validation: + minLength: 8 + maxLength: 191 + subscription_id: + type: optional + docs: >- + __LEGACY__ The ID of merchant's subscription. + + The ID is only present if the merchant signed up for a subscription + plan during authorization. + plan_id: + type: optional + docs: >- + __LEGACY__ The ID of the subscription plan the merchant signed + + up for. The ID is only present if the merchant signed up for a + subscription plan during + + authorization. + id_token: + type: optional + docs: >- + The OpenID token that belongs to this person. This token is only + present if the + + `OPENID` scope is included in the authorization request. + + + Deprecated at version 2021-09-15. Square doesn't support OpenID or + other single sign-on (SSO) + + protocols on top of OAuth. + refresh_token: + type: optional + docs: >- + A refresh token that can be used in an `ObtainToken` request to + generate a new access token. + + + With the code flow: + + - For the `authorization_code` grant type, the refresh token is + multi-use and never expires. + + - For the `refresh_token` grant type, the response returns the same + refresh token. + + + With the PKCE flow: + + - For the `authorization_code` grant type, the refresh token is + single-use and expires in 90 days. + + - For the `refresh_token` grant type, the refresh token is a new + single-use refresh token that expires in 90 days. + + + For more information, see [Refresh, Revoke, and Limit the Scope of + OAuth + Tokens](https://developer.squareup.com/docs/oauth-api/refresh-revoke-limit-scope). + validation: + minLength: 2 + maxLength: 1024 + short_lived: + type: optional + docs: >- + Indicates whether the access_token is short lived. If `true`, the + access token expires + + in 24 hours. If `false`, the access token expires in 30 days. + errors: + type: optional> + docs: Any errors that occurred during the request. + refresh_token_expires_at: + type: optional + docs: >- + The timestamp of when the `refresh_token` expires, in [ISO + 8601](http://www.iso.org/iso/home/standards/iso8601.htm) + + format. + + + This field is only returned for the PKCE flow. + validation: + minLength: 20 + maxLength: 48 + source: + openapi: ../default/openapi/openapi.json + OfflinePaymentDetails: + docs: Details specific to offline payments. + properties: + client_created_at: + type: optional + docs: >- + The client-side timestamp of when the offline payment was created, in + RFC 3339 format. + validation: + maxLength: 32 + access: read-only + source: + openapi: ../default/openapi/openapi.json + Order: + docs: >- + Contains all information related to a single order to process with Square, + + including line items that specify the products to purchase. `Order` + objects also + + include information about any associated tenders, refunds, and returns. + + + All Connect V2 Transactions have all been converted to Orders including + all associated + + itemization data. + properties: + id: + type: optional + docs: The order's unique ID. + access: read-only + location_id: + type: string + docs: The ID of the seller location that this order is associated with. + validation: + minLength: 1 + reference_id: + type: optional> + docs: |- + A client-specified ID to associate an entity in another system + with this order. + validation: + maxLength: 40 + source: + type: optional + docs: The origination details of the order. + customer_id: + type: optional> + docs: >- + The ID of the [customer](entity:Customer) associated with the order. + + + You should specify a `customer_id` on the order (or the payment) to + ensure that transactions + + are reliably linked to customers. Omitting this field might result in + the creation of new + + [instant + profiles](https://developer.squareup.com/docs/customers-api/what-it-does#instant-profiles). + validation: + maxLength: 191 + line_items: + type: optional>> + docs: The line items included in the order. + taxes: + type: optional>> + docs: >- + The list of all taxes associated with the order. + + + Taxes can be scoped to either `ORDER` or `LINE_ITEM`. For taxes with + `LINE_ITEM` scope, an + + `OrderLineItemAppliedTax` must be added to each line item that the tax + applies to. For taxes + + with `ORDER` scope, the server generates an `OrderLineItemAppliedTax` + for every line item. + + + On reads, each tax in the list includes the total amount of that tax + applied to the order. + + + __IMPORTANT__: If `LINE_ITEM` scope is set on any taxes in this field, + using the deprecated + + `line_items.taxes` field results in an error. Use + `line_items.applied_taxes` + + instead. + discounts: + type: optional>> + docs: >- + The list of all discounts associated with the order. + + + Discounts can be scoped to either `ORDER` or `LINE_ITEM`. For + discounts scoped to `LINE_ITEM`, + + an `OrderLineItemAppliedDiscount` must be added to each line item that + the discount applies to. + + For discounts with `ORDER` scope, the server generates an + `OrderLineItemAppliedDiscount` + + for every line item. + + + __IMPORTANT__: If `LINE_ITEM` scope is set on any discounts in this + field, using the deprecated + + `line_items.discounts` field results in an error. Use + `line_items.applied_discounts` + + instead. + service_charges: + type: optional>> + docs: A list of service charges applied to the order. + fulfillments: + type: optional>> + docs: >- + Details about order fulfillment. + + + Orders can only be created with at most one fulfillment. However, + orders returned + + by the API might contain multiple fulfillments. + returns: + type: optional> + docs: >- + A collection of items from sale orders being returned in this one. + Normally part of an + + itemized return or exchange. There is exactly one `Return` object per + sale `Order` being + + referenced. + access: read-only + return_amounts: + type: optional + docs: The rollup of the returned money amounts. + net_amounts: + type: optional + docs: The net money amounts (sale money - return money). + rounding_adjustment: + type: optional + docs: >- + A positive rounding adjustment to the total of the order. This + adjustment is commonly + + used to apply cash rounding when the minimum unit of account is + smaller than the lowest physical + + denomination of the currency. + tenders: + type: optional> + docs: The tenders that were used to pay for the order. + access: read-only + refunds: + type: optional> + docs: The refunds that are part of this order. + access: read-only + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this order. Metadata fields are + intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + created_at: + type: optional + docs: >- + The timestamp for when the order was created, at server side, in RFC + 3339 format (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + updated_at: + type: optional + docs: >- + The timestamp for when the order was last updated, at server side, in + RFC 3339 format (for example, "2016-09-04T23:59:33.123Z"). + access: read-only + closed_at: + type: optional + docs: >- + The timestamp for when the order reached a terminal + [state](entity:OrderState), in RFC 3339 format (for example + "2016-09-04T23:59:33.123Z"). + access: read-only + state: + type: optional + docs: |- + The current state of the order. + See [OrderState](#type-orderstate) for possible values + version: + type: optional + docs: >- + The version number, which is incremented each time an update is + committed to the order. + + Orders not created through the API do not include a version number and + + therefore cannot be updated. + + + [Read more about working with + versions](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders). + total_money: + type: optional + docs: The total amount of money to collect for the order. + total_tax_money: + type: optional + docs: The total amount of tax money to collect for the order. + total_discount_money: + type: optional + docs: The total amount of discount money to collect for the order. + total_tip_money: + type: optional + docs: The total amount of tip money to collect for the order. + total_service_charge_money: + type: optional + docs: >- + The total amount of money collected in service charges for the order. + + + Note: `total_service_charge_money` is the sum of `applied_money` + fields for each individual + + service charge. Therefore, `total_service_charge_money` only includes + inclusive tax amounts, + + not additive tax amounts. + ticket_name: + type: optional> + docs: |- + A short-term identifier for the order (such as a customer first name, + table number, or auto-generated order number that resets daily). + validation: + maxLength: 30 + pricing_options: + type: optional + docs: >- + Pricing options for an order. The options affect how the order's price + is calculated. + + They can be used, for example, to apply automatic price adjustments + that are based on + + preconfigured [pricing rules](entity:CatalogPricingRule). + rewards: + type: optional> + docs: A set-like list of Rewards that have been added to the Order. + access: read-only + net_amount_due_money: + type: optional + docs: The net amount of money due on the order. + source: + openapi: ../default/openapi/openapi.json + OrderCreated: + properties: + order_id: + type: optional> + docs: The order's unique ID. + version: + type: optional + docs: >- + The version number, which is incremented each time an update is + committed to the order. + + Orders that were not created through the API do not include a version + number and + + therefore cannot be updated. + + + [Read more about working with + versions.](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders) + location_id: + type: optional> + docs: The ID of the seller location that this order is associated with. + state: + type: optional + docs: |- + The state of the order. + See [OrderState](#type-orderstate) for possible values + created_at: + type: optional + docs: The timestamp for when the order was created, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + OrderCreatedEvent: + docs: "Published when an [Order](entity:Order) is created. This event is\ntriggered only by the [CreateOrder](api-endpoint:Orders-CreateOrder) endpoint call.\n\nCreating an order in the Point of Sale\_app will **not** publish this event." + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"order.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"order_created"`. + id: + type: optional + docs: ID of the affected order. + object: + type: optional + docs: An object containing information about the created Order. + source: + openapi: ../default/openapi/openapi.json + OrderCreatedObject: + properties: + order_created: + type: optional + docs: Information about the created order. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeDefinitionOwnedCreatedEvent: + docs: >- + Published when an order [custom attribute + definition](entity:CustomAttributeDefinition) that is owned by the + subscribing app is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute_definition.owned.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeDefinitionOwnedDeletedEvent: + docs: >- + Published when an order [custom attribute + definition](entity:CustomAttributeDefinition) that is owned by the + subscribing app is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute_definition.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeDefinitionOwnedUpdatedEvent: + docs: >- + Published when an order [custom attribute + definition](entity:CustomAttributeDefinition) that is owned by the + subscribing app is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute_definition.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeDefinitionVisibleCreatedEvent: + docs: >- + Published when an order [custom attribute + definition](entity:CustomAttributeDefinition) that is visible to the + subscribing app is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute_definition.visible.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeDefinitionVisibleDeletedEvent: + docs: >- + Published when an order [custom attribute + definition](entity:CustomAttributeDefinition) that is visible to the + subscribing app is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute_definition.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeDefinitionVisibleUpdatedEvent: + docs: >- + Published when an order [custom attribute + definition](entity:CustomAttributeDefinition) that is visible to the + subscribing app is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute_definition.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeOwnedDeletedEvent: + docs: >- + Published when an order [custom attribute](entity:CustomAttribute) + associated with a [custom attribute + definition](entity:CustomAttributeDefinition) that is owned by the + subscribing app is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute.owned.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeOwnedUpdatedEvent: + docs: >- + Published when an order [custom attribute](entity:CustomAttribute) + associated with a [custom attribute + definition](entity:CustomAttributeDefinition) that is owned by the + subscribing app is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute.owned.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeVisibleDeletedEvent: + docs: >- + Published when an order [custom attribute](entity:CustomAttribute) that is + visible to the subscribing app is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute.visible.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderCustomAttributeVisibleUpdatedEvent: + docs: >- + Published when an order [custom attribute](entity:CustomAttribute) that is + visible to the subscribing app is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target seller associated with the event. + type: + type: optional> + docs: >- + The type of this event. The value is + `"order.custom_attribute.visible.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: The data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderEntry: + docs: >- + A lightweight description of an [order](entity:Order) that is returned + when + + `returned_entries` is `true` on a + [SearchOrdersRequest](api-endpoint:Orders-SearchOrders). + properties: + order_id: + type: optional> + docs: The ID of the order. + version: + type: optional + docs: >- + The version number, which is incremented each time an update is + committed to the order. + + Orders that were not created through the API do not include a version + number and + + therefore cannot be updated. + + + [Read more about working with + versions.](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders) + access: read-only + location_id: + type: optional> + docs: The location ID the order belongs to. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentDeliveryDetailsScheduleType: + enum: + - SCHEDULED + - ASAP + docs: The schedule type of the delivery fulfillment. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentFulfillmentLineItemApplication: + enum: + - ALL + - ENTRY_LIST + docs: >- + The `line_item_application` describes what order line items this + fulfillment applies + + to. It can be `ALL` or `ENTRY_LIST` with a supplied list of fulfillment + entries. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentPickupDetailsScheduleType: + enum: + - SCHEDULED + - ASAP + docs: The schedule type of the pickup fulfillment. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentState: + enum: + - PROPOSED + - RESERVED + - PREPARED + - COMPLETED + - CANCELED + - FAILED + docs: The current state of this fulfillment. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentType: + enum: + - PICKUP + - SHIPMENT + - DELIVERY + docs: The type of fulfillment. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentUpdated: + properties: + order_id: + type: optional> + docs: The order's unique ID. + version: + type: optional + docs: >- + The version number, which is incremented each time an update is + committed to the order. + + Orders that were not created through the API do not include a version + number and + + therefore cannot be updated. + + + [Read more about working with + versions.](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders) + location_id: + type: optional> + docs: The ID of the seller location that this order is associated with. + state: + type: optional + docs: |- + The state of the order. + See [OrderState](#type-orderstate) for possible values + created_at: + type: optional + docs: The timestamp for when the order was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp for when the order was last updated, in RFC 3339 format. + access: read-only + fulfillment_update: + type: optional>> + docs: The fulfillments that were updated with this version change. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentUpdatedEvent: + docs: |- + Published when an [OrderFulfillment](entity:OrderFulfillment) + is created or updated. This event is triggered only by the + [UpdateOrder](api-endpoint:Orders-UpdateOrder) endpoint call. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"order.fulfillment.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"order_fulfillment_updated"`. + id: + type: optional + docs: ID of the affected order. + object: + type: optional + docs: An object containing information about the updated Order. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentUpdatedObject: + properties: + order_fulfillment_updated: + type: optional + docs: Information about the updated order fulfillment. + source: + openapi: ../default/openapi/openapi.json + OrderFulfillmentUpdatedUpdate: + docs: Information about fulfillment updates. + properties: + fulfillment_uid: + type: optional> + docs: A unique ID that identifies the fulfillment only within this order. + old_state: + type: optional + docs: >- + The state of the fulfillment before the change. + + The state is not populated if the fulfillment is created with this new + `Order` version. + new_state: + type: optional + docs: >- + The state of the fulfillment after the change. The state might be + equal to `old_state` if a non-state + + field was changed on the fulfillment (such as the tracking number). + source: + openapi: ../default/openapi/openapi.json + OrderLineItem: + docs: |- + Represents a line item in an order. Each line item describes a different + product to purchase, with its own quantity and price details. + properties: + uid: + type: optional> + docs: A unique ID that identifies the line item only within this order. + validation: + maxLength: 60 + name: + type: optional> + docs: The name of the line item. + validation: + maxLength: 512 + quantity: + type: string + docs: >- + The count, or measurement, of a line item being purchased: + + + If `quantity` is a whole number, and `quantity_unit` is not specified, + then `quantity` denotes an item count. For example: `3` apples. + + + If `quantity` is a whole or decimal number, and `quantity_unit` is + also specified, then `quantity` denotes a measurement. For example: + `2.25` pounds of broccoli. + + + For more information, see [Specify item quantity and measurement + unit](https://developer.squareup.com/docs/orders-api/create-orders#specify-item-quantity-and-measurement-unit). + + + Line items with a quantity of `0` are automatically removed + + when paying for or otherwise completing the order. + validation: + minLength: 1 + maxLength: 12 + quantity_unit: + type: optional + docs: >- + The measurement unit and decimal precision that this line item's + quantity is measured in. + note: + type: optional> + docs: An optional note associated with the line item. + validation: + maxLength: 2000 + catalog_object_id: + type: optional> + docs: >- + The [CatalogItemVariation](entity:CatalogItemVariation) ID applied to + this line item. + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this line item references. + variation_name: + type: optional> + docs: The name of the variation applied to this line item. + validation: + maxLength: 400 + item_type: + type: optional + docs: >- + The type of line item: an itemized sale, a non-itemized sale (custom + amount), or the + + activation or reloading of a gift card. + + See [OrderLineItemItemType](#type-orderlineitemitemtype) for possible + values + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this line item. Metadata fields + are intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + modifiers: + type: optional>> + docs: >- + The [CatalogModifier](entity:CatalogModifier)s applied to this line + item. + applied_taxes: + type: optional>> + docs: >- + The list of references to taxes applied to this line item. Each + + `OrderLineItemAppliedTax` has a `tax_uid` that references the `uid` of + a + + top-level `OrderLineItemTax` applied to the line item. On reads, the + + amount applied is populated. + + + An `OrderLineItemAppliedTax` is automatically created on every line + + item for all `ORDER` scoped taxes added to the order. + `OrderLineItemAppliedTax` + + records for `LINE_ITEM` scoped taxes must be added in requests for the + tax + + to apply to any line items. + + + To change the amount of a tax, modify the referenced top-level tax. + applied_discounts: + type: optional>> + docs: >- + The list of references to discounts applied to this line item. Each + + `OrderLineItemAppliedDiscount` has a `discount_uid` that references + the `uid` of a top-level + + `OrderLineItemDiscounts` applied to the line item. On reads, the + amount + + applied is populated. + + + An `OrderLineItemAppliedDiscount` is automatically created on every + line item for all + + `ORDER` scoped discounts that are added to the order. + `OrderLineItemAppliedDiscount` records + + for `LINE_ITEM` scoped discounts must be added in requests for the + discount to apply to any + + line items. + + + To change the amount of a discount, modify the referenced top-level + discount. + applied_service_charges: + type: optional>> + docs: >- + The list of references to service charges applied to this line item. + Each + + `OrderLineItemAppliedServiceCharge` has a `service_charge_id` that + references the `uid` of a + + top-level `OrderServiceCharge` applied to the line item. On reads, the + amount applied is + + populated. + + + To change the amount of a service charge, modify the referenced + top-level service charge. + base_price_money: + type: optional + docs: The base price for a single unit of the line item. + variation_total_price_money: + type: optional + docs: >- + The total price of all item variations sold in this line item. + + The price is calculated as `base_price_money` multiplied by + `quantity`. + + It does not include modifiers. + gross_sales_money: + type: optional + docs: >- + The amount of money made in gross sales for this line item. + + The amount is calculated as the sum of the variation's total price and + each modifier's total price. + + For inclusive tax items in the US, Canada, and Japan, tax is deducted + from `gross_sales_money`. For Europe and + + Australia, inclusive tax remains as part of the gross sale + calculation. + total_tax_money: + type: optional + docs: The total amount of tax money to collect for the line item. + total_discount_money: + type: optional + docs: The total amount of discount money to collect for the line item. + total_money: + type: optional + docs: The total amount of money to collect for this line item. + pricing_blocklists: + type: optional + docs: >- + Describes pricing adjustments that are blocked from automatic + + application to a line item. For more information, see + + [Apply Taxes and + Discounts](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts). + total_service_charge_money: + type: optional + docs: >- + The total amount of apportioned service charge money to collect for + the line item. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemAppliedDiscount: + docs: >- + Represents an applied portion of a discount to a line item in an order. + + + Order scoped discounts have automatically applied discounts present for + each line item. + + Line-item scoped discounts must have applied discounts added manually for + any applicable line + + items. The corresponding applied money is automatically computed based on + participating + + line items. + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the applied discount only within this + order. + validation: + maxLength: 60 + discount_uid: + type: string + docs: >- + The `uid` of the discount that the applied discount represents. It + must + + reference a discount present in the `order.discounts` field. + + + This field is immutable. To change which discounts apply to a line + item, + + you must delete the discount and re-add it as a new + `OrderLineItemAppliedDiscount`. + validation: + minLength: 1 + maxLength: 60 + applied_money: + type: optional + docs: The amount of money applied by the discount to the line item. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemAppliedServiceCharge: + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the applied service charge only within + this order. + validation: + maxLength: 60 + service_charge_uid: + type: string + docs: >- + The `uid` of the service charge that the applied service charge + represents. It must + + reference a service charge present in the `order.service_charges` + field. + + + This field is immutable. To change which service charges apply to a + line item, + + delete and add a new `OrderLineItemAppliedServiceCharge`. + validation: + minLength: 1 + maxLength: 60 + applied_money: + type: optional + docs: The amount of money applied by the service charge to the line item. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemAppliedTax: + docs: >- + Represents an applied portion of a tax to a line item in an order. + + + Order-scoped taxes automatically include the applied taxes in each line + item. + + Line item taxes must be referenced from any applicable line items. + + The corresponding applied money is automatically computed, based on the + + set of participating line items. + properties: + uid: + type: optional> + docs: A unique ID that identifies the applied tax only within this order. + validation: + maxLength: 60 + tax_uid: + type: string + docs: >- + The `uid` of the tax for which this applied tax represents. It must + reference + + a tax present in the `order.taxes` field. + + + This field is immutable. To change which taxes apply to a line item, + delete and add a new + + `OrderLineItemAppliedTax`. + validation: + minLength: 1 + maxLength: 60 + applied_money: + type: optional + docs: The amount of money applied by the tax to the line item. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemDiscount: + docs: >- + Represents a discount that applies to one or more line items in an + + order. + + + Fixed-amount, order-scoped discounts are distributed across all non-zero + line item totals. + + The amount distributed to each line item is relative to the + + amount contributed by the item to the order subtotal. + properties: + uid: + type: optional> + docs: A unique ID that identifies the discount only within this order. + validation: + maxLength: 60 + catalog_object_id: + type: optional> + docs: >- + The catalog object ID referencing + [CatalogDiscount](entity:CatalogDiscount). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this discount references. + name: + type: optional> + docs: The discount's name. + validation: + maxLength: 255 + type: + type: optional + docs: >- + The type of the discount. + + + Discounts that do not reference a catalog object ID must have a type + of + + `FIXED_PERCENTAGE` or `FIXED_AMOUNT`. + + See [OrderLineItemDiscountType](#type-orderlineitemdiscounttype) for + possible values + percentage: + type: optional> + docs: >- + The percentage of the discount, as a string representation of a + decimal number. + + A value of `7.25` corresponds to a percentage of 7.25%. + + + `percentage` is not set for amount-based discounts. + validation: + maxLength: 10 + amount_money: + type: optional + docs: |- + The total declared monetary amount of the discount. + + `amount_money` is not set for percentage-based discounts. + applied_money: + type: optional + docs: >- + The amount of discount actually applied to the line item. + + + The amount represents the amount of money applied as a line-item + scoped discount. + + When an amount-based discount is scoped to the entire order, the value + + of `applied_money` is different than `amount_money` because the total + + amount of the discount is distributed across all line items. + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this discount. Metadata fields + are intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + scope: + type: optional + docs: >- + Indicates the level at which the discount applies. For `ORDER` scoped + discounts, + + Square generates references in `applied_discounts` on all order line + items that do + + not have them. For `LINE_ITEM` scoped discounts, the discount only + applies to line items + + with a discount reference in their `applied_discounts` field. + + + This field is immutable. To change the scope of a discount, you must + delete + + the discount and re-add it as a new discount. + + See [OrderLineItemDiscountScope](#type-orderlineitemdiscountscope) for + possible values + reward_ids: + type: optional> + docs: >- + The reward IDs corresponding to this discount. The application and + + specification of discounts that have `reward_ids` are completely + controlled by the backing + + criteria corresponding to the reward tiers of the rewards that are + added to the order + + through the Loyalty API. To manually unapply discounts that are the + result of added rewards, + + the rewards must be removed from the order through the Loyalty API. + access: read-only + pricing_rule_id: + type: optional + docs: >- + The object ID of a [pricing rule](entity:CatalogPricingRule) to be + applied + + automatically to this discount. The specification and application of + the discounts, to + + which a `pricing_rule_id` is assigned, are completely controlled by + the corresponding + + pricing rule. + access: read-only + source: + openapi: ../default/openapi/openapi.json + OrderLineItemDiscountScope: + enum: + - OTHER_DISCOUNT_SCOPE + - LINE_ITEM + - ORDER + docs: Indicates whether this is a line-item or order-level discount. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemDiscountType: + enum: + - UNKNOWN_DISCOUNT + - FIXED_PERCENTAGE + - FIXED_AMOUNT + - VARIABLE_PERCENTAGE + - VARIABLE_AMOUNT + docs: >- + Indicates how the discount is applied to the associated line item or + order. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemItemType: + enum: + - ITEM + - CUSTOM_AMOUNT + - GIFT_CARD + docs: Represents the line item type. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemModifier: + docs: A [CatalogModifier](entity:CatalogModifier). + properties: + uid: + type: optional> + docs: A unique ID that identifies the modifier only within this order. + validation: + maxLength: 60 + catalog_object_id: + type: optional> + docs: >- + The catalog object ID referencing + [CatalogModifier](entity:CatalogModifier). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this modifier references. + name: + type: optional> + docs: The name of the item modifier. + validation: + maxLength: 255 + quantity: + type: optional> + docs: >- + The quantity of the line item modifier. The modifier quantity can be 0 + or more. + + For example, suppose a restaurant offers a cheeseburger on the menu. + When a buyer orders + + this item, the restaurant records the purchase by creating an `Order` + object with a line item + + for a burger. The line item includes a line item modifier: the name is + cheese and the quantity + + is 1. The buyer has the option to order extra cheese (or no cheese). + If the buyer chooses + + the extra cheese option, the modifier quantity increases to 2. If the + buyer does not want + + any cheese, the modifier quantity is set to 0. + base_price_money: + type: optional + docs: >- + The base price for the modifier. + + + `base_price_money` is required for ad hoc modifiers. + + If both `catalog_object_id` and `base_price_money` are set, + `base_price_money` will + + override the predefined [CatalogModifier](entity:CatalogModifier) + price. + total_price_money: + type: optional + docs: >- + The total price of the item modifier for its line item. + + This is the modifier's `base_price_money` multiplied by the line + item's quantity. + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this order. Metadata fields are + intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + source: + openapi: ../default/openapi/openapi.json + OrderLineItemPricingBlocklists: + docs: >- + Describes pricing adjustments that are blocked from automatic + + application to a line item. For more information, see + + [Apply Taxes and + Discounts](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts). + properties: + blocked_discounts: + type: >- + optional>> + docs: >- + A list of discounts blocked from applying to the line item. + + Discounts can be blocked by the `discount_uid` (for ad hoc discounts) + or + + the `discount_catalog_object_id` (for catalog discounts). + blocked_taxes: + type: optional>> + docs: |- + A list of taxes blocked from applying to the line item. + Taxes can be blocked by the `tax_uid` (for ad hoc taxes) or + the `tax_catalog_object_id` (for catalog taxes). + source: + openapi: ../default/openapi/openapi.json + OrderLineItemPricingBlocklistsBlockedDiscount: + docs: >- + A discount to block from applying to a line item. The discount must be + + identified by either `discount_uid` or `discount_catalog_object_id`, but + not both. + properties: + uid: + type: optional> + docs: A unique ID of the `BlockedDiscount` within the order. + validation: + maxLength: 60 + discount_uid: + type: optional> + docs: >- + The `uid` of the discount that should be blocked. Use this field to + block + + ad hoc discounts. For catalog discounts, use the + `discount_catalog_object_id` field. + validation: + maxLength: 60 + discount_catalog_object_id: + type: optional> + docs: >- + The `catalog_object_id` of the discount that should be blocked. + + Use this field to block catalog discounts. For ad hoc discounts, use + the + + `discount_uid` field. + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + OrderLineItemPricingBlocklistsBlockedTax: + docs: |- + A tax to block from applying to a line item. The tax must be + identified by either `tax_uid` or `tax_catalog_object_id`, but not both. + properties: + uid: + type: optional> + docs: A unique ID of the `BlockedTax` within the order. + validation: + maxLength: 60 + tax_uid: + type: optional> + docs: >- + The `uid` of the tax that should be blocked. Use this field to block + + ad hoc taxes. For catalog, taxes use the `tax_catalog_object_id` + field. + validation: + maxLength: 60 + tax_catalog_object_id: + type: optional> + docs: |- + The `catalog_object_id` of the tax that should be blocked. + Use this field to block catalog taxes. For ad hoc taxes, use the + `tax_uid` field. + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + OrderLineItemTax: + docs: >- + Represents a tax that applies to one or more line item in the order. + + + Fixed-amount, order-scoped taxes are distributed across all non-zero line + item totals. + + The amount distributed to each line item is relative to the amount the + item + + contributes to the order subtotal. + properties: + uid: + type: optional> + docs: A unique ID that identifies the tax only within this order. + validation: + maxLength: 60 + catalog_object_id: + type: optional> + docs: The catalog object ID referencing [CatalogTax](entity:CatalogTax). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this tax references. + name: + type: optional> + docs: The tax's name. + validation: + maxLength: 255 + type: + type: optional + docs: >- + Indicates the calculation method used to apply the tax. + + See [OrderLineItemTaxType](#type-orderlineitemtaxtype) for possible + values + percentage: + type: optional> + docs: >- + The percentage of the tax, as a string representation of a decimal + + number. For example, a value of `"7.25"` corresponds to a percentage + of + + 7.25%. + validation: + maxLength: 10 + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this tax. Metadata fields are + intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + applied_money: + type: optional + docs: |- + The amount of money applied to the order by the tax. + + - For percentage-based taxes, `applied_money` is the money + calculated using the percentage. + scope: + type: optional + docs: >- + Indicates the level at which the tax applies. For `ORDER` scoped + taxes, + + Square generates references in `applied_taxes` on all order line items + that do + + not have them. For `LINE_ITEM` scoped taxes, the tax only applies to + line items + + with references in their `applied_taxes` field. + + + This field is immutable. To change the scope, you must delete the tax + and + + re-add it as a new tax. + + See [OrderLineItemTaxScope](#type-orderlineitemtaxscope) for possible + values + auto_applied: + type: optional + docs: >- + Determines whether the tax was automatically applied to the order + based on + + the catalog configuration. For an example, see + + [Automatically Apply Taxes to an + Order](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts/auto-apply-taxes). + access: read-only + source: + openapi: ../default/openapi/openapi.json + OrderLineItemTaxScope: + enum: + - OTHER_TAX_SCOPE + - LINE_ITEM + - ORDER + docs: Indicates whether this is a line-item or order-level tax. + source: + openapi: ../default/openapi/openapi.json + OrderLineItemTaxType: + enum: + - UNKNOWN_TAX + - ADDITIVE + - INCLUSIVE + docs: Indicates how the tax is applied to the associated line item or order. + source: + openapi: ../default/openapi/openapi.json + OrderMoneyAmounts: + docs: A collection of various money amounts. + properties: + total_money: + type: optional + docs: The total money. + tax_money: + type: optional + docs: The money associated with taxes. + discount_money: + type: optional + docs: The money associated with discounts. + tip_money: + type: optional + docs: The money associated with tips. + service_charge_money: + type: optional + docs: The money associated with service charges. + source: + openapi: ../default/openapi/openapi.json + OrderPricingOptions: + docs: >- + Pricing options for an order. The options affect how the order's price is + calculated. + + They can be used, for example, to apply automatic price adjustments that + are based on preconfigured + + [pricing rules](entity:CatalogPricingRule). + properties: + auto_apply_discounts: + type: optional> + docs: |- + The option to determine whether pricing rule-based + discounts are automatically applied to an order. + auto_apply_taxes: + type: optional> + docs: >- + The option to determine whether rule-based taxes are automatically + + applied to an order when the criteria of the corresponding rules are + met. + source: + openapi: ../default/openapi/openapi.json + OrderQuantityUnit: + docs: >- + Contains the measurement unit for a quantity and a precision that + + specifies the number of digits after the decimal point for decimal + quantities. + properties: + measurement_unit: + type: optional + docs: |- + A [MeasurementUnit](entity:MeasurementUnit) that represents the + unit of measure for the quantity. + precision: + type: optional> + docs: >- + For non-integer quantities, represents the number of digits after the + decimal point that are + + recorded for this quantity. + + + For example, a precision of 1 allows quantities such as `"1.0"` and + `"1.1"`, but not `"1.01"`. + + + Min: 0. Max: 5. + catalog_object_id: + type: optional> + docs: |- + The catalog object ID referencing the + [CatalogMeasurementUnit](entity:CatalogMeasurementUnit). + + This field is set when this is a catalog-backed measurement unit. + catalog_version: + type: optional> + docs: >- + The version of the catalog object that this measurement unit + references. + + + This field is set when this is a catalog-backed measurement unit. + source: + openapi: ../default/openapi/openapi.json + OrderReturn: + docs: >- + The set of line items, service charges, taxes, discounts, tips, and other + items being returned in an order. + properties: + uid: + type: optional> + docs: A unique ID that identifies the return only within this order. + validation: + maxLength: 60 + source_order_id: + type: optional> + docs: >- + An order that contains the original sale of these return line items. + This is unset + + for unlinked returns. + return_line_items: + type: optional>> + docs: A collection of line items that are being returned. + return_service_charges: + type: optional>> + docs: A collection of service charges that are being returned. + return_taxes: + type: optional> + docs: >- + A collection of references to taxes being returned for an order, + including the total + + applied tax amount to be returned. The taxes must reference a + top-level tax ID from the source + + order. + access: read-only + return_discounts: + type: optional> + docs: >- + A collection of references to discounts being returned for an order, + including the total + + applied discount amount to be returned. The discounts must reference a + top-level discount ID + + from the source order. + access: read-only + return_tips: + type: optional>> + docs: A collection of references to tips being returned for an order. + rounding_adjustment: + type: optional + docs: >- + A positive or negative rounding adjustment to the total value being + returned. Adjustments are commonly + + used to apply cash rounding when the minimum unit of the account is + smaller than the lowest + + physical denomination of the currency. + return_amounts: + type: optional + docs: An aggregate monetary value being returned by this return entry. + source: + openapi: ../default/openapi/openapi.json + OrderReturnDiscount: + docs: >- + Represents a discount being returned that applies to one or more return + line items in an + + order. + + + Fixed-amount, order-scoped discounts are distributed across all non-zero + return line item totals. + + The amount distributed to each return line item is relative to that item’s + contribution to the + + order subtotal. + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the returned discount only within this + order. + validation: + maxLength: 60 + source_discount_uid: + type: optional> + docs: >- + The discount `uid` from the order that contains the original + application of this discount. + validation: + maxLength: 60 + catalog_object_id: + type: optional> + docs: >- + The catalog object ID referencing + [CatalogDiscount](entity:CatalogDiscount). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this discount references. + name: + type: optional> + docs: The discount's name. + validation: + maxLength: 255 + type: + type: optional + docs: >- + The type of the discount. If it is created by the API, it is + `FIXED_PERCENTAGE` or `FIXED_AMOUNT`. + + + Discounts that do not reference a catalog object ID must have a type + of + + `FIXED_PERCENTAGE` or `FIXED_AMOUNT`. + + See [OrderLineItemDiscountType](#type-orderlineitemdiscounttype) for + possible values + percentage: + type: optional> + docs: >- + The percentage of the tax, as a string representation of a decimal + number. + + A value of `"7.25"` corresponds to a percentage of 7.25%. + + + `percentage` is not set for amount-based discounts. + validation: + maxLength: 10 + amount_money: + type: optional + docs: |- + The total declared monetary amount of the discount. + + `amount_money` is not set for percentage-based discounts. + applied_money: + type: optional + docs: >- + The amount of discount actually applied to this line item. When an + amount-based + + discount is at the order level, this value is different from + `amount_money` because the discount + + is distributed across the line items. + scope: + type: optional + docs: >- + Indicates the level at which the `OrderReturnDiscount` applies. For + `ORDER` scoped + + discounts, the server generates references in `applied_discounts` on + all + + `OrderReturnLineItem`s. For `LINE_ITEM` scoped discounts, the discount + is only applied to + + `OrderReturnLineItem`s with references in their `applied_discounts` + field. + + See [OrderLineItemDiscountScope](#type-orderlineitemdiscountscope) for + possible values + source: + openapi: ../default/openapi/openapi.json + OrderReturnLineItem: + docs: The line item being returned in an order. + properties: + uid: + type: optional> + docs: A unique ID for this return line-item entry. + validation: + maxLength: 60 + source_line_item_uid: + type: optional> + docs: The `uid` of the line item in the original sale order. + validation: + maxLength: 60 + name: + type: optional> + docs: The name of the line item. + validation: + maxLength: 512 + quantity: + type: string + docs: |- + The quantity returned, formatted as a decimal number. + For example, `"3"`. + + Line items with a `quantity_unit` can have non-integer quantities. + For example, `"1.70000"`. + validation: + minLength: 1 + maxLength: 12 + quantity_unit: + type: optional + docs: >- + The unit and precision that this return line item's quantity is + measured in. + note: + type: optional> + docs: The note of the return line item. + validation: + maxLength: 2000 + catalog_object_id: + type: optional> + docs: >- + The [CatalogItemVariation](entity:CatalogItemVariation) ID applied to + this return line item. + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this line item references. + variation_name: + type: optional> + docs: The name of the variation applied to this return line item. + validation: + maxLength: 400 + item_type: + type: optional + docs: >- + The type of line item: an itemized return, a non-itemized return + (custom amount), + + or the return of an unactivated gift card sale. + + See [OrderLineItemItemType](#type-orderlineitemitemtype) for possible + values + return_modifiers: + type: optional>> + docs: >- + The [CatalogModifier](entity:CatalogModifier)s applied to this line + item. + applied_taxes: + type: optional>> + docs: >- + The list of references to `OrderReturnTax` entities applied to the + return line item. Each + + `OrderLineItemAppliedTax` has a `tax_uid` that references the `uid` of + a top-level + + `OrderReturnTax` applied to the return line item. On reads, the + applied amount + + is populated. + applied_discounts: + type: optional>> + docs: >- + The list of references to `OrderReturnDiscount` entities applied to + the return line item. Each + + `OrderLineItemAppliedDiscount` has a `discount_uid` that references + the `uid` of a top-level + + `OrderReturnDiscount` applied to the return line item. On reads, the + applied amount + + is populated. + base_price_money: + type: optional + docs: The base price for a single unit of the line item. + variation_total_price_money: + type: optional + docs: >- + The total price of all item variations returned in this line item. + + The price is calculated as `base_price_money` multiplied by `quantity` + and + + does not include modifiers. + gross_return_money: + type: optional + docs: >- + The gross return amount of money calculated as (item base price + + modifiers price) * quantity. + total_tax_money: + type: optional + docs: The total amount of tax money to return for the line item. + total_discount_money: + type: optional + docs: The total amount of discount money to return for the line item. + total_money: + type: optional + docs: The total amount of money to return for this line item. + applied_service_charges: + type: optional>> + docs: >- + The list of references to `OrderReturnServiceCharge` entities applied + to the return + + line item. Each `OrderLineItemAppliedServiceCharge` has a + `service_charge_uid` that + + references the `uid` of a top-level `OrderReturnServiceCharge` applied + to the return line + + item. On reads, the applied amount is populated. + total_service_charge_money: + type: optional + docs: >- + The total amount of apportioned service charge money to return for the + line item. + source: + openapi: ../default/openapi/openapi.json + OrderReturnLineItemModifier: + docs: A line item modifier being returned. + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the return modifier only within this + order. + validation: + maxLength: 60 + source_modifier_uid: + type: optional> + docs: |- + The modifier `uid` from the order's line item that contains the + original sale of this line item modifier. + validation: + maxLength: 60 + catalog_object_id: + type: optional> + docs: >- + The catalog object ID referencing + [CatalogModifier](entity:CatalogModifier). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: >- + The version of the catalog object that this line item modifier + references. + name: + type: optional> + docs: The name of the item modifier. + validation: + maxLength: 255 + base_price_money: + type: optional + docs: >- + The base price for the modifier. + + + `base_price_money` is required for ad hoc modifiers. + + If both `catalog_object_id` and `base_price_money` are set, + `base_price_money` overrides the predefined + [CatalogModifier](entity:CatalogModifier) price. + total_price_money: + type: optional + docs: >- + The total price of the item modifier for its line item. + + This is the modifier's `base_price_money` multiplied by the line + item's quantity. + quantity: + type: optional> + docs: >- + The quantity of the line item modifier. The modifier quantity can be 0 + or more. + + For example, suppose a restaurant offers a cheeseburger on the menu. + When a buyer orders + + this item, the restaurant records the purchase by creating an `Order` + object with a line item + + for a burger. The line item includes a line item modifier: the name is + cheese and the quantity + + is 1. The buyer has the option to order extra cheese (or no cheese). + If the buyer chooses + + the extra cheese option, the modifier quantity increases to 2. If the + buyer does not want + + any cheese, the modifier quantity is set to 0. + source: + openapi: ../default/openapi/openapi.json + OrderReturnServiceCharge: + docs: Represents the service charge applied to the original order. + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the return service charge only within this + order. + validation: + maxLength: 60 + source_service_charge_uid: + type: optional> + docs: |- + The service charge `uid` from the order containing the original + service charge. `source_service_charge_uid` is `null` for + unlinked returns. + validation: + maxLength: 60 + name: + type: optional> + docs: The name of the service charge. + validation: + maxLength: 255 + catalog_object_id: + type: optional> + docs: >- + The catalog object ID of the associated + [OrderServiceCharge](entity:OrderServiceCharge). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this service charge references. + percentage: + type: optional> + docs: |- + The percentage of the service charge, as a string representation of + a decimal number. For example, a value of `"7.25"` corresponds to a + percentage of 7.25%. + + Either `percentage` or `amount_money` should be set, but not both. + validation: + maxLength: 10 + amount_money: + type: optional + docs: |- + The amount of a non-percentage-based service charge. + + Either `percentage` or `amount_money` should be set, but not both. + applied_money: + type: optional + docs: >- + The amount of money applied to the order by the service charge, + including + + any inclusive tax amounts, as calculated by Square. + + + - For fixed-amount service charges, `applied_money` is equal to + `amount_money`. + + - For percentage-based service charges, `applied_money` is the money + calculated using the percentage. + total_money: + type: optional + docs: >- + The total amount of money to collect for the service charge. + + + __NOTE__: If an inclusive tax is applied to the service charge, + `total_money` + + does not equal `applied_money` plus `total_tax_money` because the + inclusive + + tax amount is already included in both `applied_money` and + `total_tax_money`. + total_tax_money: + type: optional + docs: The total amount of tax money to collect for the service charge. + calculation_phase: + type: optional + docs: >- + The calculation phase after which to apply the service charge. + + See + [OrderServiceChargeCalculationPhase](#type-orderservicechargecalculationphase) + for possible values + taxable: + type: optional> + docs: |- + Indicates whether the surcharge can be taxed. Service charges + calculated in the `TOTAL_PHASE` cannot be marked as taxable. + applied_taxes: + type: optional>> + docs: >- + The list of references to `OrderReturnTax` entities applied to the + + `OrderReturnServiceCharge`. Each `OrderLineItemAppliedTax` has a + `tax_uid` + + that references the `uid` of a top-level `OrderReturnTax` that is + being + + applied to the `OrderReturnServiceCharge`. On reads, the applied + amount is + + populated. + treatment_type: + type: optional + docs: >- + The treatment type of the service charge. + + See + [OrderServiceChargeTreatmentType](#type-orderservicechargetreatmenttype) + for possible values + scope: + type: optional + docs: >- + Indicates the level at which the apportioned service charge applies. + For `ORDER` + + scoped service charges, Square generates references in + `applied_service_charges` on + + all order line items that do not have them. For `LINE_ITEM` scoped + service charges, + + the service charge only applies to line items with a service charge + reference in their + + `applied_service_charges` field. + + + This field is immutable. To change the scope of an apportioned service + charge, you must delete + + the apportioned service charge and re-add it as a new apportioned + service charge. + + See [OrderServiceChargeScope](#type-orderservicechargescope) for + possible values + source: + openapi: ../default/openapi/openapi.json + OrderReturnTax: + docs: >- + Represents a tax being returned that applies to one or more return line + items in an order. + + + Fixed-amount, order-scoped taxes are distributed across all non-zero + return line item totals. + + The amount distributed to each return line item is relative to that item’s + contribution to the + + order subtotal. + properties: + uid: + type: optional> + docs: A unique ID that identifies the returned tax only within this order. + validation: + maxLength: 60 + source_tax_uid: + type: optional> + docs: The tax `uid` from the order that contains the original tax charge. + validation: + maxLength: 60 + catalog_object_id: + type: optional> + docs: The catalog object ID referencing [CatalogTax](entity:CatalogTax). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this tax references. + name: + type: optional> + docs: The tax's name. + validation: + maxLength: 255 + type: + type: optional + docs: >- + Indicates the calculation method used to apply the tax. + + See [OrderLineItemTaxType](#type-orderlineitemtaxtype) for possible + values + percentage: + type: optional> + docs: >- + The percentage of the tax, as a string representation of a decimal + number. + + For example, a value of `"7.25"` corresponds to a percentage of 7.25%. + validation: + maxLength: 10 + applied_money: + type: optional + docs: The amount of money applied by the tax in an order. + scope: + type: optional + docs: >- + Indicates the level at which the `OrderReturnTax` applies. For `ORDER` + scoped + + taxes, Square generates references in `applied_taxes` on all + + `OrderReturnLineItem`s. For `LINE_ITEM` scoped taxes, the tax is only + applied to + + `OrderReturnLineItem`s with references in their `applied_discounts` + field. + + See [OrderLineItemTaxScope](#type-orderlineitemtaxscope) for possible + values + source: + openapi: ../default/openapi/openapi.json + OrderReturnTip: + docs: A tip being returned. + properties: + uid: + type: optional> + docs: A unique ID that identifies the tip only within this order. + validation: + maxLength: 60 + applied_money: + type: optional + docs: |- + The amount of tip being returned + -- + source_tender_uid: + type: optional> + docs: >- + The tender `uid` from the order that contains the original application + of this tip. + validation: + maxLength: 192 + source_tender_id: + type: optional> + docs: >- + The tender `id` from the order that contains the original application + of this tip. + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + OrderReward: + docs: |- + Represents a reward that can be applied to an order if the necessary + reward tier criteria are met. Rewards are created through the Loyalty API. + properties: + id: + type: string + docs: The identifier of the reward. + validation: + minLength: 1 + reward_tier_id: + type: string + docs: The identifier of the reward tier corresponding to this reward. + validation: + minLength: 1 + source: + openapi: ../default/openapi/openapi.json + OrderRoundingAdjustment: + docs: >- + A rounding adjustment of the money being returned. Commonly used to apply + cash rounding + + when the minimum unit of the account is smaller than the lowest physical + denomination of the currency. + properties: + uid: + type: optional> + docs: >- + A unique ID that identifies the rounding adjustment only within this + order. + validation: + maxLength: 60 + name: + type: optional> + docs: The name of the rounding adjustment from the original sale order. + amount_money: + type: optional + docs: The actual rounding adjustment amount. + source: + openapi: ../default/openapi/openapi.json + OrderServiceCharge: + docs: Represents a service charge applied to an order. + properties: + uid: + type: optional> + docs: A unique ID that identifies the service charge only within this order. + validation: + maxLength: 60 + name: + type: optional> + docs: The name of the service charge. + validation: + maxLength: 512 + catalog_object_id: + type: optional> + docs: >- + The catalog object ID referencing the service charge + [CatalogObject](entity:CatalogObject). + validation: + maxLength: 192 + catalog_version: + type: optional> + docs: The version of the catalog object that this service charge references. + percentage: + type: optional> + docs: >- + The service charge percentage as a string representation of a + + decimal number. For example, `"7.25"` indicates a service charge of + 7.25%. + + + Exactly 1 of `percentage` or `amount_money` should be set. + validation: + maxLength: 10 + amount_money: + type: optional + docs: |- + The amount of a non-percentage-based service charge. + + Exactly one of `percentage` or `amount_money` should be set. + applied_money: + type: optional + docs: >- + The amount of money applied to the order by the service charge, + + including any inclusive tax amounts, as calculated by Square. + + + - For fixed-amount service charges, `applied_money` is equal to + `amount_money`. + + - For percentage-based service charges, `applied_money` is the money + + calculated using the percentage. + total_money: + type: optional + docs: |- + The total amount of money to collect for the service charge. + + __Note__: If an inclusive tax is applied to the service charge, + `total_money` does not equal `applied_money` plus `total_tax_money` + because the inclusive tax amount is already included in both + `applied_money` and `total_tax_money`. + total_tax_money: + type: optional + docs: The total amount of tax money to collect for the service charge. + calculation_phase: + type: optional + docs: >- + The calculation phase at which to apply the service charge. + + See + [OrderServiceChargeCalculationPhase](#type-orderservicechargecalculationphase) + for possible values + taxable: + type: optional> + docs: >- + Indicates whether the service charge can be taxed. If set to `true`, + + order-level taxes automatically apply to the service charge. Note that + + service charges calculated in the `TOTAL_PHASE` cannot be marked as + taxable. + applied_taxes: + type: optional>> + docs: >- + The list of references to the taxes applied to this service charge. + Each + + `OrderLineItemAppliedTax` has a `tax_uid` that references the `uid` of + a top-level + + `OrderLineItemTax` that is being applied to this service charge. On + reads, the amount applied + + is populated. + + + An `OrderLineItemAppliedTax` is automatically created on every taxable + service charge + + for all `ORDER` scoped taxes that are added to the order. + `OrderLineItemAppliedTax` records + + for `LINE_ITEM` scoped taxes must be added in requests for the tax to + apply to any taxable + + service charge. Taxable service charges have the `taxable` field set + to `true` and calculated + + in the `SUBTOTAL_PHASE`. + + + To change the amount of a tax, modify the referenced top-level tax. + metadata: + type: optional>>>> + docs: >- + Application-defined data attached to this service charge. Metadata + fields are intended + + to store descriptive references or associations with an entity in + another system or store brief + + information about the object. Square does not process this field; it + only stores and returns it + + in relevant API calls. Do not use metadata to store any sensitive + information (such as personally + + identifiable information or card details). + + + Keys written by applications must be 60 characters or less and must be + in the character set + + `[a-zA-Z0-9_-]`. Entries can also include metadata generated by + Square. These keys are prefixed + + with a namespace, separated from the key with a ':' character. + + + Values have a maximum length of 255 characters. + + + An application can have up to 10 entries per metadata field. + + + Entries written by applications are private and can only be read or + modified by the same + + application. + + + For more information, see + [Metadata](https://developer.squareup.com/docs/build-basics/metadata). + type: + type: optional + docs: >- + The type of the service charge. + + See [OrderServiceChargeType](#type-orderservicechargetype) for + possible values + treatment_type: + type: optional + docs: >- + The treatment type of the service charge. + + See + [OrderServiceChargeTreatmentType](#type-orderservicechargetreatmenttype) + for possible values + scope: + type: optional + docs: >- + Indicates the level at which the apportioned service charge applies. + For `ORDER` + + scoped service charges, Square generates references in + `applied_service_charges` on + + all order line items that do not have them. For `LINE_ITEM` scoped + service charges, + + the service charge only applies to line items with a service charge + reference in their + + `applied_service_charges` field. + + + This field is immutable. To change the scope of an apportioned service + charge, you must delete + + the apportioned service charge and re-add it as a new apportioned + service charge. + + See [OrderServiceChargeScope](#type-orderservicechargescope) for + possible values + source: + openapi: ../default/openapi/openapi.json + OrderServiceChargeCalculationPhase: + enum: + - SUBTOTAL_PHASE + - TOTAL_PHASE + - APPORTIONED_PERCENTAGE_PHASE + - APPORTIONED_AMOUNT_PHASE + docs: >- + Represents a phase in the process of calculating order totals. + + Service charges are applied after the indicated phase. + + + [Read more about how order totals are + calculated.](https://developer.squareup.com/docs/orders-api/how-it-works#how-totals-are-calculated) + source: + openapi: ../default/openapi/openapi.json + OrderServiceChargeScope: + enum: + - OTHER_SERVICE_CHARGE_SCOPE + - LINE_ITEM + - ORDER + docs: |- + Indicates whether this is a line-item or order-level apportioned + service charge. + source: + openapi: ../default/openapi/openapi.json + OrderServiceChargeTreatmentType: + enum: + - LINE_ITEM_TREATMENT + - APPORTIONED_TREATMENT + docs: >- + Indicates whether the service charge will be treated as a value-holding + line item or + + apportioned toward a line item. + source: + openapi: ../default/openapi/openapi.json + OrderServiceChargeType: + enum: + - AUTO_GRATUITY + - CUSTOM + source: + openapi: ../default/openapi/openapi.json + OrderSource: + docs: Represents the origination details of an order. + properties: + name: + type: optional> + docs: >- + The name used to identify the place (physical or digital) that an + order originates. + + If unset, the name defaults to the name of the application that + created the order. + source: + openapi: ../default/openapi/openapi.json + OrderState: + enum: + - OPEN + - COMPLETED + - CANCELED + - DRAFT + docs: The state of the order. + source: + openapi: ../default/openapi/openapi.json + OrderUpdated: + properties: + order_id: + type: optional> + docs: The order's unique ID. + version: + type: optional + docs: >- + The version number, which is incremented each time an update is + committed to the order. + + Orders that were not created through the API do not include a version + number and + + therefore cannot be updated. + + + [Read more about working with + versions.](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders) + location_id: + type: optional> + docs: The ID of the seller location that this order is associated with. + state: + type: optional + docs: |- + The state of the order. + See [OrderState](#type-orderstate) for possible values + created_at: + type: optional + docs: The timestamp for when the order was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp for when the order was last updated, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + OrderUpdatedEvent: + docs: |- + Published when an [Order](entity:Order) is updated. This + event is triggered by the [UpdateOrder](api-endpoint:Orders-UpdateOrder) + endpoint call, Order Manager, or the Square Dashboard. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"order.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + OrderUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"order_updated"`. + id: + type: optional + docs: ID of the affected order. + object: + type: optional + docs: An object containing information about the updated Order. + source: + openapi: ../default/openapi/openapi.json + OrderUpdatedObject: + properties: + order_updated: + type: optional + docs: Information about the updated order. + source: + openapi: ../default/openapi/openapi.json + PauseSubscriptionResponse: + docs: >- + Defines output parameters in a response from the + + [PauseSubscription](api-endpoint:Subscriptions-PauseSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The subscription to be paused by the scheduled `PAUSE` action. + actions: + type: optional> + docs: >- + The list of a `PAUSE` action and a possible `RESUME` action created by + the request. + source: + openapi: ../default/openapi/openapi.json + PayOrderResponse: + docs: >- + Defines the fields that are included in the response body of a request to + the + + [PayOrder](api-endpoint:Orders-PayOrder) endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + order: + type: optional + docs: The paid, updated [order](entity:Order). + source: + openapi: ../default/openapi/openapi.json + Payment: + docs: Represents a payment processed by the Square API. + properties: + id: + type: optional + docs: A unique ID for the payment. + validation: + maxLength: 192 + access: read-only + created_at: + type: optional + docs: The timestamp of when the payment was created, in RFC 3339 format. + validation: + maxLength: 32 + access: read-only + updated_at: + type: optional + docs: >- + The timestamp of when the payment was last updated, in RFC 3339 + format. + validation: + maxLength: 32 + access: read-only + amount_money: + type: optional + docs: >- + The amount processed for this payment, not including `tip_money`. + + + The amount is specified in the smallest denomination of the applicable + currency (for example, + + US dollar amounts are specified in cents). For more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + tip_money: + type: optional + docs: >- + The amount designated as a tip for the seller's staff. + + + Tips for external vendors such as a 3rd party delivery courier must be + recorded using Order.service_charges. + + + This amount is specified in the smallest denomination of the + applicable currency (for example, + + US dollar amounts are specified in cents). For more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + total_money: + type: optional + docs: >- + The total amount for the payment, including `amount_money` and + `tip_money`. + + This amount is specified in the smallest denomination of the + applicable currency (for example, + + US dollar amounts are specified in cents). For more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + app_fee_money: + type: optional + docs: >- + The amount the developer is taking as a fee for facilitating the + payment on behalf + + of the seller. This amount is specified in the smallest denomination + of the applicable currency + + (for example, US dollar amounts are specified in cents). For more + information, + + see [Take Payments and Collect + Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). + + + The amount cannot be more than 90% of the `total_money` value. + + + To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth + permission is required. + + For more information, see + [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions). + approved_money: + type: optional + docs: >- + The amount of money approved for this payment. This value may change + if Square chooses to + + obtain reauthorization as part of a call to + [UpdatePayment](api-endpoint:Payments-UpdatePayment). + processing_fee: + type: optional> + docs: >- + The processing fees and fee adjustments assessed by Square for this + payment. + access: read-only + refunded_money: + type: optional + docs: >- + The total amount of the payment refunded to date. + + + This amount is specified in the smallest denomination of the + applicable currency (for example, + + US dollar amounts are specified in cents). + status: + type: optional + docs: >- + Indicates whether the payment is APPROVED, PENDING, COMPLETED, + CANCELED, or FAILED. + validation: + maxLength: 50 + access: read-only + delay_duration: + type: optional + docs: >- + The duration of time after the payment's creation when Square + automatically applies the + + `delay_action` to the payment. This automatic `delay_action` applies + only to payments that + + do not reach a terminal state (COMPLETED, CANCELED, or FAILED) before + the `delay_duration` + + time period. + + + This field is specified as a time duration, in RFC 3339 format. + + + Notes: + + This feature is only supported for card payments. + + + Default: + + + - Card-present payments: "PT36H" (36 hours) from the creation time. + + - Card-not-present payments: "P7D" (7 days) from the creation time. + access: read-only + delay_action: + type: optional> + docs: >- + The action to be applied to the payment when the `delay_duration` has + elapsed. + + + Current values include `CANCEL` and `COMPLETE`. + delayed_until: + type: optional + docs: >- + The read-only timestamp of when the `delay_action` is automatically + applied, + + in RFC 3339 format. + + + Note that this field is calculated by summing the payment's + `delay_duration` and `created_at` + + fields. The `created_at` field is generated by Square and might not + exactly match the + + time on your local machine. + access: read-only + source_type: + type: optional + docs: >- + The source type for this payment. + + + Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, + `BUY_NOW_PAY_LATER`, `SQUARE_ACCOUNT`, + + `CASH` and `EXTERNAL`. For information about these payment source + types, + + see [Take + Payments](https://developer.squareup.com/docs/payments-api/take-payments). + validation: + maxLength: 50 + access: read-only + card_details: + type: optional + docs: >- + Details about a card payment. These details are only populated if the + source_type is `CARD`. + cash_details: + type: optional + docs: >- + Details about a cash payment. These details are only populated if the + source_type is `CASH`. + bank_account_details: + type: optional + docs: >- + Details about a bank account payment. These details are only populated + if the source_type is `BANK_ACCOUNT`. + external_details: + type: optional + docs: |- + Details about an external payment. The details are only populated + if the `source_type` is `EXTERNAL`. + wallet_details: + type: optional + docs: |- + Details about an wallet payment. The details are only populated + if the `source_type` is `WALLET`. + buy_now_pay_later_details: + type: optional + docs: >- + Details about a Buy Now Pay Later payment. The details are only + populated + + if the `source_type` is `BUY_NOW_PAY_LATER`. For more information, + see + + [Afterpay + Payments](https://developer.squareup.com/docs/payments-api/take-payments/afterpay-payments). + square_account_details: + type: optional + docs: |- + Details about a Square Account payment. The details are only populated + if the `source_type` is `SQUARE_ACCOUNT`. + location_id: + type: optional + docs: The ID of the location associated with the payment. + validation: + maxLength: 50 + access: read-only + order_id: + type: optional + docs: The ID of the order associated with the payment. + validation: + maxLength: 192 + access: read-only + reference_id: + type: optional + docs: |- + An optional ID that associates the payment with an entity in + another system. + validation: + maxLength: 40 + access: read-only + customer_id: + type: optional + docs: >- + The ID of the customer associated with the payment. If the ID is + + not provided in the `CreatePayment` request that was used to create + the `Payment`, + + Square may use information in the request + + (such as the billing and shipping address, email address, and payment + source) + + to identify a matching customer profile in the Customer Directory. + + If found, the profile ID is used. If a profile is not found, the + + API attempts to create an + + [instant + profile](https://developer.squareup.com/docs/customers-api/what-it-does#instant-profiles). + + If the API cannot create an + + instant profile (either because the seller has disabled it or the + + seller's region prevents creating it), this field remains unset. Note + that + + this process is asynchronous and it may take some time before a + + customer ID is added to the payment. + validation: + maxLength: 191 + access: read-only + employee_id: + type: optional + docs: |- + __Deprecated__: Use `Payment.team_member_id` instead. + + An optional ID of the employee associated with taking the payment. + validation: + maxLength: 192 + access: read-only + team_member_id: + type: optional> + docs: >- + An optional ID of the [TeamMember](entity:TeamMember) associated with + taking the payment. + validation: + maxLength: 192 + refund_ids: + type: optional> + docs: A list of `refund_id`s identifying refunds for the payment. + access: read-only + risk_evaluation: + type: optional + docs: >- + Provides information about the risk associated with the payment, as + determined by Square. + + This field is present for payments to sellers that have opted in to + receive risk + + evaluations. + terminal_checkout_id: + type: optional + docs: >- + An optional ID for a Terminal checkout that is associated with the + payment. + access: read-only + buyer_email_address: + type: optional + docs: The buyer's email address. + validation: + maxLength: 255 + access: read-only + billing_address: + type: optional
+ docs: The buyer's billing address. + shipping_address: + type: optional
+ docs: The buyer's shipping address. + note: + type: optional + docs: An optional note to include when creating a payment. + validation: + maxLength: 500 + access: read-only + statement_description_identifier: + type: optional + docs: >- + Additional payment information that gets added to the customer's card + statement + + as part of the statement description. + + + Note that the `statement_description_identifier` might get truncated + on the statement description + + to fit the required information including the Square identifier (SQ *) + and the name of the + + seller taking the payment. + access: read-only + capabilities: + type: optional> + docs: |- + Actions that can be performed on this payment: + - `EDIT_AMOUNT_UP` - The payment amount can be edited up. + - `EDIT_AMOUNT_DOWN` - The payment amount can be edited down. + - `EDIT_TIP_AMOUNT_UP` - The tip amount can be edited up. + - `EDIT_TIP_AMOUNT_DOWN` - The tip amount can be edited down. + - `EDIT_DELAY_ACTION` - The delay_action can be edited. + access: read-only + receipt_number: + type: optional + docs: |- + The payment's receipt number. + The field is missing if a payment is canceled. + validation: + maxLength: 4 + access: read-only + receipt_url: + type: optional + docs: |- + The URL for the payment's receipt. + The field is only populated for COMPLETED payments. + validation: + maxLength: 255 + access: read-only + device_details: + type: optional + docs: Details about the device that took the payment. + application_details: + type: optional + docs: Details about the application that took the payment. + is_offline_payment: + type: optional + docs: Whether or not this payment was taken offline. + access: read-only + offline_payment_details: + type: optional + docs: Additional information about the payment if it was taken offline. + version_token: + type: optional> + docs: >- + Used for optimistic concurrency. This opaque token identifies a + specific version of the + + `Payment` object. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityAppFeeRefundDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + refund_id: + type: optional> + docs: The ID of the refund associated with this activity. + location_id: + type: optional> + docs: >- + The ID of the location of the merchant associated with the payment + refund activity + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityAppFeeRevenueDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + location_id: + type: optional> + docs: >- + The ID of the location of the merchant associated with the payment + activity + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityAutomaticSavingsDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + payout_id: + type: optional> + docs: The ID of the payout associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityAutomaticSavingsReversedDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + payout_id: + type: optional> + docs: The ID of the payout associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityChargeDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityDepositFeeDetail: + properties: + payout_id: + type: optional> + docs: The ID of the payout that triggered this deposit fee activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityDepositFeeReversedDetail: + properties: + payout_id: + type: optional> + docs: The ID of the payout that triggered this deposit fee activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityDisputeDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + dispute_id: + type: optional> + docs: The ID of the dispute associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityFeeDetail: + properties: + payment_id: + type: optional> + docs: >- + The ID of the payment associated with this activity + + This will only be populated when a principal LedgerEntryToken is also + populated. + + If the fee is independent (there is no principal LedgerEntryToken) + then this will likely not + + be populated. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityFreeProcessingDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityHoldAdjustmentDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityOpenDisputeDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + dispute_id: + type: optional> + docs: The ID of the dispute associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityOtherAdjustmentDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityOtherDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityRefundDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + refund_id: + type: optional> + docs: The ID of the refund associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityReleaseAdjustmentDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityReserveHoldDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityReserveReleaseDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivitySquareCapitalPaymentDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivitySquareCapitalReversedPaymentDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivitySquarePayrollTransferDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivitySquarePayrollTransferReversedDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityTaxOnFeeDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + tax_rate_description: + type: optional> + docs: >- + The description of the tax rate being applied. For example: "GST", + "HST". + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityThirdPartyFeeDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentBalanceActivityThirdPartyFeeRefundDetail: + properties: + payment_id: + type: optional> + docs: The ID of the payment associated with this activity. + refund_id: + type: optional> + docs: The public refund id associated with this activity. + source: + openapi: ../default/openapi/openapi.json + PaymentCreatedEvent: + docs: Published when a [Payment](entity:Payment) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"payment.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + PaymentCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"payment"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected payment. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the created payment. + source: + openapi: ../default/openapi/openapi.json + PaymentCreatedEventObject: + properties: + payment: + type: optional + docs: The created payment. + source: + openapi: ../default/openapi/openapi.json + PaymentLink: + properties: + id: + type: optional + docs: The Square-assigned ID of the payment link. + access: read-only + version: + type: integer + docs: >- + The Square-assigned version number, which is incremented each time an + update is committed to the payment link. + validation: + max: 65535 + description: + type: optional> + docs: |- + The optional description of the `payment_link` object. + It is primarily for use by your application and is not used anywhere. + validation: + maxLength: 4096 + order_id: + type: optional + docs: The ID of the order associated with the payment link. + validation: + maxLength: 192 + access: read-only + checkout_options: + type: optional + docs: >- + The checkout options configured for the payment link. + + For more information, see [Optional Checkout + Configurations](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations). + pre_populated_data: + type: optional + docs: |- + Describes buyer data to prepopulate + on the checkout page. + url: + type: optional + docs: The shortened URL of the payment link. + validation: + maxLength: 255 + access: read-only + long_url: + type: optional + docs: The long URL of the payment link. + validation: + maxLength: 255 + access: read-only + created_at: + type: optional + docs: The timestamp when the payment link was created, in RFC 3339 format. + updated_at: + type: optional + docs: >- + The timestamp when the payment link was last updated, in RFC 3339 + format. + payment_note: + type: optional> + docs: >- + An optional note. After Square processes the payment, this note is + added to the + + resulting `Payment`. + validation: + maxLength: 500 + source: + openapi: ../default/openapi/openapi.json + PaymentLinkRelatedResources: + properties: + orders: + type: optional>> + docs: The order associated with the payment link. + subscription_plans: + type: optional>> + docs: The subscription plan associated with the payment link. + source: + openapi: ../default/openapi/openapi.json + PaymentOptions: + properties: + autocomplete: + type: optional> + docs: >- + Indicates whether the `Payment` objects created from this + `TerminalCheckout` are + + automatically `COMPLETED` or left in an `APPROVED` state for later + modification. + + + Default: true + delay_duration: + type: optional> + docs: >- + 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 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). + + + Default: "PT36H" (36 hours) from the creation time + accept_partial_authorization: + type: optional> + docs: >- + 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 + + a Square Gift Card with a balance of $5 results in an APPROVED payment + of $5. You might choose + + to prompt the buyer for an additional payment to cover the remainder + or cancel the Gift Card + + payment. + + + 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). + + + Default: false + delay_action: + type: optional + docs: >- + The action to be applied to the `Payment` when the delay_duration has + elapsed. + + The action must be CANCEL or COMPLETE. + + + 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 + source: + openapi: ../default/openapi/openapi.json + PaymentOptionsDelayAction: + enum: + - CANCEL + - COMPLETE + docs: >- + Describes the action to be applied to a delayed capture payment when the + delay_duration + + has elapsed. + source: + openapi: ../default/openapi/openapi.json + PaymentRefund: + docs: >- + Represents a refund of a payment made using Square. Contains information + about + + the original payment and the amount of money refunded. + properties: + id: + type: string + docs: The unique ID for this refund, generated by Square. + validation: + minLength: 1 + maxLength: 255 + status: + type: optional> + docs: |- + The refund's status: + - `PENDING` - Awaiting approval. + - `COMPLETED` - Successfully completed. + - `REJECTED` - The refund was rejected. + - `FAILED` - An error occurred. + validation: + maxLength: 50 + location_id: + type: optional> + docs: >- + The location ID associated with the payment this refund is attached + to. + validation: + maxLength: 50 + unlinked: + type: optional + docs: >- + Flag indicating whether or not the refund is linked to an existing + payment in Square. + access: read-only + destination_type: + type: optional> + docs: >- + The destination type for this refund. + + + Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, + `BUY_NOW_PAY_LATER`, `CASH`, + + `EXTERNAL`, and `SQUARE_ACCOUNT`. + validation: + maxLength: 50 + destination_details: + type: optional + docs: >- + Contains information about the refund destination. This field is + populated only if + + `destination_id` is defined in the `RefundPayment` request. + amount_money: + type: Money + docs: >- + The amount of money refunded. This amount is specified in the smallest + denomination + + of the applicable currency (for example, US dollar amounts are + specified in cents). + app_fee_money: + type: optional + docs: >- + The amount of money the application developer contributed to help + cover the refunded amount. + + This amount is specified in the smallest denomination of the + applicable currency (for example, + + US dollar amounts are specified in cents). For more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + processing_fee: + type: optional>> + docs: >- + Processing fees and fee adjustments assessed by Square for this + refund. + payment_id: + type: optional> + docs: The ID of the payment associated with this refund. + validation: + maxLength: 192 + order_id: + type: optional> + docs: The ID of the order associated with the refund. + validation: + maxLength: 192 + reason: + type: optional> + docs: The reason for the refund. + validation: + maxLength: 192 + created_at: + type: optional + docs: The timestamp of when the refund was created, in RFC 3339 format. + validation: + maxLength: 32 + access: read-only + updated_at: + type: optional + docs: The timestamp of when the refund was last updated, in RFC 3339 format. + validation: + maxLength: 32 + access: read-only + team_member_id: + type: optional + docs: An optional ID of the team member associated with taking the payment. + validation: + maxLength: 192 + access: read-only + terminal_refund_id: + type: optional + docs: An optional ID for a Terminal refund. + access: read-only + source: + openapi: ../default/openapi/openapi.json + PaymentUpdatedEvent: + docs: >- + Published when a [Payment](entity:Payment) is updated. + + Typically the `payment.status`, or `card_details.status` fields are + updated + + as a payment is canceled, authorized, or completed. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"payment.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + PaymentUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"payment"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected payment. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the updated payment. + source: + openapi: ../default/openapi/openapi.json + PaymentUpdatedEventObject: + properties: + payment: + type: optional + docs: The updated payment. + source: + openapi: ../default/openapi/openapi.json + Payout: + docs: >- + An accounting of the amount owed the seller and record of the actual + transfer to their + + external bank account or to the Square balance. + properties: + id: + type: string + docs: A unique ID for the payout. + validation: + minLength: 1 + status: + type: optional + docs: |- + Indicates the payout status. + See [PayoutStatus](#type-payoutstatus) for possible values + location_id: + type: string + docs: The ID of the location associated with the payout. + validation: + minLength: 1 + created_at: + type: optional + docs: >- + The timestamp of when the payout was created and submitted for deposit + to the seller's banking destination, in RFC 3339 format. + updated_at: + type: optional + docs: The timestamp of when the payout was last updated, in RFC 3339 format. + amount_money: + type: optional + docs: >- + The amount of money involved in the payout. A positive amount + indicates a deposit, and a negative amount indicates a withdrawal. + This amount is never zero. + destination: + type: optional + docs: >- + Information about the banking destination (such as a bank account, + Square checking account, or debit card) + + against which the payout was made. + version: + type: optional + docs: >- + The version number, which is incremented each time an update is made + to this payout record. + + The version number helps developers receive event notifications or + feeds out of order. + type: + type: optional + docs: |- + Indicates the payout type. + See [PayoutType](#type-payouttype) for possible values + payout_fee: + type: optional>> + docs: >- + A list of transfer fees and any taxes on the fees assessed by Square + for this payout. + arrival_date: + type: optional> + docs: >- + The calendar date, in ISO 8601 format (YYYY-MM-DD), when the payout is + due to arrive in the seller’s banking destination. + end_to_end_id: + type: optional> + docs: >- + A unique ID for each `Payout` object that might also appear on the + seller’s bank statement. You can use this ID to automate the process + of reconciling each payout with the corresponding line item on the + bank statement. + source: + openapi: ../default/openapi/openapi.json + PayoutEntry: + docs: >- + One or more PayoutEntries that make up a Payout. Each one has a date, + amount, and type of activity. + + The total amount of the payout will equal the sum of the payout entries + for a batch payout + properties: + id: + type: string + docs: A unique ID for the payout entry. + validation: + minLength: 1 + payout_id: + type: string + docs: The ID of the payout entries’ associated payout. + validation: + minLength: 1 + effective_at: + type: optional> + docs: >- + The timestamp of when the payout entry affected the balance, in RFC + 3339 format. + type: + type: optional + docs: |- + The type of activity associated with this payout entry. + See [ActivityType](#type-activitytype) for possible values + gross_amount_money: + type: optional + docs: The amount of money involved in this payout entry. + fee_amount_money: + type: optional + docs: The amount of Square fees associated with this payout entry. + net_amount_money: + type: optional + docs: The net proceeds from this transaction after any fees. + type_app_fee_revenue_details: + type: optional + docs: Details of any developer app fee revenue generated on a payment. + type_app_fee_refund_details: + type: optional + docs: Details of a refund for an app fee on a payment. + type_automatic_savings_details: + type: optional + docs: >- + Details of any automatic transfer from the payment processing balance + to the Square Savings account. These are, generally, proportional to + the merchant's sales. + type_automatic_savings_reversed_details: + type: optional + docs: >- + Details of any automatic transfer from the Square Savings account back + to the processing balance. These are, generally, proportional to the + merchant's refunds. + type_charge_details: + type: optional + docs: Details of credit card payment captures. + type_deposit_fee_details: + type: optional + docs: >- + Details of any fees involved with deposits such as for instant + deposits. + type_deposit_fee_reversed_details: + type: optional + docs: >- + Details of any reversal or refund of fees involved with deposits such + as for instant deposits. + type_dispute_details: + type: optional + docs: Details of any balance change due to a dispute event. + type_fee_details: + type: optional + docs: Details of adjustments due to the Square processing fee. + type_free_processing_details: + type: optional + docs: >- + Square offers Free Payments Processing for a variety of business + scenarios including seller referral or when Square wants to apologize + for a bug, customer service, repricing complication, and so on. This + entry represents details of any credit to the merchant for the + purposes of Free Processing. + type_hold_adjustment_details: + type: optional + docs: >- + Details of any adjustment made by Square related to the holding or + releasing of a payment. + type_open_dispute_details: + type: optional + docs: Details of any open disputes. + type_other_details: + type: optional + docs: >- + Details of any other type that does not belong in the rest of the + types. + type_other_adjustment_details: + type: optional + docs: >- + Details of any other type of adjustments that don't fall under + existing types. + type_refund_details: + type: optional + docs: Details of a refund for an existing card payment. + type_release_adjustment_details: + type: optional + docs: Details of fees released for adjustments. + type_reserve_hold_details: + type: optional + docs: Details of fees paid for funding risk reserve. + type_reserve_release_details: + type: optional + docs: Details of fees released from risk reserve. + type_square_capital_payment_details: + type: optional + docs: >- + Details of capital merchant cash advance (MCA) assessments. These are, + generally, proportional to the merchant's sales but may be issued for + other reasons related to the MCA. + type_square_capital_reversed_payment_details: + type: optional + docs: >- + Details of capital merchant cash advance (MCA) assessment refunds. + These are, generally, proportional to the merchant's refunds but may + be issued for other reasons related to the MCA. + type_tax_on_fee_details: + type: optional + docs: Details of tax paid on fee amounts. + type_third_party_fee_details: + type: optional + docs: Details of fees collected by a 3rd party platform. + type_third_party_fee_refund_details: + type: optional + docs: Details of refunded fees from a 3rd party platform. + type_square_payroll_transfer_details: + type: optional + docs: >- + Details of a payroll payment that was transferred to a team member’s + bank account. + type_square_payroll_transfer_reversed_details: + type: optional + docs: >- + Details of a payroll payment to a team member’s bank account that was + deposited back to the seller’s account by Square. + source: + openapi: ../default/openapi/openapi.json + PayoutFailedEvent: + docs: Published when a [Payout](entity:Payout) has failed. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event that this represents, `payout.failed`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: The timestamp of when the event was verified, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + PayoutFailedEventData: + properties: + type: + type: optional> + docs: The name of the affected object's type, `payout`. + id: + type: optional + docs: The ID of the failed payout. + object: + type: optional + docs: An object containing the failed payout. + source: + openapi: ../default/openapi/openapi.json + PayoutFailedEventObject: + properties: + payout: + type: optional + docs: The payout that failed. + source: + openapi: ../default/openapi/openapi.json + PayoutFee: + docs: Represents a payout fee that can incur as part of a payout. + properties: + amount_money: + type: optional + docs: The money amount of the payout fee. + effective_at: + type: optional> + docs: The timestamp of when the fee takes effect, in RFC 3339 format. + type: + type: optional + docs: |- + The type of fee assessed as part of the payout. + See [PayoutFeeType](#type-payoutfeetype) for possible values + source: + openapi: ../default/openapi/openapi.json + PayoutFeeType: + enum: + - TRANSFER_FEE + - TAX_ON_TRANSFER_FEE + docs: Represents the type of payout fee that can incur as part of a payout. + source: + openapi: ../default/openapi/openapi.json + PayoutPaidEvent: + docs: Published when a [Payout](entity:Payout) is complete. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents, `"payout.paid"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was verified, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + PayoutPaidEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"payout"`. + id: + type: optional + docs: ID of the completed payout. + object: + type: optional + docs: An object containing the completed payout. + source: + openapi: ../default/openapi/openapi.json + PayoutPaidEventObject: + properties: + payout: + type: optional + docs: The payout that has completed. + source: + openapi: ../default/openapi/openapi.json + PayoutSentEvent: + docs: Published when a [Payout](entity:Payout) is sent. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + location_id: + type: optional> + docs: The ID of the target location associated with the event. + type: + type: optional> + docs: The type of event this represents, `"payout.sent"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was verified, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + PayoutSentEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"payout"`. + id: + type: optional + docs: ID of the sent payout. + object: + type: optional + docs: An object containing the sent payout. + source: + openapi: ../default/openapi/openapi.json + PayoutSentEventObject: + properties: + payout: + type: optional + docs: The payout that was sent. + source: + openapi: ../default/openapi/openapi.json + PayoutStatus: + enum: + - SENT + - FAILED + - PAID + docs: Payout status types + source: + openapi: ../default/openapi/openapi.json + PayoutType: + enum: + - BATCH + - SIMPLE + docs: >- + The type of payout: “BATCH” or “SIMPLE”. + + BATCH payouts include a list of payout entries that can be considered + settled. + + SIMPLE payouts do not have any payout entries associated with them + + and will show up as one of the payout entries in a future BATCH payout. + source: + openapi: ../default/openapi/openapi.json + Phase: + docs: >- + Represents a phase, which can override subscription phases as defined by + plan_id + properties: + uid: + type: optional> + docs: id of subscription phase + ordinal: + type: optional> + docs: index of phase in total subscription plan + order_template_id: + type: optional> + docs: id of order to be used in billing + plan_phase_uid: + type: optional> + docs: the uid from the plan's phase in catalog + source: + openapi: ../default/openapi/openapi.json + PhaseInput: + docs: Represents the arguments used to construct a new phase. + properties: + ordinal: + type: long + docs: index of phase in total subscription plan + order_template_id: + type: optional> + docs: id of order to be used in billing + source: + openapi: ../default/openapi/openapi.json + PrePopulatedData: + docs: >- + Describes buyer data to prepopulate in the payment form. + + For more information, + + see [Optional Checkout + Configurations](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations). + properties: + buyer_email: + type: optional> + docs: The buyer email to prepopulate in the payment form. + validation: + maxLength: 256 + buyer_phone_number: + type: optional> + docs: The buyer phone number to prepopulate in the payment form. + validation: + maxLength: 17 + buyer_address: + type: optional
+ docs: The buyer address to prepopulate in the payment form. + source: + openapi: ../default/openapi/openapi.json + ProcessingFee: + docs: Represents the Square processing fee. + properties: + effective_at: + type: optional> + docs: The timestamp of when the fee takes effect, in RFC 3339 format. + type: + type: optional> + docs: >- + The type of fee assessed or adjusted. The fee type can be `INITIAL` or + `ADJUSTMENT`. + amount_money: + type: optional + docs: >- + The fee amount, which might be negative, that is assessed or adjusted + by Square. + + + Positive values represent funds being assessed, while negative values + represent + + funds being returned. + source: + openapi: ../default/openapi/openapi.json + Product: + enum: + - SQUARE_POS + - EXTERNAL_API + - BILLING + - APPOINTMENTS + - INVOICES + - ONLINE_STORE + - PAYROLL + - DASHBOARD + - ITEM_LIBRARY_IMPORT + - OTHER + docs: Indicates the Square product used to generate a change. + source: + openapi: ../default/openapi/openapi.json + ProductType: literal<"TERMINAL_API"> + PublishInvoiceResponse: + docs: Describes a `PublishInvoice` response. + properties: + invoice: + type: optional + docs: The published invoice. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + PublishScheduledShiftResponse: + docs: >- + Represents a + [PublishScheduledShift](api-endpoint:Labor-PublishScheduledShift) + response. + + Either `scheduled_shift` or `errors` is present in the response. + properties: + scheduled_shift: + type: optional + docs: The published scheduled shift. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + QrCodeOptions: + docs: Fields to describe the action that displays QR-Codes. + properties: + title: + type: string + docs: The title text to display in the QR code flow on the Terminal. + validation: + minLength: 1 + maxLength: 250 + body: + type: string + docs: The body text to display in the QR code flow on the Terminal. + validation: + minLength: 1 + maxLength: 10000 + barcode_contents: + type: string + docs: |- + The text representation of the data to show in the QR code + as UTF8-encoded data. + validation: + minLength: 1 + maxLength: 1024 + source: + openapi: ../default/openapi/openapi.json + QuickPay: + docs: >- + Describes an ad hoc item and price to generate a quick pay checkout link. + + For more information, + + see [Quick Pay + Checkout](https://developer.squareup.com/docs/checkout-api/quick-pay-checkout). + properties: + name: + type: string + docs: >- + The ad hoc item name. In the resulting `Order`, this name appears as + the line item name. + validation: + minLength: 1 + maxLength: 255 + price_money: + type: Money + docs: The price of the item. + location_id: + type: string + docs: The ID of the business location the checkout is associated with. + source: + openapi: ../default/openapi/openapi.json + Range: + docs: The range of a number value between the specified lower and upper bounds. + properties: + min: + type: optional> + docs: >- + The lower bound of the number range. At least one of `min` or `max` + must be specified. + + If unspecified, the results will have no minimum value. + max: + type: optional> + docs: >- + The upper bound of the number range. At least one of `min` or `max` + must be specified. + + If unspecified, the results will have no maximum value. + source: + openapi: ../default/openapi/openapi.json + ReceiptOptions: + docs: Describes receipt action fields. + properties: + payment_id: + type: string + docs: The reference to the Square payment ID for the receipt. + print_only: + type: optional> + docs: >- + Instructs the device to print the receipt without displaying the + receipt selection screen. + + Requires `printer_enabled` set to true. + + Defaults to false. + is_duplicate: + type: optional> + docs: |- + Identify the receipt as a reprint rather than an original receipt. + Defaults to false. + source: + openapi: ../default/openapi/openapi.json + ReceiveTransferOrderResponse: + docs: Response for receiving items for a transfer order + properties: + transfer_order: + type: optional + docs: The updated transfer order + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + RedeemLoyaltyRewardResponse: + docs: >- + A response that includes the `LoyaltyEvent` published for redeeming the + reward. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + event: + type: optional + docs: The `LoyaltyEvent` for redeeming the reward. + source: + openapi: ../default/openapi/openapi.json + Reference: + properties: + type: + type: optional + docs: |- + The type of entity a channel is associated with. + See [Type](#type-type) for possible values + id: + type: optional + docs: The id of the entity a channel is associated with. + source: + openapi: ../default/openapi/openapi.json + ReferenceType: + enum: + - UNKNOWN_TYPE + - LOCATION + - FIRST_PARTY_INTEGRATION + - OAUTH_APPLICATION + - ONLINE_SITE + - ONLINE_CHECKOUT + - INVOICE + - GIFT_CARD + - GIFT_CARD_MARKETPLACE + - RECURRING_SUBSCRIPTION + - ONLINE_BOOKING_FLOW + - SQUARE_ASSISTANT + - CASH_LOCAL + - POINT_OF_SALE + - KIOSK + docs: The type of platform concept a channel can represent. + source: + openapi: ../default/openapi/openapi.json + Refund: + docs: Represents a refund processed for a Square transaction. + properties: + id: + type: string + docs: The refund's unique ID. + validation: + maxLength: 255 + location_id: + type: string + docs: The ID of the refund's associated location. + validation: + maxLength: 50 + transaction_id: + type: optional> + docs: The ID of the transaction that the refunded tender is part of. + validation: + maxLength: 192 + tender_id: + type: optional> + docs: The ID of the refunded tender. + validation: + maxLength: 192 + created_at: + type: optional + docs: The timestamp for when the refund was created, in RFC 3339 format. + validation: + maxLength: 32 + access: read-only + reason: + type: string + docs: The reason for the refund being issued. + validation: + maxLength: 192 + amount_money: + type: Money + docs: The amount of money refunded to the buyer. + status: + type: RefundStatus + docs: |- + The current status of the refund (`PENDING`, `APPROVED`, `REJECTED`, + or `FAILED`). + See [RefundStatus](#type-refundstatus) for possible values + processing_fee_money: + type: optional + docs: The amount of Square processing fee money refunded to the *merchant*. + additional_recipients: + type: optional>> + docs: >- + Additional recipients (other than the merchant) receiving a portion of + this refund. + + For example, fees assessed on a refund of a purchase by a third party + integration. + source: + openapi: ../default/openapi/openapi.json + RefundCreatedEvent: + docs: Published when a [Refund](entity:PaymentRefund) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"refund.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + RefundCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"refund"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected refund. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the created refund. + source: + openapi: ../default/openapi/openapi.json + RefundCreatedEventObject: + properties: + refund: + type: optional + docs: The created refund. + source: + openapi: ../default/openapi/openapi.json + RefundPaymentResponse: + docs: >- + Defines the response returned by + + [RefundPayment](api-endpoint:Refunds-RefundPayment). + + + If there are errors processing the request, the `refund` field might not + be + + present, or it might be present with a status of `FAILED`. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refund: + type: optional + docs: The successfully created `PaymentRefund`. + source: + openapi: ../default/openapi/openapi.json + RefundStatus: + enum: + - PENDING + - APPROVED + - REJECTED + - FAILED + docs: Indicates a refund's current status. + source: + openapi: ../default/openapi/openapi.json + RefundUpdatedEvent: + docs: |- + Published when a [Refund](entity:PaymentRefund) is updated. + Typically the `refund.status` changes when a refund is completed. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"refund.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + RefundUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"refund"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected refund. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the updated refund. + source: + openapi: ../default/openapi/openapi.json + RefundUpdatedEventObject: + properties: + refund: + type: optional + docs: The updated refund. + source: + openapi: ../default/openapi/openapi.json + RegisterDomainResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [RegisterDomain](api-endpoint:ApplePay-RegisterDomain) + endpoint. + + + Either `errors` or `status` are present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + status: + type: optional + docs: >- + The status of the domain registration. + + + See + [RegisterDomainResponseStatus](entity:RegisterDomainResponseStatus) + for possible values. + + See [RegisterDomainResponseStatus](#type-registerdomainresponsestatus) + for possible values + source: + openapi: ../default/openapi/openapi.json + RegisterDomainResponseStatus: + enum: + - PENDING + - VERIFIED + docs: The status of the domain registration. + source: + openapi: ../default/openapi/openapi.json + RemoveGroupFromCustomerResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [RemoveGroupFromCustomer](api-endpoint:Customers-RemoveGroupFromCustomer) + + endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + ResumeSubscriptionResponse: + docs: >- + Defines output parameters in a response from the + + [ResumeSubscription](api-endpoint:Subscriptions-ResumeSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The resumed subscription. + actions: + type: optional> + docs: >- + A list of `RESUME` actions created by the request and scheduled for + the subscription. + source: + openapi: ../default/openapi/openapi.json + RetrieveBookingCustomAttributeDefinitionResponse: + docs: >- + Represents a + [RetrieveBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-RetrieveBookingCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The retrieved custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveBookingCustomAttributeResponse: + docs: >- + Represents a + [RetrieveBookingCustomAttribute](api-endpoint:BookingCustomAttributes-RetrieveBookingCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: >- + The retrieved custom attribute. If `with_definition` was set to `true` + in the request, + + the custom attribute definition is returned in the `definition` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetBookingResponse: + properties: + booking: + type: optional + docs: The booking that was requested. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetBusinessBookingProfileResponse: + properties: + business_booking_profile: + type: optional + docs: The seller's booking profile. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetCardResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [RetrieveCard](api-endpoint:Cards-RetrieveCard) endpoint. + + + Note: if there are errors processing the request, the card field will not + be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + card: + type: optional + docs: The retrieved card. + source: + openapi: ../default/openapi/openapi.json + GetCashDrawerShiftResponse: + properties: + cash_drawer_shift: + type: optional + docs: The cash drawer shift queried for. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetCatalogObjectResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + object: + type: optional + docs: The `CatalogObject`s returned. + related_objects: + type: optional> + docs: >- + A list of `CatalogObject`s referenced by the object in the `object` + field. + source: + openapi: ../default/openapi/openapi.json + RetrieveChannelResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + channel: + type: optional + docs: The requested Channel. + source: + openapi: ../default/openapi/openapi.json + GetCustomerCustomAttributeDefinitionResponse: + docs: >- + Represents a + [RetrieveCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-RetrieveCustomerCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The retrieved custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetCustomerCustomAttributeResponse: + docs: >- + Represents a + [RetrieveCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-RetrieveCustomerCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: >- + The retrieved custom attribute. If `with_definition` was set to `true` + in the request, + + the custom attribute definition is returned in the `definition` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetCustomerGroupResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [RetrieveCustomerGroup](api-endpoint:CustomerGroups-RetrieveCustomerGroup) + endpoint. + + + Either `errors` or `group` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + group: + type: optional + docs: The retrieved customer group. + source: + openapi: ../default/openapi/openapi.json + GetCustomerResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `RetrieveCustomer` endpoint. + + Either `errors` or `customer` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + customer: + type: optional + docs: The requested customer. + source: + openapi: ../default/openapi/openapi.json + GetCustomerSegmentResponse: + docs: >- + Defines the fields that are included in the response body for requests to + the `RetrieveCustomerSegment` endpoint. + + + Either `errors` or `segment` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + segment: + type: optional + docs: The retrieved customer segment. + source: + openapi: ../default/openapi/openapi.json + GetDisputeEvidenceResponse: + docs: Defines the fields in a `RetrieveDisputeEvidence` response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + evidence: + type: optional + docs: Metadata about the dispute evidence file. + source: + openapi: ../default/openapi/openapi.json + GetDisputeResponse: + docs: Defines fields in a `RetrieveDispute` response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + dispute: + type: optional + docs: Details about the requested `Dispute`. + source: + openapi: ../default/openapi/openapi.json + GetEmployeeResponse: + properties: + employee: optional + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetGiftCardFromGANResponse: + docs: >- + A response that contains a `GiftCard`. This response might contain a set + of `Error` objects + + if the request resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card: + type: optional + docs: >- + A gift card that was fetched, if present. It returns empty if an error + occurred. + source: + openapi: ../default/openapi/openapi.json + GetGiftCardFromNonceResponse: + docs: >- + A response that contains a `GiftCard` object. If the request resulted in + errors, + + the response contains a set of `Error` objects. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card: + type: optional + docs: The retrieved gift card. + source: + openapi: ../default/openapi/openapi.json + GetGiftCardResponse: + docs: >- + A response that contains a `GiftCard`. The response might contain a set of + `Error` objects + + if the request resulted in errors. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card: + type: optional + docs: The gift card retrieved. + source: + openapi: ../default/openapi/openapi.json + GetInventoryAdjustmentResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + adjustment: + type: optional + docs: The requested [InventoryAdjustment](entity:InventoryAdjustment). + source: + openapi: ../default/openapi/openapi.json + GetInventoryChangesResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + changes: + type: optional> + docs: The set of inventory changes for the requested object and locations. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + + this is the final response. + + + See the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + source: + openapi: ../default/openapi/openapi.json + GetInventoryCountResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + counts: + type: optional> + docs: |- + The current calculated inventory counts for the requested object and + locations. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + + this is the final response. + + + See the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + source: + openapi: ../default/openapi/openapi.json + GetInventoryPhysicalCountResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + count: + type: optional + docs: The requested [InventoryPhysicalCount](entity:InventoryPhysicalCount). + source: + openapi: ../default/openapi/openapi.json + GetInventoryTransferResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + transfer: + type: optional + docs: The requested [InventoryTransfer](entity:InventoryTransfer). + source: + openapi: ../default/openapi/openapi.json + RetrieveJobResponse: + docs: >- + Represents a [RetrieveJob](api-endpoint:Team-RetrieveJob) response. Either + `job` or `errors` + + is present in the response. + properties: + job: + type: optional + docs: The retrieved job. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveLocationBookingProfileResponse: + properties: + location_booking_profile: + type: optional + docs: The requested location booking profile. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveLocationCustomAttributeDefinitionResponse: + docs: >- + Represents a + [RetrieveLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-RetrieveLocationCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The retrieved custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveLocationCustomAttributeResponse: + docs: >- + Represents a + [RetrieveLocationCustomAttribute](api-endpoint:LocationCustomAttributes-RetrieveLocationCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: >- + The retrieved custom attribute. If `with_definition` was set to `true` + in the request, + + the custom attribute definition is returned in the `definition` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetLocationResponse: + docs: >- + Defines the fields that the + [RetrieveLocation](api-endpoint:Locations-RetrieveLocation) + + endpoint returns in a response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + location: + type: optional + docs: The requested location. + source: + openapi: ../default/openapi/openapi.json + RetrieveLocationSettingsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + location_settings: + type: optional + docs: The location settings. + source: + openapi: ../default/openapi/openapi.json + GetLoyaltyAccountResponse: + docs: A response that includes the loyalty account. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_account: + type: optional + docs: The loyalty account. + source: + openapi: ../default/openapi/openapi.json + GetLoyaltyProgramResponse: + docs: A response that contains the loyalty program. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + program: + type: optional + docs: The loyalty program that was requested. + source: + openapi: ../default/openapi/openapi.json + GetLoyaltyPromotionResponse: + docs: >- + Represents a + [RetrieveLoyaltyPromotionPromotions](api-endpoint:Loyalty-RetrieveLoyaltyPromotion) + response. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_promotion: + type: optional + docs: The retrieved loyalty promotion. + source: + openapi: ../default/openapi/openapi.json + GetLoyaltyRewardResponse: + docs: A response that includes the loyalty reward. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + reward: + type: optional + docs: The loyalty reward retrieved. + source: + openapi: ../default/openapi/openapi.json + RetrieveMerchantCustomAttributeDefinitionResponse: + docs: >- + Represents a + [RetrieveMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-RetrieveMerchantCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The retrieved custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveMerchantCustomAttributeResponse: + docs: >- + Represents a + [RetrieveMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-RetrieveMerchantCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: >- + The retrieved custom attribute. If `with_definition` was set to `true` + in the request, + + the custom attribute definition is returned in the `definition` field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetMerchantResponse: + docs: >- + The response object returned by the + [RetrieveMerchant](api-endpoint:Merchants-RetrieveMerchant) endpoint. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + merchant: + type: optional + docs: The requested `Merchant` object. + source: + openapi: ../default/openapi/openapi.json + RetrieveMerchantSettingsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + merchant_settings: + type: optional + docs: The merchant settings. + source: + openapi: ../default/openapi/openapi.json + RetrieveOrderCustomAttributeDefinitionResponse: + docs: Represents a response from getting an order custom attribute definition. + properties: + custom_attribute_definition: + type: optional + docs: The retrieved custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveOrderCustomAttributeResponse: + docs: Represents a response from getting an order custom attribute. + properties: + custom_attribute: + type: optional + docs: >- + The retrieved custom attribute. If `with_definition` was set to `true` + in the request, the custom attribute definition is returned in the + `definition field. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetOrderResponse: + properties: + order: + type: optional + docs: The requested order. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetPaymentLinkResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + payment_link: + type: optional + docs: The payment link that is retrieved. + source: + openapi: ../default/openapi/openapi.json + RetrieveScheduledShiftResponse: + docs: >- + Represents a + [RetrieveScheduledShift](api-endpoint:Labor-RetrieveScheduledShift) + response. + + Either `scheduled_shift` or `errors` is present in the response. + properties: + scheduled_shift: + type: optional + docs: The requested scheduled shift. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetSnippetResponse: + docs: >- + Represents a `RetrieveSnippet` response. The response can include either + `snippet` or `errors`. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + snippet: + type: optional + docs: The retrieved snippet. + source: + openapi: ../default/openapi/openapi.json + GetSubscriptionResponse: + docs: >- + Defines output parameters in a response from the + + [RetrieveSubscription](api-endpoint:Subscriptions-RetrieveSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The subscription retrieved. + source: + openapi: ../default/openapi/openapi.json + GetTeamMemberBookingProfileResponse: + properties: + team_member_booking_profile: + type: optional + docs: The returned team member booking profile. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetTeamMemberResponse: + docs: >- + Represents a response from a retrieve request containing a `TeamMember` + object or error messages. + properties: + team_member: + type: optional + docs: The successfully retrieved `TeamMember` object. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveTimecardResponse: + docs: >- + A response to a request to get a `Timecard`. The response contains + + the requested `Timecard` object and might contain a set of `Error` objects + if + + the request resulted in errors. + properties: + timecard: + type: optional + docs: The requested `Timecard`. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RetrieveTokenStatusResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the `RetrieveTokenStatus` endpoint. + properties: + scopes: + type: optional> + docs: The list of scopes associated with an access token. + expires_at: + type: optional + docs: "The date and time when the\_`access_token`\_expires, in RFC 3339 format. Empty if the token never expires." + client_id: + type: optional + docs: >- + The Square-issued application ID associated with the access token. + This is the same application ID used to obtain the token. + validation: + maxLength: 191 + merchant_id: + type: optional + docs: The ID of the authorizing merchant's business. + validation: + minLength: 8 + maxLength: 191 + errors: + type: optional> + docs: ' Any errors that occurred during the request.' + source: + openapi: ../default/openapi/openapi.json + GetTransactionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [RetrieveTransaction](api-endpoint:Transactions-RetrieveTransaction) + endpoint. + + + One of `errors` or `transaction` is present in a given response (never + both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + transaction: + type: optional + docs: The requested transaction. + source: + openapi: ../default/openapi/openapi.json + RetrieveTransferOrderResponse: + docs: Response containing the requested transfer order + properties: + transfer_order: + type: optional + docs: The requested transfer order + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + GetVendorResponse: + docs: >- + Represents an output from a call to + [RetrieveVendor](api-endpoint:Vendors-RetrieveVendor). + properties: + errors: + type: optional> + docs: Errors encountered when the request fails. + vendor: + type: optional + docs: The successfully retrieved [Vendor](entity:Vendor) object. + source: + openapi: ../default/openapi/openapi.json + GetWageSettingResponse: + docs: >- + Represents a response from a retrieve request containing the specified + `WageSetting` object or error messages. + properties: + wage_setting: + type: optional + docs: The successfully retrieved `WageSetting` object. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + GetWebhookSubscriptionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [RetrieveWebhookSubscription](api-endpoint:WebhookSubscriptions-RetrieveWebhookSubscription) + endpoint. + + + Note: if there are errors processing the request, the + [Subscription](entity:WebhookSubscription) will not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + subscription: + type: optional + docs: The requested [Subscription](entity:WebhookSubscription). + source: + openapi: ../default/openapi/openapi.json + RevokeTokenResponse: + properties: + success: + type: optional + docs: If the request is successful, this is `true`. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + RiskEvaluation: + docs: >- + Represents fraud risk information for the associated payment. + + + When you take a payment through Square's Payments API (using the + `CreatePayment` + + endpoint), Square evaluates it and assigns a risk level to the payment. + Sellers + + can use this information to determine the course of action (for example, + + provide the goods/services or refund the payment). + properties: + created_at: + type: optional + docs: The timestamp when payment risk was evaluated, in RFC 3339 format. + access: read-only + risk_level: + type: optional + docs: >- + The risk level associated with the payment + + See [RiskEvaluationRiskLevel](#type-riskevaluationrisklevel) for + possible values + source: + openapi: ../default/openapi/openapi.json + RiskEvaluationRiskLevel: + enum: + - PENDING + - NORMAL + - MODERATE + - HIGH + source: + openapi: ../default/openapi/openapi.json + SaveCardOptions: + docs: Describes save-card action fields. + properties: + customer_id: + type: string + docs: The square-assigned ID of the customer linked to the saved card. + card_id: + type: optional + docs: The id of the created card-on-file. + validation: + maxLength: 64 + access: read-only + reference_id: + type: optional> + docs: >- + An optional user-defined reference ID that can be used to associate + + this `Card` to another entity in an external system. For example, a + customer + + ID generated by a third-party system. + validation: + maxLength: 128 + source: + openapi: ../default/openapi/openapi.json + ScheduledShift: + docs: >- + Represents a specific time slot in a work schedule. This object is used to + manage the + + lifecycle of a scheduled shift from the draft to published state. A + scheduled shift contains + + the latest draft shift details and current published shift details. + properties: + id: + type: optional + docs: '**Read only** The Square-issued ID of the scheduled shift.' + validation: + maxLength: 255 + draft_shift_details: + type: optional + docs: >- + The latest draft shift details for the scheduled shift. Draft shift + details are used to + + stage and manage shifts before publishing. This field is always + present. + published_shift_details: + type: optional + docs: >- + The current published (public) shift details for the scheduled shift. + This field is + + present only if the shift was published. + version: + type: optional + docs: >- + **Read only** The current version of the scheduled shift, which is + incremented with each update. + + This field is used for [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control to ensure that requests don't overwrite data from another + request. + created_at: + type: optional + docs: >- + The timestamp of when the scheduled shift was created, in RFC 3339 + format presented as UTC. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp of when the scheduled shift was last updated, in RFC + 3339 format presented as UTC. + access: read-only + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftDetails: + docs: >- + Represents shift details for draft and published versions of a [scheduled + shift](entity:ScheduledShift), + + such as job ID, team member assignment, and start and end times. + properties: + team_member_id: + type: optional> + docs: >- + The ID of the [team member](entity:TeamMember) scheduled for the + shift. + validation: + maxLength: 255 + location_id: + type: optional> + docs: The ID of the [location](entity:Location) the shift is scheduled for. + validation: + maxLength: 255 + job_id: + type: optional> + docs: The ID of the [job](entity:Job) the shift is scheduled for. + start_at: + type: optional> + docs: >- + The start time of the shift, in RFC 3339 format in the time zone + + + + offset of the shift location specified in `location_id`. Precision up + to the minute + + is respected; seconds are truncated. + end_at: + type: optional> + docs: >- + The end time for the shift, in RFC 3339 format in the time zone + + + offset of the shift location specified in `location_id`. Precision up + to the minute + + is respected; seconds are truncated. + notes: + type: optional> + docs: Optional notes for the shift. + validation: + maxLength: 1000 + is_deleted: + type: optional> + docs: >- + Indicates whether the draft shift version is deleted. If set to `true` + when the shift + + is published, the entire scheduled shift (including the published + shift) is deleted and + + cannot be accessed using any endpoint. + timezone: + type: optional + docs: >- + The time zone of the shift location, calculated based on the + `location_id`. This field + + is provided for convenience. + access: read-only + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftFilter: + docs: >- + Defines filter criteria for a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) + + request. Multiple filters in a query are combined as an `AND` operation. + properties: + location_ids: + type: optional>> + docs: >- + Return shifts for the specified locations. When omitted, shifts for + all + + locations are returned. If needed, call + [ListLocations](api-endpoint:Locations-ListLocations) + + to get location IDs. + start: + type: optional + docs: |- + Return shifts whose `start_at` time is within the specified + time range (inclusive). + end: + type: optional + docs: |- + Return shifts whose `end_at` time is within the specified + time range (inclusive). + workday: + type: optional + docs: Return shifts based on a workday date range. + team_member_ids: + type: optional>> + docs: >- + Return shifts assigned to specified team members. If needed, call + + [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers) to get team + member IDs. + + + To return only the shifts assigned to the specified team members, + include the + + `assignment_status` filter in the query. Otherwise, all unassigned + shifts are + + returned along with shifts assigned to the specified team members. + assignment_status: + type: optional + docs: >- + Return shifts based on whether a team member is assigned. A shift is + + assigned if the `team_member_id` field is populated in the + `draft_shift_details` + + or `published_shift details` field of the shift. + + + To return only draft or published shifts, include the + `scheduled_shift_statuses` + + filter in the query. + + See + [ScheduledShiftFilterAssignmentStatus](#type-scheduledshiftfilterassignmentstatus) + for possible values + scheduled_shift_statuses: + type: optional>> + docs: >- + Return shifts based on the draft or published status of the shift. + + A shift is published if the `published_shift_details` field is + present. + + + Note that shifts with `draft_shift_details.is_deleted` set to `true` + are ignored + + with the `DRAFT` filter. + + See + [ScheduledShiftFilterScheduledShiftStatus](#type-scheduledshiftfilterscheduledshiftstatus) + for possible values + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftFilterAssignmentStatus: + enum: + - ASSIGNED + - UNASSIGNED + docs: |- + Defines valid values for the `assignment_status` filter in a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) request. + Assignment status is based on the `draft_shift_details.team_member_id` and + `published_shift_details.team_member_id` fields of the scheduled shift. + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftFilterScheduledShiftStatus: + enum: + - DRAFT + - PUBLISHED + docs: |- + Defines valid values for the `scheduled_shift_statuses` filter in a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) request. + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftNotificationAudience: + enum: + - ALL + - AFFECTED + - NONE + docs: >- + Indicates whether Square sends an email notification to team members + + when a scheduled shift is published and which team members receive the + notification. + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftQuery: + docs: |- + Represents filter and sort criteria for the `query` field in a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) request. + properties: + filter: + type: optional + docs: Filtering options for the query. + sort: + type: optional + docs: Sorting options for the query. + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftSort: + docs: >- + Defines sort criteria for a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) + + request. + properties: + field: + type: optional + docs: >- + The field to sort on. The default value is `START_AT`. + + See [ScheduledShiftSortField](#type-scheduledshiftsortfield) for + possible values + order: + type: optional + docs: |- + The order in which results are returned. The default value is `ASC`. + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftSortField: + enum: + - START_AT + - END_AT + - CREATED_AT + - UPDATED_AT + docs: |- + Defines valid values for the `field` sort setting in a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) request. + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftWorkday: + docs: >- + A `ScheduledShift` search query filter parameter that sets a range of days + that + + a `Shift` must start or end in before passing the filter condition. + properties: + date_range: + type: optional + docs: Dates for fetching the scheduled shifts. + match_scheduled_shifts_by: + type: optional + docs: >- + The strategy on which the dates are applied. + + See [ScheduledShiftWorkdayMatcher](#type-scheduledshiftworkdaymatcher) + for possible values + default_timezone: + type: optional> + docs: >- + Location-specific timezones convert workdays to datetime filters. + + Every location included in the query must have a timezone or this + field + + must be provided as a fallback. Format: the IANA timezone database + + identifier for the relevant timezone. + source: + openapi: ../default/openapi/openapi.json + ScheduledShiftWorkdayMatcher: + enum: + - START_AT + - END_AT + - INTERSECTION + docs: Defines the logic used to apply a workday filter. + source: + openapi: ../default/openapi/openapi.json + SearchAvailabilityFilter: + docs: A query filter to search for buyer-accessible availabilities by. + properties: + start_at_range: + type: TimeRange + docs: >- + The query expression to search for buy-accessible availabilities with + their starting times falling within the specified time range. + + The time range must be at least 24 hours and at most 32 days long. + + For waitlist availabilities, the time range can be 0 or more up to 367 + days long. + location_id: + type: optional> + docs: >- + The query expression to search for buyer-accessible availabilities + with their location IDs matching the specified location ID. + + This query expression cannot be set if `booking_id` is set. + validation: + maxLength: 32 + segment_filters: + type: optional>> + docs: >- + The query expression to search for buyer-accessible availabilities + matching the specified list of segment filters. + + If the size of the `segment_filters` list is `n`, the search returns + availabilities with `n` segments per availability. + + + This query expression cannot be set if `booking_id` is set. + booking_id: + type: optional> + docs: >- + The query expression to search for buyer-accessible availabilities for + an existing booking by matching the specified `booking_id` value. + + This is commonly used to reschedule an appointment. + + If this expression is set, the `location_id` and `segment_filters` + expressions cannot be set. + validation: + maxLength: 36 + source: + openapi: ../default/openapi/openapi.json + SearchAvailabilityQuery: + docs: The query used to search for buyer-accessible availabilities of bookings. + properties: + filter: + type: SearchAvailabilityFilter + docs: >- + The query filter to search for buyer-accessible availabilities of + existing bookings. + source: + openapi: ../default/openapi/openapi.json + SearchAvailabilityResponse: + properties: + availabilities: + type: optional> + docs: List of appointment slots available for booking. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + SearchCatalogItemsRequestStockLevel: + enum: + - OUT + - LOW + docs: Defines supported stock levels of the item inventory. + source: + openapi: ../default/openapi/openapi.json + SearchCatalogItemsResponse: + docs: >- + Defines the response body returned from the + [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + items: + type: optional> + docs: Returned items matching the specified query expressions. + cursor: + type: optional + docs: >- + Pagination token used in the next request to return more of the search + result. + matched_variation_ids: + type: optional> + docs: >- + Ids of returned item variations matching the specified query + expression. + source: + openapi: ../default/openapi/openapi.json + SearchCatalogObjectsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + this is the final response. + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + objects: + type: optional> + docs: The CatalogObjects returned. + related_objects: + type: optional> + docs: >- + A list of CatalogObjects referenced by the objects in the `objects` + field. + latest_time: + type: optional + docs: >- + When the associated product catalog was last updated. Will + + match the value for `end_time` or `cursor` if either field is included + in the `SearchCatalog` request. + source: + openapi: ../default/openapi/openapi.json + SearchCustomersResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the `SearchCustomers` endpoint. + + + Either `errors` or `customers` is present in a given response (never + both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + customers: + type: optional> + docs: >- + The customer profiles that match the search query. If any search + condition is not met, the result is an empty object (`{}`). + + Only customer profiles with public information (`given_name`, + `family_name`, `company_name`, `email_address`, or `phone_number`) + + are included in the response. + cursor: + type: optional + docs: >- + A pagination cursor that can be used during subsequent calls + + to `SearchCustomers` to retrieve the next set of results associated + + with the original query. Pagination cursors are only present when + + a request succeeds and additional results are available. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + count: + type: optional + docs: >- + The total count of customers associated with the Square account that + match the search query. Only customer profiles with + + public information (`given_name`, `family_name`, `company_name`, + `email_address`, or `phone_number`) are counted. This field is + + present only if `count` is set to `true` in the request. + source: + openapi: ../default/openapi/openapi.json + SearchEventsFilter: + docs: Criteria to filter events by. + properties: + event_types: + type: optional>> + docs: Filter events by event types. + merchant_ids: + type: optional>> + docs: Filter events by merchant. + location_ids: + type: optional>> + docs: Filter events by location. + created_at: + type: optional + docs: Filter events by when they were created. + source: + openapi: ../default/openapi/openapi.json + SearchEventsQuery: + docs: Contains query criteria for the search. + properties: + filter: + type: optional + docs: Criteria to filter events by. + sort: + type: optional + docs: Criteria to sort events by. + source: + openapi: ../default/openapi/openapi.json + SearchEventsResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [SearchEvents](api-endpoint:Events-SearchEvents) + endpoint. + + + Note: if there are errors processing the request, the events field will + not be + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + events: + type: optional> + docs: The list of [Event](entity:Event)s returned by the search. + metadata: + type: optional> + docs: >- + Contains the metadata of an event. For more information, see + [Event](entity:Event). + cursor: + type: optional + docs: >- + When a response is truncated, it includes a cursor that you can use in + a subsequent request to fetch the next set of events. If empty, this + is the final response. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + SearchEventsSort: + docs: Criteria to sort events by. + properties: + field: + type: optional + docs: >- + Sort events by event types. + + See [SearchEventsSortField](#type-searcheventssortfield) for possible + values + order: + type: optional + docs: |- + The order to use for sorting the events. + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + SearchEventsSortField: + type: literal<"DEFAULT"> + docs: Specifies the sort key for events returned from a search. + SearchInvoicesResponse: + docs: Describes a `SearchInvoices` response. + properties: + invoices: + type: optional> + docs: The list of invoices returned by the search. + cursor: + type: optional + docs: >- + When a response is truncated, it includes a cursor that you can use in + a + + subsequent request to fetch the next set of invoices. If empty, this + is the final + + response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + SearchLoyaltyAccountsRequestLoyaltyAccountQuery: + docs: The search criteria for the loyalty accounts. + properties: + mappings: + type: optional>> + docs: |- + The set of mappings to use in the loyalty account search. + + This cannot be combined with `customer_ids`. + + Max: 30 mappings + customer_ids: + type: optional>> + docs: |- + The set of customer IDs to use in the loyalty account search. + + This cannot be combined with `mappings`. + + Max: 30 customer IDs + source: + openapi: ../default/openapi/openapi.json + SearchLoyaltyAccountsResponse: + docs: >- + A response that includes loyalty accounts that satisfy the search + criteria. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + loyalty_accounts: + type: optional> + docs: |- + The loyalty accounts that met the search criteria, + in order of creation date. + cursor: + type: optional + docs: >- + The pagination cursor to use in a subsequent + + request. If empty, this is the final response. + + For more information, + + see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + SearchLoyaltyEventsResponse: + docs: |- + A response that contains loyalty events that satisfy the search + criteria, in order by the `created_at` date. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + events: + type: optional> + docs: The loyalty events that satisfy the search criteria. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent + + request. If empty, this is the final response. + + For more information, + + see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + SearchLoyaltyRewardsRequestLoyaltyRewardQuery: + docs: The set of search requirements. + properties: + loyalty_account_id: + type: string + docs: >- + The ID of the [loyalty account](entity:LoyaltyAccount) to which the + loyalty reward belongs. + validation: + minLength: 1 + status: + type: optional + docs: >- + The status of the loyalty reward. + + See [LoyaltyRewardStatus](#type-loyaltyrewardstatus) for possible + values + source: + openapi: ../default/openapi/openapi.json + SearchLoyaltyRewardsResponse: + docs: >- + A response that includes the loyalty rewards satisfying the search + criteria. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + rewards: + type: optional> + docs: |- + The loyalty rewards that satisfy the search criteria. + These are returned in descending order by `updated_at`. + cursor: + type: optional + docs: |- + The pagination cursor to be used in a subsequent + request. If empty, this is the final response. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersCustomerFilter: + docs: |- + A filter based on the order `customer_id` and any tender `customer_id` + associated with the order. It does not filter based on the + [FulfillmentRecipient](entity:FulfillmentRecipient) `customer_id`. + properties: + customer_ids: + type: optional>> + docs: |- + A list of customer IDs to filter by. + + Max: 10 customer ids. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersDateTimeFilter: + docs: >- + Filter for `Order` objects based on whether their `CREATED_AT`, + + `CLOSED_AT`, or `UPDATED_AT` timestamps fall within a specified time + range. + + You can specify the time range and which timestamp to filter for. You can + filter + + for only one time range at a time. + + + For each time range, the start time and end time are inclusive. If the end + time + + is absent, it defaults to the time of the first request for the cursor. + + + __Important:__ If you use the `DateTimeFilter` in a `SearchOrders` query, + + you must set the `sort_field` in [OrdersSort](entity:SearchOrdersSort) + + to the same field you filter for. For example, if you set the `CLOSED_AT` + field + + in `DateTimeFilter`, you must set the `sort_field` in `SearchOrdersSort` + to + + `CLOSED_AT`. Otherwise, `SearchOrders` throws an error. + + [Learn more about filtering orders by time + range.](https://developer.squareup.com/docs/orders-api/manage-orders/search-orders#important-note-about-filtering-orders-by-time-range) + properties: + created_at: + type: optional + docs: >- + The time range for filtering on the `created_at` timestamp. If you use + this + + value, you must set the `sort_field` in the `OrdersSearchSort` object + to + + `CREATED_AT`. + updated_at: + type: optional + docs: >- + The time range for filtering on the `updated_at` timestamp. If you use + this + + value, you must set the `sort_field` in the `OrdersSearchSort` object + to + + `UPDATED_AT`. + closed_at: + type: optional + docs: >- + The time range for filtering on the `closed_at` timestamp. If you use + this + + value, you must set the `sort_field` in the `OrdersSearchSort` object + to + + `CLOSED_AT`. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersFilter: + docs: |- + Filtering criteria to use for a `SearchOrders` request. Multiple filters + are ANDed together. + properties: + state_filter: + type: optional + docs: Filter by [OrderState](entity:OrderState). + date_time_filter: + type: optional + docs: >- + Filter for results within a time range. + + + __Important:__ If you filter for orders by time range, you must set + `SearchOrdersSort` + + to sort by the same field. + + [Learn more about filtering orders by time + range.](https://developer.squareup.com/docs/orders-api/manage-orders/search-orders#important-note-about-filtering-orders-by-time-range) + fulfillment_filter: + type: optional + docs: Filter by the fulfillment type or state. + source_filter: + type: optional + docs: Filter by the source of the order. + customer_filter: + type: optional + docs: Filter by customers associated with the order. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersFulfillmentFilter: + docs: Filter based on [order fulfillment](entity:Fulfillment) information. + properties: + fulfillment_types: + type: optional>> + docs: >- + A list of [fulfillment types](entity:FulfillmentType) to filter + + for. The list returns orders if any of its fulfillments match any of + the fulfillment types + + listed in this field. + + See [FulfillmentType](#type-fulfillmenttype) for possible values + fulfillment_states: + type: optional>> + docs: >- + A list of [fulfillment states](entity:FulfillmentState) to filter + + for. The list returns orders if any of its fulfillments match any of + the + + fulfillment states listed in this field. + + See [FulfillmentState](#type-fulfillmentstate) for possible values + source: + openapi: ../default/openapi/openapi.json + SearchOrdersQuery: + docs: Contains query criteria for the search. + properties: + filter: + type: optional + docs: Criteria to filter results by. + sort: + type: optional + docs: Criteria to sort results by. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersResponse: + docs: >- + Either the `order_entries` or `orders` field is set, depending on whether + + `return_entries` is set on the + [SearchOrdersRequest](api-endpoint:Orders-SearchOrders). + properties: + order_entries: + type: optional> + docs: >- + A list of [OrderEntries](entity:OrderEntry) that fit the query + + conditions. The list is populated only if `return_entries` is set to + `true` in the request. + orders: + type: optional> + docs: >- + A list of + + [Order](entity:Order) objects that match the query conditions. The + list is populated only if + + `return_entries` is set to `false` in the request. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + + this is the final response. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + errors: + type: optional> + docs: '[Errors](entity:Error) encountered during the search.' + source: + openapi: ../default/openapi/openapi.json + SearchOrdersSort: + docs: |- + Sorting criteria for a `SearchOrders` request. Results can only be sorted + by a timestamp field. + properties: + sort_field: + type: SearchOrdersSortField + docs: >- + The field to sort by. + + + __Important:__ When using a + [DateTimeFilter](entity:SearchOrdersFilter), + + `sort_field` must match the timestamp field that the `DateTimeFilter` + uses to + + filter. For example, if you set your `sort_field` to `CLOSED_AT` and + you use a + + `DateTimeFilter`, your `DateTimeFilter` must filter for orders by + their `CLOSED_AT` date. + + If this field does not match the timestamp field in `DateTimeFilter`, + + `SearchOrders` returns an error. + + + Default: `CREATED_AT`. + + See [SearchOrdersSortField](#type-searchorderssortfield) for possible + values + sort_order: + type: optional + docs: >- + The chronological order in which results are returned. Defaults to + `DESC`. + + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + SearchOrdersSortField: + enum: + - CREATED_AT + - UPDATED_AT + - CLOSED_AT + docs: Specifies which timestamp to use to sort `SearchOrder` results. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersSourceFilter: + docs: A filter based on order `source` information. + properties: + source_names: + type: optional>> + docs: >- + Filters by the [Source](entity:OrderSource) `name`. The filter returns + any orders + + with a `source.name` that matches any of the listed source names. + + + Max: 10 source names. + source: + openapi: ../default/openapi/openapi.json + SearchOrdersStateFilter: + docs: Filter by the current order `state`. + properties: + states: + docs: |- + States to filter for. + See [OrderState](#type-orderstate) for possible values + type: list + source: + openapi: ../default/openapi/openapi.json + SearchScheduledShiftsResponse: + docs: >- + Represents a + [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) + response. + + Either `scheduled_shifts` or `errors` is present in the response. + properties: + scheduled_shifts: + type: optional> + docs: A paginated list of scheduled shifts that match the query conditions. + cursor: + type: optional + docs: >- + The pagination cursor used to retrieve the next page of results. This + field is present + + only if additional results are available. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + SearchShiftsResponse: + docs: >- + The response to a request for `Shift` objects. The response contains + + the requested `Shift` objects and might contain a set of `Error` objects + if + + the request resulted in errors. + properties: + shifts: + type: optional> + docs: Shifts. + cursor: + type: optional + docs: An opaque cursor for fetching the next page. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + SearchSubscriptionsFilter: + docs: >- + Represents a set of query expressions (filters) to narrow the scope of + targeted subscriptions returned by + + the [SearchSubscriptions](api-endpoint:Subscriptions-SearchSubscriptions) + endpoint. + properties: + customer_ids: + type: optional>> + docs: >- + A filter to select subscriptions based on the subscribing customer + IDs. + location_ids: + type: optional>> + docs: A filter to select subscriptions based on the location. + source_names: + type: optional>> + docs: A filter to select subscriptions based on the source application. + source: + openapi: ../default/openapi/openapi.json + SearchSubscriptionsQuery: + docs: >- + Represents a query, consisting of specified query expressions, used to + search for subscriptions. + properties: + filter: + type: optional + docs: A list of query expressions. + source: + openapi: ../default/openapi/openapi.json + SearchSubscriptionsResponse: + docs: >- + Defines output parameters in a response from the + + [SearchSubscriptions](api-endpoint:Subscriptions-SearchSubscriptions) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscriptions: + type: optional> + docs: The subscriptions matching the specified query expressions. + cursor: + type: optional + docs: >- + When the total number of resulting subscription exceeds the limit of a + paged response, + + the response includes a cursor for you to use in a subsequent request + to fetch the next set of results. + + If the cursor is unset, the response contains the last page of the + results. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + source: + openapi: ../default/openapi/openapi.json + SearchTeamMembersFilter: + docs: >- + Represents a filter used in a search for `TeamMember` objects. `AND` logic + is applied + + between the individual fields, and `OR` logic is applied within list-based + fields. + + For example, setting this filter value: + + ``` + + filter = (locations_ids = ["A", "B"], status = ACTIVE) + + ``` + + returns only active team members assigned to either location "A" or "B". + properties: + location_ids: + type: optional>> + docs: >- + When present, filters by team members assigned to the specified + locations. + + When empty, includes team members assigned to any location. + status: + type: optional + docs: |- + When present, filters by team members who match the given status. + When empty, includes team members of all statuses. + See [TeamMemberStatus](#type-teammemberstatus) for possible values + is_owner: + type: optional> + docs: >- + When present and set to true, returns the team member who is the owner + of the Square account. + source: + openapi: ../default/openapi/openapi.json + SearchTeamMembersQuery: + docs: Represents the parameters in a search for `TeamMember` objects. + properties: + filter: + type: optional + docs: The options to filter by. + source: + openapi: ../default/openapi/openapi.json + SearchTeamMembersResponse: + docs: >- + Represents a response from a search request containing a filtered list of + `TeamMember` objects. + properties: + team_members: + type: optional> + docs: The filtered list of `TeamMember` objects. + cursor: + type: optional + docs: >- + The opaque cursor for fetching the next page. For more information, + see + + [pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + SearchTerminalActionsResponse: + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + action: + type: optional> + docs: The requested search result of `TerminalAction`s. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more + + information. + source: + openapi: ../default/openapi/openapi.json + SearchTerminalCheckoutsResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + checkouts: + type: optional> + docs: The requested search result of `TerminalCheckout` objects. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + source: + openapi: ../default/openapi/openapi.json + SearchTerminalRefundsResponse: + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + refunds: + type: optional> + docs: The requested search result of `TerminalRefund` objects. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If empty, + + this is the final response. + + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + source: + openapi: ../default/openapi/openapi.json + SearchTimecardsResponse: + docs: >- + The response to a request for `Timecard` objects. The response contains + + the requested `Timecard` objects and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + timecards: + type: optional> + docs: Timecards. + cursor: + type: optional + docs: An opaque cursor for fetching the next page. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + SearchTransferOrdersResponse: + docs: Response for searching transfer orders + properties: + transfer_orders: + type: optional> + docs: List of transfer orders matching the search criteria + cursor: + type: optional + docs: Pagination cursor for fetching the next page of results + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + SearchVendorsRequestFilter: + docs: Defines supported query expressions to search for vendors by. + properties: + name: + type: optional>> + docs: The names of the [Vendor](entity:Vendor) objects to retrieve. + status: + type: optional>> + docs: |- + The statuses of the [Vendor](entity:Vendor) objects to retrieve. + See [VendorStatus](#type-vendorstatus) for possible values + source: + openapi: ../default/openapi/openapi.json + SearchVendorsRequestSort: + docs: >- + Defines a sorter used to sort results from + [SearchVendors](api-endpoint:Vendors-SearchVendors). + properties: + field: + type: optional + docs: |- + Specifies the sort key to sort the returned vendors. + See [Field](#type-field) for possible values + order: + type: optional + docs: |- + Specifies the sort order for the returned vendors. + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + SearchVendorsRequestSortField: + enum: + - NAME + - CREATED_AT + docs: The field to sort the returned [Vendor](entity:Vendor) objects by. + source: + openapi: ../default/openapi/openapi.json + SearchVendorsResponse: + docs: >- + Represents an output from a call to + [SearchVendors](api-endpoint:Vendors-SearchVendors). + properties: + errors: + type: optional> + docs: Errors encountered when the request fails. + vendors: + type: optional> + docs: >- + The [Vendor](entity:Vendor) objects matching the specified search + filter. + cursor: + type: optional + docs: >- + The pagination cursor to be used in a subsequent request. If unset, + + this is the final response. + + + See the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + source: + openapi: ../default/openapi/openapi.json + SegmentFilter: + docs: A query filter to search for buyer-accessible appointment segments by. + properties: + service_variation_id: + type: string + docs: >- + The ID of the [CatalogItemVariation](entity:CatalogItemVariation) + object representing the service booked in this segment. + validation: + minLength: 1 + maxLength: 36 + team_member_id_filter: + type: optional + docs: >- + A query filter to search for buyer-accessible appointment segments + with service-providing team members matching the specified list of + team member IDs. Supported query expressions are + + - `ANY`: return the appointment segments with team members whose IDs + match any member in this list. + + - `NONE`: return the appointment segments with team members whose IDs + are not in this list. + + - `ALL`: not supported. + + + When no expression is specified, any service-providing team member is + eligible to fulfill the Booking. + source: + openapi: ../default/openapi/openapi.json + SelectOption: + properties: + reference_id: + type: string + docs: The reference id for the option. + validation: + minLength: 1 + maxLength: 40 + title: + type: string + docs: The title text that displays in the select option button. + validation: + minLength: 1 + maxLength: 250 + source: + openapi: ../default/openapi/openapi.json + SelectOptions: + properties: + title: + type: string + docs: The title text to display in the select flow on the Terminal. + validation: + minLength: 1 + maxLength: 250 + body: + type: string + docs: The body text to display in the select flow on the Terminal. + validation: + minLength: 1 + maxLength: 10000 + options: + docs: >- + Represents the buttons/options that should be displayed in the select + flow on the Terminal. + type: list + selected_option: + type: optional + docs: The buyer’s selected option. + source: + openapi: ../default/openapi/openapi.json + Shift: + docs: >- + A record of the hourly rate, start, and end times for a single work shift + + for an employee. This might include a record of the start and end times + for breaks + + taken during the shift. + + + Deprecated at Square API version 2025-05-21. Replaced by + [Timecard](entity:Timecard). + + See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + properties: + id: + type: optional + docs: The UUID for this object. + validation: + maxLength: 255 + employee_id: + type: optional> + docs: >- + The ID of the employee this shift belongs to. DEPRECATED at version + 2020-08-26. Use `team_member_id` instead. + location_id: + type: string + docs: >- + The ID of the location this shift occurred at. The location should be + based on + + where the employee clocked in. + validation: + minLength: 1 + timezone: + type: optional> + docs: >- + The read-only convenience value that is calculated from the location + based + + on the `location_id`. Format: the IANA timezone database identifier + for the + + location timezone. + start_at: + type: string + docs: >- + RFC 3339; shifted to the location timezone + offset. Precision up to + the + + minute is respected; seconds are truncated. + validation: + minLength: 1 + end_at: + type: optional> + docs: >- + RFC 3339; shifted to the timezone + offset. Precision up to the minute + is + + respected; seconds are truncated. + wage: + type: optional + docs: >- + Job and pay related information. If the wage is not set on create, it + defaults to a wage + + of zero. If the title is not set on create, it defaults to the name of + the role the employee + + is assigned to, if any. + breaks: + type: optional>> + docs: >- + A list of all the paid or unpaid breaks that were taken during this + shift. + status: + type: optional + docs: |- + Describes the working state of the current `Shift`. + See [ShiftStatus](#type-shiftstatus) for possible values + version: + type: optional + docs: >- + Used for resolving concurrency issues. The request fails if the + version + + provided does not match the server version at the time of the request. + If not provided, + + Square executes a blind write; potentially overwriting data from + another + + write. + created_at: + type: optional + docs: A read-only timestamp in RFC 3339 format; presented in UTC. + access: read-only + updated_at: + type: optional + docs: A read-only timestamp in RFC 3339 format; presented in UTC. + access: read-only + team_member_id: + type: optional> + docs: >- + The ID of the team member this shift belongs to. Replaced + `employee_id` at version "2020-08-26". + declared_cash_tip_money: + type: optional + docs: The tips declared by the team member for the shift. + source: + openapi: ../default/openapi/openapi.json + ShiftFilter: + docs: >- + Defines a filter used in a search for `Shift` records. `AND` logic is + + used by Square's servers to apply each filter property specified. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + properties: + location_ids: + type: optional>> + docs: Fetch shifts for the specified location. + employee_ids: + type: optional>> + docs: >- + Fetch shifts for the specified employees. DEPRECATED at version + 2020-08-26. Use `team_member_ids` instead. + status: + type: optional + docs: |- + Fetch a `Shift` instance by `Shift.status`. + See [ShiftFilterStatus](#type-shiftfilterstatus) for possible values + start: + type: optional + docs: Fetch `Shift` instances that start in the time range - Inclusive. + end: + type: optional + docs: Fetch the `Shift` instances that end in the time range - Inclusive. + workday: + type: optional + docs: Fetch the `Shift` instances based on the workday date range. + team_member_ids: + type: optional>> + docs: >- + Fetch shifts for the specified team members. Replaced `employee_ids` + at version "2020-08-26". + source: + openapi: ../default/openapi/openapi.json + ShiftFilterStatus: + enum: + - OPEN + - CLOSED + docs: >- + Specifies the `status` of `Shift` records to be returned. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + source: + openapi: ../default/openapi/openapi.json + ShiftQuery: + docs: >- + The parameters of a `Shift` search query, which includes filter and sort + options. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + properties: + filter: + type: optional + docs: Query filter options. + sort: + type: optional + docs: Sort order details. + source: + openapi: ../default/openapi/openapi.json + ShiftSort: + docs: >- + Sets the sort order of search results. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + properties: + field: + type: optional + docs: |- + The field to sort on. + See [ShiftSortField](#type-shiftsortfield) for possible values + order: + type: optional + docs: |- + The order in which results are returned. Defaults to DESC. + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + ShiftSortField: + enum: + - START_AT + - END_AT + - CREATED_AT + - UPDATED_AT + docs: >- + Enumerates the `Shift` fields to sort on. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + source: + openapi: ../default/openapi/openapi.json + ShiftStatus: + enum: + - OPEN + - CLOSED + docs: >- + Enumerates the possible status of a `Shift`. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + source: + openapi: ../default/openapi/openapi.json + ShiftWage: + docs: >- + The hourly wage rate used to compensate an employee for this shift. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + properties: + title: + type: optional> + docs: The name of the job performed during this shift. + hourly_rate: + type: optional + docs: |- + Can be a custom-set hourly wage or the calculated effective hourly + wage based on the annual wage and hours worked per week. + job_id: + type: optional + docs: |- + The id of the job performed during this shift. Square + labor-reporting UIs might group shifts together by id. + access: read-only + tip_eligible: + type: optional> + docs: Whether team members are eligible for tips when working this job. + source: + openapi: ../default/openapi/openapi.json + ShiftWorkday: + docs: >- + A `Shift` search query filter parameter that sets a range of days that + + a `Shift` must start or end in before passing the filter condition. + + + Deprecated at Square API version 2025-05-21. See the [migration + notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). + properties: + date_range: + type: optional + docs: Dates for fetching the shifts. + match_shifts_by: + type: optional + docs: >- + The strategy on which the dates are applied. + + See [ShiftWorkdayMatcher](#type-shiftworkdaymatcher) for possible + values + default_timezone: + type: optional> + docs: >- + Location-specific timezones convert workdays to datetime filters. + + Every location included in the query must have a timezone or this + field + + must be provided as a fallback. Format: the IANA timezone database + + identifier for the relevant timezone. + source: + openapi: ../default/openapi/openapi.json + ShiftWorkdayMatcher: + enum: + - START_AT + - END_AT + - INTERSECTION + docs: Defines the logic used to apply a workday filter. + source: + openapi: ../default/openapi/openapi.json + ShippingFee: + properties: + name: + type: optional> + docs: The name for the shipping fee. + charge: + type: Money + docs: The amount and currency for the shipping fee. + source: + openapi: ../default/openapi/openapi.json + SignatureImage: + properties: + image_type: + type: optional + docs: |- + The mime/type of the image data. + Use `image/png;base64` for png. + access: read-only + data: + type: optional + docs: The base64 representation of the image. + access: read-only + source: + openapi: ../default/openapi/openapi.json + SignatureOptions: + properties: + title: + type: string + docs: >- + The title text to display in the signature capture flow on the + Terminal. + validation: + minLength: 1 + maxLength: 250 + body: + type: string + docs: >- + The body text to display in the signature capture flow on the + Terminal. + validation: + minLength: 1 + maxLength: 10000 + signature: + type: optional> + docs: An image representation of the collected signature. + access: read-only + source: + openapi: ../default/openapi/openapi.json + Site: + docs: >- + Represents a Square Online site, which is an online store for a Square + seller. + properties: + id: + type: optional + docs: The Square-assigned ID of the site. + validation: + maxLength: 32 + access: read-only + site_title: + type: optional> + docs: The title of the site. + domain: + type: optional> + docs: >- + The domain of the site (without the protocol). For example, + `mysite1.square.site`. + is_published: + type: optional> + docs: Indicates whether the site is published. + created_at: + type: optional + docs: The timestamp of when the site was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: The timestamp of when the site was last updated, in RFC 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + Snippet: + docs: >- + Represents the snippet that is added to a Square Online site. The snippet + code is injected into the `head` element of all pages on the site, except + for checkout pages. + properties: + id: + type: optional + docs: The Square-assigned ID for the snippet. + validation: + maxLength: 48 + access: read-only + site_id: + type: optional + docs: The ID of the site that contains the snippet. + access: read-only + content: + type: string + docs: The snippet code, which can contain valid HTML, JavaScript, or both. + validation: + minLength: 1 + maxLength: 65535 + created_at: + type: optional + docs: >- + The timestamp of when the snippet was initially added to the site, in + RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp of when the snippet was last updated on the site, in RFC + 3339 format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + SortOrder: + enum: + - DESC + - ASC + docs: >- + The order (e.g., chronological or alphabetical) in which results from a + request are returned. + source: + openapi: ../default/openapi/openapi.json + SourceApplication: + docs: Represents information about the application used to generate a change. + properties: + product: + type: optional + docs: |- + __Read only__ The [product](entity:Product) type of the application. + See [Product](#type-product) for possible values + application_id: + type: optional> + docs: >- + __Read only__ The Square-assigned ID of the application. This field is + used only if the + + [product](entity:Product) type is `EXTERNAL_API`. + name: + type: optional> + docs: >- + __Read only__ The display name of the application + + (for example, `"Custom Application"` or `"Square POS 4.74 for + Android"`). + source: + openapi: ../default/openapi/openapi.json + SquareAccountDetails: + docs: Additional details about Square Account payments. + properties: + payment_source_token: + type: optional> + docs: Unique identifier for the payment source used for this payment. + validation: + maxLength: 255 + errors: + type: optional>> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + StandardUnitDescription: + docs: Contains the name and abbreviation for standard measurement unit. + properties: + unit: + type: optional + docs: Identifies the measurement unit being described. + name: + type: optional> + docs: UI display name of the measurement unit. For example, 'Pound'. + abbreviation: + type: optional> + docs: UI display abbreviation for the measurement unit. For example, 'lb'. + source: + openapi: ../default/openapi/openapi.json + StandardUnitDescriptionGroup: + docs: Group of standard measurement units. + properties: + standard_unit_descriptions: + type: optional>> + docs: >- + List of standard (non-custom) measurement units in this description + group. + language_code: + type: optional> + docs: IETF language tag. + source: + openapi: ../default/openapi/openapi.json + StartTransferOrderResponse: + docs: Response for starting a transfer order. + properties: + transfer_order: + type: optional + docs: The updated transfer order with status changed to STARTED + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + SubmitEvidenceResponse: + docs: Defines the fields in a `SubmitEvidence` response. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + dispute: + type: optional + docs: The `Dispute` for which evidence was submitted. + source: + openapi: ../default/openapi/openapi.json + Subscription: + docs: >- + Represents a subscription purchased by a customer. + + + For more information, see + + [Manage + Subscriptions](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions). + properties: + id: + type: optional + docs: The Square-assigned ID of the subscription. + validation: + maxLength: 255 + access: read-only + location_id: + type: optional + docs: The ID of the location associated with the subscription. + access: read-only + plan_variation_id: + type: optional + docs: >- + The ID of the subscribed-to [subscription plan + variation](entity:CatalogSubscriptionPlanVariation). + access: read-only + customer_id: + type: optional + docs: The ID of the subscribing [customer](entity:Customer) profile. + access: read-only + start_date: + type: optional + docs: >- + The `YYYY-MM-DD`-formatted date (for example, 2013-01-15) to start the + subscription. + access: read-only + canceled_date: + type: optional> + docs: >- + The `YYYY-MM-DD`-formatted date (for example, 2013-01-15) to cancel + the subscription, + + when the subscription status changes to `CANCELED` and the + subscription billing stops. + + + If this field is not set, the subscription ends according its + subscription plan. + + + This field cannot be updated, other than being cleared. + charged_through_date: + type: optional + docs: >- + The `YYYY-MM-DD`-formatted date up to when the subscriber is invoiced + for the + + subscription. + + + After the invoice is sent for a given billing period, + + this date will be the last day of the billing period. + + For example, + + suppose for the month of May a subscriber gets an invoice + + (or charged the card) on May 1. For the monthly billing scenario, + + this date is then set to May 31. + access: read-only + status: + type: optional + docs: |- + The current status of the subscription. + See [SubscriptionStatus](#type-subscriptionstatus) for possible values + tax_percentage: + type: optional> + docs: |- + The tax amount applied when billing the subscription. The + percentage is expressed in decimal form, using a `'.'` as the decimal + separator and without a `'%'` sign. For example, a value of `7.5` + corresponds to 7.5%. + invoice_ids: + type: optional> + docs: |- + The IDs of the [invoices](entity:Invoice) created for the + subscription, listed in order when the invoices were created + (newest invoices appear first). + access: read-only + price_override_money: + type: optional + docs: >- + A custom price which overrides the cost of a subscription plan + variation with `STATIC` pricing. + + This field does not affect itemized subscriptions with `RELATIVE` + pricing. Instead, + + you should edit the Subscription's [order + template](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#phases-and-order-templates). + version: + type: optional + docs: >- + The version of the object. When updating an object, the version + + supplied must match the version in the database, otherwise the write + will + + be rejected as conflicting. + created_at: + type: optional + docs: The timestamp when the subscription was created, in RFC 3339 format. + access: read-only + card_id: + type: optional> + docs: |- + The ID of the [subscriber's](entity:Customer) [card](entity:Card) + used to charge for the subscription. + timezone: + type: optional + docs: >- + Timezone that will be used in date calculations for the subscription. + + Defaults to the timezone of the location based on `location_id`. + + Format: the IANA Timezone Database identifier for the location + timezone (for example, `America/Los_Angeles`). + access: read-only + source: + type: optional + docs: The origination details of the subscription. + actions: + type: optional>> + docs: >- + The list of scheduled actions on this subscription. It is set only in + the response from + + [RetrieveSubscription](api-endpoint:Subscriptions-RetrieveSubscription) + with the query parameter + + of `include=actions` or from + + [SearchSubscriptions](api-endpoint:Subscriptions-SearchSubscriptions) + with the input parameter + + of `include:["actions"]`. + monthly_billing_anchor_date: + type: optional + docs: >- + The day of the month on which the subscription will issue invoices and + publish orders. + access: read-only + phases: + type: optional> + docs: array of phases for this subscription + access: read-only + completed_date: + type: optional> + docs: >- + The `YYYY-MM-DD`-formatted date when the subscription enters a + terminal state. + source: + openapi: ../default/openapi/openapi.json + SubscriptionAction: + docs: Represents an action as a pending change to a subscription. + properties: + id: + type: optional + docs: The ID of an action scoped to a subscription. + type: + type: optional + docs: >- + The type of the action. + + See [SubscriptionActionType](#type-subscriptionactiontype) for + possible values + effective_date: + type: optional> + docs: >- + The `YYYY-MM-DD`-formatted date when the action occurs on the + subscription. + monthly_billing_anchor_date: + type: optional> + docs: >- + The new billing anchor day value, for a `CHANGE_BILLING_ANCHOR_DATE` + action. + phases: + type: optional>> + docs: A list of Phases, to pass phase-specific information used in the swap. + new_plan_variation_id: + type: optional> + docs: >- + The target subscription plan variation that a subscription switches + to, for a `SWAP_PLAN` action. + source: + openapi: ../default/openapi/openapi.json + SubscriptionActionType: + enum: + - CANCEL + - PAUSE + - RESUME + - SWAP_PLAN + - CHANGE_BILLING_ANCHOR_DATE + - COMPLETE + docs: Supported types of an action as a pending change to a subscription. + source: + openapi: ../default/openapi/openapi.json + SubscriptionCadence: + enum: + - DAILY + - WEEKLY + - EVERY_TWO_WEEKS + - THIRTY_DAYS + - SIXTY_DAYS + - NINETY_DAYS + - MONTHLY + - EVERY_TWO_MONTHS + - QUARTERLY + - EVERY_FOUR_MONTHS + - EVERY_SIX_MONTHS + - ANNUAL + - EVERY_TWO_YEARS + docs: Determines the billing cadence of a [Subscription](entity:Subscription) + source: + openapi: ../default/openapi/openapi.json + SubscriptionCreatedEvent: + docs: Published when a [Subscription](entity:Subscription) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"subscription.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + SubscriptionCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"subscription"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected subscription. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the created subscription. + source: + openapi: ../default/openapi/openapi.json + SubscriptionCreatedEventObject: + properties: + subscription: + type: optional + docs: The created subscription. + source: + openapi: ../default/openapi/openapi.json + SubscriptionEvent: + docs: Describes changes to a subscription and the subscription status. + properties: + id: + type: string + docs: The ID of the subscription event. + subscription_event_type: + type: SubscriptionEventSubscriptionEventType + docs: >- + Type of the subscription event. + + See + [SubscriptionEventSubscriptionEventType](#type-subscriptioneventsubscriptioneventtype) + for possible values + effective_date: + type: string + docs: >- + The `YYYY-MM-DD`-formatted date (for example, 2013-01-15) when the + subscription event occurred. + monthly_billing_anchor_date: + type: optional + docs: >- + The day-of-the-month the billing anchor date was changed to, if + applicable. + access: read-only + info: + type: optional + docs: Additional information about the subscription event. + phases: + type: optional>> + docs: A list of Phases, to pass phase-specific information used in the swap. + plan_variation_id: + type: string + docs: >- + The ID of the subscription plan variation associated with the + subscription. + source: + openapi: ../default/openapi/openapi.json + SubscriptionEventInfo: + docs: Provides information about the subscription event. + properties: + detail: + type: optional> + docs: A human-readable explanation for the event. + code: + type: optional + docs: |- + An info code indicating the subscription event that occurred. + See [InfoCode](#type-infocode) for possible values + source: + openapi: ../default/openapi/openapi.json + SubscriptionEventInfoCode: + enum: + - LOCATION_NOT_ACTIVE + - LOCATION_CANNOT_ACCEPT_PAYMENT + - CUSTOMER_DELETED + - CUSTOMER_NO_EMAIL + - CUSTOMER_NO_NAME + - USER_PROVIDED + docs: Supported info codes of a subscription event. + source: + openapi: ../default/openapi/openapi.json + SubscriptionEventSubscriptionEventType: + enum: + - START_SUBSCRIPTION + - PLAN_CHANGE + - STOP_SUBSCRIPTION + - DEACTIVATE_SUBSCRIPTION + - RESUME_SUBSCRIPTION + - PAUSE_SUBSCRIPTION + - BILLING_ANCHOR_DATE_CHANGED + docs: Supported types of an event occurred to a subscription. + source: + openapi: ../default/openapi/openapi.json + SubscriptionPhase: + docs: >- + Describes a phase in a subscription plan variation. For more information, + see [Subscription Plans and + Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). + properties: + uid: + type: optional> + docs: >- + The Square-assigned ID of the subscription phase. This field cannot be + changed after a `SubscriptionPhase` is created. + cadence: + type: SubscriptionCadence + docs: >- + The billing cadence of the phase. For example, weekly or monthly. This + field cannot be changed after a `SubscriptionPhase` is created. + + See [SubscriptionCadence](#type-subscriptioncadence) for possible + values + periods: + type: optional> + docs: >- + The number of `cadence`s the phase lasts. If not set, the phase never + ends. Only the last phase can be indefinite. This field cannot be + changed after a `SubscriptionPhase` is created. + recurring_price_money: + type: optional + docs: >- + The amount to bill for each `cadence`. Failure to specify this field + results in a `MISSING_REQUIRED_PARAMETER` error at runtime. + ordinal: + type: optional> + docs: >- + The position this phase appears in the sequence of phases defined for + the plan, indexed from 0. This field cannot be changed after a + `SubscriptionPhase` is created. + pricing: + type: optional + docs: The subscription pricing. + source: + openapi: ../default/openapi/openapi.json + SubscriptionPricing: + docs: Describes the pricing for the subscription. + properties: + type: + type: optional + docs: >- + RELATIVE or STATIC + + See [SubscriptionPricingType](#type-subscriptionpricingtype) for + possible values + discount_ids: + type: optional>> + docs: The ids of the discount catalog objects + price_money: + type: optional + docs: The price of the subscription, if STATIC + source: + openapi: ../default/openapi/openapi.json + SubscriptionPricingType: + enum: + - STATIC + - RELATIVE + docs: Determines the pricing of a [Subscription](entity:Subscription) + source: + openapi: ../default/openapi/openapi.json + SubscriptionSource: + docs: The origination details of the subscription. + properties: + name: + type: optional> + docs: |- + The name used to identify the place (physical or digital) that + a subscription originates. If unset, the name defaults to the name + of the application that created the subscription. + validation: + maxLength: 255 + source: + openapi: ../default/openapi/openapi.json + SubscriptionStatus: + enum: + - PENDING + - ACTIVE + - CANCELED + - DEACTIVATED + - PAUSED + - COMPLETED + docs: Supported subscription statuses. + source: + openapi: ../default/openapi/openapi.json + SubscriptionTestResult: + docs: >- + Represents the details of a webhook subscription, including notification + URL, + + event types, and signature key. + properties: + id: + type: optional + docs: A Square-generated unique ID for the subscription test result. + validation: + maxLength: 64 + access: read-only + status_code: + type: optional> + docs: The status code returned by the subscription notification URL. + payload: + type: optional> + docs: >- + An object containing the payload of the test event. For example, a + `payment.created` event. + created_at: + type: optional + docs: >- + The timestamp of when the subscription was created, in RFC 3339 + format. + + For example, "2016-09-04T23:59:33.123Z". + access: read-only + updated_at: + type: optional + docs: >- + The timestamp of when the subscription was updated, in RFC 3339 + format. For example, "2016-09-04T23:59:33.123Z". + + Because a subscription test result is unique, this field is the same + as the `created_at` field. + access: read-only + source: + openapi: ../default/openapi/openapi.json + SubscriptionUpdatedEvent: + docs: >- + Published when a [Subscription](entity:Subscription) is updated. + + Typically the `subscription.status` is updated as subscriptions become + active + + or cancelled. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"subscription.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + SubscriptionUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"subscription"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected subscription. + validation: + maxLength: 255 + object: + type: optional + docs: An object containing the updated subscription. + source: + openapi: ../default/openapi/openapi.json + SubscriptionUpdatedEventObject: + properties: + subscription: + type: optional + docs: The updated subscription. + source: + openapi: ../default/openapi/openapi.json + SwapPlanResponse: + docs: |- + Defines output parameters in a response of the + [SwapPlan](api-endpoint:Subscriptions-SwapPlan) endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The subscription with the updated subscription plan. + actions: + type: optional> + docs: A list of a `SWAP_PLAN` action created by the request. + source: + openapi: ../default/openapi/openapi.json + TaxCalculationPhase: + enum: + - TAX_SUBTOTAL_PHASE + - TAX_TOTAL_PHASE + docs: When to calculate the taxes due on a cart. + source: + openapi: ../default/openapi/openapi.json + TaxIds: + docs: Identifiers for the location used by various governments for tax purposes. + properties: + eu_vat: + type: optional + docs: |- + The EU VAT number for this location. For example, `IE3426675K`. + If the EU VAT number is present, it is well-formed and has been + validated with VIES, the VAT Information Exchange System. + access: read-only + fr_siret: + type: optional + docs: >- + The SIRET (Système d'Identification du Répertoire des Entreprises et + de leurs Etablissements) + + number is a 14-digit code issued by the French INSEE. For example, + `39922799000021`. + access: read-only + fr_naf: + type: optional + docs: >- + The French government uses the NAF (Nomenclature des Activités + Françaises) to display and + + track economic statistical data. This is also called the APE (Activite + Principale de l’Entreprise) code. + + For example, `6910Z`. + access: read-only + es_nif: + type: optional + docs: >- + The NIF (Numero de Identificacion Fiscal) number is a nine-character + tax identifier used in Spain. + + If it is present, it has been validated. For example, `73628495A`. + access: read-only + jp_qii: + type: optional + docs: >- + The QII (Qualified Invoice Issuer) number is a 14-character tax + identifier used in Japan. + + For example, `T1234567890123`. + access: read-only + source: + openapi: ../default/openapi/openapi.json + TaxInclusionType: + enum: + - ADDITIVE + - INCLUSIVE + docs: >- + Whether to the tax amount should be additional to or included in the + CatalogItem price. + source: + openapi: ../default/openapi/openapi.json + TeamMember: + docs: A record representing an individual team member for a business. + properties: + id: + type: optional + docs: The unique ID for the team member. + access: read-only + reference_id: + type: optional> + docs: >- + A second ID used to associate the team member with an entity in + another system. + is_owner: + type: optional + docs: Whether the team member is the owner of the Square account. + access: read-only + status: + type: optional + docs: |- + Describes the status of the team member. + See [TeamMemberStatus](#type-teammemberstatus) for possible values + given_name: + type: optional> + docs: >- + The given name (that is, the first name) associated with the team + member. + family_name: + type: optional> + docs: >- + The family name (that is, the last name) associated with the team + member. + email_address: + type: optional> + docs: >- + The email address associated with the team member. After accepting the + invitation + + from Square, only the team member can change this value. + phone_number: + type: optional> + docs: |- + The team member's phone number, in E.164 format. For example: + +14155552671 - the country code is 1 for US + +551155256325 - the country code is 55 for BR + created_at: + type: optional + docs: The timestamp when the team member was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp when the team member was last updated, in RFC 3339 + format. + access: read-only + assigned_locations: + type: optional + docs: Describes the team member's assigned locations. + wage_setting: + type: optional + docs: >- + Information about the team member's overtime exemption status, job + assignments, and compensation. + source: + openapi: ../default/openapi/openapi.json + TeamMemberAssignedLocations: + docs: An object that represents a team member's assignment to locations. + properties: + assignment_type: + type: optional + docs: >- + The current assignment type of the team member. + + See + [TeamMemberAssignedLocationsAssignmentType](#type-teammemberassignedlocationsassignmenttype) + for possible values + location_ids: + type: optional>> + docs: The explicit locations that the team member is assigned to. + source: + openapi: ../default/openapi/openapi.json + TeamMemberAssignedLocationsAssignmentType: + enum: + - ALL_CURRENT_AND_FUTURE_LOCATIONS + - EXPLICIT_LOCATIONS + docs: Enumerates the possible assignment types that the team member can have. + source: + openapi: ../default/openapi/openapi.json + TeamMemberBookingProfile: + docs: >- + The booking profile of a seller's team member, including the team member's + ID, display name, description and whether the team member can be booked as + a service provider. + properties: + team_member_id: + type: optional + docs: >- + The ID of the [TeamMember](entity:TeamMember) object for the team + member associated with the booking profile. + validation: + maxLength: 32 + access: read-only + description: + type: optional + docs: The description of the team member. + validation: + maxLength: 65536 + access: read-only + display_name: + type: optional + docs: The display name of the team member. + validation: + maxLength: 512 + access: read-only + is_bookable: + type: optional> + docs: >- + Indicates whether the team member can be booked through the Bookings + API or the seller's online booking channel or site (`true`) or not + (`false`). + profile_image_url: + type: optional + docs: The URL of the team member's image for the bookings profile. + validation: + maxLength: 2048 + access: read-only + source: + openapi: ../default/openapi/openapi.json + TeamMemberCreatedEvent: + docs: Published when a Team Member is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"team_member.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TeamMemberCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"team_member"`. + id: + type: optional + docs: ID of the created team member. + object: + type: optional + docs: An object containing the created team member. + source: + openapi: ../default/openapi/openapi.json + TeamMemberCreatedEventObject: + properties: + team_member: + type: optional + docs: The created team member. + source: + openapi: ../default/openapi/openapi.json + TeamMemberInvitationStatus: + enum: + - UNINVITED + - PENDING + - ACCEPTED + docs: >- + Enumerates the possible invitation statuses the team member can have + within a business. + source: + openapi: ../default/openapi/openapi.json + TeamMemberStatus: + enum: + - ACTIVE + - INACTIVE + docs: >- + Enumerates the possible statuses the team member can have within a + business. + source: + openapi: ../default/openapi/openapi.json + TeamMemberUpdatedEvent: + docs: Published when a Team Member is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"team_member.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TeamMemberUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"team_member"`. + id: + type: optional + docs: ID of the affected team member. + object: + type: optional + docs: An object containing the updated team member. + source: + openapi: ../default/openapi/openapi.json + TeamMemberUpdatedEventObject: + properties: + team_member: + type: optional + docs: The updated team member. + source: + openapi: ../default/openapi/openapi.json + TeamMemberWage: + docs: |- + Job and wage information for a [team member](entity:TeamMember). + This convenience object provides details needed to specify the `wage` + field for a [timecard](entity:Timecard). + properties: + id: + type: optional + docs: The UUID for this object. + team_member_id: + type: optional> + docs: The `TeamMember` that this wage is assigned to. + title: + type: optional> + docs: The job title that this wage relates to. + hourly_rate: + type: optional + docs: |- + Can be a custom-set hourly wage or the calculated effective hourly + wage based on the annual wage and hours worked per week. + job_id: + type: optional> + docs: An identifier for the [job](entity:Job) that this wage relates to. + tip_eligible: + type: optional> + docs: Whether team members are eligible for tips when working this job. + source: + openapi: ../default/openapi/openapi.json + TeamMemberWageSettingUpdatedEvent: + docs: Published when a Wage Setting is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: >- + The type of event this represents, + `"team_member.wage_setting.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TeamMemberWageSettingUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"wage_setting"`. + id: + type: optional + docs: ID of the updated team member wage setting. + object: + type: optional + docs: An object containing the updated team member wage setting. + source: + openapi: ../default/openapi/openapi.json + TeamMemberWageSettingUpdatedEventObject: + properties: + wage_setting: + type: optional + docs: The updated team member wage setting. + source: + openapi: ../default/openapi/openapi.json + Tender: + docs: >- + Represents a tender (i.e., a method of payment) used in a Square + transaction. + properties: + id: + type: optional + docs: The tender's unique ID. It is the associated payment ID. + validation: + maxLength: 192 + location_id: + type: optional> + docs: The ID of the transaction's associated location. + validation: + maxLength: 50 + transaction_id: + type: optional> + docs: The ID of the tender's associated transaction. + validation: + maxLength: 192 + created_at: + type: optional + docs: The timestamp for when the tender was created, in RFC 3339 format. + validation: + maxLength: 32 + access: read-only + note: + type: optional> + docs: An optional note associated with the tender at the time of payment. + validation: + maxLength: 500 + amount_money: + type: optional + docs: >- + The total amount of the tender, including `tip_money`. If the tender + has a `payment_id`, + + the `total_money` of the corresponding [Payment](entity:Payment) will + be equal to the + + `amount_money` of the tender. + tip_money: + type: optional + docs: The tip's amount of the tender. + processing_fee_money: + type: optional + docs: >- + The amount of any Square processing fees applied to the tender. + + + This field is not immediately populated when a new transaction is + created. + + It is usually available after about ten seconds. + customer_id: + type: optional> + docs: >- + If the tender is associated with a customer or represents a customer's + card on file, + + this is the ID of the associated customer. + validation: + maxLength: 191 + type: + type: TenderType + docs: |- + The type of tender, such as `CARD` or `CASH`. + See [TenderType](#type-tendertype) for possible values + card_details: + type: optional + docs: |- + The details of the card tender. + + This value is present only if the value of `type` is `CARD`. + cash_details: + type: optional + docs: |- + The details of the cash tender. + + This value is present only if the value of `type` is `CASH`. + bank_account_details: + type: optional + docs: |- + The details of the bank account tender. + + This value is present only if the value of `type` is `BANK_ACCOUNT`. + buy_now_pay_later_details: + type: optional + docs: >- + The details of a Buy Now Pay Later tender. + + + This value is present only if the value of `type` is + `BUY_NOW_PAY_LATER`. + square_account_details: + type: optional + docs: |- + The details of a Square Account tender. + + This value is present only if the value of `type` is `SQUARE_ACCOUNT`. + additional_recipients: + type: optional>> + docs: >- + Additional recipients (other than the merchant) receiving a portion of + this tender. + + For example, fees assessed on the purchase by a third party + integration. + payment_id: + type: optional> + docs: >- + The ID of the [Payment](entity:Payment) that corresponds to this + tender. + + This value is only present for payments created with the v2 Payments + API. + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + TenderBankAccountDetails: + docs: |- + Represents the details of a tender with `type` `BANK_ACCOUNT`. + + See [BankAccountPaymentDetails](entity:BankAccountPaymentDetails) + for more exposed details of a bank account payment. + properties: + status: + type: optional + docs: >- + The bank account payment's current state. + + + See + [TenderBankAccountPaymentDetailsStatus](entity:TenderBankAccountDetailsStatus) + for possible values. + + See + [TenderBankAccountDetailsStatus](#type-tenderbankaccountdetailsstatus) + for possible values + source: + openapi: ../default/openapi/openapi.json + TenderBankAccountDetailsStatus: + enum: + - PENDING + - COMPLETED + - FAILED + docs: Indicates the bank account payment's current status. + source: + openapi: ../default/openapi/openapi.json + TenderBuyNowPayLaterDetails: + docs: Represents the details of a tender with `type` `BUY_NOW_PAY_LATER`. + properties: + buy_now_pay_later_brand: + type: optional + docs: |- + The Buy Now Pay Later brand. + See [Brand](#type-brand) for possible values + status: + type: optional + docs: >- + The buy now pay later payment's current state (such as `AUTHORIZED` or + + `CAPTURED`). See + [TenderBuyNowPayLaterDetailsStatus](entity:TenderBuyNowPayLaterDetailsStatus) + + for possible values. + + See [Status](#type-status) for possible values + source: + openapi: ../default/openapi/openapi.json + TenderBuyNowPayLaterDetailsBrand: + enum: + - OTHER_BRAND + - AFTERPAY + source: + openapi: ../default/openapi/openapi.json + TenderBuyNowPayLaterDetailsStatus: + enum: + - AUTHORIZED + - CAPTURED + - VOIDED + - FAILED + source: + openapi: ../default/openapi/openapi.json + TenderCardDetails: + docs: >- + Represents additional details of a tender with `type` `CARD` or + `SQUARE_GIFT_CARD` + properties: + status: + type: optional + docs: >- + The credit card payment's current state (such as `AUTHORIZED` or + + `CAPTURED`). See + [TenderCardDetailsStatus](entity:TenderCardDetailsStatus) + + for possible values. + + See [TenderCardDetailsStatus](#type-tendercarddetailsstatus) for + possible values + card: + type: optional + docs: The credit card's non-confidential details. + entry_method: + type: optional + docs: >- + The method used to enter the card's details for the transaction. + + See [TenderCardDetailsEntryMethod](#type-tendercarddetailsentrymethod) + for possible values + source: + openapi: ../default/openapi/openapi.json + TenderCardDetailsEntryMethod: + enum: + - SWIPED + - KEYED + - EMV + - ON_FILE + - CONTACTLESS + docs: Indicates the method used to enter the card's details. + source: + openapi: ../default/openapi/openapi.json + TenderCardDetailsStatus: + enum: + - AUTHORIZED + - CAPTURED + - VOIDED + - FAILED + docs: Indicates the card transaction's current status. + source: + openapi: ../default/openapi/openapi.json + TenderCashDetails: + docs: Represents the details of a tender with `type` `CASH`. + properties: + buyer_tendered_money: + type: optional + docs: >- + The total amount of cash provided by the buyer, before change is + given. + change_back_money: + type: optional + docs: The amount of change returned to the buyer. + source: + openapi: ../default/openapi/openapi.json + TenderSquareAccountDetails: + docs: Represents the details of a tender with `type` `SQUARE_ACCOUNT`. + properties: + status: + type: optional + docs: >- + The Square Account payment's current state (such as `AUTHORIZED` or + + `CAPTURED`). See + [TenderSquareAccountDetailsStatus](entity:TenderSquareAccountDetailsStatus) + + for possible values. + + See [Status](#type-status) for possible values + source: + openapi: ../default/openapi/openapi.json + TenderSquareAccountDetailsStatus: + enum: + - AUTHORIZED + - CAPTURED + - VOIDED + - FAILED + source: + openapi: ../default/openapi/openapi.json + TenderType: + enum: + - CARD + - CASH + - THIRD_PARTY_CARD + - SQUARE_GIFT_CARD + - NO_SALE + - BANK_ACCOUNT + - WALLET + - BUY_NOW_PAY_LATER + - SQUARE_ACCOUNT + - OTHER + docs: Indicates a tender's type. + source: + openapi: ../default/openapi/openapi.json + TerminalAction: + docs: Represents an action processed by the Square Terminal. + properties: + id: + type: optional + docs: A unique ID for this `TerminalAction`. + validation: + minLength: 10 + maxLength: 255 + access: read-only + device_id: + type: optional> + docs: |- + The unique Id of the device intended for this `TerminalAction`. + The Id can be retrieved from /v2/devices api. + deadline_duration: + type: optional> + docs: >- + The duration as an RFC 3339 duration, after which the action will be + automatically canceled. + + TerminalActions that are `PENDING` will be automatically `CANCELED` + and have a cancellation reason + + of `TIMED_OUT` + + + Default: 5 minutes from creation + + + Maximum: 5 minutes + status: + type: optional + docs: >- + The status of the `TerminalAction`. + + Options: `PENDING`, `IN_PROGRESS`, `CANCEL_REQUESTED`, `CANCELED`, + `COMPLETED` + access: read-only + cancel_reason: + type: optional + docs: >- + The reason why `TerminalAction` is canceled. Present if the status is + `CANCELED`. + + See [ActionCancelReason](#type-actioncancelreason) for possible values + created_at: + type: optional + docs: >- + The time when the `TerminalAction` was created as an RFC 3339 + timestamp. + access: read-only + updated_at: + type: optional + docs: >- + The time when the `TerminalAction` was last updated as an RFC 3339 + timestamp. + access: read-only + app_id: + type: optional + docs: The ID of the application that created the action. + access: read-only + location_id: + type: optional + docs: The location id the action is attached to, if a link can be made. + validation: + maxLength: 64 + access: read-only + type: + type: optional + docs: |- + Represents the type of the action. + See [ActionType](#type-actiontype) for possible values + qr_code_options: + type: optional + docs: >- + Describes configuration for the QR code action. Requires `QR_CODE` + type. + save_card_options: + type: optional + docs: >- + Describes configuration for the save-card action. Requires `SAVE_CARD` + type. + signature_options: + type: optional + docs: >- + Describes configuration for the signature capture action. Requires + `SIGNATURE` type. + confirmation_options: + type: optional + docs: >- + Describes configuration for the confirmation action. Requires + `CONFIRMATION` type. + receipt_options: + type: optional + docs: >- + Describes configuration for the receipt action. Requires `RECEIPT` + type. + data_collection_options: + type: optional + docs: >- + Describes configuration for the data collection action. Requires + `DATA_COLLECTION` type. + select_options: + type: optional + docs: Describes configuration for the select action. Requires `SELECT` type. + device_metadata: + type: optional + docs: >- + Details about the Terminal that received the action request (such as + battery level, + + operating system version, and network connection settings). + + + Only available for `PING` action type. + await_next_action: + type: optional> + docs: >- + Indicates the action will be linked to another action and requires a + waiting dialog to be + + displayed instead of returning to the idle screen on completion of the + action. + + + Only supported on SIGNATURE, CONFIRMATION, DATA_COLLECTION, and SELECT + types. + await_next_action_duration: + type: optional> + docs: >- + The timeout duration of the waiting dialog as an RFC 3339 duration, + after which the + + waiting dialog will no longer be displayed and the Terminal will + return to the idle screen. + + + Default: 5 minutes from when the waiting dialog is displayed + + + Maximum: 5 minutes + source: + openapi: ../default/openapi/openapi.json + TerminalActionActionType: + enum: + - QR_CODE + - PING + - SAVE_CARD + - SIGNATURE + - CONFIRMATION + - RECEIPT + - DATA_COLLECTION + - SELECT + docs: >- + Describes the type of this unit and indicates which field contains the + unit information. This is an ‘open’ enum. + source: + openapi: ../default/openapi/openapi.json + TerminalActionCreatedEvent: + docs: Published when a TerminalAction is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"terminal.action.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TerminalActionCreatedEventData: + properties: + type: + type: optional> + docs: Name of the created object’s type, `"action"`. + id: + type: optional + docs: ID of the created terminal action. + object: + type: optional + docs: An object containing the created terminal action. + source: + openapi: ../default/openapi/openapi.json + TerminalActionCreatedEventObject: + properties: + action: + type: optional + docs: The created terminal action. + source: + openapi: ../default/openapi/openapi.json + TerminalActionQuery: + properties: + filter: + type: optional + docs: Options for filtering returned `TerminalAction`s + sort: + type: optional + docs: Option for sorting returned `TerminalAction` objects. + source: + openapi: ../default/openapi/openapi.json + TerminalActionQueryFilter: + properties: + device_id: + type: optional> + docs: >- + `TerminalAction`s associated with a specific device. If no device is + specified then all + + `TerminalAction`s for the merchant will be displayed. + created_at: + type: optional + docs: |- + Time range for the beginning of the reporting period. Inclusive. + Default value: The current time minus one day. + Note that `TerminalAction`s are available for 30 days after creation. + status: + type: optional> + docs: >- + Filter results with the desired status of the `TerminalAction` + + Options: `PENDING`, `IN_PROGRESS`, `CANCEL_REQUESTED`, `CANCELED`, + `COMPLETED` + type: + type: optional + docs: >- + Filter results with the requested ActionType. + + See [TerminalActionActionType](#type-terminalactionactiontype) for + possible values + source: + openapi: ../default/openapi/openapi.json + TerminalActionQuerySort: + properties: + sort_order: + type: optional + docs: |- + The order in which results are listed. + - `ASC` - Oldest to newest. + - `DESC` - Newest to oldest (default). + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + TerminalActionUpdatedEvent: + docs: Published when a TerminalAction is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"terminal.action.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TerminalActionUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the updated object’s type, `"action"`. + id: + type: optional + docs: ID of the updated terminal action. + object: + type: optional + docs: An object containing the updated terminal action. + source: + openapi: ../default/openapi/openapi.json + TerminalActionUpdatedEventObject: + properties: + action: + type: optional + docs: The updated terminal action. + source: + openapi: ../default/openapi/openapi.json + TerminalCheckout: + docs: Represents a checkout processed by the Square Terminal. + properties: + id: + type: optional + docs: A unique ID for this `TerminalCheckout`. + validation: + minLength: 10 + maxLength: 255 + access: read-only + amount_money: + type: Money + docs: >- + The amount of money (including the tax amount) that the Square + Terminal device should try to collect. + reference_id: + type: optional> + docs: >- + An optional user-defined reference ID that can be used to associate + + this `TerminalCheckout` to another entity in an external system. For + example, an order + + ID generated by a third-party shopping cart. The ID is also associated + with any payments + + used to complete the checkout. + validation: + maxLength: 40 + note: + type: optional> + docs: >- + An optional note to associate with the checkout, as well as with any + payments used to complete the checkout. + + Note: maximum 500 characters + validation: + maxLength: 500 + order_id: + type: optional> + docs: The reference to the Square order ID for the checkout request. + payment_options: + type: optional + docs: Payment-specific options for the checkout request. + device_options: + type: DeviceCheckoutOptions + docs: >- + Options to control the display and behavior of the Square Terminal + device. + deadline_duration: + type: optional> + docs: >- + An RFC 3339 duration, after which the checkout is automatically + canceled. + + A `TerminalCheckout` that is `PENDING` is automatically `CANCELED` and + has a cancellation reason + + of `TIMED_OUT`. + + + Default: 5 minutes from creation + + + Maximum: 5 minutes + status: + type: optional + docs: >- + The status of the `TerminalCheckout`. + + Options: `PENDING`, `IN_PROGRESS`, `CANCEL_REQUESTED`, `CANCELED`, + `COMPLETED` + access: read-only + cancel_reason: + type: optional + docs: >- + The reason why `TerminalCheckout` is canceled. Present if the status + is `CANCELED`. + + See [ActionCancelReason](#type-actioncancelreason) for possible values + payment_ids: + type: optional> + docs: A list of IDs for payments created by this `TerminalCheckout`. + access: read-only + created_at: + type: optional + docs: >- + The time when the `TerminalCheckout` was created, as an RFC 3339 + timestamp. + access: read-only + updated_at: + type: optional + docs: >- + The time when the `TerminalCheckout` was last updated, as an RFC 3339 + timestamp. + access: read-only + app_id: + type: optional + docs: The ID of the application that created the checkout. + access: read-only + location_id: + type: optional + docs: The location of the device where the `TerminalCheckout` was directed. + validation: + maxLength: 64 + access: read-only + payment_type: + type: optional + docs: >- + The type of payment the terminal should attempt to capture from. + Defaults to `CARD_PRESENT`. + + See [CheckoutOptionsPaymentType](#type-checkoutoptionspaymenttype) for + possible values + team_member_id: + type: optional> + docs: >- + An optional ID of the team member associated with creating the + checkout. + customer_id: + type: optional> + docs: An optional ID of the customer associated with the checkout. + app_fee_money: + type: optional + docs: >- + The amount the developer is taking as a fee for facilitating the + payment on behalf + + of the seller. + + + The amount cannot be more than 90% of the total amount of the payment. + + + The amount must be specified in the smallest denomination of the + applicable currency (for example, US dollar amounts are specified in + cents). For more information, see [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + + + The fee currency code must match the currency associated with the + seller that is accepting the payment. The application must be from a + developer account in the same country and using the same currency code + as the seller. + + + For more information about the application fee scenario, see [Take + Payments and Collect + Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). + + + To set this field, PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS OAuth + permission is required. For more information, see + [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions). + statement_description_identifier: + type: optional> + docs: >- + Optional additional payment information to include on the customer's + card statement as + + part of the statement description. This can be, for example, an + invoice number, ticket number, + + or short description that uniquely identifies the purchase. + validation: + maxLength: 20 + tip_money: + type: optional + docs: >- + The amount designated as a tip, in addition to `amount_money`. This + may only be set for a + + checkout that has tipping disabled (`tip_settings.allow_tipping` is + `false`). + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutCreatedEvent: + docs: Published when a [TerminalCheckout](entity:TerminalCheckout) is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"terminal.checkout.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutCreatedEventData: + properties: + type: + type: optional> + docs: Name of the created object’s type, `"checkout"`. + id: + type: optional + docs: ID of the created terminal checkout. + validation: + minLength: 10 + maxLength: 255 + object: + type: optional + docs: An object containing the created terminal checkout + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutCreatedEventObject: + properties: + checkout: + type: optional + docs: The created terminal checkout + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutQuery: + properties: + filter: + type: optional + docs: Options for filtering returned `TerminalCheckout` objects. + sort: + type: optional + docs: Option for sorting returned `TerminalCheckout` objects. + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutQueryFilter: + properties: + device_id: + type: optional> + docs: >- + The `TerminalCheckout` objects associated with a specific device. If + no device is specified, then all + + `TerminalCheckout` objects for the merchant are displayed. + created_at: + type: optional + docs: >- + The time range for the beginning of the reporting period, which is + inclusive. + + Default value: The current time minus one day. + + Note that `TerminalCheckout`s are available for 30 days after + creation. + status: + type: optional> + docs: >- + Filtered results with the desired status of the `TerminalCheckout`. + + Options: `PENDING`, `IN_PROGRESS`, `CANCEL_REQUESTED`, `CANCELED`, + `COMPLETED` + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutQuerySort: + properties: + sort_order: + type: optional + docs: |- + The order in which results are listed. + Default: `DESC` + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutUpdatedEvent: + docs: Published when a [TerminalCheckout](entity:TerminalCheckout) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"terminal.checkout.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the updated object’s type, `"checkout"`. + id: + type: optional + docs: ID of the updated terminal checkout. + validation: + minLength: 10 + maxLength: 255 + object: + type: optional + docs: An object containing the updated terminal checkout + source: + openapi: ../default/openapi/openapi.json + TerminalCheckoutUpdatedEventObject: + properties: + checkout: + type: optional + docs: The updated terminal checkout + source: + openapi: ../default/openapi/openapi.json + TerminalRefund: + docs: >- + Represents a payment refund processed by the Square Terminal. Only + supports Interac (Canadian debit network) payment refunds. + properties: + id: + type: optional + docs: A unique ID for this `TerminalRefund`. + validation: + minLength: 10 + maxLength: 255 + access: read-only + refund_id: + type: optional + docs: >- + The reference to the payment refund created by completing this + `TerminalRefund`. + access: read-only + payment_id: + type: string + docs: The unique ID of the payment being refunded. + validation: + minLength: 1 + order_id: + type: optional + docs: >- + The reference to the Square order ID for the payment identified by the + `payment_id`. + access: read-only + amount_money: + type: Money + docs: >- + The amount of money, inclusive of `tax_money`, that the + `TerminalRefund` should return. + + This value is limited to the amount taken in the original payment + minus any completed or + + pending refunds. + reason: + type: string + docs: A description of the reason for the refund. + validation: + maxLength: 192 + device_id: + type: string + docs: |- + The unique ID of the device intended for this `TerminalRefund`. + The Id can be retrieved from /v2/devices api. + deadline_duration: + type: optional> + docs: >- + The RFC 3339 duration, after which the refund is automatically + canceled. + + A `TerminalRefund` that is `PENDING` is automatically `CANCELED` and + has a cancellation reason + + of `TIMED_OUT`. + + + Default: 5 minutes from creation. + + + Maximum: 5 minutes + status: + type: optional + docs: >- + The status of the `TerminalRefund`. + + Options: `PENDING`, `IN_PROGRESS`, `CANCEL_REQUESTED`, `CANCELED`, or + `COMPLETED`. + access: read-only + cancel_reason: + type: optional + docs: |- + Present if the status is `CANCELED`. + See [ActionCancelReason](#type-actioncancelreason) for possible values + created_at: + type: optional + docs: >- + The time when the `TerminalRefund` was created, as an RFC 3339 + timestamp. + access: read-only + updated_at: + type: optional + docs: >- + The time when the `TerminalRefund` was last updated, as an RFC 3339 + timestamp. + access: read-only + app_id: + type: optional + docs: The ID of the application that created the refund. + access: read-only + location_id: + type: optional + docs: The location of the device where the `TerminalRefund` was directed. + validation: + maxLength: 64 + access: read-only + source: + openapi: ../default/openapi/openapi.json + TerminalRefundCreatedEvent: + docs: Published when a Terminal API refund is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"terminal.refund.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundCreatedEventData: + properties: + type: + type: optional> + docs: Name of the created object’s type, `"refund"`. + id: + type: optional + docs: ID of the created terminal refund. + object: + type: optional + docs: An object containing the created terminal refund. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundCreatedEventObject: + properties: + refund: + type: optional + docs: The created terminal refund. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundQuery: + properties: + filter: + type: optional + docs: The filter for the Terminal refund query. + sort: + type: optional + docs: The sort order for the Terminal refund query. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundQueryFilter: + properties: + device_id: + type: optional> + docs: >- + `TerminalRefund` objects associated with a specific device. If no + device is specified, then all + + `TerminalRefund` objects for the signed-in account are displayed. + created_at: + type: optional + docs: >- + The timestamp for the beginning of the reporting period, in RFC 3339 + format. Inclusive. + + Default value: The current time minus one day. + + Note that `TerminalRefund`s are available for 30 days after creation. + status: + type: optional> + docs: >- + Filtered results with the desired status of the `TerminalRefund`. + + Options: `PENDING`, `IN_PROGRESS`, `CANCEL_REQUESTED`, `CANCELED`, or + `COMPLETED`. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundQuerySort: + properties: + sort_order: + type: optional> + docs: |- + The order in which results are listed. + - `ASC` - Oldest to newest. + - `DESC` - Newest to oldest (default). + source: + openapi: ../default/openapi/openapi.json + TerminalRefundUpdatedEvent: + docs: Published when a Terminal API refund is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"terminal.refund.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: RFC 3339 timestamp of when the event was created. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the updated object’s type, `"refund"`. + id: + type: optional + docs: ID of the updated terminal refund. + object: + type: optional + docs: An object containing the updated terminal refund. + source: + openapi: ../default/openapi/openapi.json + TerminalRefundUpdatedEventObject: + properties: + refund: + type: optional + docs: The updated terminal refund. + source: + openapi: ../default/openapi/openapi.json + TestWebhookSubscriptionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [TestWebhookSubscription](api-endpoint:WebhookSubscriptions-TestWebhookSubscription) + endpoint. + + + Note: If there are errors processing the request, the + [SubscriptionTestResult](entity:SubscriptionTestResult) field is not + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + subscription_test_result: + type: optional + docs: The [SubscriptionTestResult](entity:SubscriptionTestResult). + source: + openapi: ../default/openapi/openapi.json + TimeRange: + docs: |- + Represents a generic time range. The start and end values are + represented in RFC 3339 format. Time ranges are customized to be + inclusive or exclusive based on the needs of a particular endpoint. + Refer to the relevant endpoint-specific documentation to determine + how time ranges are handled. + properties: + start_at: + type: optional> + docs: |- + A datetime value in RFC 3339 format indicating when the time range + starts. + end_at: + type: optional> + docs: |- + A datetime value in RFC 3339 format indicating when the time range + ends. + source: + openapi: ../default/openapi/openapi.json + Timecard: + docs: >- + A record of the hourly rate, start time, and end time of a single timecard + (shift) + + for a team member. This might include a record of the start and end times + of breaks + + taken during the shift. + properties: + id: + type: optional + docs: '**Read only** The Square-issued UUID for this object.' + validation: + maxLength: 255 + location_id: + type: string + docs: >- + The ID of the [location](entity:Location) for this timecard. The + location should be based on + + where the team member clocked in. + validation: + minLength: 1 + timezone: + type: optional> + docs: >- + **Read only** The time zone calculated from the location based on the + `location_id`, + + provided as a convenience value. Format: the IANA time zone database + identifier for the + + location time zone. + start_at: + type: string + docs: >- + The start time of the timecard, in RFC 3339 format and shifted to the + location + + timezone + offset. Precision up to the minute is respected; seconds + are truncated. + validation: + minLength: 1 + end_at: + type: optional> + docs: >- + The end time of the timecard, in RFC 3339 format and shifted to the + location + + timezone + offset. Precision up to the minute is respected; seconds + are truncated. + wage: + type: optional + docs: >- + Job and pay related information. If the wage is not set on create, it + defaults to a wage + + of zero. If the title is not set on create, it defaults to the name of + the role the team member + + is assigned to, if any. + breaks: + type: optional>> + docs: >- + A list of all the paid or unpaid breaks that were taken during this + timecard. + status: + type: optional + docs: |- + Describes the working state of the timecard. + See [TimecardStatus](#type-timecardstatus) for possible values + version: + type: optional + docs: >- + **Read only** The current version of the timecard, which is + incremented with each update. + + This field is used for [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control to ensure that requests don't overwrite data from another + request. + created_at: + type: optional + docs: >- + The timestamp of when the timecard was created, in RFC 3339 format + presented as UTC. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp of when the timecard was last updated, in RFC 3339 + format presented as UTC. + access: read-only + team_member_id: + type: string + docs: >- + The ID of the [team member](entity:TeamMember) this timecard belongs + to. + validation: + minLength: 1 + declared_cash_tip_money: + type: optional + docs: The cash tips declared by the team member for this timecard. + source: + openapi: ../default/openapi/openapi.json + TimecardFilter: + docs: |- + Defines a filter used in a search for `Timecard` records. `AND` logic is + used by Square's servers to apply each filter property specified. + properties: + location_ids: + type: optional>> + docs: Fetch timecards for the specified location. + status: + type: optional + docs: >- + Fetch a `Timecard` instance by `Timecard.status`. + + See [TimecardFilterStatus](#type-timecardfilterstatus) for possible + values + start: + type: optional + docs: Fetch `Timecard` instances that start in the time range - Inclusive. + end: + type: optional + docs: Fetch the `Timecard` instances that end in the time range - Inclusive. + workday: + type: optional + docs: Fetch the `Timecard` instances based on the workday date range. + team_member_ids: + type: optional>> + docs: Fetch timecards for the specified team members. + source: + openapi: ../default/openapi/openapi.json + TimecardFilterStatus: + enum: + - OPEN + - CLOSED + docs: Specifies the `status` of `Timecard` records to be returned. + source: + openapi: ../default/openapi/openapi.json + TimecardQuery: + docs: >- + The parameters of a `Timecard` search query, which includes filter and + sort options. + properties: + filter: + type: optional + docs: Query filter options. + sort: + type: optional + docs: Sort order details. + source: + openapi: ../default/openapi/openapi.json + TimecardSort: + docs: Sets the sort order of search results. + properties: + field: + type: optional + docs: |- + The field to sort on. + See [TimecardSortField](#type-timecardsortfield) for possible values + order: + type: optional + docs: |- + The order in which results are returned. Defaults to DESC. + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + TimecardSortField: + enum: + - START_AT + - END_AT + - CREATED_AT + - UPDATED_AT + docs: Enumerates the `Timecard` fields to sort on. + source: + openapi: ../default/openapi/openapi.json + TimecardStatus: + enum: + - OPEN + - CLOSED + docs: >- + **Read only** Enumerates the possible status of a + [timecard](entity:Timecard). + source: + openapi: ../default/openapi/openapi.json + TimecardWage: + docs: >- + The hourly wage rate used to compensate a team member for a + [timecard](entity:Timecard). + properties: + title: + type: optional> + docs: The name of the job performed during this timecard. + hourly_rate: + type: optional + docs: |- + Can be a custom-set hourly wage or the calculated effective hourly + wage based on the annual wage and hours worked per week. + job_id: + type: optional + docs: |- + The ID of the [job](entity:Job) performed for this timecard. Square + labor-reporting UIs might group timecards together by ID. + access: read-only + tip_eligible: + type: optional> + docs: Whether team members are eligible for tips when working this job. + source: + openapi: ../default/openapi/openapi.json + TimecardWorkday: + docs: |- + A `Timecard` search query filter parameter that sets a range of days that + a `Timecard` must start or end in before passing the filter condition. + properties: + date_range: + type: optional + docs: Dates for fetching the timecards. + match_timecards_by: + type: optional + docs: >- + The strategy on which the dates are applied. + + See [TimecardWorkdayMatcher](#type-timecardworkdaymatcher) for + possible values + default_timezone: + type: optional> + docs: >- + Location-specific timezones convert workdays to datetime filters. + + Every location included in the query must have a timezone or this + field + + must be provided as a fallback. Format: the IANA timezone database + + identifier for the relevant timezone. + source: + openapi: ../default/openapi/openapi.json + TimecardWorkdayMatcher: + enum: + - START_AT + - END_AT + - INTERSECTION + docs: Defines the logic used to apply a workday filter. + source: + openapi: ../default/openapi/openapi.json + TipSettings: + properties: + allow_tipping: + type: optional> + docs: >- + Indicates whether tipping is enabled for this checkout. Defaults to + false. + separate_tip_screen: + type: optional> + docs: >- + Indicates whether tip options should be presented on the screen before + presenting + + the signature screen during card payment. Defaults to false. + custom_tip_field: + type: optional> + docs: >- + Indicates whether custom tip amounts are allowed during the checkout + flow. Defaults to false. + tip_percentages: + type: optional>> + docs: >- + A list of tip percentages that should be presented during the checkout + flow, specified as + + up to 3 non-negative integers from 0 to 100 (inclusive). Defaults to + 15, 20, and 25. + smart_tipping: + type: optional> + docs: >- + Enables the "Smart Tip Amounts" behavior. + + Exact tipping options depend on the region in which the Square seller + is active. + + + For payments under 10.00, in the Australia, Canada, Ireland, United + Kingdom, and United States, tipping options are presented as no tip, + .50, 1.00 or 2.00. + + + For payment amounts of 10.00 or greater, tipping options are presented + as the following percentages: 0%, 5%, 10%, 15%. + + + If set to true, the `tip_percentages` settings is ignored. + + Defaults to false. + + + To learn more about smart tipping, see [Accept Tips with the Square + App](https://squareup.com/help/us/en/article/5069-accept-tips-with-the-square-app). + source: + openapi: ../default/openapi/openapi.json + Transaction: + docs: >- + Represents a transaction processed with Square, either with the + + Connect API or with Square Point of Sale. + + + The `tenders` field of this object lists all methods of payment used to + pay in + + the transaction. + properties: + id: + type: optional + docs: The transaction's unique ID, issued by Square payments servers. + validation: + maxLength: 192 + location_id: + type: optional> + docs: The ID of the transaction's associated location. + validation: + maxLength: 50 + created_at: + type: optional + docs: >- + The timestamp for when the transaction was created, in RFC 3339 + format. + validation: + maxLength: 32 + tenders: + type: optional>> + docs: The tenders used to pay in the transaction. + refunds: + type: optional>> + docs: Refunds that have been applied to any tender in the transaction. + reference_id: + type: optional> + docs: >- + If the transaction was created with the + [Charge](api-endpoint:Transactions-Charge) + + endpoint, this value is the same as the value provided for the + `reference_id` + + parameter in the request to that endpoint. Otherwise, it is not set. + validation: + maxLength: 40 + product: + type: optional + docs: |- + The Square product that processed the transaction. + See [TransactionProduct](#type-transactionproduct) for possible values + client_id: + type: optional> + docs: >- + If the transaction was created in the Square Point of Sale app, this + value + + is the ID generated for the transaction by Square Point of Sale. + + + This ID has no relationship to the transaction's canonical `id`, which + is + + generated by Square's backend servers. This value is generated for + bookkeeping + + purposes, in case the transaction cannot immediately be completed (for + example, + + if the transaction is processed in offline mode). + + + It is not currently possible with the Connect API to perform a + transaction + + lookup by this value. + validation: + maxLength: 192 + shipping_address: + type: optional
+ docs: The shipping address provided in the request, if any. + order_id: + type: optional> + docs: >- + The order_id is an identifier for the order associated with this + transaction, if any. + validation: + maxLength: 192 + source: + openapi: ../default/openapi/openapi.json + TransactionProduct: + enum: + - REGISTER + - EXTERNAL_API + - BILLING + - APPOINTMENTS + - INVOICES + - ONLINE_STORE + - PAYROLL + - OTHER + docs: Indicates the Square product used to process a transaction. + source: + openapi: ../default/openapi/openapi.json + TransactionType: + enum: + - DEBIT + - CREDIT + docs: The transaction type used in the disputed payment. + source: + openapi: ../default/openapi/openapi.json + TransferOrder: + docs: >- + Represents a transfer order for moving + [CatalogItemVariation](entity:CatalogItemVariation)s + + between [Location](entity:Location)s. Transfer orders track the entire + lifecycle of an inventory + + transfer, including: + + - What items and quantities are being moved + + - Source and destination locations + + - Current [TransferOrderStatus](entity:TransferOrderStatus) + + - Shipping information and tracking + + - Which [TeamMember](entity:TeamMember) initiated the transfer + + + This object is commonly used to: + + - Track [CatalogItemVariation](entity:CatalogItemVariation) movements + between [Location](entity:Location)s + + - Reconcile expected vs received quantities + + - Monitor transfer progress and shipping status + + - Audit inventory movement history + properties: + id: + type: optional + docs: >- + Unique system-generated identifier for this transfer order. Use this + ID for: + + - Retrieving transfer order details + + - Tracking status changes via webhooks + + - Linking transfers in external systems + access: read-only + source_location_id: + type: optional> + docs: >- + The source [Location](entity:Location) sending the + [CatalogItemVariation](entity:CatalogItemVariation)s. + + This location must: + + - Be active in your Square organization + + - Have sufficient inventory for the items being transferred + + - Not be the same as the destination location + + + This field is not updatable. + destination_location_id: + type: optional> + docs: >- + The destination [Location](entity:Location) receiving the + [CatalogItemVariation](entity:CatalogItemVariation)s. + + This location must: + + - Be active in your Square organization + + - Not be the same as the source location + + + This field is not updatable. + status: + type: optional + docs: >- + Current [TransferOrderStatus](entity:TransferOrderStatus) indicating + where the order is in its lifecycle. + + Status transitions follow this progression: + + 1. [DRAFT](entity:TransferOrderStatus) -> + [STARTED](entity:TransferOrderStatus) via + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder) + + 2. [STARTED](entity:TransferOrderStatus) -> + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) via + [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder) + + 3. [PARTIALLY_RECEIVED](entity:TransferOrderStatus) -> + [COMPLETED](entity:TransferOrderStatus) after all items received + + + Orders can be [CANCELED](entity:TransferOrderStatus) from + [STARTED](entity:TransferOrderStatus) or + + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + + + This field is read-only and reflects the current state of the transfer + order, and cannot be updated directly. Use the appropriate + + endpoints (e.g. + [StartPurchaseOrder](api-endpoint:TransferOrders-StartTransferOrder), + to change the status. + + See [TransferOrderStatus](#type-transferorderstatus) for possible + values + created_at: + type: optional + docs: |- + Timestamp when the transfer order was created, in RFC 3339 format. + Used for: + - Auditing transfer history + - Tracking order age + - Reporting and analytics + access: read-only + updated_at: + type: optional + docs: >- + Timestamp when the transfer order was last updated, in RFC 3339 + format. + + Updated when: + + - Order status changes + + - Items are received + + - Notes or metadata are modified + access: read-only + expected_at: + type: optional> + docs: |- + Expected transfer completion date, in RFC 3339 format. + Used for: + - Planning inventory availability + - Scheduling receiving staff + - Monitoring transfer timeliness + completed_at: + type: optional + docs: >- + Timestamp when the transfer order was completed or canceled, in RFC + 3339 format (e.g. "2023-10-01T12:00:00Z"). + access: read-only + notes: + type: optional> + docs: Optional notes about the transfer. + tracking_number: + type: optional> + docs: Shipment tracking number for monitoring transfer progress. + created_by_team_member_id: + type: optional + docs: >- + ID of the [TeamMember](entity:TeamMember) who created this transfer + order. This field is not writeable by the Connect V2 API. + access: read-only + line_items: + type: optional>> + docs: >- + List of [CatalogItemVariation](entity:CatalogItemVariation)s being + transferred. + version: + type: optional + docs: >- + Version for optimistic concurrency control. This is a monotonically + increasing integer + + that changes whenever the transfer order is modified. Use this when + calling + + [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder) + and other endpoints to ensure you're + + not overwriting concurrent changes. + source: + openapi: ../default/openapi/openapi.json + TransferOrderCreatedEvent: + docs: Published when a transfer_order is created. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"transfer_order.created"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TransferOrderCreatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"transfer_order"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected transfer_order. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the created transfer_order. + source: + openapi: ../default/openapi/openapi.json + TransferOrderCreatedEventObject: + properties: + transfer_order: + type: optional + docs: The created transfer_order. + source: + openapi: ../default/openapi/openapi.json + TransferOrderDeletedEvent: + docs: Published when a transfer_order is deleted. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"transfer_order.deleted"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TransferOrderDeletedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"transfer_order"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected transfer_order. + validation: + maxLength: 192 + deleted: + type: optional> + docs: Is true if the affected object was deleted. Otherwise absent. + source: + openapi: ../default/openapi/openapi.json + TransferOrderFilter: + docs: Filter criteria for searching transfer orders + properties: + source_location_ids: + type: optional>> + docs: Filter by source location IDs + destination_location_ids: + type: optional>> + docs: Filter by destination location IDs + statuses: + type: optional>> + docs: >- + Filter by order statuses + + See [TransferOrderStatus](#type-transferorderstatus) for possible + values + source: + openapi: ../default/openapi/openapi.json + TransferOrderGoodsReceipt: + docs: >- + The goods receipt details for a transfer order. This object represents a + single receipt + + of goods against a transfer order, tracking: + + + - Which [CatalogItemVariation](entity:CatalogItemVariation)s were received + + - Quantities received in good condition + + - Quantities damaged during transit/handling + + - Quantities canceled during receipt + + + Multiple goods receipts can be created for a single transfer order to + handle: + + - Partial deliveries + + - Multiple shipments + + - Split receipts across different dates + + - Cancellations of specific quantities + + + Each receipt automatically: + + - Updates the transfer order status + + - Adjusts received quantities + + - Updates inventory levels at both source and destination + [Location](entity:Location)s + properties: + line_items: + type: optional>> + docs: >- + Line items being received. Each line item specifies: + + - The item being received + + - Quantity received in good condition + + - Quantity received damaged + + - Quantity canceled + + + Constraints: + + - Must include at least one line item + + - Maximum of 1000 line items per receipt + + - Each line item must reference a valid item from the transfer order + + - Total of received, damaged, and canceled quantities cannot exceed + ordered quantity + source: + openapi: ../default/openapi/openapi.json + TransferOrderGoodsReceiptLineItem: + docs: A simplified line item for goods receipts in transfer orders + properties: + transfer_order_line_uid: + type: string + docs: The unique identifier of the Transfer Order line being received + validation: + maxLength: 64 + quantity_received: + type: optional> + docs: >- + The quantity received for this line item as a decimal string (e.g. + "10.5"). + + These items will be added to the destination + [Location](entity:Location)'s inventory with + [InventoryState](entity:InventoryState) of IN_STOCK. + validation: + pattern: ^(0|[1-9]\d*)(\.\d{1,4})?$ + minLength: 1 + maxLength: 16 + quantity_damaged: + type: optional> + docs: >- + The quantity that was damaged during shipping/handling as a decimal + string (e.g. "1.5"). + + These items will be added to the destination + [Location](entity:Location)'s inventory with + [InventoryState](entity:InventoryState) of WASTE. + validation: + pattern: ^(0|[1-9]\d*)(\.\d{1,4})?$ + minLength: 1 + maxLength: 16 + quantity_canceled: + type: optional> + docs: >- + The quantity that was canceled during shipping/handling as a decimal + string (e.g. "1.5"). These will be immediately added to inventory in + the source location. + validation: + pattern: ^(0|[1-9]\d*)(\.\d{1,4})?$ + minLength: 1 + maxLength: 16 + source: + openapi: ../default/openapi/openapi.json + TransferOrderLine: + docs: >- + Represents a line item in a transfer order. Each line item tracks a + specific + + [CatalogItemVariation](entity:CatalogItemVariation) being transferred, + including ordered quantities + + and receipt status. + properties: + uid: + type: optional + docs: >- + Unique system-generated identifier for the line item. Provide when + updating/removing a line via + [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). + access: read-only + item_variation_id: + type: string + docs: >- + The required identifier of the + [CatalogItemVariation](entity:CatalogItemVariation) being transferred. + Must reference + + a valid catalog item variation that exists in the + [Catalog](api:Catalog). + validation: + pattern: ^[a-zA-Z0-9_:\-]+$ + minLength: 1 + maxLength: 64 + quantity_ordered: + type: string + docs: >- + Total quantity ordered, formatted as a decimal string (e.g. "10 or + 10.0000"). Required to be a positive number. + + + To remove a line item, set `remove` to `true` in + [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). + validation: + pattern: ^\d*\.?\d*$ + minLength: 1 + quantity_pending: + type: optional + docs: >- + Calculated quantity of this line item's yet to be received stock. This + is the difference between the total quantity ordered and the sum of + quantities received, canceled, and damaged. + access: read-only + quantity_received: + type: optional + docs: >- + Quantity received at destination. These items are added to the + destination + + [Location](entity:Location)'s inventory with + [InventoryState](entity:InventoryState) of IN_STOCK. + + + This field cannot be updated directly in Create/Update operations, + instead use + [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder). + access: read-only + quantity_damaged: + type: optional + docs: >- + Quantity received in damaged condition. These items are added to the + destination + + [Location](entity:Location)'s inventory with + [InventoryState](entity:InventoryState) of WASTE. + + + This field cannot be updated directly in Create/Update operations, + instead use + [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder). + access: read-only + quantity_canceled: + type: optional + docs: >- + Quantity that was canceled. These items will be immediately added to + inventory in the source location. + + + This field cannot be updated directly in Create/Update operations, + instead use + [ReceiveTransferOrder](api-endpoint:TransferOrders-ReceiveTransferOrder) + or + [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + access: read-only + source: + openapi: ../default/openapi/openapi.json + TransferOrderQuery: + docs: Query parameters for searching transfer orders + properties: + filter: + type: optional + docs: Filter criteria + sort: + type: optional + docs: Sort configuration + source: + openapi: ../default/openapi/openapi.json + TransferOrderSort: + docs: Sort configuration for search results + properties: + field: + type: optional + docs: >- + Field to sort by + + See [TransferOrderSortField](#type-transferordersortfield) for + possible values + order: + type: optional + docs: |- + Sort order direction + See [SortOrder](#type-sortorder) for possible values + source: + openapi: ../default/openapi/openapi.json + TransferOrderSortField: + enum: + - CREATED_AT + - UPDATED_AT + docs: >- + Fields that can be used for sorting [TransferOrder](entity:TransferOrder)s + in search results. + + Used with + [SearchTransferOrders](api-endpoint:TransferOrders-SearchTransferOrders) + to control + + the order of returned results. + source: + openapi: ../default/openapi/openapi.json + TransferOrderStatus: + enum: + - DRAFT + - STARTED + - PARTIALLY_RECEIVED + - COMPLETED + - CANCELED + docs: >- + Status values for transfer orders. Represents the current state of a + + [TransferOrder](entity:TransferOrder) in its lifecycle from creation to + completion. + + Each status determines what actions are available and how inventory is + affected. + source: + openapi: ../default/openapi/openapi.json + TransferOrderUpdatedEvent: + docs: Published when a transfer_order is updated. + properties: + merchant_id: + type: optional> + docs: The ID of the target merchant associated with the event. + type: + type: optional> + docs: The type of event this represents, `"transfer_order.updated"`. + event_id: + type: optional> + docs: A unique ID for the event. + created_at: + type: optional + docs: Timestamp of when the event was created, in RFC 3339 format. + access: read-only + data: + type: optional + docs: Data associated with the event. + source: + openapi: ../default/openapi/openapi.json + TransferOrderUpdatedEventData: + properties: + type: + type: optional> + docs: Name of the affected object’s type, `"transfer_order"`. + validation: + maxLength: 50 + id: + type: optional + docs: ID of the affected transfer_order. + validation: + maxLength: 192 + object: + type: optional + docs: An object containing the updated transfer_order. + source: + openapi: ../default/openapi/openapi.json + TransferOrderUpdatedEventObject: + properties: + transfer_order: + type: optional + docs: The updated transfer_order. + source: + openapi: ../default/openapi/openapi.json + UnlinkCustomerFromGiftCardResponse: + docs: >- + A response that contains the unlinked `GiftCard` object. If the request + resulted in errors, + + the response contains a set of `Error` objects. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + gift_card: + type: optional + docs: >- + The gift card with the ID of the unlinked customer removed from the + `customer_ids` field. + + If no other customers are linked, the `customer_ids` field is also + removed. + source: + openapi: ../default/openapi/openapi.json + UpdateBookingCustomAttributeDefinitionResponse: + docs: >- + Represents an + [UpdateBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-UpdateBookingCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The updated custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateBookingResponse: + properties: + booking: + type: optional + docs: The booking that was updated. + errors: + type: optional> + docs: Errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateBreakTypeResponse: + docs: >- + A response to a request to update a `BreakType`. The response contains + + the requested `BreakType` objects and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + break_type: + type: optional + docs: The response object. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateCatalogImageRequest: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this UpdateCatalogImage request. + + Keys can be any valid string but must be unique for every + UpdateCatalogImage request. + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 128 + source: + openapi: ../default/openapi/openapi.json + UpdateCatalogImageResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + image: + type: optional + docs: |- + The newly updated `CatalogImage` including a Square-generated + URL for the encapsulated image file. + source: + openapi: ../default/openapi/openapi.json + UpdateCustomerCustomAttributeDefinitionResponse: + docs: >- + Represents an + [UpdateCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-UpdateCustomerCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The updated custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateCustomerGroupResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [UpdateCustomerGroup](api-endpoint:CustomerGroups-UpdateCustomerGroup) + endpoint. + + + Either `errors` or `group` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + group: + type: optional + docs: The successfully updated customer group. + source: + openapi: ../default/openapi/openapi.json + UpdateCustomerResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the [UpdateCustomer](api-endpoint:Customers-UpdateCustomer) + or + + [BulkUpdateCustomers](api-endpoint:Customers-BulkUpdateCustomers) + endpoint. + + + Either `errors` or `customer` is present in a given response (never both). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + customer: + type: optional + docs: The updated customer. + source: + openapi: ../default/openapi/openapi.json + UpdateInvoiceResponse: + docs: Describes a `UpdateInvoice` response. + properties: + invoice: + type: optional + docs: The updated invoice. + errors: + type: optional> + docs: Information about errors encountered during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateItemModifierListsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + updated_at: + type: optional + docs: >- + The database + [timestamp](https://developer.squareup.com/docs/build-basics/common-data-types/working-with-dates) + of this update in RFC 3339 format, e.g., `2016-09-04T23:59:33.123Z`. + source: + openapi: ../default/openapi/openapi.json + UpdateItemTaxesResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + updated_at: + type: optional + docs: >- + The database + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates) + of this update in RFC 3339 format, e.g., `2016-09-04T23:59:33.123Z`. + source: + openapi: ../default/openapi/openapi.json + UpdateJobResponse: + docs: >- + Represents an [UpdateJob](api-endpoint:Team-UpdateJob) response. Either + `job` or `errors` + + is present in the response. + properties: + job: + type: optional + docs: The updated job. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateLocationCustomAttributeDefinitionResponse: + docs: >- + Represents an + [UpdateLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-UpdateLocationCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The updated custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateLocationResponse: + docs: >- + The response object returned by the + [UpdateLocation](api-endpoint:Locations-UpdateLocation) endpoint. + properties: + errors: + type: optional> + docs: Information about errors encountered during the request. + location: + type: optional + docs: The updated `Location` object. + source: + openapi: ../default/openapi/openapi.json + UpdateLocationSettingsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred when updating the location settings. + location_settings: + type: optional + docs: The updated location settings. + source: + openapi: ../default/openapi/openapi.json + UpdateMerchantCustomAttributeDefinitionResponse: + docs: >- + Represents an + [UpdateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-UpdateMerchantCustomAttributeDefinition) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute_definition: + type: optional + docs: The updated custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateMerchantSettingsResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred when updating the merchant settings. + merchant_settings: + type: optional + docs: The updated merchant settings. + source: + openapi: ../default/openapi/openapi.json + UpdateOrderCustomAttributeDefinitionResponse: + docs: Represents a response from updating an order custom attribute definition. + properties: + custom_attribute_definition: + type: optional + docs: The updated order custom attribute definition. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateOrderResponse: + docs: |- + Defines the fields that are included in the response body of + a request to the [UpdateOrder](api-endpoint:Orders-UpdateOrder) endpoint. + properties: + order: + type: optional + docs: The updated order. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdatePaymentLinkResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred when updating the payment link. + payment_link: + type: optional + docs: The updated payment link. + source: + openapi: ../default/openapi/openapi.json + UpdatePaymentResponse: + docs: |- + Defines the response returned by + [UpdatePayment](api-endpoint:Payments-UpdatePayment). + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + payment: + type: optional + docs: The updated payment. + source: + openapi: ../default/openapi/openapi.json + UpdateScheduledShiftResponse: + docs: >- + Represents an + [UpdateScheduledShift](api-endpoint:Labor-UpdateScheduledShift) response. + + Either `scheduled_shift` or `errors` is present in the response. + properties: + scheduled_shift: + type: optional + docs: >- + The updated scheduled shift. To make the changes public, call + + [PublishScheduledShift](api-endpoint:Labor-PublishScheduledShift) or + + [BulkPublishScheduledShifts](api-endpoint:Labor-BulkPublishScheduledShifts). + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateShiftResponse: + docs: |- + The response to a request to update a `Shift`. The response contains + the updated `Shift` object and might contain a set of `Error` objects if + the request resulted in errors. + properties: + shift: + type: optional + docs: The updated `Shift`. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateSubscriptionResponse: + docs: >- + Defines output parameters in a response from the + + [UpdateSubscription](api-endpoint:Subscriptions-UpdateSubscription) + endpoint. + properties: + errors: + type: optional> + docs: Errors encountered during the request. + subscription: + type: optional + docs: The updated subscription. + source: + openapi: ../default/openapi/openapi.json + UpdateTeamMemberRequest: + docs: Represents an update request for a `TeamMember` object. + properties: + team_member: + type: optional + docs: >- + The team member fields to add, change, or clear. Fields can be cleared + using a null value. To update + + `wage_setting.job_assignments`, you must provide the complete list of + job assignments. If needed, call + + [ListJobs](api-endpoint:Team-ListJobs) to get the required `job_id` + values. + source: + openapi: ../default/openapi/openapi.json + UpdateTeamMemberResponse: + docs: >- + Represents a response from an update request containing the updated + `TeamMember` object or error messages. + properties: + team_member: + type: optional + docs: The successfully updated `TeamMember` object. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateTimecardResponse: + docs: >- + The response to a request to update a `Timecard`. The response contains + + the updated `Timecard` object and might contain a set of `Error` objects + if + + the request resulted in errors. + properties: + timecard: + type: optional + docs: The updated `Timecard`. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateTransferOrderData: + docs: Data model for updating a transfer order. All fields are optional. + properties: + source_location_id: + type: optional> + docs: >- + The source [Location](entity:Location) that will send the items. Must + be an active location + + in your Square account with sufficient inventory of the requested + items. + validation: + minLength: 1 + maxLength: 64 + destination_location_id: + type: optional> + docs: >- + The destination [Location](entity:Location) that will receive the + items. Must be an active location + + in your Square account. + validation: + minLength: 1 + maxLength: 64 + expected_at: + type: optional> + docs: >- + Expected transfer date in RFC 3339 format (e.g. + "2023-10-01T12:00:00Z"). + notes: + type: optional> + docs: Optional notes about the transfer + validation: + maxLength: 4096 + tracking_number: + type: optional> + docs: Shipment tracking number + validation: + maxLength: 64 + line_items: + type: optional>> + docs: List of items being transferred + source: + openapi: ../default/openapi/openapi.json + UpdateTransferOrderLineData: + docs: Represents a line item update in a transfer order + properties: + uid: + type: optional> + docs: >- + Line item id being updated. Required for updating/removing existing + line items, but should not be set for new line items. + validation: + minLength: 1 + maxLength: 64 + item_variation_id: + type: optional> + docs: |- + Catalog item variation being transferred + + Required for new line items, but otherwise is not updatable. + validation: + minLength: 1 + maxLength: 64 + quantity_ordered: + type: optional> + docs: Total quantity ordered + validation: + pattern: ^(0|[1-9]\d*)(\.\d{1,4})?$ + minLength: 1 + maxLength: 16 + remove: + type: optional> + docs: >- + Flag to remove the line item during update. Must include `uid` in + removal request + source: + openapi: ../default/openapi/openapi.json + UpdateTransferOrderResponse: + docs: Response for updating a transfer order + properties: + transfer_order: + type: optional + docs: The updated transfer order + errors: + type: optional> + docs: Any errors that occurred during the request + source: + openapi: ../default/openapi/openapi.json + UpdateVendorRequest: + docs: >- + Represents an input to a call to + [UpdateVendor](api-endpoint:Vendors-UpdateVendor). + properties: + idempotency_key: + type: optional> + docs: >- + A client-supplied, universally unique identifier (UUID) for the + + request. + + + See + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + in the + + [API Development 101](https://developer.squareup.com/docs/buildbasics) + section for more + + information. + validation: + maxLength: 128 + vendor: + type: Vendor + docs: The specified [Vendor](entity:Vendor) to be updated. + source: + openapi: ../default/openapi/openapi.json + UpdateVendorResponse: + docs: >- + Represents an output from a call to + [UpdateVendor](api-endpoint:Vendors-UpdateVendor). + properties: + errors: + type: optional> + docs: Errors occurred when the request fails. + vendor: + type: optional + docs: The [Vendor](entity:Vendor) that has been updated. + source: + openapi: ../default/openapi/openapi.json + UpdateWageSettingResponse: + docs: >- + Represents a response from an update request containing the updated + `WageSetting` object + + or error messages. + properties: + wage_setting: + type: optional + docs: The successfully updated `WageSetting` object. + errors: + type: optional> + docs: The errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpdateWebhookSubscriptionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [UpdateWebhookSubscription](api-endpoint:WebhookSubscriptions-UpdateWebhookSubscription) + endpoint. + + + Note: If there are errors processing the request, the + [Subscription](entity:WebhookSubscription) is not + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + subscription: + type: optional + docs: The updated [Subscription](entity:WebhookSubscription). + source: + openapi: ../default/openapi/openapi.json + UpdateWebhookSubscriptionSignatureKeyResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [UpdateWebhookSubscriptionSignatureKey](api-endpoint:WebhookSubscriptions-UpdateWebhookSubscriptionSignatureKey) + endpoint. + + + Note: If there are errors processing the request, the + [Subscription](entity:WebhookSubscription) is not + + present. + properties: + errors: + type: optional> + docs: Information on errors encountered during the request. + signature_key: + type: optional + docs: >- + The new Square-generated signature key used to validate the origin of + the webhook event. + access: read-only + source: + openapi: ../default/openapi/openapi.json + UpdateWorkweekConfigResponse: + docs: >- + The response to a request to update a `WorkweekConfig` object. The + response contains + + the updated `WorkweekConfig` object and might contain a set of `Error` + objects if + + the request resulted in errors. + properties: + workweek_config: + type: optional + docs: The response object. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpsertBookingCustomAttributeResponse: + docs: >- + Represents an + [UpsertBookingCustomAttribute](api-endpoint:BookingCustomAttributes-UpsertBookingCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpsertCatalogObjectResponse: + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + catalog_object: + type: optional + docs: The successfully created or updated CatalogObject. + id_mappings: + type: optional> + docs: The mapping between client and server IDs for this upsert. + source: + openapi: ../default/openapi/openapi.json + UpsertCustomerCustomAttributeResponse: + docs: >- + Represents an + [UpsertCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-UpsertCustomerCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpsertLocationCustomAttributeResponse: + docs: >- + Represents an + [UpsertLocationCustomAttribute](api-endpoint:LocationCustomAttributes-UpsertLocationCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpsertMerchantCustomAttributeResponse: + docs: >- + Represents an + [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) + response. + + Either `custom_attribute_definition` or `errors` is present in the + response. + properties: + custom_attribute: + type: optional + docs: The new or updated custom attribute. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpsertOrderCustomAttributeResponse: + docs: Represents a response from upserting order custom attribute definitions. + properties: + custom_attribute: + type: optional + docs: The order custom attribute that was created or modified. + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + UpsertSnippetResponse: + docs: >- + Represents an `UpsertSnippet` response. The response can include either + `snippet` or `errors`. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + snippet: + type: optional + docs: The new or updated snippet. + source: + openapi: ../default/openapi/openapi.json + V1Money: + properties: + amount: + type: optional> + docs: >- + Amount in the lowest denominated value of this Currency. E.g. in USD + + these are cents, in JPY they are Yen (which do not have a 'cent' + concept). + currency_code: + type: optional + docs: |- + + See [Currency](#type-currency) for possible values + source: + openapi: ../default/openapi/openapi.json + V1Order: + docs: V1Order + properties: + errors: + type: optional>> + docs: Any errors that occurred during the request. + id: + type: optional + docs: The order's unique identifier. + buyer_email: + type: optional> + docs: The email address of the order's buyer. + recipient_name: + type: optional> + docs: The name of the order's buyer. + recipient_phone_number: + type: optional> + docs: The phone number to use for the order's delivery. + state: + type: optional + docs: |- + Whether the tax is an ADDITIVE tax or an INCLUSIVE tax. + See [V1OrderState](#type-v1orderstate) for possible values + shipping_address: + type: optional
+ docs: The address to ship the order to. + subtotal_money: + type: optional + docs: >- + The amount of all items purchased in the order, before taxes and + shipping. + total_shipping_money: + type: optional + docs: The shipping cost for the order. + total_tax_money: + type: optional + docs: The total of all taxes applied to the order. + total_price_money: + type: optional + docs: The total cost of the order. + total_discount_money: + type: optional + docs: The total of all discounts applied to the order. + created_at: + type: optional + docs: The time when the order was created, in ISO 8601 format. + updated_at: + type: optional + docs: The time when the order was last modified, in ISO 8601 format. + expires_at: + type: optional> + docs: >- + The time when the order expires if no action is taken, in ISO 8601 + format. + payment_id: + type: optional> + docs: The unique identifier of the payment associated with the order. + buyer_note: + type: optional> + docs: A note provided by the buyer when the order was created, if any. + completed_note: + type: optional> + docs: >- + A note provided by the merchant when the order's state was set to + COMPLETED, if any + refunded_note: + type: optional> + docs: >- + A note provided by the merchant when the order's state was set to + REFUNDED, if any. + canceled_note: + type: optional> + docs: >- + A note provided by the merchant when the order's state was set to + CANCELED, if any. + tender: + type: optional + docs: The tender used to pay for the order. + order_history: + type: optional>> + docs: The history of actions associated with the order. + promo_code: + type: optional> + docs: The promo code provided by the buyer, if any. + btc_receive_address: + type: optional> + docs: For Bitcoin transactions, the address that the buyer sent Bitcoin to. + btc_price_satoshi: + type: optional> + docs: >- + For Bitcoin transactions, the price of the buyer's order in satoshi + (100 million satoshi equals 1 BTC). + source: + openapi: ../default/openapi/openapi.json + V1OrderHistoryEntry: + docs: V1OrderHistoryEntry + properties: + action: + type: optional + docs: >- + The type of action performed on the order. + + See [V1OrderHistoryEntryAction](#type-v1orderhistoryentryaction) for + possible values + created_at: + type: optional + docs: The time when the action was performed, in ISO 8601 format. + source: + openapi: ../default/openapi/openapi.json + V1OrderHistoryEntryAction: + enum: + - ORDER_PLACED + - DECLINED + - PAYMENT_RECEIVED + - CANCELED + - COMPLETED + - REFUNDED + - EXPIRED + source: + openapi: ../default/openapi/openapi.json + V1OrderState: + enum: + - PENDING + - OPEN + - COMPLETED + - CANCELED + - REFUNDED + - REJECTED + source: + openapi: ../default/openapi/openapi.json + V1Tender: + docs: >- + A tender represents a discrete monetary exchange. Square represents this + + exchange as a money object with a specific currency and amount, where the + + amount is given in the smallest denomination of the given currency. + + + Square POS can accept more than one form of tender for a single payment + (such + + as by splitting a bill between a credit card and a gift card). The + `tender` + + field of the Payment object lists all forms of tender used for the + payment. + + + Split tender payments behave slightly differently from single tender + payments: + + + The receipt_url for a split tender corresponds only to the first tender + listed + + in the tender field. To get the receipt URLs for the remaining tenders, + use + + the receipt_url fields of the corresponding Tender objects. + + + *A note on gift cards**: when a customer purchases a Square gift card from + a + + merchant, the merchant receives the full amount of the gift card in the + + associated payment. + + + When that gift card is used as a tender, the balance of the gift card is + + reduced and the merchant receives no funds. A `Tender` object with a type + of + + `SQUARE_GIFT_CARD` indicates a gift card was used for some or all of the + + associated payment. + properties: + id: + type: optional + docs: The tender's unique ID. + type: + type: optional + docs: |- + The type of tender. + See [V1TenderType](#type-v1tendertype) for possible values + name: + type: optional> + docs: A human-readable description of the tender. + employee_id: + type: optional> + docs: The ID of the employee that processed the tender. + receipt_url: + type: optional> + docs: The URL of the receipt for the tender. + card_brand: + type: optional + docs: |- + The brand of credit card provided. + See [V1TenderCardBrand](#type-v1tendercardbrand) for possible values + pan_suffix: + type: optional> + docs: The last four digits of the provided credit card's account number. + entry_method: + type: optional + docs: >- + The tender's unique ID. + + See [V1TenderEntryMethod](#type-v1tenderentrymethod) for possible + values + payment_note: + type: optional> + docs: >- + Notes entered by the merchant about the tender at the time of payment, + if any. Typically only present for tender with the type: OTHER. + total_money: + type: optional + docs: The total amount of money provided in this form of tender. + tendered_money: + type: optional + docs: The amount of total_money applied to the payment. + tendered_at: + type: optional> + docs: The time when the tender was created, in ISO 8601 format. + settled_at: + type: optional> + docs: The time when the tender was settled, in ISO 8601 format. + change_back_money: + type: optional + docs: The amount of total_money returned to the buyer as change. + refunded_money: + type: optional + docs: >- + The total of all refunds applied to this tender. This amount is always + negative or zero. + is_exchange: + type: optional> + docs: >- + Indicates whether or not the tender is associated with an exchange. If + is_exchange is true, the tender represents the value of goods returned + in an exchange not the actual money paid. The exchange value reduces + the tender amounts needed to pay for items purchased in the exchange. + source: + openapi: ../default/openapi/openapi.json + V1TenderCardBrand: + enum: + - OTHER_BRAND + - VISA + - MASTER_CARD + - AMERICAN_EXPRESS + - DISCOVER + - DISCOVER_DINERS + - JCB + - CHINA_UNIONPAY + - SQUARE_GIFT_CARD + docs: The brand of a credit card. + source: + openapi: ../default/openapi/openapi.json + V1TenderEntryMethod: + enum: + - MANUAL + - SCANNED + - SQUARE_CASH + - SQUARE_WALLET + - SWIPED + - WEB_FORM + - OTHER + source: + openapi: ../default/openapi/openapi.json + V1TenderType: + enum: + - CREDIT_CARD + - CASH + - THIRD_PARTY_CARD + - NO_SALE + - SQUARE_WALLET + - SQUARE_GIFT_CARD + - UNKNOWN + - OTHER + source: + openapi: ../default/openapi/openapi.json + V1UpdateOrderRequestAction: + enum: + - COMPLETE + - CANCEL + - REFUND + source: + openapi: ../default/openapi/openapi.json + Vendor: + docs: Represents a supplier to a seller. + properties: + id: + type: optional + docs: >- + A unique Square-generated ID for the [Vendor](entity:Vendor). + + This field is required when attempting to update a + [Vendor](entity:Vendor). + validation: + maxLength: 100 + created_at: + type: optional + docs: |- + An RFC 3339-formatted timestamp that indicates when the + [Vendor](entity:Vendor) was created. + validation: + maxLength: 34 + access: read-only + updated_at: + type: optional + docs: |- + An RFC 3339-formatted timestamp that indicates when the + [Vendor](entity:Vendor) was last updated. + validation: + maxLength: 34 + access: read-only + name: + type: optional> + docs: >- + The name of the [Vendor](entity:Vendor). + + This field is required when attempting to create or update a + [Vendor](entity:Vendor). + validation: + maxLength: 100 + address: + type: optional
+ docs: The address of the [Vendor](entity:Vendor). + contacts: + type: optional>> + docs: The contacts of the [Vendor](entity:Vendor). + account_number: + type: optional> + docs: The account number of the [Vendor](entity:Vendor). + validation: + maxLength: 100 + note: + type: optional> + docs: A note detailing information about the [Vendor](entity:Vendor). + validation: + maxLength: 4096 + version: + type: optional + docs: The version of the [Vendor](entity:Vendor). + status: + type: optional + docs: |- + The status of the [Vendor](entity:Vendor). + See [Status](#type-status) for possible values + source: + openapi: ../default/openapi/openapi.json + VendorContact: + docs: Represents a contact of a [Vendor](entity:Vendor). + properties: + id: + type: optional + docs: >- + A unique Square-generated ID for the + [VendorContact](entity:VendorContact). + + This field is required when attempting to update a + [VendorContact](entity:VendorContact). + validation: + maxLength: 100 + name: + type: optional> + docs: >- + The name of the [VendorContact](entity:VendorContact). + + This field is required when attempting to create a + [Vendor](entity:Vendor). + validation: + maxLength: 255 + email_address: + type: optional> + docs: The email address of the [VendorContact](entity:VendorContact). + validation: + maxLength: 255 + phone_number: + type: optional> + docs: The phone number of the [VendorContact](entity:VendorContact). + validation: + maxLength: 255 + removed: + type: optional> + docs: The state of the [VendorContact](entity:VendorContact). + ordinal: + type: integer + docs: The ordinal of the [VendorContact](entity:VendorContact). + source: + openapi: ../default/openapi/openapi.json + VendorCreatedEvent: + docs: Published when a [Vendor](entity:Vendor) is created. + properties: + merchant_id: + type: optional> + docs: The ID of a seller associated with this event. + location_id: + type: optional> + docs: >- + The ID of a location associated with the event, if the event is + associated with the location of the seller. + type: + type: optional> + docs: The type of this event. The value is `"vendor.created".` + event_id: + type: optional> + docs: A unique ID for this event. + created_at: + type: optional + docs: >- + The RFC 3339-formatted time when the underlying event data object is + created. + access: read-only + data: + type: optional + docs: The data associated with this event. + source: + openapi: ../default/openapi/openapi.json + VendorCreatedEventData: + docs: Defines the `vendor.created` event data structure. + properties: + type: + type: optional> + docs: The type of the event data object. The value is `vendor` + id: + type: optional + docs: The ID of the event data object. + object: + type: optional + docs: An object containing the created vendor. + source: + openapi: ../default/openapi/openapi.json + VendorCreatedEventObject: + properties: + operation: + type: optional + docs: >- + The operation on the vendor that caused the event to be published. The + value is `CREATED`. + + See [Operation](#type-operation) for possible values + vendor: + type: optional + docs: The created vendor as the result of the specified operation. + source: + openapi: ../default/openapi/openapi.json + VendorCreatedEventObjectOperation: + type: literal<"CREATED"> + docs: >- + The operation that can be performed against a vendor to cause the event to + be published. + VendorStatus: + enum: + - ACTIVE + - INACTIVE + docs: |- + The status of the [Vendor](entity:Vendor), + whether a [Vendor](entity:Vendor) is active or inactive. + source: + openapi: ../default/openapi/openapi.json + VendorUpdatedEvent: + docs: Published when a [Vendor](entity:Vendor) is updated. + properties: + merchant_id: + type: optional> + docs: The ID of a seller associated with this event. + location_id: + type: optional> + docs: >- + The ID of a seller location associated with this event, if the event + is associated with the location. + type: + type: optional> + docs: The type of this event. The value is `"vendor.updated".` + event_id: + type: optional> + docs: A unique ID for this webhoook event. + created_at: + type: optional + docs: >- + The RFC 3339-formatted time when the underlying event data object is + created. + access: read-only + data: + type: optional + docs: The data associated with this event. + source: + openapi: ../default/openapi/openapi.json + VendorUpdatedEventData: + docs: Defines the `vendor.updated` event data structure. + properties: + type: + type: optional> + docs: The type of the event data object. The value is `vendor`. + id: + type: optional + docs: The ID of the event data object. + object: + type: optional + docs: An object containing updated vendor. + source: + openapi: ../default/openapi/openapi.json + VendorUpdatedEventObject: + properties: + operation: + type: optional + docs: >- + The operation on the vendor that caused the event to be published. The + value is `UPDATED`. + + See [Operation](#type-operation) for possible values + vendor: + type: optional + docs: The updated vendor as the result of the specified operation. + source: + openapi: ../default/openapi/openapi.json + VendorUpdatedEventObjectOperation: + type: literal<"UPDATED"> + docs: >- + The operation that can be performed against a vendor to cause the event to + be published. + VisibilityFilter: + enum: + - ALL + - READ + - READ_WRITE + docs: >- + Enumeration of visibility-filter values used to set the ability to view + custom attributes or custom attribute definitions. + source: + openapi: ../default/openapi/openapi.json + VoidTransactionResponse: + docs: >- + Defines the fields that are included in the response body of + + a request to the + [VoidTransaction](api-endpoint:Transactions-VoidTransaction) endpoint. + properties: + errors: + type: optional> + docs: Any errors that occurred during the request. + source: + openapi: ../default/openapi/openapi.json + WageSetting: + docs: >- + Represents information about the overtime exemption status, job + assignments, and compensation + + for a [team member](entity:TeamMember). + properties: + team_member_id: + type: optional> + docs: The ID of the team member associated with the wage setting. + job_assignments: + type: optional>> + docs: >- + **Required** The ordered list of jobs that the team member is assigned + to. + + The first job assignment is considered the team member's primary job. + is_overtime_exempt: + type: optional> + docs: >- + Whether the team member is exempt from the overtime rules of the + seller's country. + version: + type: optional + docs: >- + **Read only** Used for resolving concurrency issues. The request fails + if the version + + provided does not match the server version at the time of the request. + If not provided, + + Square executes a blind write, potentially overwriting data from + another write. For more information, + + see [optimistic + concurrency](https://developer.squareup.com/docs/working-with-apis/optimistic-concurrency). + created_at: + type: optional + docs: The timestamp when the wage setting was created, in RFC 3339 format. + access: read-only + updated_at: + type: optional + docs: >- + The timestamp when the wage setting was last updated, in RFC 3339 + format. + access: read-only + source: + openapi: ../default/openapi/openapi.json + WebhookSubscription: + docs: >- + Represents the details of a webhook subscription, including notification + URL, + + event types, and signature key. + properties: + id: + type: optional + docs: A Square-generated unique ID for the subscription. + validation: + maxLength: 64 + access: read-only + name: + type: optional> + docs: The name of this subscription. + validation: + maxLength: 64 + enabled: + type: optional> + docs: >- + Indicates whether the subscription is enabled (`true`) or not + (`false`). + event_types: + type: optional>> + docs: The event types associated with this subscription. + notification_url: + type: optional> + docs: The URL to which webhooks are sent. + api_version: + type: optional> + docs: |- + The API version of the subscription. + This field is optional for `CreateWebhookSubscription`. + The value defaults to the API version used by the application. + signature_key: + type: optional + docs: >- + The Square-generated signature key used to validate the origin of the + webhook event. + access: read-only + created_at: + type: optional + docs: >- + The timestamp of when the subscription was created, in RFC 3339 + format. For example, "2016-09-04T23:59:33.123Z". + access: read-only + updated_at: + type: optional + docs: >- + The timestamp of when the subscription was last updated, in RFC 3339 + format. + + For example, "2016-09-04T23:59:33.123Z". + access: read-only + source: + openapi: ../default/openapi/openapi.json + Weekday: + enum: + - MON + - TUE + - WED + - THU + - FRI + - SAT + - SUN + docs: The days of the week. + source: + openapi: ../default/openapi/openapi.json + WorkweekConfig: + docs: |- + Sets the day of the week and hour of the day that a business starts a + workweek. This is used to calculate overtime pay. + properties: + id: + type: optional + docs: The UUID for this object. + start_of_week: + type: Weekday + docs: |- + The day of the week on which a business week starts for + compensation purposes. + See [Weekday](#type-weekday) for possible values + start_of_day_local_time: + type: string + docs: |- + The local time at which a business week starts. Represented as a + string in `HH:MM` format (`HH:MM:SS` is also accepted, but seconds are + truncated). + validation: + minLength: 1 + version: + type: optional + docs: >- + Used for resolving concurrency issues. The request fails if the + version + + provided does not match the server version at the time of the request. + If not provided, + + Square executes a blind write; potentially overwriting data from + another + + write. + created_at: + type: optional + docs: A read-only timestamp in RFC 3339 format; presented in UTC. + access: read-only + updated_at: + type: optional + docs: A read-only timestamp in RFC 3339 format; presented in UTC. + access: read-only + source: + openapi: ../default/openapi/openapi.json + CatalogObjectItem: + properties: + item_data: + type: optional + docs: >- + Structured data for a `CatalogItem`, set for CatalogObjects of type + `ITEM`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectImage: + properties: + image_data: + type: optional + docs: >- + Structured data for a `CatalogImage`, set for CatalogObjects of type + `IMAGE`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectItemVariation: + properties: + item_variation_data: + type: optional + docs: >- + Structured data for a `CatalogItemVariation`, set for CatalogObjects + of type `ITEM_VARIATION`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectTax: + properties: + tax_data: + type: optional + docs: >- + Structured data for a `CatalogTax`, set for CatalogObjects of type + `TAX`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectDiscount: + properties: + discount_data: + type: optional + docs: >- + Structured data for a `CatalogDiscount`, set for CatalogObjects of + type `DISCOUNT`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectModifierList: + properties: + modifier_list_data: + type: optional + docs: >- + Structured data for a `CatalogModifierList`, set for CatalogObjects of + type `MODIFIER_LIST`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectModifier: + properties: + modifier_data: + type: optional + docs: >- + Structured data for a `CatalogModifier`, set for CatalogObjects of + type `MODIFIER`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectPricingRule: + properties: + pricing_rule_data: + type: optional + docs: >- + Structured data for a `CatalogPricingRule`, set for CatalogObjects of + type `PRICING_RULE`. + + A `CatalogPricingRule` object often works with a `CatalogProductSet` + object or a `CatalogTimePeriod` object. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectProductSet: + properties: + product_set_data: + type: optional + docs: >- + Structured data for a `CatalogProductSet`, set for CatalogObjects of + type `PRODUCT_SET`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectTimePeriod: + properties: + time_period_data: + type: optional + docs: >- + Structured data for a `CatalogTimePeriod`, set for CatalogObjects of + type `TIME_PERIOD`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectMeasurementUnit: + properties: + measurement_unit_data: + type: optional + docs: >- + Structured data for a `CatalogMeasurementUnit`, set for CatalogObjects + of type `MEASUREMENT_UNIT`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectSubscriptionPlanVariation: + properties: + subscription_plan_variation_data: + type: optional + docs: >- + Structured data for a `CatalogSubscriptionPlanVariation`, set for + CatalogObjects of type `SUBSCRIPTION_PLAN_VARIATION`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectItemOption: + properties: + item_option_data: + type: optional + docs: >- + Structured data for a `CatalogItemOption`, set for CatalogObjects of + type `ITEM_OPTION`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectItemOptionValue: + properties: + item_option_value_data: + type: optional + docs: >- + Structured data for a `CatalogItemOptionValue`, set for CatalogObjects + of type `ITEM_OPTION_VAL`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectCustomAttributeDefinition: + properties: + custom_attribute_definition_data: + type: optional + docs: >- + Structured data for a `CatalogCustomAttributeDefinition`, set for + CatalogObjects of type `CUSTOM_ATTRIBUTE_DEFINITION`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectQuickAmountsSettings: + properties: + quick_amounts_settings_data: + type: optional + docs: >- + Structured data for a `CatalogQuickAmountsSettings`, set for + CatalogObjects of type `QUICK_AMOUNTS_SETTINGS`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectSubscriptionPlan: + properties: + subscription_plan_data: + type: optional + docs: >- + Structured data for a `CatalogSubscriptionPlan`, set for + CatalogObjects of type `SUBSCRIPTION_PLAN`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + CatalogObjectAvailabilityPeriod: + properties: + availability_period_data: + type: optional + docs: >- + Structured data for a `CatalogAvailabilityPeriod`, set for + CatalogObjects of type `AVAILABILITY_PERIOD`. + extends: + - CatalogObjectBase + source: + openapi: ../default/openapi/openapi.json + GetLoyaltyAccountRequest: unknown + GetLoyaltyProgramRequest: unknown + GetLoyaltyPromotionRequest: unknown + GetLoyaltyRewardRequest: unknown + GetCardRequest: unknown + GetDisputeEvidenceRequest: unknown + GetDisputeRequest: unknown + V1GetPaymentRequest: unknown + V1GetSettlementRequest: unknown + GetCustomerGroupRequest: unknown + GetCustomerRequest: unknown + GetCustomerSegmentRequest: unknown + GetTransactionRequest: unknown + GetBookingRequest: unknown + GetBusinessBookingProfileRequest: unknown + GetTeamMemberBookingProfileRequest: unknown + GetSnippetRequest: unknown + GetInventoryAdjustmentRequest: unknown + GetInventoryPhysicalCountRequest: unknown + GetInventoryTransferRequest: unknown + GetVendorRequest: unknown + GetPaymentLinkRequest: unknown + GetGiftCardRequest: unknown + GetOrderRequest: unknown + GetEmployeeRequest: unknown + GetLocationRequest: unknown + GetMerchantRequest: unknown + GetTeamMemberRequest: unknown + GetWageSettingRequest: unknown + GetWebhookSubscriptionRequest: unknown +imports: + checkout: checkout.yml diff --git a/.mock/definition/api.yml b/.mock/definition/api.yml new file mode 100644 index 00000000..b1e07d59 --- /dev/null +++ b/.mock/definition/api.yml @@ -0,0 +1,19 @@ +name: api +error-discrimination: + strategy: status-code +display-name: Square +environments: + Production: https://connect.squareup.com + Sandbox: https://connect.squareupsandbox.com +default-environment: Production +headers: + Square-Version: + name: version + env: VERSION + type: literal<"2025-10-16"> +auth-schemes: + Bearer: + scheme: bearer + token: + env: SQUARE_TOKEN +auth: Bearer diff --git a/.mock/definition/applePay.yml b/.mock/definition/applePay.yml new file mode 100644 index 00000000..65e4ec53 --- /dev/null +++ b/.mock/definition/applePay.yml @@ -0,0 +1,81 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + RegisterDomain: + path: /v2/apple-pay/domains + method: POST + auth: + - oauth2: [] + docs: >- + Activates a domain for use with Apple Pay on the Web and Square. A + validation + + is performed on this domain by Apple to ensure that it is properly set + up as + + an Apple Pay enabled domain. + + + This endpoint provides an easy way for platform developers to bulk + activate + + Apple Pay on the Web with Square for merchants using their platform. + + + Note: You will need to host a valid domain verification file on your + domain to support Apple Pay. The + + current version of this file is always available at + https://app.squareup.com/digital-wallets/apple-pay/apple-developer-merchantid-domain-association, + + and should be hosted at + `.well_known/apple-developer-merchantid-domain-association` on your + + domain. This file is subject to change; we strongly recommend checking + for updates regularly and avoiding + + long-lived caches that might not keep in sync with the correct file + version. + + + 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). + source: + openapi: ../default/openapi/openapi.json + display-name: RegisterDomain + request: + name: RegisterDomainRequest + body: + properties: + domain_name: + type: string + docs: >- + A domain name as described in RFC-1034 that will be registered + with ApplePay. + validation: + minLength: 1 + maxLength: 255 + content-type: application/json + response: + docs: Success + type: root.RegisterDomainResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + domain_name: example.com + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + status: VERIFIED + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/bankAccounts.yml b/.mock/definition/bankAccounts.yml new file mode 100644 index 00000000..0cde77b6 --- /dev/null +++ b/.mock/definition/bankAccounts.yml @@ -0,0 +1,222 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/bank-accounts + method: GET + auth: + - oauth2: + - BANK_ACCOUNTS_READ + docs: >- + Returns a list of [BankAccount](entity:BankAccount) objects linked to a + Square account. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.bank_accounts + source: + openapi: ../default/openapi/openapi.json + display-name: ListBankAccounts + request: + name: ListBankAccountsRequest + query-parameters: + cursor: + type: optional> + docs: >- + The pagination cursor returned by a previous call to this + endpoint. + + Use it in the next `ListBankAccounts` request to retrieve the next + set + + of results. + + + See the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + limit: + type: optional> + docs: >- + Upper limit on the number of bank accounts to return in the + response. + + Currently, 1000 is the largest supported limit. You can specify a + limit + + of up to 1000 bank accounts. This is also the default limit. + location_id: + type: optional> + docs: >- + Location ID. You can specify this optional filter + + to retrieve only the linked bank accounts belonging to a specific + location. + response: + docs: Success + type: root.ListBankAccountsResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + limit: 1 + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + bank_accounts: + - id: ao6iaQ9vhDiaQD7n3GB + account_number_suffix: '971' + country: US + currency: USD + account_type: CHECKING + holder_name: Jane Doe + primary_bank_identification_number: '112200303' + secondary_bank_identification_number: secondary_bank_identification_number + debit_mandate_reference_id: debit_mandate_reference_id + reference_id: reference_id + location_id: S8GWD5example + status: VERIFICATION_IN_PROGRESS + creditable: false + debitable: false + fingerprint: fingerprint + version: 5 + bank_name: Bank Name + - id: 4x7WXuaxrkQkVlka3GB + account_number_suffix: '972' + country: US + currency: USD + account_type: CHECKING + holder_name: Jane Doe + primary_bank_identification_number: '112200303' + secondary_bank_identification_number: secondary_bank_identification_number + debit_mandate_reference_id: debit_mandate_reference_id + reference_id: reference_id + location_id: S8GWD5example + status: VERIFICATION_IN_PROGRESS + creditable: false + debitable: false + fingerprint: fingerprint + version: 5 + bank_name: Bank Name + cursor: cursor + GetByV1Id: + path: /v2/bank-accounts/by-v1-id/{v1_bank_account_id} + method: GET + auth: + - oauth2: + - BANK_ACCOUNTS_READ + docs: >- + Returns details of a [BankAccount](entity:BankAccount) identified by V1 + bank account ID. + source: + openapi: ../default/openapi/openapi.json + display-name: GetBankAccountByV1Id + request: + name: GetByV1IdBankAccountsRequest + path-parameters: + v1_bank_account_id: + type: string + docs: >- + Connect V1 ID of the desired `BankAccount`. For more information, + see + + [Retrieve a bank account by using an ID issued by V1 Bank Accounts + API](https://developer.squareup.com/docs/bank-accounts-api#retrieve-a-bank-account-by-using-an-id-issued-by-v1-bank-accounts-api). + response: + docs: Success + type: root.GetBankAccountByV1IdResponse + status-code: 200 + examples: + - path-parameters: + v1_bank_account_id: v1_bank_account_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + bank_account: + id: w3yRgCGYQnwmdl0R3GB + account_number_suffix: '971' + country: US + currency: USD + account_type: CHECKING + holder_name: Jane Doe + primary_bank_identification_number: '112200303' + secondary_bank_identification_number: secondary_bank_identification_number + debit_mandate_reference_id: debit_mandate_reference_id + reference_id: reference_id + location_id: S8GWD5example + status: VERIFICATION_IN_PROGRESS + creditable: false + debitable: false + fingerprint: fingerprint + version: 5 + bank_name: Bank Name + get: + path: /v2/bank-accounts/{bank_account_id} + method: GET + auth: + - oauth2: + - BANK_ACCOUNTS_READ + docs: |- + Returns details of a [BankAccount](entity:BankAccount) + linked to a Square account. + source: + openapi: ../default/openapi/openapi.json + display-name: GetBankAccount + request: + name: GetBankAccountsRequest + path-parameters: + bank_account_id: + type: string + docs: Square-issued ID of the desired `BankAccount`. + response: + docs: Success + type: root.GetBankAccountResponse + status-code: 200 + examples: + - path-parameters: + bank_account_id: bank_account_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + bank_account: + id: w3yRgCGYQnwmdl0R3GB + account_number_suffix: '971' + country: US + currency: USD + account_type: CHECKING + holder_name: Jane Doe + primary_bank_identification_number: '112200303' + secondary_bank_identification_number: secondary_bank_identification_number + debit_mandate_reference_id: debit_mandate_reference_id + reference_id: reference_id + location_id: S8GWD5example + status: VERIFICATION_IN_PROGRESS + creditable: false + debitable: false + fingerprint: fingerprint + version: 5 + bank_name: Bank Name + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/bookings.yml b/.mock/definition/bookings.yml new file mode 100644 index 00000000..b351549b --- /dev/null +++ b/.mock/definition/bookings.yml @@ -0,0 +1,909 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/bookings + method: GET + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Retrieve a collection of bookings. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.bookings + source: + openapi: ../default/openapi/openapi.json + display-name: ListBookings + request: + name: ListBookingsRequest + query-parameters: + limit: + type: optional> + docs: >- + The maximum number of results per page to return in a paged + response. + cursor: + type: optional> + docs: >- + The pagination cursor from the preceding response to return the + next page of the results. Do not set this when retrieving the + first page of the results. + customer_id: + type: optional> + docs: >- + The [customer](entity:Customer) for whom to retrieve bookings. If + this is not set, bookings for all customers are retrieved. + team_member_id: + type: optional> + docs: >- + The team member for whom to retrieve bookings. If this is not set, + bookings of all members are retrieved. + location_id: + type: optional> + docs: >- + The location for which to retrieve bookings. If this is not set, + all locations' bookings are retrieved. + start_at_min: + type: optional> + docs: >- + The RFC 3339 timestamp specifying the earliest of the start time. + If this is not set, the current time is used. + start_at_max: + type: optional> + docs: >- + The RFC 3339 timestamp specifying the latest of the start time. If + this is not set, the time of 31 days after `start_at_min` is used. + response: + docs: Success + type: root.ListBookingsResponse + status-code: 200 + examples: + - query-parameters: + limit: 1 + cursor: cursor + customer_id: customer_id + team_member_id: team_member_id + location_id: location_id + start_at_min: start_at_min + start_at_max: start_at_max + headers: + Square-Version: '2025-10-16' + response: + body: + bookings: + - id: zkras0xv0xwswx + version: 1 + status: ACCEPTED + created_at: '2020-10-28T15:47:41Z' + updated_at: '2020-10-28T15:49:25Z' + start_at: '2020-11-26T13:00:00Z' + location_id: LEQHH0YY8B42M + customer_id: EX2QSVGTZN4K1E5QE1CBFNVQ8M + customer_note: '' + seller_note: '' + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + transition_time_minutes: 1 + all_day: true + location_type: BUSINESS_LOCATION + source: FIRST_PARTY_MERCHANT + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/bookings + method: POST + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Creates a booking. + + + The required input must include the following: + + - `Booking.location_id` + + - `Booking.start_at` + + - `Booking.AppointmentSegment.team_member_id` + + - `Booking.AppointmentSegment.service_variation_id` + + - `Booking.AppointmentSegment.service_variation_version` + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateBooking + request: + name: CreateBookingRequest + body: + properties: + idempotency_key: + type: optional + docs: A unique key to make this request an idempotent operation. + validation: + maxLength: 255 + booking: + type: root.Booking + docs: The details of the booking to be created. + content-type: application/json + response: + docs: Success + type: root.CreateBookingResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + booking: {} + response: + body: + booking: + id: zkras0xv0xwswx + version: 0 + status: ACCEPTED + created_at: '2020-10-28T15:47:41Z' + updated_at: '2020-10-28T15:47:41Z' + start_at: '2020-11-26T13:00:00Z' + location_id: LEQHH0YY8B42M + customer_id: EX2QSVGTZN4K1E5QE1CBFNVQ8M + customer_note: '' + seller_note: '' + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + transition_time_minutes: 1 + all_day: true + location_type: BUSINESS_LOCATION + creator_details: + creator_type: TEAM_MEMBER + team_member_id: team_member_id + customer_id: customer_id + source: FIRST_PARTY_MERCHANT + address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + SearchAvailability: + path: /v2/bookings/availability/search + method: POST + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Searches for availabilities for booking. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchAvailability + request: + name: SearchAvailabilityRequest + body: + properties: + query: + type: root.SearchAvailabilityQuery + docs: >- + Query conditions used to filter buyer-accessible booking + availabilities. + content-type: application/json + response: + docs: Success + type: root.SearchAvailabilityResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + start_at_range: {} + response: + body: + availabilities: + - start_at: '2020-11-26T13:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-26T13:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-26T14:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-26T14:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-26T15:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-26T15:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-26T16:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-27T09:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-27T09:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-27T10:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-27T10:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-27T11:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-27T11:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-27T12:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-27T12:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + - start_at: '2020-11-27T13:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-27T13:30:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + - start_at: '2020-11-27T14:00:00Z' + location_id: LEQHH0YY8B42M + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMaJcbiRqPIGZuS9 + service_variation_version: 1599775456731 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + BulkRetrieveBookings: + path: /v2/bookings/bulk-retrieve + method: POST + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Bulk-Retrieves a list of bookings by booking IDs. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkRetrieveBookings + request: + name: BulkRetrieveBookingsRequest + body: + properties: + booking_ids: + docs: >- + A non-empty list of [Booking](entity:Booking) IDs specifying + bookings to retrieve. + type: list + content-type: application/json + response: + docs: Success + type: root.BulkRetrieveBookingsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + booking_ids: + - booking_ids + response: + body: + bookings: + sc3p3m7dvctfr1: + booking: + id: sc3p3m7dvctfr1 + version: 0 + status: ACCEPTED + created_at: '2023-04-26T18:19:21Z' + updated_at: '2023-04-26T18:19:21Z' + start_at: '2023-05-01T14:00:00Z' + location_id: LY6WNBPVM6VGV + customer_id: 4TDWKN9E8165X8Z77MRS0VFMJM + appointment_segments: + - duration_minutes: 60 + service_variation_id: VG4FYBKK3UL6UITOEYQ6MFLS + team_member_id: TMjiqI3PxyLMKr4k + service_variation_version: 1641341724039 + any_team_member: false + all_day: false + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + tdegug1dvctdef: + errors: + - category: INVALID_REQUEST_ERROR + code: NOT_FOUND + detail: Specified booking was not found. + field: booking_id + tdegug1fqni3wh: + booking: + id: tdegug1fqni3wh + version: 0 + status: ACCEPTED + created_at: '2023-04-26T18:19:30Z' + updated_at: '2023-04-26T18:19:30Z' + start_at: '2023-05-02T14:00:00Z' + location_id: LY6WNBPVM6VGV + customer_id: 4TDWKN9E8165X8Z77MRS0VFMJM + appointment_segments: + - duration_minutes: 60 + service_variation_id: VG4FYBKK3UL6UITOEYQ6MFLS + team_member_id: TMjiqI3PxyLMKr4k + service_variation_version: 1641341724039 + any_team_member: false + all_day: false + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + getBusinessProfile: + path: /v2/bookings/business-booking-profile + method: GET + auth: + - oauth2: + - APPOINTMENTS_BUSINESS_SETTINGS_READ + docs: Retrieves a seller's booking profile. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveBusinessBookingProfile + response: + docs: Success + type: root.GetBusinessBookingProfileResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + business_booking_profile: + seller_id: MLJQYZZRM0D3Y + created_at: '2020-09-10T21:40:38Z' + booking_enabled: true + customer_timezone_choice: CUSTOMER_CHOICE + booking_policy: ACCEPT_ALL + allow_user_cancel: true + business_appointment_settings: + location_types: + - BUSINESS_LOCATION + alignment_time: HALF_HOURLY + min_booking_lead_time_seconds: 0 + max_booking_lead_time_seconds: 31536000 + any_team_member_booking_enabled: true + multiple_service_booking_enabled: true + max_appointments_per_day_limit_type: PER_TEAM_MEMBER + max_appointments_per_day_limit: 1 + cancellation_window_seconds: 1 + cancellation_fee_money: + currency: USD + cancellation_policy: CUSTOM_POLICY + cancellation_policy_text: cancellation_policy_text + skip_booking_flow_staff_selection: false + support_seller_level_writes: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + RetrieveLocationBookingProfile: + path: /v2/bookings/location-booking-profiles/{location_id} + method: GET + auth: + - oauth2: + - APPOINTMENTS_BUSINESS_SETTINGS_READ + docs: Retrieves a seller's location booking profile. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLocationBookingProfile + request: + name: RetrieveLocationBookingProfileRequest + path-parameters: + location_id: + type: string + docs: The ID of the location to retrieve the booking profile. + response: + docs: Success + type: root.RetrieveLocationBookingProfileResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + location_booking_profile: + location_id: L3HETDGYQ4A2C + booking_site_url: https://square.site/book/L3HETDGYQ4A2C/prod-business + online_booking_enabled: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + BulkRetrieveTeamMemberBookingProfiles: + path: /v2/bookings/team-member-booking-profiles/bulk-retrieve + method: POST + auth: + - oauth2: + - APPOINTMENTS_BUSINESS_SETTINGS_READ + docs: Retrieves one or more team members' booking profiles. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkRetrieveTeamMemberBookingProfiles + request: + name: BulkRetrieveTeamMemberBookingProfilesRequest + body: + properties: + team_member_ids: + docs: >- + A non-empty list of IDs of team members whose booking profiles + you want to retrieve. + type: list + content-type: application/json + response: + docs: Success + type: root.BulkRetrieveTeamMemberBookingProfilesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + team_member_ids: + - team_member_ids + response: + body: + team_member_booking_profiles: + TMXUrsBWWcHTt79t: + errors: + - category: INVALID_REQUEST_ERROR + code: NOT_FOUND + detail: Resource not found. + TMaJcbiRqPIGZuS9: + team_member_booking_profile: + team_member_id: TMaJcbiRqPIGZuS9 + display_name: Sandbox Staff 1 + is_bookable: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + TMtdegug1fqni3wh: + team_member_booking_profile: + team_member_id: TMtdegug1fqni3wh + display_name: Sandbox Staff 2 + is_bookable: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/bookings/{booking_id} + method: GET + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Retrieves a booking. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveBooking + request: + name: GetBookingsRequest + path-parameters: + booking_id: + type: string + docs: >- + The ID of the [Booking](entity:Booking) object representing the + to-be-retrieved booking. + response: + docs: Success + type: root.GetBookingResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + headers: + Square-Version: '2025-10-16' + response: + body: + booking: + id: zkras0xv0xwswx + version: 1 + status: ACCEPTED + created_at: '2020-10-28T15:47:41Z' + updated_at: '2020-10-28T15:49:25Z' + start_at: '2020-11-26T13:00:00Z' + location_id: LEQHH0YY8B42M + customer_id: EX2QSVGTZN4K1E5QE1CBFNVQ8M + customer_note: '' + seller_note: '' + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + transition_time_minutes: 1 + all_day: true + location_type: BUSINESS_LOCATION + creator_details: + creator_type: TEAM_MEMBER + team_member_id: team_member_id + customer_id: customer_id + source: FIRST_PARTY_MERCHANT + address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/bookings/{booking_id} + method: PUT + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Updates a booking. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateBooking + request: + name: UpdateBookingRequest + path-parameters: + booking_id: + type: string + docs: >- + The ID of the [Booking](entity:Booking) object representing the + to-be-updated booking. + body: + properties: + idempotency_key: + type: optional> + docs: A unique key to make this request an idempotent operation. + validation: + maxLength: 255 + booking: + type: root.Booking + docs: >- + The booking to be updated. Individual attributes explicitly + specified here override the corresponding values of the existing + booking. + content-type: application/json + response: + docs: Success + type: root.UpdateBookingResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + headers: + Square-Version: '2025-10-16' + request: + booking: {} + response: + body: + booking: + id: zkras0xv0xwswx + version: 2 + status: ACCEPTED + created_at: '2020-10-28T15:47:41Z' + updated_at: '2020-10-28T15:49:25Z' + start_at: '2020-11-26T13:00:00Z' + location_id: LEQHH0YY8B42M + customer_id: EX2QSVGTZN4K1E5QE1CBFNVQ8M + customer_note: I would like to sit near the window please + seller_note: '' + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + transition_time_minutes: 1 + all_day: true + location_type: CUSTOMER_LOCATION + creator_details: + creator_type: TEAM_MEMBER + team_member_id: team_member_id + customer_id: customer_id + source: FIRST_PARTY_MERCHANT + address: + address_line_1: 1955 Broadway + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: Oakland + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: CA + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '94612' + country: ZZ + first_name: first_name + last_name: last_name + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cancel: + path: /v2/bookings/{booking_id}/cancel + method: POST + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Cancels an existing booking. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelBooking + request: + name: CancelBookingRequest + path-parameters: + booking_id: + type: string + docs: >- + The ID of the [Booking](entity:Booking) object representing the + to-be-cancelled booking. + body: + properties: + idempotency_key: + type: optional> + docs: A unique key to make this request an idempotent operation. + validation: + maxLength: 255 + booking_version: + type: optional> + docs: >- + The revision number for the booking used for optimistic + concurrency. + content-type: application/json + response: + docs: Success + type: root.CancelBookingResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + booking: + id: zkras0xv0xwswx + version: 1 + status: CANCELLED_BY_CUSTOMER + created_at: '2020-10-28T15:47:41Z' + updated_at: '2020-10-28T15:49:25Z' + start_at: '2020-11-26T13:00:00Z' + location_id: LEQHH0YY8B42M + customer_id: EX2QSVGTZN4K1E5QE1CBFNVQ8M + customer_note: '' + seller_note: '' + appointment_segments: + - duration_minutes: 60 + service_variation_id: RU3PBTZTK7DXZDQFCJHOK2MC + team_member_id: TMXUrsBWWcHTt79t + service_variation_version: 1599775456731 + transition_time_minutes: 1 + all_day: true + location_type: BUSINESS_LOCATION + creator_details: + creator_type: TEAM_MEMBER + team_member_id: team_member_id + customer_id: customer_id + source: FIRST_PARTY_MERCHANT + address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/bookings/customAttributeDefinitions.yml b/.mock/definition/bookings/customAttributeDefinitions.yml new file mode 100644 index 00000000..0ca0c195 --- /dev/null +++ b/.mock/definition/bookings/customAttributeDefinitions.yml @@ -0,0 +1,413 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/bookings/custom-attribute-definitions + method: GET + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Get all bookings custom attribute definitions. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attribute_definitions + source: + openapi: ../default/openapi/openapi.json + display-name: ListBookingCustomAttributeDefinitions + request: + name: ListCustomAttributeDefinitionsRequest + query-parameters: + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + response: + docs: Success + type: root.ListBookingCustomAttributeDefinitionsResponse + status-code: 200 + examples: + - query-parameters: + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definitions: + - key: favoriteShampoo + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite shampoo + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + version: 3 + updated_at: '2022-11-16T15:39:38Z' + created_at: '2022-11-16T15:27:30Z' + - key: partySize + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Party size + description: Number of people in the party for dine-in + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: '2022-11-16T15:49:05Z' + created_at: '2022-11-16T15:49:05Z' + cursor: >- + YEk4UPbUEsu8MUV0xouO5hCiFcD9T5ztB6UWEJq5vZnqBFmoBEi0j1j6HWYTFGMRre4p7T5wAQBj3Th1NX3XgBFcQVEVsIxUQ2NsbwjRitfoEZDml9uxxQXepowyRvCuSThHPbJSn7M7wInl3x8XypQF9ahVVQXegJ0CxEKc0SBH + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/bookings/custom-attribute-definitions + method: POST + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Creates a bookings custom attribute definition. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateBookingCustomAttributeDefinition + request: + name: CreateBookingCustomAttributeDefinitionRequest + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + The custom attribute definition to create, with the following + fields: + + + - `key` + + + - `name`. If provided, `name` must be unique (case-sensitive) + across all visible booking-related custom attribute + + definitions for the seller. + + + - `description` + + + - `visibility`. Note that all custom attributes are visible in + exported booking data, including those set to + + `VISIBILITY_HIDDEN`. + + + - `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). + idempotency_key: + type: optional + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CreateBookingCustomAttributeDefinitionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: {} + response: + body: + custom_attribute_definition: + key: favoriteShampoo + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite Shampoo + description: The favorite shampoo of the customer. + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: '2022-11-16T15:27:30Z' + created_at: '2022-11-16T15:27:30Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/bookings/custom-attribute-definitions/{key} + method: GET + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Retrieves a bookings custom attribute definition. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveBookingCustomAttributeDefinition + request: + name: GetCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: >- + The key of the custom attribute definition to retrieve. If the + requesting application + + is not the definition owner, you must use the qualified key. + query-parameters: + version: + type: optional> + docs: >- + The current version of the custom attribute definition, which is + used for strongly consistent + + reads to guarantee that you receive the most up-to-date data. When + included in the request, + + Square returns the specified version or a higher version if one + exists. If the specified version + + is higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.RetrieveBookingCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + query-parameters: + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definition: + key: favoriteShampoo + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite shampoo + description: The favorite shampoo of the customer. + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-11-16T15:27:30Z' + created_at: '2022-11-16T15:27:30Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/bookings/custom-attribute-definitions/{key} + method: PUT + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Updates a bookings custom attribute definition. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateBookingCustomAttributeDefinition + request: + name: UpdateBookingCustomAttributeDefinitionRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to update. + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + The custom attribute definition that contains the fields to + update. 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 + + [Updatable definition + fields](https://developer.squareup.com/docs/booking-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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdateBookingCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: {} + response: + body: + custom_attribute_definition: + key: favoriteShampoo + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite shampoo + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + version: 2 + updated_at: '2022-11-16T15:39:38Z' + created_at: '2022-11-16T15:27:30Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/bookings/custom-attribute-definitions/{key} + method: DELETE + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Deletes a bookings custom attribute definition. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteBookingCustomAttributeDefinition + request: + name: DeleteCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to delete. + response: + docs: Success + type: root.DeleteBookingCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/bookings/customAttributes.yml b/.mock/definition/bookings/customAttributes.yml new file mode 100644 index 00000000..ed35cc1d --- /dev/null +++ b/.mock/definition/bookings/customAttributes.yml @@ -0,0 +1,565 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + batchDelete: + path: /v2/bookings/custom-attributes/bulk-delete + method: POST + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Bulk deletes bookings custom attributes. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkDeleteBookingCustomAttributes + request: + name: BulkDeleteBookingCustomAttributesRequest + body: + properties: + values: + type: map + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BulkDeleteBookingCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + key: + booking_id: booking_id + key: key + response: + body: + values: + id1: + booking_id: N3NCVYY3WS27HF0HKANA3R9FP8 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + booking_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id3: + booking_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchUpsert: + path: /v2/bookings/custom-attributes/bulk-upsert + method: POST + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Bulk upserts bookings custom attributes. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpsertBookingCustomAttributes + request: + name: BulkUpsertBookingCustomAttributesRequest + body: + properties: + values: + type: map + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BulkUpsertBookingCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + key: + booking_id: booking_id + custom_attribute: {} + response: + body: + values: + id1: + booking_id: N3NCVYY3WS27HF0HKANA3R9FP8 + custom_attribute: + key: favoriteShampoo + value: Spring Fresh + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-16T00:16:23Z' + created_at: '2022-11-16T23:14:47Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + booking_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + custom_attribute: + key: hasShoes + value: false + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-16T00:16:23Z' + created_at: '2022-11-16T00:16:20Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id3: + booking_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + custom_attribute: + key: favoriteShampoo + value: Hydro-Cool + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-16T00:16:23Z' + created_at: '2022-11-16T00:16:20Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id4: + booking_id: N3NCVYY3WS27HF0HKANA3R9FP8 + custom_attribute: + key: partySize + value: 4 + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-16T00:16:23Z' + created_at: '2022-11-16T23:14:47Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id5: + booking_id: 70548QG1HN43B05G0KCZ4MMC1G + custom_attribute: + key: celebrating + value: birthday + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-16T00:16:23Z' + created_at: '2022-11-16T00:16:20Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + list: + path: /v2/bookings/{booking_id}/custom-attributes + method: GET + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Lists a booking's custom attributes. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attributes + source: + openapi: ../default/openapi/openapi.json + display-name: ListBookingCustomAttributes + request: + name: ListCustomAttributesRequest + path-parameters: + booking_id: + type: string + docs: The ID of the target [booking](entity:Booking). + query-parameters: + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + with_definitions: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of each + + custom attribute. Set this parameter to `true` to get the name and + description of each custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + response: + docs: Success + type: root.ListBookingCustomAttributesResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + query-parameters: + limit: 1 + cursor: cursor + with_definitions: true + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attributes: + - key: favoriteShampoo + value: Hydro-Cool + version: 1 + visibility: VISIBILITY_READ_ONLY + updated_at: '2022-11-16T15:50:27Z' + created_at: '2022-11-16T15:50:27Z' + - key: hasShoes + value: false + version: 1 + visibility: VISIBILITY_HIDDEN + updated_at: '2022-11-16T15:51:53Z' + created_at: '2022-11-16T15:51:53Z' + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/bookings/{booking_id}/custom-attributes/{key} + method: GET + auth: + - oauth2: + - APPOINTMENTS_READ + docs: >- + Retrieves a bookings custom attribute. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_READ` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveBookingCustomAttribute + request: + name: GetCustomAttributesRequest + path-parameters: + booking_id: + type: string + docs: The ID of the target [booking](entity:Booking). + key: + type: string + docs: >- + The key of the custom attribute to retrieve. This key must match + the `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + query-parameters: + with_definition: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of + + the custom attribute. Set this parameter to `true` to get the name + and description of the custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + version: + type: optional> + docs: >- + The current version of the custom attribute, which is used for + strongly consistent reads to + + guarantee that you receive the most up-to-date data. When included + in the request, Square + + returns the specified version or a higher version if one exists. + If the specified version is + + higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.RetrieveBookingCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + key: key + query-parameters: + with_definition: true + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute: + key: favoriteShampoo + value: Dune + version: 1 + visibility: VISIBILITY_READ_ONLY + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2022-11-16T15:50:27Z' + created_at: '2022-11-16T15:50:27Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + upsert: + path: /v2/bookings/{booking_id}/custom-attributes/{key} + method: PUT + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Upserts a bookings custom attribute. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertBookingCustomAttribute + request: + name: UpsertBookingCustomAttributeRequest + path-parameters: + booking_id: + type: string + docs: The ID of the target [booking](entity:Booking). + key: + type: string + docs: >- + The key of the custom attribute to create or update. This key must + match the `key` of a + + custom attribute definition in the Square seller account. If the + requesting application is not + + the definition owner, you must use the qualified key. + body: + properties: + custom_attribute: + type: root.CustomAttribute + docs: >- + The custom attribute to create or update, with the following + fields: + + + - `value`. This value must conform to the `schema` specified by + the definition. + + For more information, see [Value data + types](https://developer.squareup.com/docs/booking-custom-attributes-api/custom-attributes#value-data-types). + + + - `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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpsertBookingCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute: {} + response: + body: + custom_attribute: + key: favoriteShampoo + value: Spring Fresh + version: 1 + visibility: VISIBILITY_READ_ONLY + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2022-11-16T15:50:27Z' + created_at: '2022-11-16T15:50:27Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/bookings/{booking_id}/custom-attributes/{key} + method: DELETE + auth: + - oauth2: + - APPOINTMENTS_WRITE + docs: >- + Deletes a bookings custom attribute. + + + To call this endpoint with buyer-level permissions, set + `APPOINTMENTS_WRITE` for the OAuth scope. + + To call this endpoint with seller-level permissions, set + `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. + + + For calls to this endpoint with seller-level permissions to succeed, the + seller must have subscribed to *Appointments Plus* + + or *Appointments Premium*. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteBookingCustomAttribute + request: + name: DeleteCustomAttributesRequest + path-parameters: + booking_id: + type: string + docs: The ID of the target [booking](entity:Booking). + key: + type: string + docs: >- + The key of the custom attribute to delete. This key must match the + `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + response: + docs: Success + type: root.DeleteBookingCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + booking_id: booking_id + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/bookings/locationProfiles.yml b/.mock/definition/bookings/locationProfiles.yml new file mode 100644 index 00000000..bc741e62 --- /dev/null +++ b/.mock/definition/bookings/locationProfiles.yml @@ -0,0 +1,59 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/bookings/location-booking-profiles + method: GET + auth: + - oauth2: + - APPOINTMENTS_BUSINESS_SETTINGS_READ + docs: Lists location booking profiles of a seller. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.location_booking_profiles + source: + openapi: ../default/openapi/openapi.json + display-name: ListLocationBookingProfiles + request: + name: ListLocationProfilesRequest + query-parameters: + limit: + type: optional> + docs: The maximum number of results to return in a paged response. + cursor: + type: optional> + docs: >- + The pagination cursor from the preceding response to return the + next page of the results. Do not set this when retrieving the + first page of the results. + response: + docs: Success + type: root.ListLocationBookingProfilesResponse + status-code: 200 + examples: + - query-parameters: + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + location_booking_profiles: + - location_id: LY6WNBPVM6VGV + booking_site_url: https://squareup.com/book/LY6WNBPVM6VGV/testbusiness + online_booking_enabled: true + - location_id: PYTRNBPVMJUPV + booking_site_url: booking_site_url + online_booking_enabled: false + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/bookings/teamMemberProfiles.yml b/.mock/definition/bookings/teamMemberProfiles.yml new file mode 100644 index 00000000..b31bba07 --- /dev/null +++ b/.mock/definition/bookings/teamMemberProfiles.yml @@ -0,0 +1,114 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/bookings/team-member-booking-profiles + method: GET + auth: + - oauth2: + - APPOINTMENTS_BUSINESS_SETTINGS_READ + docs: Lists booking profiles for team members. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.team_member_booking_profiles + source: + openapi: ../default/openapi/openapi.json + display-name: ListTeamMemberBookingProfiles + request: + name: ListTeamMemberProfilesRequest + query-parameters: + bookable_only: + type: optional> + default: false + docs: >- + Indicates whether to include only bookable team members in the + returned result (`true`) or not (`false`). + limit: + type: optional> + docs: The maximum number of results to return in a paged response. + cursor: + type: optional> + docs: >- + The pagination cursor from the preceding response to return the + next page of the results. Do not set this when retrieving the + first page of the results. + location_id: + type: optional> + docs: >- + Indicates whether to include only team members enabled at the + given location in the returned result. + response: + docs: Success + type: root.ListTeamMemberBookingProfilesResponse + status-code: 200 + examples: + - query-parameters: + bookable_only: true + limit: 1 + cursor: cursor + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + team_member_booking_profiles: + - team_member_id: TMXUrsBWWcHTt79t + description: description + display_name: Sandbox Seller + is_bookable: true + profile_image_url: profile_image_url + - team_member_id: TMaJcbiRqPIGZuS9 + description: description + display_name: Sandbox Staff + is_bookable: true + profile_image_url: profile_image_url + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/bookings/team-member-booking-profiles/{team_member_id} + method: GET + auth: + - oauth2: + - APPOINTMENTS_BUSINESS_SETTINGS_READ + docs: Retrieves a team member's booking profile. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveTeamMemberBookingProfile + request: + name: GetTeamMemberProfilesRequest + path-parameters: + team_member_id: + type: string + docs: The ID of the team member to retrieve. + response: + docs: Success + type: root.GetTeamMemberBookingProfileResponse + status-code: 200 + examples: + - path-parameters: + team_member_id: team_member_id + headers: + Square-Version: '2025-10-16' + response: + body: + team_member_booking_profile: + team_member_id: TMaJcbiRqPIGZuS9 + description: description + display_name: Sandbox Staff + is_bookable: true + profile_image_url: profile_image_url + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/cards.yml b/.mock/definition/cards.yml new file mode 100644 index 00000000..ac532b89 --- /dev/null +++ b/.mock/definition/cards.yml @@ -0,0 +1,365 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/cards + method: GET + auth: + - oauth2: [] + docs: |- + Retrieves a list of cards owned by the account making the request. + A max of 25 cards will be returned. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.cards + source: + openapi: ../default/openapi/openapi.json + display-name: ListCards + request: + name: ListCardsRequest + query-parameters: + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this to retrieve the next set of results for your original + query. + + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + customer_id: + type: optional> + docs: |- + Limit results to cards associated with the customer supplied. + By default, all cards owned by the merchant are returned. + include_disabled: + type: optional> + default: false + docs: |- + Includes disabled cards. + By default, all enabled cards owned by the merchant are returned. + reference_id: + type: optional> + docs: Limit results to cards associated with the reference_id supplied. + sort_order: + type: optional> + docs: >- + Sorts the returned list by when the card was created with the + specified order. + + This field defaults to ASC. + response: + docs: Success + type: root.ListCardsResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + customer_id: customer_id + include_disabled: true + reference_id: reference_id + sort_order: DESC + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cards: + - id: ccof:uIbfJXhXETSP197M3GB + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + cardholder_name: Amelia Earhart + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + fingerprint: >- + ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q + customer_id: VDKXEEKPJN48QDG3BGGFAK05P8 + merchant_id: 6SSW7HV8K2ST5 + reference_id: user-id-1 + enabled: true + card_type: CREDIT + prepaid_type: NOT_PREPAID + bin: '411111' + version: 1 + card_co_brand: UNKNOWN + issuer_alert: ISSUER_ALERT_CARD_CLOSED + issuer_alert_at: issuer_alert_at + hsa_fsa: false + cursor: cursor + create: + path: /v2/cards + method: POST + auth: + - oauth2: [] + docs: Adds a card on file to an existing merchant. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCard + request: + name: CreateCardRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this CreateCard request. Keys + can be + + any valid string and must be unique for every request. + + + Max: 45 characters + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + source_id: + type: string + docs: >- + The ID of the source which represents the card information to be + stored. This can be a card nonce or a payment id. + validation: + minLength: 1 + maxLength: 16384 + verification_token: + type: optional + docs: >- + An identifying token generated by + [Payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer). + + Verification tokens encapsulate customer device information and + 3-D Secure + + challenge results to indicate that Square has verified the buyer + identity. + + + See the [SCA + Overview](https://developer.squareup.com/docs/sca-overview). + card: + type: root.Card + docs: Payment details associated with the card to be stored. + content-type: application/json + response: + docs: Success + type: root.CreateCardResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 4935a656-a929-4792-b97c-8848be85c27c + source_id: cnon:uIbfJXhXETSP197M3GB + card: + cardholder_name: Amelia Earhart + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + customer_id: VDKXEEKPJN48QDG3BGGFAK05P8 + reference_id: user-id-1 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + card: + id: ccof:uIbfJXhXETSP197M3GB + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + cardholder_name: Amelia Earhart + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + fingerprint: >- + ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q + customer_id: VDKXEEKPJN48QDG3BGGFAK05P8 + merchant_id: 6SSW7HV8K2ST5 + reference_id: user-id-1 + enabled: true + card_type: CREDIT + prepaid_type: NOT_PREPAID + bin: '411111' + version: 1 + card_co_brand: UNKNOWN + issuer_alert: ISSUER_ALERT_CARD_CLOSED + issuer_alert_at: issuer_alert_at + hsa_fsa: false + get: + path: /v2/cards/{card_id} + method: GET + auth: + - oauth2: [] + docs: Retrieves details for a specific Card. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCard + request: + name: GetCardsRequest + path-parameters: + card_id: + type: string + docs: Unique ID for the desired Card. + response: + docs: Success + type: root.GetCardResponse + status-code: 200 + examples: + - path-parameters: + card_id: card_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + card: + id: ccof:uIbfJXhXETSP197M3GB + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + cardholder_name: Amelia Earhart + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + fingerprint: >- + ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q + customer_id: VDKXEEKPJN48QDG3BGGFAK05P8 + merchant_id: 6SSW7HV8K2ST5 + reference_id: user-id-1 + enabled: true + card_type: CREDIT + prepaid_type: NOT_PREPAID + bin: '411111' + version: 1 + card_co_brand: UNKNOWN + issuer_alert: ISSUER_ALERT_CARD_CLOSED + issuer_alert_at: issuer_alert_at + hsa_fsa: false + disable: + path: /v2/cards/{card_id}/disable + method: POST + auth: + - oauth2: [] + docs: |- + Disables the card, preventing any further updates or charges. + Disabling an already disabled card is allowed but has no effect. + source: + openapi: ../default/openapi/openapi.json + display-name: DisableCard + request: + name: DisableCardsRequest + path-parameters: + card_id: + type: string + docs: Unique ID for the desired Card. + response: + docs: Success + type: root.DisableCardResponse + status-code: 200 + examples: + - path-parameters: + card_id: card_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + card: + id: ccof:uIbfJXhXETSP197M3GB + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + cardholder_name: Amelia Earhart + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + fingerprint: >- + ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q + customer_id: VDKXEEKPJN48QDG3BGGFAK05P8 + merchant_id: 6SSW7HV8K2ST5 + reference_id: user-id-1 + enabled: false + card_type: CREDIT + prepaid_type: NOT_PREPAID + bin: '411111' + version: 2 + card_co_brand: UNKNOWN + issuer_alert: ISSUER_ALERT_CARD_CLOSED + issuer_alert_at: issuer_alert_at + hsa_fsa: false + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/cashDrawers/shifts.yml b/.mock/definition/cashDrawers/shifts.yml new file mode 100644 index 00000000..4e559667 --- /dev/null +++ b/.mock/definition/cashDrawers/shifts.yml @@ -0,0 +1,277 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/cash-drawers/shifts + method: GET + auth: + - oauth2: + - CASH_DRAWER_READ + docs: |- + Provides the details for all of the cash drawer shifts for a location + in a date range. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.cash_drawer_shifts + source: + openapi: ../default/openapi/openapi.json + display-name: ListCashDrawerShifts + request: + name: ListShiftsRequest + query-parameters: + location_id: + type: string + docs: The ID of the location to query for a list of cash drawer shifts. + sort_order: + type: optional> + docs: |- + The order in which cash drawer shifts are listed in the response, + based on their opened_at field. Default value: ASC + begin_time: + type: optional> + docs: >- + The inclusive start time of the query on opened_at, in ISO 8601 + format. + end_time: + type: optional> + docs: >- + The exclusive end date of the query on opened_at, in ISO 8601 + format. + limit: + type: optional> + docs: |- + Number of cash drawer shift events in a page of results (200 by + default, 1000 max). + cursor: + type: optional> + docs: Opaque cursor for fetching the next page of results. + response: + docs: Success + type: root.ListCashDrawerShiftsResponse + status-code: 200 + examples: + - query-parameters: + location_id: location_id + sort_order: DESC + begin_time: begin_time + end_time: end_time + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cash_drawer_shifts: + - id: DCC99978-09A6-4926-849F-300BE9C5793A + state: CLOSED + opened_at: '2019-11-22T00:42:54.000Z' + ended_at: '2019-11-22T00:44:49.000Z' + closed_at: '2019-11-22T00:44:49.000Z' + description: Misplaced some change + opened_cash_money: + amount: 10000 + currency: USD + expected_cash_money: + amount: 10000 + currency: USD + closed_cash_money: + amount: 9970 + currency: USD + created_at: created_at + updated_at: updated_at + location_id: location_id + get: + path: /v2/cash-drawers/shifts/{shift_id} + method: GET + auth: + - oauth2: + - CASH_DRAWER_READ + docs: >- + Provides the summary details for a single cash drawer shift. See + + [ListCashDrawerShiftEvents](api-endpoint:CashDrawers-ListCashDrawerShiftEvents) + for a list of cash drawer shift events. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCashDrawerShift + request: + name: GetShiftsRequest + path-parameters: + shift_id: + type: string + docs: The shift ID. + query-parameters: + location_id: + type: string + docs: The ID of the location to retrieve cash drawer shifts from. + response: + docs: Success + type: root.GetCashDrawerShiftResponse + status-code: 200 + examples: + - path-parameters: + shift_id: shift_id + query-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + cash_drawer_shift: + id: DCC99978-09A6-4926-849F-300BE9C5793A + state: CLOSED + opened_at: '2019-11-22T00:42:54.000Z' + ended_at: '2019-11-22T00:44:49.000Z' + closed_at: '2019-11-22T00:44:49.000Z' + description: Misplaced some change + opened_cash_money: + amount: 10000 + currency: USD + cash_payment_money: + amount: 100 + currency: USD + cash_refunds_money: + amount: -100 + currency: USD + cash_paid_in_money: + amount: 10000 + currency: USD + cash_paid_out_money: + amount: -10000 + currency: USD + expected_cash_money: + amount: 10000 + currency: USD + closed_cash_money: + amount: 9970 + currency: USD + device: + id: id + name: My iPad + created_at: created_at + updated_at: updated_at + location_id: location_id + team_member_ids: + - team_member_ids + opening_team_member_id: '' + ending_team_member_id: '' + closing_team_member_id: '' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + listEvents: + path: /v2/cash-drawers/shifts/{shift_id}/events + method: GET + auth: + - oauth2: + - CASH_DRAWER_READ + docs: Provides a paginated list of events for a single cash drawer shift. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.cash_drawer_shift_events + source: + openapi: ../default/openapi/openapi.json + display-name: ListCashDrawerShiftEvents + request: + name: ListEventsShiftsRequest + path-parameters: + shift_id: + type: string + docs: The shift ID. + query-parameters: + location_id: + type: string + docs: The ID of the location to list cash drawer shifts for. + limit: + type: optional> + docs: |- + Number of resources to be returned in a page of results (200 by + default, 1000 max). + cursor: + type: optional> + docs: Opaque cursor for fetching the next page of results. + response: + docs: Success + type: root.ListCashDrawerShiftEventsResponse + status-code: 200 + examples: + - path-parameters: + shift_id: shift_id + query-parameters: + location_id: location_id + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cash_drawer_shift_events: + - id: 9F07DB01-D85A-4B77-88C3-D5C64CEB5155 + event_type: CASH_TENDER_PAYMENT + event_money: + amount: 100 + currency: USD + created_at: '2019-11-22T00:43:02.000Z' + description: '' + team_member_id: '' + - id: B2854CEA-A781-49B3-8F31-C64558231F48 + event_type: CASH_TENDER_PAYMENT + event_money: + amount: 250 + currency: USD + created_at: '2019-11-22T00:43:12.000Z' + description: '' + team_member_id: '' + - id: B5FB7F72-95CD-44A3-974D-26C41064D042 + event_type: CASH_TENDER_CANCELLED_PAYMENT + event_money: + amount: 250 + currency: USD + created_at: '2019-11-22T00:43:23.000Z' + description: '' + team_member_id: '' + - id: 0B425480-8504-40B4-A867-37B23543931B + event_type: CASH_TENDER_REFUND + event_money: + amount: 100 + currency: USD + created_at: '2019-11-22T00:43:46.000Z' + description: '' + team_member_id: '' + - id: 8C66E60E-FDCF-4EEF-A98D-3B14B7ED5CBE + event_type: PAID_IN + event_money: + amount: 10000 + currency: USD + created_at: '2019-11-22T00:44:18.000Z' + description: Transfer from another drawer + team_member_id: '' + - id: D5ACA7FE-C64D-4ADA-8BC8-82118A2DAE4F + event_type: PAID_OUT + event_money: + amount: 10000 + currency: USD + created_at: '2019-11-22T00:44:29.000Z' + description: Transfer out to another drawer + team_member_id: '' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/catalog.yml b/.mock/definition/catalog.yml new file mode 100644 index 00000000..36556e05 --- /dev/null +++ b/.mock/definition/catalog.yml @@ -0,0 +1,1226 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + batchDelete: + path: /v2/catalog/batch-delete + method: POST + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Deletes a set of [CatalogItem](entity:CatalogItem)s based on the + + provided list of target IDs and returns a set of successfully deleted + IDs in + + the response. Deletion is a cascading event such that all children of + the + + targeted object are also deleted. For example, deleting a CatalogItem + will + + also delete all of its + [CatalogItemVariation](entity:CatalogItemVariation) + + children. + + + `BatchDeleteCatalogObjects` succeeds even if only a portion of the + targeted + + IDs can be deleted. The response will only include IDs that were + + actually deleted. + + + To ensure consistency, only one delete request is processed at a time + per seller account. + + While one (batch or non-batch) delete request is being processed, other + (batched and non-batched) + + delete requests are rejected with the `429` error code. + source: + openapi: ../default/openapi/openapi.json + display-name: BatchDeleteCatalogObjects + request: + name: BatchDeleteCatalogObjectsRequest + body: + properties: + object_ids: + docs: >- + The IDs of the CatalogObjects to be deleted. When an object is + deleted, other objects + + in the graph that depend on that object will be deleted as well + (for example, deleting a + + CatalogItem will delete its CatalogItemVariation. + type: list + content-type: application/json + response: + docs: Success + type: root.BatchDeleteCatalogObjectsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + - AA27W3M2GGTF3H6AVPNB77CK + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + deleted_object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + - AA27W3M2GGTF3H6AVPNB77CK + deleted_at: '2016-11-16T22:25:24.878Z' + batchGet: + path: /v2/catalog/batch-retrieve + method: POST + auth: + - oauth2: + - ITEMS_READ + docs: >- + Returns a set of objects based on the provided ID. + + Each [CatalogItem](entity:CatalogItem) returned in the set includes all + of its + + child information including: all of its + + [CatalogItemVariation](entity:CatalogItemVariation) objects, references + to + + its [CatalogModifierList](entity:CatalogModifierList) objects, and the + ids of + + any [CatalogTax](entity:CatalogTax) objects that apply to it. + source: + openapi: ../default/openapi/openapi.json + display-name: BatchRetrieveCatalogObjects + request: + name: BatchGetCatalogObjectsRequest + body: + properties: + object_ids: + docs: The IDs of the CatalogObjects to be retrieved. + type: list + include_related_objects: + type: optional> + docs: >- + If `true`, the response will include additional objects that are + related to the + + requested objects. Related objects are defined as any objects + referenced by ID by the results in the `objects` field + + of the response. These objects are put in the `related_objects` + field. Setting this to `true` is + + helpful when the objects are needed for immediate display to a + user. + + This process only goes one level deep. Objects referenced by the + related objects will not be included. For example, + + + if the `objects` field of the response contains a CatalogItem, + its associated + + CatalogCategory objects, CatalogTax objects, CatalogImage + objects and + + CatalogModifierLists will be returned in the `related_objects` + field of the + + response. If the `objects` field of the response contains a + CatalogItemVariation, + + its parent CatalogItem will be returned in the `related_objects` + field of + + the response. + + + Default value: `false` + catalog_version: + type: optional> + docs: >- + The specific version of the catalog objects to be included in + the response. + + This allows you to retrieve historical versions of objects. The + specified version value is matched against + + the [CatalogObject](entity:CatalogObject)s' `version` attribute. + If not included, results will + + be from the current version of the catalog. + include_deleted_objects: + type: optional> + docs: >- + Indicates whether to include (`true`) or not (`false`) in the + response deleted objects, namely, those with the `is_deleted` + attribute set to `true`. + include_category_path_to_root: + type: optional> + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BatchGetCatalogObjectsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + - AA27W3M2GGTF3H6AVPNB77CK + include_related_objects: true + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + related_objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + ordinal: 1000000 + type: CATEGORY + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: TAX + batchUpsert: + path: /v2/catalog/batch-upsert + method: POST + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Creates or updates up to 10,000 target objects based on the provided + + list of objects. The target objects are grouped into batches and each + batch is + + inserted/updated in an all-or-nothing manner. If an object within a + batch is + + malformed in some way, or violates a database constraint, the entire + batch + + containing that item will be disregarded. However, other batches in the + same + + request may still succeed. Each batch may contain up to 1,000 objects, + and + + batches will be processed in order as long as the total object count for + the + + request (items, variations, modifier lists, discounts, and taxes) is no + more + + than 10,000. + + + To ensure consistency, only one update request is processed at a time + per seller account. + + While one (batch or non-batch) update request is being processed, other + (batched and non-batched) + + update requests are rejected with the `429` error code. + source: + openapi: ../default/openapi/openapi.json + display-name: BatchUpsertCatalogObjects + request: + name: BatchUpsertCatalogObjectsRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A value you specify that uniquely identifies this + + request among all your requests. A common way to create + + a valid idempotency key is to use a Universally unique + + identifier (UUID). + + + If you're unsure whether a particular request was successful, + + you can reattempt it with the same idempotency key without + + worrying about creating duplicate objects. + + + See + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 128 + batches: + docs: >- + A batch of CatalogObjects to be inserted/updated atomically. + + The objects within a batch will be inserted in an all-or-nothing + fashion, i.e., if an error occurs + + attempting to insert or update an object within a batch, the + entire batch will be rejected. However, an error + + in one batch will not affect other batches within the same + request. + + + For each object, its `updated_at` field is ignored and replaced + with a current + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates), + and its + + `is_deleted` field must not be set to `true`. + + + To modify an existing object, supply its ID. To create a new + object, use an ID starting + + with `#`. These IDs may be used to create relationships between + an object and attributes of + + other objects that reference it. For example, you can create a + CatalogItem with + + ID `#ABC` and a CatalogItemVariation with its `item_id` + attribute set to + + `#ABC` in order to associate the CatalogItemVariation with its + parent + + CatalogItem. + + + Any `#`-prefixed IDs are valid only within a single atomic + batch, and will be replaced by server-generated IDs. + + + Each batch may contain up to 1,000 objects. The total number of + objects across all batches for a single request + + may not exceed 10,000. If either of these limits is violated, an + error will be returned and no objects will + + be inserted or updated. + type: list + content-type: application/json + response: + docs: Success + type: root.BatchUpsertCatalogObjectsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 789ff020-f723-43a9-b4b5-43b5dc1fa3dc + batches: + - objects: + - id: id + type: ITEM + - id: id + type: ITEM + - id: id + type: ITEM + - id: id + type: TAX + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + ordinal: 1000000 + type: CATEGORY + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: TAX + updated_at: updated_at + id_mappings: + - client_object_id: '#Tea' + object_id: 67GA7XA2FWMRYY2VCONTYZJR + - client_object_id: '#Coffee' + object_id: MQ4TZKOG3SR2EQI3TWEK4AH7 + - client_object_id: '#Beverages' + object_id: XCS4SCGN4WQYE2VU4U3TKXEH + - client_object_id: '#SalesTax' + object_id: HP5VNYPKZKTNCKZ2Z5NPUH6A + - client_object_id: '#Tea_Mug' + object_id: CAJBHUIQH7ONTSZI2KTVOUP6 + - client_object_id: '#Coffee_Regular' + object_id: GY2GXJTVVPQAPW43GFRR3NG6 + - client_object_id: '#Coffee_Large' + object_id: JE6VHPSRQL6IWSN26C36CJ7W + info: + path: /v2/catalog/info + method: GET + auth: + - oauth2: + - ITEMS_READ + docs: |- + Retrieves information about the Square Catalog API, such as batch size + limits that can be used by the `BatchUpsertCatalogObjects` endpoint. + source: + openapi: ../default/openapi/openapi.json + display-name: CatalogInfo + response: + docs: Success + type: root.CatalogInfoResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + limits: + batch_upsert_max_objects_per_batch: 1000 + batch_upsert_max_total_objects: 10000 + batch_retrieve_max_object_ids: 1000 + search_max_page_limit: 1000 + batch_delete_max_object_ids: 200 + update_item_taxes_max_item_ids: 1000 + update_item_taxes_max_taxes_to_enable: 1000 + update_item_taxes_max_taxes_to_disable: 1000 + update_item_modifier_lists_max_item_ids: 1000 + update_item_modifier_lists_max_modifier_lists_to_enable: 1000 + update_item_modifier_lists_max_modifier_lists_to_disable: 1000 + standard_unit_description_group: + standard_unit_descriptions: + - {} + language_code: language_code + list: + path: /v2/catalog/list + method: GET + auth: + - oauth2: + - ITEMS_READ + docs: >- + Returns a list of all [CatalogObject](entity:CatalogObject)s of the + specified types in the catalog. + + + The `types` parameter is specified as a comma-separated list of the + [CatalogObjectType](entity:CatalogObjectType) values, + + for example, "`ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, + `CATEGORY`, `DISCOUNT`, `TAX`, `IMAGE`". + + + __Important:__ ListCatalog does not return deleted catalog items. To + retrieve + + deleted catalog items, use + [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects) + + and set the `include_deleted_objects` attribute value to `true`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.objects + source: + openapi: ../default/openapi/openapi.json + display-name: ListCatalog + request: + name: ListCatalogRequest + query-parameters: + cursor: + type: optional> + docs: >- + The pagination cursor returned in the previous response. Leave + unset for an initial request. + + The page size is currently set to be 100. + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + types: + type: optional> + docs: >- + An optional case-insensitive, comma-separated list of object types + to retrieve. + + + The valid values are defined in the + [CatalogObjectType](entity:CatalogObjectType) enum, for example, + + `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, + + `MODIFIER`, `MODIFIER_LIST`, `IMAGE`, etc. + + + If this is unspecified, the operation returns objects of all the + top level types at the version + + of the Square API used to make the request. Object types that are + nested onto other object types + + are not included in the defaults. + + + At the current API version the default object types are: + + ITEM, CATEGORY, TAX, DISCOUNT, MODIFIER_LIST, + + PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT, + + SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION, + QUICK_AMOUNT_SETTINGS. + catalog_version: + type: optional> + docs: >- + The specific version of the catalog objects to be included in the + response. + + This allows you to retrieve historical versions of objects. The + specified version value is matched against + + the [CatalogObject](entity:CatalogObject)s' `version` attribute. + If not included, results will be from the + + current version of the catalog. + response: + docs: Success + type: root.ListCatalogResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + types: types + catalog_version: 1000000 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cursor: cursor + objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + ordinal: 1000000 + type: CATEGORY + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: TAX + search: + path: /v2/catalog/search + method: POST + auth: + - oauth2: + - ITEMS_READ + docs: >- + Searches for [CatalogObject](entity:CatalogObject) of any type by + matching supported search attribute values, + + excluding custom attribute values on items or item variations, against + one or more of the specified query filters. + + + This (`SearchCatalogObjects`) endpoint differs from the + [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) + + endpoint in the following aspects: + + + - `SearchCatalogItems` can only search for items or item variations, + whereas `SearchCatalogObjects` can search for any type of catalog + objects. + + - `SearchCatalogItems` supports the custom attribute query filters to + return items or item variations that contain custom attribute values, + where `SearchCatalogObjects` does not. + + - `SearchCatalogItems` does not support the `include_deleted_objects` + filter to search for deleted items or item variations, whereas + `SearchCatalogObjects` does. + + - The both endpoints have different call conventions, including the + query filter formats. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchCatalogObjects + request: + name: SearchCatalogObjectsRequest + body: + properties: + cursor: + type: optional + docs: >- + The pagination cursor returned in the previous response. Leave + unset for an initial request. + + See + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination) + for more information. + object_types: + type: optional> + docs: >- + The desired set of object types to appear in the search results. + + + If this is unspecified, the operation returns objects of all the + top level types at the version + + of the Square API used to make the request. Object types that + are nested onto other object types + + are not included in the defaults. + + + At the current API version the default object types are: + + ITEM, CATEGORY, TAX, DISCOUNT, MODIFIER_LIST, + + PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT, + + SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION, + QUICK_AMOUNT_SETTINGS. + + + Note that if you wish for the query to return objects belonging + to nested types (i.e., COMPONENT, IMAGE, + + ITEM_OPTION_VAL, ITEM_VARIATION, or MODIFIER), you must + explicitly include all the types of interest + + in this field. + include_deleted_objects: + type: optional + docs: >- + 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. + include_related_objects: + type: optional + docs: >- + 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 + + in the response. This is helpful if the objects are being + fetched for immediate display to a user. + + This process only goes one level deep. Objects referenced by the + related objects will not be included. + + For example: + + + If the `objects` field of the response contains a CatalogItem, + its associated + + CatalogCategory objects, CatalogTax objects, CatalogImage + objects and + + CatalogModifierLists will be returned in the `related_objects` + field of the + + response. If the `objects` field of the response contains a + CatalogItemVariation, + + its parent CatalogItem will be returned in the `related_objects` + field of + + the response. + + + Default value: `false` + begin_time: + type: optional + docs: >- + Return objects modified after this + [timestamp](https://developer.squareup.com/docs/build-basics/working-with-dates), + in RFC 3339 + + format, e.g., `2016-09-04T23:59:33.123Z`. The timestamp is + exclusive - objects with a + + timestamp equal to `begin_time` will not be included in the + response. + query: + type: optional + docs: >- + A query to be used to filter or sort the results. If no query is + specified, the entire catalog will be returned. + limit: + type: optional + docs: >- + A limit on the number of results to be returned in a single + page. The limit is advisory - + + 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. + include_category_path_to_root: + type: optional + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.SearchCatalogObjectsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + object_types: + - ITEM + query: + prefix_query: + attribute_name: name + attribute_prefix: tea + limit: 100 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cursor: cursor + objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + related_objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + latest_time: latest_time + SearchItems: + path: /v2/catalog/search-catalog-items + method: POST + auth: + - oauth2: + - ITEMS_READ + docs: >- + Searches for catalog items or item variations by matching supported + search attribute values, including + + custom attribute values, against one or more of the specified query + filters. + + + This (`SearchCatalogItems`) endpoint differs from the + [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects) + + endpoint in the following aspects: + + + - `SearchCatalogItems` can only search for items or item variations, + whereas `SearchCatalogObjects` can search for any type of catalog + objects. + + - `SearchCatalogItems` supports the custom attribute query filters to + return items or item variations that contain custom attribute values, + where `SearchCatalogObjects` does not. + + - `SearchCatalogItems` does not support the `include_deleted_objects` + filter to search for deleted items or item variations, whereas + `SearchCatalogObjects` does. + + - The both endpoints use different call conventions, including the query + filter formats. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchCatalogItems + request: + name: SearchCatalogItemsRequest + body: + properties: + text_filter: + type: optional + docs: >- + The text filter expression to return items or item variations + containing specified text in + + the `name`, `description`, or `abbreviation` attribute value of + an item, or in + + the `name`, `sku`, or `upc` attribute value of an item + variation. + category_ids: + type: optional> + docs: >- + The category id query expression to return items containing the + specified category IDs. + stock_levels: + type: optional> + docs: >- + The stock-level query expression to return item variations with + the specified stock levels. + + See + [SearchCatalogItemsRequestStockLevel](#type-searchcatalogitemsrequeststocklevel) + for possible values + enabled_location_ids: + type: optional> + docs: >- + The enabled-location query expression to return items and item + variations having specified enabled locations. + cursor: + type: optional + docs: >- + The pagination token, returned in the previous response, used to + fetch the next batch of pending results. + limit: + type: optional + docs: >- + The maximum number of results to return per page. The default + value is 100. + validation: + max: 100 + sort_order: + type: optional + docs: >- + The order to sort the results by item names. The default sort + order is ascending (`ASC`). + + See [SortOrder](#type-sortorder) for possible values + product_types: + type: optional> + docs: >- + The product types query expression to return items or item + variations having the specified product types. + custom_attribute_filters: + type: optional> + docs: >- + The customer-attribute filter to return items or item variations + matching the specified + + custom attribute expressions. A maximum number of 10 custom + attribute expressions are supported in + + a single call to the + [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) + endpoint. + archived_state: + type: optional + docs: >- + The query filter to return not archived + (`ARCHIVED_STATE_NOT_ARCHIVED`), archived + (`ARCHIVED_STATE_ARCHIVED`), or either type + (`ARCHIVED_STATE_ALL`) of items. + content-type: application/json + response: + docs: Success + type: root.SearchCatalogItemsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + text_filter: red + category_ids: + - WINE_CATEGORY_ID + stock_levels: + - OUT + - LOW + enabled_location_ids: + - ATL_LOCATION_ID + limit: 100 + sort_order: ASC + product_types: + - REGULAR + custom_attribute_filters: + - custom_attribute_definition_id: VEGAN_DEFINITION_ID + bool_filter: true + - custom_attribute_definition_id: BRAND_DEFINITION_ID + string_filter: Dark Horse + - key: VINTAGE + number_filter: + min: min + max: max + - custom_attribute_definition_id: VARIETAL_DEFINITION_ID + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + items: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: ITEM + cursor: cursor + matched_variation_ids: + - VBJNPHCOKDFECR6VU25WRJUD + UpdateItemModifierLists: + path: /v2/catalog/update-item-modifier-lists + method: POST + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Updates the [CatalogModifierList](entity:CatalogModifierList) objects + + that apply to the targeted [CatalogItem](entity:CatalogItem) without + having + + to perform an upsert on the entire item. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateItemModifierLists + request: + name: UpdateItemModifierListsRequest + body: + properties: + item_ids: + docs: >- + The IDs of the catalog items associated with the + CatalogModifierList objects being updated. + type: list + modifier_lists_to_enable: + type: optional>> + docs: >- + The IDs of the CatalogModifierList objects to enable for the + CatalogItem. + + At least one of `modifier_lists_to_enable` or + `modifier_lists_to_disable` must be specified. + modifier_lists_to_disable: + type: optional>> + docs: >- + The IDs of the CatalogModifierList objects to disable for the + CatalogItem. + + At least one of `modifier_lists_to_enable` or + `modifier_lists_to_disable` must be specified. + content-type: application/json + response: + docs: Success + type: root.UpdateItemModifierListsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + item_ids: + - H42BRLUJ5KTZTTMPVSLFAACQ + - 2JXOBJIHCWBQ4NZ3RIXQGJA6 + modifier_lists_to_enable: + - H42BRLUJ5KTZTTMPVSLFAACQ + - 2JXOBJIHCWBQ4NZ3RIXQGJA6 + modifier_lists_to_disable: + - 7WRC16CJZDVLSNDQ35PP6YAD + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + updated_at: '2016-11-16T22:25:24.878Z' + UpdateItemTaxes: + path: /v2/catalog/update-item-taxes + method: POST + auth: + - oauth2: + - ITEMS_WRITE + docs: |- + Updates the [CatalogTax](entity:CatalogTax) objects that apply to the + targeted [CatalogItem](entity:CatalogItem) without having to perform an + upsert on the entire item. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateItemTaxes + request: + name: UpdateItemTaxesRequest + body: + properties: + item_ids: + docs: >- + IDs for the CatalogItems associated with the CatalogTax objects + being updated. + + No more than 1,000 IDs may be provided. + type: list + taxes_to_enable: + type: optional>> + docs: >- + IDs of the CatalogTax objects to enable. + + At least one of `taxes_to_enable` or `taxes_to_disable` must be + specified. + taxes_to_disable: + type: optional>> + docs: >- + IDs of the CatalogTax objects to disable. + + At least one of `taxes_to_enable` or `taxes_to_disable` must be + specified. + content-type: application/json + response: + docs: Success + type: root.UpdateItemTaxesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + item_ids: + - H42BRLUJ5KTZTTMPVSLFAACQ + - 2JXOBJIHCWBQ4NZ3RIXQGJA6 + taxes_to_enable: + - 4WRCNHCJZDVLSNDQ35PP6YAD + taxes_to_disable: + - AQCEGCEBBQONINDOHRGZISEX + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + updated_at: '2016-11-16T22:25:24.878Z' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/catalog/images.yml b/.mock/definition/catalog/images.yml new file mode 100644 index 00000000..02346150 --- /dev/null +++ b/.mock/definition/catalog/images.yml @@ -0,0 +1,152 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/catalog/images + method: POST + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Uploads an image file to be represented by a + [CatalogImage](entity:CatalogImage) object that can be linked to an + existing + + [CatalogObject](entity:CatalogObject) instance. The resulting + `CatalogImage` is unattached to any `CatalogObject` if the `object_id` + + is not specified. + + + This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data + requests with a JSON part and an image file part in + + JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCatalogImage + request: + name: CreateImagesRequest + body: + properties: + request: + type: optional + content-type: application/json; charset=utf-8 + image_file: + type: optional + content-type: image/jpeg + content-type: multipart/form-data + response: + docs: Success + type: root.CreateCatalogImageResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + image: + id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + image_data: + name: name + url: url + caption: caption + photo_studio_order_id: photo_studio_order_id + type: IMAGE + update: + path: /v2/catalog/images/{image_id} + method: PUT + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Uploads a new image file to replace the existing one in the specified + [CatalogImage](entity:CatalogImage) object. + + + This `UpdateCatalogImage` endpoint accepts HTTP multipart/form-data + requests with a JSON part and an image file part in + + JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateCatalogImage + request: + name: UpdateImagesRequest + path-parameters: + image_id: + type: string + docs: >- + The ID of the `CatalogImage` object to update the encapsulated + image file. + body: + properties: + request: + type: optional + content-type: application/json; charset=utf-8 + image_file: + type: optional + content-type: image/jpeg + content-type: multipart/form-data + response: + docs: Success + type: root.UpdateCatalogImageResponse + status-code: 200 + examples: + - path-parameters: + image_id: image_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + image: + id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + image_data: + name: name + url: url + caption: caption + photo_studio_order_id: photo_studio_order_id + type: IMAGE + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/catalog/object.yml b/.mock/definition/catalog/object.yml new file mode 100644 index 00000000..a8294858 --- /dev/null +++ b/.mock/definition/catalog/object.yml @@ -0,0 +1,400 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + upsert: + path: /v2/catalog/object + method: POST + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Creates a new or updates the specified + [CatalogObject](entity:CatalogObject). + + + To ensure consistency, only one update request is processed at a time + per seller account. + + While one (batch or non-batch) update request is being processed, other + (batched and non-batched) + + update requests are rejected with the `429` error code. + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertCatalogObject + request: + name: UpsertCatalogObjectRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A value you specify that uniquely identifies this + + request among all your requests. A common way to create + + a valid idempotency key is to use a Universally unique + + identifier (UUID). + + + If you're unsure whether a particular request was successful, + + you can reattempt it with the same idempotency key without + + worrying about creating duplicate objects. + + + See + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 128 + object: + type: root.CatalogObject + docs: >- + A CatalogObject to be created or updated. + + + - 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. + content-type: application/json + response: + docs: Success + type: root.UpsertCatalogObjectResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: af3d1afc-7212-4300-b463-0bfc5314a5ae + object: + id: id + type: ITEM + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + catalog_object: + id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + item_data: + name: name + description: description + abbreviation: abbreviation + label_color: label_color + is_taxable: true + category_id: category_id + tax_ids: + - tax_ids + modifier_list_info: + - modifier_list_id: modifier_list_id + product_type: REGULAR + skip_modifier_screen: true + item_options: + - {} + ecom_uri: ecom_uri + ecom_image_uris: + - ecom_image_uris + image_ids: + - image_ids + sort_name: sort_name + description_html: description_html + description_plaintext: description_plaintext + channels: + - channels + is_archived: true + is_alcoholic: true + type: ITEM + id_mappings: + - client_object_id: '#Cocoa' + object_id: R2TA2FOBUGCJZNIWJSOSNAI4 + - client_object_id: '#Small' + object_id: QRT53UP4LITLWGOGBZCUWP63 + - client_object_id: '#Large' + object_id: NS77DKEIQ3AEQTCP727DSA7U + get: + path: /v2/catalog/object/{object_id} + method: GET + auth: + - oauth2: + - ITEMS_READ + docs: >- + Returns a single [CatalogItem](entity:CatalogItem) as a + + [CatalogObject](entity:CatalogObject) based on the provided ID. The + returned + + object includes all of the relevant [CatalogItem](entity:CatalogItem) + + information including: + [CatalogItemVariation](entity:CatalogItemVariation) + + children, references to its + + [CatalogModifierList](entity:CatalogModifierList) objects, and the ids + of + + any [CatalogTax](entity:CatalogTax) objects that apply to it. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCatalogObject + request: + name: GetObjectRequest + path-parameters: + object_id: + type: string + docs: The object ID of any type of catalog objects to be retrieved. + query-parameters: + include_related_objects: + type: optional> + default: false + docs: >- + If `true`, the response will include additional objects that are + related to the + + requested objects. Related objects are defined as any objects + referenced by ID by the results in the `objects` field + + of the response. These objects are put in the `related_objects` + field. Setting this to `true` is + + helpful when the objects are needed for immediate display to a + user. + + This process only goes one level deep. Objects referenced by the + related objects will not be included. For example, + + + if the `objects` field of the response contains a CatalogItem, its + associated + + CatalogCategory objects, CatalogTax objects, CatalogImage objects + and + + CatalogModifierLists will be returned in the `related_objects` + field of the + + response. If the `objects` field of the response contains a + CatalogItemVariation, + + its parent CatalogItem will be returned in the `related_objects` + field of + + the response. + + + Default value: `false` + catalog_version: + type: optional> + docs: >- + Requests objects as of a specific version of the catalog. This + allows you to retrieve historical + + versions of objects. The value to retrieve a specific version of + an object can be found + + in the version field of [CatalogObject](entity:CatalogObject)s. If + not included, results will + + be from the current version of the catalog. + include_category_path_to_root: + type: optional> + default: false + docs: >- + 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. + response: + docs: Success + type: root.GetCatalogObjectResponse + status-code: 200 + examples: + - path-parameters: + object_id: object_id + query-parameters: + include_related_objects: true + catalog_version: 1000000 + include_category_path_to_root: true + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + object: + id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + item_data: + name: name + description: description + abbreviation: abbreviation + label_color: label_color + is_taxable: true + category_id: category_id + tax_ids: + - tax_ids + modifier_list_info: + - modifier_list_id: modifier_list_id + product_type: REGULAR + skip_modifier_screen: true + item_options: + - {} + ecom_uri: ecom_uri + ecom_image_uris: + - ecom_image_uris + image_ids: + - image_ids + sort_name: sort_name + description_html: description_html + description_plaintext: description_plaintext + channels: + - channels + is_archived: true + is_alcoholic: true + type: ITEM + related_objects: + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + ordinal: 1000000 + type: CATEGORY + - id: id + updated_at: updated_at + version: 1000000 + is_deleted: true + custom_attribute_values: + key: {} + catalog_v1_ids: + - {} + present_at_all_locations: true + present_at_location_ids: + - present_at_location_ids + absent_at_location_ids: + - absent_at_location_ids + image_id: image_id + type: TAX + delete: + path: /v2/catalog/object/{object_id} + method: DELETE + auth: + - oauth2: + - ITEMS_WRITE + docs: >- + Deletes a single [CatalogObject](entity:CatalogObject) based on the + + provided ID and returns the set of successfully deleted IDs in the + response. + + Deletion is a cascading event such that all children of the targeted + object + + are also deleted. For example, deleting a + [CatalogItem](entity:CatalogItem) + + will also delete all of its + + [CatalogItemVariation](entity:CatalogItemVariation) children. + + + To ensure consistency, only one delete request is processed at a time + per seller account. + + While one (batch or non-batch) delete request is being processed, other + (batched and non-batched) + + delete requests are rejected with the `429` error code. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteCatalogObject + request: + name: DeleteObjectRequest + path-parameters: + object_id: + type: string + docs: >- + The ID of the catalog object to be deleted. When an object is + deleted, other + + objects in the graph that depend on that object will be deleted as + well (for example, deleting a + + catalog item will delete its catalog item variations). + response: + docs: Success + type: root.DeleteCatalogObjectResponse + status-code: 200 + examples: + - path-parameters: + object_id: object_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + deleted_object_ids: + - 7SB3ZQYJ5GDMVFL7JK46JCHT + - KQLFFHA6K6J3YQAQAWDQAL57 + deleted_at: '2016-11-16T22:25:24.878Z' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/channels.yml b/.mock/definition/channels.yml new file mode 100644 index 00000000..c76ec24e --- /dev/null +++ b/.mock/definition/channels.yml @@ -0,0 +1,189 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/channels + method: GET + auth: + - oauth2: + - CHANNELS_READ + docs: '' + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.channels + source: + openapi: ../default/openapi/openapi.json + display-name: ListChannels + request: + name: ListChannelsRequest + query-parameters: + reference_type: + type: optional> + docs: Type of reference associated to channel + reference_id: + type: optional> + docs: id of reference associated to channel + status: + type: optional> + docs: Status of channel + cursor: + type: optional> + docs: Cursor to fetch the next result + limit: + type: optional> + docs: >- + Maximum number of results to return. + + When not provided the returned results will be cap at 100 + channels. + response: + docs: Success + type: root.ListChannelsResponse + status-code: 200 + examples: + - query-parameters: + reference_type: UNKNOWN_TYPE + reference_id: reference_id + status: ACTIVE + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + channels: + - id: CH_9C03D0B59 + merchant_id: ML64FACEA + name: Contoso Fulfillment Application + version: 1 + reference: + type: OAUTH_APPLICATION + id: OA_9C03D0444 + status: ACTIVE + created_at: '2022-10-25T16:27:00Z' + updated_at: '2022-10-25T16:48:00Z' + cursor: cursor + bulkRetrieve: + path: /v2/channels/bulk-retrieve + method: POST + auth: + - oauth2: + - CHANNELS_READ + docs: '' + source: + openapi: ../default/openapi/openapi.json + display-name: BulkRetrieveChannels + request: + name: BulkRetrieveChannelsRequest + body: + properties: + channel_ids: list + content-type: application/json + response: + docs: Success + type: root.BulkRetrieveChannelsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + channel_ids: + - CH_9C03D0B59 + - CH_6X139B5MN + - NOT_EXISTING + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + responses: + CH_6X139B5MN: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + channel: + id: CH_6X139B5MN + merchant_id: ML64FACEA + name: Contoso Fulfillment Application + version: 1 + reference: + type: OAUTH_APPLICATION + id: OA_9C03D0444 + status: ACTIVE + created_at: '2022-10-25T16:27:00Z' + updated_at: '2022-10-25T16:48:00Z' + CH_9C03D0B59: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + channel: + id: CH_9C03D0B59 + merchant_id: ML64FACEA + name: State Street Store + version: 1 + reference: + type: LOCATION + id: OA_9C03D0B59 + status: ACTIVE + created_at: '2022-10-25T16:27:00Z' + updated_at: '2022-10-25T16:48:00Z' + NOT_EXISTING: + errors: + - category: API_ERROR + code: NOT_FOUND + get: + path: /v2/channels/{channel_id} + method: GET + auth: + - oauth2: + - CHANNELS_READ + docs: '' + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveChannel + request: + name: GetChannelsRequest + path-parameters: + channel_id: + type: string + docs: A channel id + response: + docs: Success + type: root.RetrieveChannelResponse + status-code: 200 + examples: + - path-parameters: + channel_id: channel_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + channel: + id: CH_9C03D0B59 + merchant_id: ML64FACEA + name: Contoso Fulfillment Application + version: 1 + reference: + type: OAUTH_APPLICATION + id: OA_9C03D0444 + status: ACTIVE + created_at: '2022-10-25T16:27:00Z' + updated_at: '2022-10-25T16:48:00Z' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/checkout.yml b/.mock/definition/checkout.yml new file mode 100644 index 00000000..e6849079 --- /dev/null +++ b/.mock/definition/checkout.yml @@ -0,0 +1,341 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + RetrieveLocationSettings: + path: /v2/online-checkout/location-settings/{location_id} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: Retrieves the location-level settings for a Square-hosted checkout page. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLocationSettings + request: + name: RetrieveLocationSettingsRequest + path-parameters: + location_id: + type: string + docs: The ID of the location for which to retrieve settings. + response: + docs: Success + type: root.RetrieveLocationSettingsResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + location_settings: + location_id: LOCATION_ID_1 + customer_notes_enabled: true + policies: + - uid: POLICY_ID_1 + title: Return Policy + description: This is my Return Policy + branding: + header_type: FRAMED_LOGO + button_color: '#ffffff' + button_shape: ROUNDED + tipping: + percentages: + - 10 + - 15 + - 20 + smart_tipping_enabled: true + default_percent: 15 + smart_tips: + - {} + coupons: + enabled: true + updated_at: '2022-06-16T22:25:35Z' + UpdateLocationSettings: + path: /v2/online-checkout/location-settings/{location_id} + method: PUT + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + - MERCHANT_PROFILE_READ + docs: Updates the location-level settings for a Square-hosted checkout page. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateLocationSettings + request: + name: UpdateLocationSettingsRequest + path-parameters: + location_id: + type: string + docs: The ID of the location for which to retrieve settings. + body: + properties: + location_settings: + type: root.CheckoutLocationSettings + docs: >- + Describe your updates using the `location_settings` object. Make + sure it contains only the fields that have changed. + content-type: application/json + response: + docs: Success + type: root.UpdateLocationSettingsResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + request: + location_settings: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + location_settings: + location_id: LOCATION_ID_1 + customer_notes_enabled: false + policies: + - uid: POLICY_ID_1 + title: Return Policy + description: This is my Return Policy + - uid: POLICY_ID_2 + title: Return Policy + description: Items may be returned within 30 days of purchase. + branding: + header_type: FRAMED_LOGO + button_color: '#00b23b' + button_shape: ROUNDED + tipping: + percentages: + - 15 + - 20 + - 25 + smart_tipping_enabled: true + default_percent: 20 + smart_tips: + - {} + coupons: + enabled: true + updated_at: '2022-06-16T22:25:35Z' + RetrieveMerchantSettings: + path: /v2/online-checkout/merchant-settings + method: GET + auth: + - oauth2: + - PAYMENT_METHODS_READ + - MERCHANT_PROFILE_READ + docs: Retrieves the merchant-level settings for a Square-hosted checkout page. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveMerchantSettings + response: + docs: Success + type: root.RetrieveMerchantSettingsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + merchant_settings: + payment_methods: + apple_pay: + enabled: true + google_pay: + enabled: true + afterpay_clearpay: + order_eligibility_range: + min: + amount: 100 + currency: USD + max: + amount: 10000 + currency: USD + item_eligibility_range: + min: + amount: 100 + currency: USD + max: + amount: 10000 + currency: USD + enabled: true + updated_at: '2022-06-16T22:25:35Z' + UpdateMerchantSettings: + path: /v2/online-checkout/merchant-settings + method: PUT + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + - PAYMENT_METHODS_READ + - MERCHANT_PROFILE_READ + docs: Updates the merchant-level settings for a Square-hosted checkout page. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateMerchantSettings + request: + name: UpdateMerchantSettingsRequest + body: + properties: + merchant_settings: + type: root.CheckoutMerchantSettings + docs: >- + Describe your updates using the `merchant_settings` object. Make + sure it contains only the fields that have changed. + content-type: application/json + response: + docs: Success + type: root.UpdateMerchantSettingsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + merchant_settings: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + merchant_settings: + payment_methods: + apple_pay: + enabled: false + google_pay: + enabled: true + afterpay_clearpay: + order_eligibility_range: + min: + amount: 100 + currency: USD + max: + amount: 10000 + currency: USD + item_eligibility_range: + min: + amount: 100 + currency: USD + max: + amount: 10000 + currency: USD + enabled: true + updated_at: '2022-06-16T22:25:35Z' + source: + openapi: ../default/openapi/openapi.json +types: + Checkout: + docs: |- + Square Checkout lets merchants accept online payments for supported + payment types using a checkout workflow hosted on squareup.com. + properties: + id: + type: optional + docs: ID generated by Square Checkout when a new checkout is requested. + checkout_page_url: + type: optional> + docs: |- + The URL that the buyer's browser should be redirected to after the + checkout is completed. + ask_for_shipping_address: + type: optional> + docs: >- + If `true`, Square Checkout will collect shipping information on your + + behalf and store that information with the transaction information in + your + + Square Dashboard. + + + Default: `false`. + merchant_support_email: + type: optional> + docs: >- + The email address to display on the Square Checkout confirmation page + + and confirmation email that the buyer can use to contact the merchant. + + + If this value is not set, the confirmation page and email will display + the + + primary email address associated with the merchant's Square account. + + + Default: none; only exists if explicitly set. + pre_populate_buyer_email: + type: optional> + docs: |- + If provided, the buyer's email is pre-populated on the checkout page + as an editable text field. + + Default: none; only exists if explicitly set. + pre_populate_shipping_address: + type: optional + docs: |- + If provided, the buyer's shipping info is pre-populated on the + checkout page as editable text fields. + + Default: none; only exists if explicitly set. + redirect_url: + type: optional> + docs: >- + The URL to redirect to after checkout is completed with `checkoutId`, + + Square's `orderId`, `transactionId`, and `referenceId` appended as URL + + parameters. For example, if the provided redirect_url is + + `http://www.example.com/order-complete`, a successful transaction + redirects + + the customer to: + + +
http://www.example.com/order-complete?checkoutId=xxxxxx&orderId=xxxxxx&referenceId=xxxxxx&transactionId=xxxxxx
+ + + If you do not provide a redirect URL, Square Checkout will display an + order + + confirmation page on your behalf; however Square strongly recommends + that + + you provide a redirect URL so you can verify the transaction results + and + + finalize the order through your existing/normal confirmation workflow. + order: + type: optional + docs: Order to be checked out. + created_at: + type: optional + docs: The time when the checkout was created, in RFC 3339 format. + access: read-only + additional_recipients: + type: optional>> + docs: >- + Additional recipients (other than the merchant) receiving a portion of + this checkout. + + For example, fees assessed on the purchase by a third party + integration. + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/checkout/paymentLinks.yml b/.mock/definition/checkout/paymentLinks.yml new file mode 100644 index 00000000..04daf4d3 --- /dev/null +++ b/.mock/definition/checkout/paymentLinks.yml @@ -0,0 +1,466 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/online-checkout/payment-links + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: Lists all payment links. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.payment_links + source: + openapi: ../default/openapi/openapi.json + display-name: ListPaymentLinks + request: + name: ListPaymentLinksRequest + query-parameters: + cursor: + type: optional> + docs: >- + 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. + + If a cursor is not provided, the endpoint returns the first page + of the results. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional> + docs: >- + A limit on the number of results to return per page. The limit is + advisory and + + the implementation might return more or less results. If the + supplied limit is negative, zero, or + + greater than the maximum limit of 1000, it is ignored. + + + Default value: `100` + response: + docs: Success + type: root.ListPaymentLinksResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment_links: + - id: TN4BWEDJ9AI5MBIV + version: 2 + description: description + order_id: Qqc6yppGvxVwc46Cch4zHTaJqc4F + checkout_options: + ask_for_shipping_address: true + url: https://square.link/u/EXAMPLE + long_url: long_url + created_at: '2022-04-26T00:15:15Z' + updated_at: '2022-04-26T00:18:24Z' + payment_note: test + - id: RY5UNCUMPJN5XKCT + version: 1 + description: '' + order_id: EmBmGt3zJD15QeO1dxzBTxMxtwfZY + url: https://square.link/u/EXAMPLE + long_url: long_url + created_at: '2022-04-11T23:14:59Z' + updated_at: updated_at + payment_note: payment_note + cursor: MTY1NQ== + create: + path: /v2/online-checkout/payment-links + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + - ORDERS_READ + - ORDERS_WRITE + docs: >- + Creates a Square-hosted checkout page. Applications can share the + resulting payment link with their buyer to pay for goods and services. + source: + openapi: ../default/openapi/openapi.json + display-name: CreatePaymentLink + request: + name: CreatePaymentLinkRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique string that identifies this `CreatePaymentLinkRequest` + request. + + If you do not provide a unique string (or provide an empty + string as the value), + + the endpoint treats each request as independent. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + maxLength: 192 + description: + type: optional + docs: >- + A description of the payment link. You provide this optional + description that is useful in your + + application context. It is not used anywhere. + validation: + maxLength: 4096 + quick_pay: + type: optional + docs: >- + 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). + order: + type: optional + docs: >- + 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). + checkout_options: + type: optional + docs: >- + 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). + pre_populated_data: + type: optional + docs: >- + 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). + payment_note: + type: optional + docs: >- + A note for the payment. After processing the payment, Square + adds this note to the resulting `Payment`. + validation: + maxLength: 500 + content-type: application/json + response: + docs: Success + type: root.CreatePaymentLinkResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: cd9e25dc-d9f2-4430-aedb-61605070e95f + quick_pay: + name: Auto Detailing + price_money: + amount: 10000 + currency: USD + location_id: A9Y43N9ABXZBP + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment_link: + id: PKVT6XGJZXYUP3NZ + version: 1 + description: description + order_id: o4b7saqp4HzhNttf5AJxC0Srjd4F + checkout_options: + allow_tipping: true + custom_fields: + - title: title + subscription_plan_id: subscription_plan_id + redirect_url: redirect_url + merchant_support_email: merchant_support_email + ask_for_shipping_address: true + shipping_fee: + charge: {} + enable_coupon: true + enable_loyalty: true + pre_populated_data: + buyer_email: buyer_email + buyer_phone_number: buyer_phone_number + url: https://square.link/u/EXAMPLE + long_url: https://checkout.square.site/EXAMPLE + created_at: '2022-04-25T23:58:01Z' + updated_at: updated_at + payment_note: payment_note + related_resources: + orders: + - id: o4b7saqp4HzhNttf5AJxC0Srjd4F + location_id: '{LOCATION_ID}' + source: + name: Test Online Checkout Application + line_items: + - uid: 8YX13D1U3jO7czP8JVrAR + name: Auto Detailing + quantity: '1' + item_type: ITEM + base_price_money: + amount: 12500 + currency: USD + variation_total_price_money: + amount: 12500 + currency: USD + gross_sales_money: + amount: 12500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_money: + amount: 12500 + currency: USD + fulfillments: + - uid: bBpNrxjdQxGQP16sTmdzi + type: PICKUP + state: PROPOSED + net_amounts: + total_money: + amount: 12500 + currency: USD + tax_money: + amount: 0 + currency: USD + discount_money: + amount: 0 + currency: USD + tip_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + created_at: '2022-03-03T00:53:15.829Z' + updated_at: '2022-03-03T00:53:15.829Z' + state: DRAFT + version: 1 + total_money: + amount: 12500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_tip_money: + amount: 0 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + subscription_plans: + - id: id + type: ITEM + get: + path: /v2/online-checkout/payment-links/{id} + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: Retrieves a payment link. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrievePaymentLink + request: + name: GetPaymentLinksRequest + path-parameters: + id: + type: string + docs: The ID of link to retrieve. + response: + docs: Success + type: root.GetPaymentLinkResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment_link: + id: LLO5Q3FRCFICDB4B + version: 1 + description: description + order_id: 4uKASDATqSd1QQ9jV86sPhMdVEbSJc4F + checkout_options: + allow_tipping: true + custom_fields: + - title: title + subscription_plan_id: subscription_plan_id + redirect_url: redirect_url + merchant_support_email: merchant_support_email + ask_for_shipping_address: true + shipping_fee: + charge: {} + enable_coupon: true + enable_loyalty: true + pre_populated_data: + buyer_email: buyer_email + buyer_phone_number: buyer_phone_number + url: https://square.link/u/EXAMPLE + long_url: https://checkout.square.site/EXAMPLE + created_at: '2022-04-26T00:10:29Z' + updated_at: updated_at + payment_note: payment_note + update: + path: /v2/online-checkout/payment-links/{id} + method: PUT + auth: + - oauth2: + - PAYMENTS_WRITE + - ORDERS_READ + - ORDERS_WRITE + docs: >- + Updates a payment link. You can update the `payment_link` fields such as + + `description`, `checkout_options`, and `pre_populated_data`. + + You cannot update other fields such as the `order_id`, `version`, `URL`, + or `timestamp` field. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdatePaymentLink + request: + name: UpdatePaymentLinkRequest + path-parameters: + id: + type: string + docs: The ID of the payment link to update. + body: + properties: + payment_link: + type: root.PaymentLink + docs: >- + 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). + content-type: application/json + response: + docs: Success + type: root.UpdatePaymentLinkResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + payment_link: + version: 1 + checkout_options: + ask_for_shipping_address: true + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment_link: + id: TY4BWEDJ6AI5MBIV + version: 2 + description: description + order_id: Qqc8ypQGvxVwc46Cch4zHTaJqc4F + checkout_options: + allow_tipping: true + custom_fields: + - title: title + subscription_plan_id: subscription_plan_id + redirect_url: redirect_url + merchant_support_email: merchant_support_email + ask_for_shipping_address: true + shipping_fee: + charge: {} + enable_coupon: true + enable_loyalty: true + pre_populated_data: + buyer_email: buyer_email + buyer_phone_number: buyer_phone_number + url: https://square.link/u/EXAMPLE + long_url: https://checkout.square.site/EXAMPLE + created_at: '2022-04-26T00:15:15Z' + updated_at: '2022-04-26T00:18:24Z' + payment_note: test + delete: + path: /v2/online-checkout/payment-links/{id} + method: DELETE + auth: + - oauth2: + - ORDERS_READ + - ORDERS_WRITE + docs: Deletes a payment link. + source: + openapi: ../default/openapi/openapi.json + display-name: DeletePaymentLink + request: + name: DeletePaymentLinksRequest + path-parameters: + id: + type: string + docs: The ID of the payment link to delete. + response: + docs: Success + type: root.DeletePaymentLinkResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + id: MQASNYL6QB6DFCJ3 + cancelled_order_id: asx8LgZ6MRzD0fObfkJ6obBmSh4F + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/customers.yml b/.mock/definition/customers.yml new file mode 100644 index 00000000..aec16add --- /dev/null +++ b/.mock/definition/customers.yml @@ -0,0 +1,1180 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/customers + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Lists customer profiles associated with a Square account. + + + Under normal operating conditions, newly created or updated customer + profiles become available + + for the listing operation in well under 30 seconds. Occasionally, + propagation of the new or updated + + profiles can take closer to one minute or longer, especially during + network incidents and outages. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.customers + source: + openapi: ../default/openapi/openapi.json + display-name: ListCustomers + request: + name: ListCustomersRequest + query-parameters: + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this cursor to retrieve the next set of results for your + original query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional> + docs: >- + The maximum number of results to return in a single page. This + limit is advisory. The response might contain more or fewer + results. + + If the specified limit is less than 1 or greater than 100, Square + returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error. The + default value is 100. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + sort_field: + type: optional> + docs: |- + Indicates how customers should be sorted. + + The default value is `DEFAULT`. + sort_order: + type: optional> + docs: >- + Indicates whether customers should be sorted in ascending (`ASC`) + or + + descending (`DESC`) order. + + + The default value is `ASC`. + count: + type: optional> + default: false + docs: >- + Indicates whether to return the total count of customers in the + `count` field of the response. + + + The default value is `false`. + response: + docs: Success + type: root.ListCustomersResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + limit: 1 + sort_field: DEFAULT + sort_order: DESC + count: true + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + customers: + - id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2016-03-23T20:21:54.859Z' + updated_at: '2016-03-23T20:21:55Z' + given_name: Amelia + family_name: Earhart + nickname: nickname + company_name: company_name + email_address: Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-555-4240 + birthday: birthday + reference_id: YOUR_REFERENCE_ID + note: a customer + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + group_ids: + - 545AXB44B4XXWMVQ4W8SBT3HHF + segment_ids: + - 1KB9JE5EGJXCW.REACHABLE + version: 1 + cursor: cursor + count: 1000000 + create: + path: /v2/customers + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Creates a new customer for a business. + + + You must provide at least one of the following values in your request to + this + + endpoint: + + + - `given_name` + + - `family_name` + + - `company_name` + + - `email_address` + + - `phone_number` + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCustomer + request: + name: CreateCustomerRequest + body: + properties: + idempotency_key: + type: optional + docs: "The idempotency key for the request.\tFor more information, see\n[Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency)." + given_name: + type: optional + docs: >- + The given name (that is, the first name) associated with the + customer profile. + + + The maximum length for this value is 300 characters. + family_name: + type: optional + docs: >- + The family name (that is, the last name) associated with the + customer profile. + + + The maximum length for this value is 300 characters. + company_name: + type: optional + docs: |- + A business name associated with the customer profile. + + The maximum length for this value is 500 characters. + nickname: + type: optional + docs: |- + A nickname for the customer profile. + + The maximum length for this value is 100 characters. + email_address: + type: optional + docs: |- + The email address associated with the customer profile. + + The maximum length for this value is 254 characters. + address: + type: optional + docs: >- + The physical address associated with the customer profile. For + maximum length constraints, see + + [Customer + addresses](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#address). + + The `first_name` and `last_name` fields are ignored if they are + present in the request. + phone_number: + type: optional + docs: >- + The phone number associated with the customer profile. The phone + number must be valid and can contain + + 9–16 digits, with an optional `+` prefix and country code. For + more information, see + + [Customer phone + numbers](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#phone-number). + reference_id: + type: optional + docs: >- + An optional second ID used to associate the customer profile + with an + + entity in another system. + + + The maximum length for this value is 100 characters. + note: + type: optional + docs: A custom note associated with the customer profile. + birthday: + type: optional + docs: >- + The birthday associated with the customer profile, in + `YYYY-MM-DD` or `MM-DD` format. For example, + + specify `1998-09-21` for September 21, 1998, or `09-21` for + September 21. Birthdays are returned in `YYYY-MM-DD` + + format, where `YYYY` is the specified birth year or `0000` if a + birth year is not specified. + tax_ids: + type: optional + docs: >- + The tax ID associated with the customer profile. This field is + available 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). + content-type: application/json + response: + docs: Success + type: root.CreateCustomerResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-555-4240 + reference_id: YOUR_REFERENCE_ID + note: a customer + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + customer: + id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2016-03-23T20:21:54.859Z' + updated_at: '2016-03-23T20:21:54.859Z' + given_name: Amelia + family_name: Earhart + nickname: nickname + company_name: company_name + email_address: Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + phone_number: +1-212-555-4240 + birthday: birthday + reference_id: YOUR_REFERENCE_ID + note: a customer + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + group_ids: + - group_ids + segment_ids: + - segment_ids + version: 0 + tax_ids: + eu_vat: eu_vat + batchCreate: + path: /v2/customers/bulk-create + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Creates multiple [customer profiles](entity:Customer) for a business. + + + This endpoint takes a map of individual create requests and returns a + map of responses. + + + You must provide at least one of the following values in each create + request: + + + - `given_name` + + - `family_name` + + - `company_name` + + - `email_address` + + - `phone_number` + source: + openapi: ../default/openapi/openapi.json + display-name: BulkCreateCustomers + request: + name: BulkCreateCustomersRequest + body: + properties: + customers: + type: map + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BulkCreateCustomersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + customers: + 8bb76c4f-e35d-4c5b-90de-1194cd9179f0: + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-555-4240 + reference_id: YOUR_REFERENCE_ID + note: a customer + d1689f23-b25d-4932-b2f0-aed00f5e2029: + given_name: Marie + family_name: Curie + email_address: Marie.Curie@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 601 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-444-4240 + reference_id: YOUR_REFERENCE_ID + note: another customer + response: + body: + responses: + 8bb76c4f-e35d-4c5b-90de-1194cd9179f4: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + customer: + id: 8DDA5NZVBZFGAX0V3HPF81HHE0 + created_at: '2024-03-23T20:21:54.859Z' + updated_at: '2024-03-23T20:21:54.859Z' + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-555-4240 + reference_id: YOUR_REFERENCE_ID + note: a customer + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + version: 0 + d1689f23-b25d-4932-b2f0-aed00f5e2029: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + customer: + id: N18CPRVXR5214XPBBA6BZQWF3C + created_at: '2024-03-23T20:21:54.859Z' + updated_at: '2024-03-23T20:21:54.859Z' + given_name: Marie + family_name: Curie + email_address: Marie.Curie@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 601 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-444-4240 + reference_id: YOUR_REFERENCE_ID + note: another customer + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + version: 0 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + BulkDeleteCustomers: + path: /v2/customers/bulk-delete + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Deletes multiple customer profiles. + + + The endpoint takes a list of customer IDs and returns a map of + responses. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkDeleteCustomers + request: + name: BulkDeleteCustomersRequest + body: + properties: + customer_ids: + docs: The IDs of the [customer profiles](entity:Customer) to delete. + type: list + content-type: application/json + response: + docs: Success + type: root.BulkDeleteCustomersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + customer_ids: + - 8DDA5NZVBZFGAX0V3HPF81HHE0 + - N18CPRVXR5214XPBBA6BZQWF3C + - 2GYD7WNXF7BJZW1PMGNXZ3Y8M8 + response: + body: + responses: + 2GYD7WNXF7BJZW1PMGNXZ3Y8M8: + errors: + - category: INVALID_REQUEST_ERROR + code: NOT_FOUND + detail: Customer with ID `2GYD7WNXF7BJZW1PMGNXZ3Y8M8` not found. + 8DDA5NZVBZFGAX0V3HPF81HHE0: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + N18CPRVXR5214XPBBA6BZQWF3C: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + BulkRetrieveCustomers: + path: /v2/customers/bulk-retrieve + method: POST + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Retrieves multiple customer profiles. + + + This endpoint takes a list of customer IDs and returns a map of + responses. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkRetrieveCustomers + request: + name: BulkRetrieveCustomersRequest + body: + properties: + customer_ids: + docs: The IDs of the [customer profiles](entity:Customer) to retrieve. + type: list + content-type: application/json + response: + docs: Success + type: root.BulkRetrieveCustomersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + customer_ids: + - 8DDA5NZVBZFGAX0V3HPF81HHE0 + - N18CPRVXR5214XPBBA6BZQWF3C + - 2GYD7WNXF7BJZW1PMGNXZ3Y8M8 + response: + body: + responses: + 2GYD7WNXF7BJZW1PMGNXZ3Y8M8: + errors: + - category: INVALID_REQUEST_ERROR + code: NOT_FOUND + detail: Customer with ID `2GYD7WNXF7BJZW1PMGNXZ3Y8M8` not found. + 8DDA5NZVBZFGAX0V3HPF81HHE0: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + customer: + id: 8DDA5NZVBZFGAX0V3HPF81HHE0 + created_at: '2024-01-19T00:27:54.59Z' + updated_at: '2024-01-19T00:38:06Z' + given_name: Amelia + family_name: Earhart + email_address: New.Amelia.Earhart@example.com + birthday: '1897-07-24' + note: updated customer note + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + version: 3 + N18CPRVXR5214XPBBA6BZQWF3C: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + customer: + id: N18CPRVXR5214XPBBA6BZQWF3C + created_at: '2024-01-19T00:27:54.59Z' + updated_at: '2024-01-19T00:38:06Z' + given_name: Marie + family_name: Curie + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + version: 1 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + BulkUpdateCustomers: + path: /v2/customers/bulk-update + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Updates multiple customer profiles. + + + This endpoint takes a map of individual update requests and returns a + map of responses. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpdateCustomers + request: + name: BulkUpdateCustomersRequest + body: + properties: + customers: + type: map + docs: >- + A map of 1 to 100 individual update requests, represented by + `customer ID: { customer data }` + + key-value pairs. + + + Each key is the ID of the [customer profile](entity:Customer) to + update. To update a customer profile + + that was created by merging existing profiles, provide the ID of + the newly created profile. + + + Each value contains the updated customer data. Only new or + changed fields are required. To add or + + update a field, specify the new value. To remove a field, + specify `null`. + content-type: application/json + response: + docs: Success + type: root.BulkUpdateCustomersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + customers: + 8DDA5NZVBZFGAX0V3HPF81HHE0: + email_address: New.Amelia.Earhart@example.com + note: updated customer note + version: 2 + N18CPRVXR5214XPBBA6BZQWF3C: + given_name: Marie + family_name: Curie + version: 0 + response: + body: + responses: + 8DDA5NZVBZFGAX0V3HPF81HHE0: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + customer: + id: 8DDA5NZVBZFGAX0V3HPF81HHE0 + created_at: '2024-01-19T00:27:54.59Z' + updated_at: '2024-01-19T00:38:06Z' + given_name: Amelia + family_name: Earhart + email_address: New.Amelia.Earhart@example.com + birthday: '1897-07-24' + note: updated customer note + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + version: 3 + N18CPRVXR5214XPBBA6BZQWF3C: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + customer: + id: N18CPRVXR5214XPBBA6BZQWF3C + created_at: '2024-01-19T00:27:54.59Z' + updated_at: '2024-01-19T00:38:06Z' + given_name: Marie + family_name: Curie + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + version: 1 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + search: + path: /v2/customers/search + method: POST + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Searches the customer profiles associated with a Square account using + one or more supported query filters. + + + Calling `SearchCustomers` without any explicit query filter returns all + + customer profiles ordered alphabetically based on `given_name` and + + `family_name`. + + + Under normal operating conditions, newly created or updated customer + profiles become available + + for the search operation in well under 30 seconds. Occasionally, + propagation of the new or updated + + profiles can take closer to one minute or longer, especially during + network incidents and outages. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchCustomers + request: + name: SearchCustomersRequest + body: + properties: + cursor: + type: optional + docs: >- + Include the pagination cursor in subsequent calls to this + endpoint to retrieve + + the next set of results associated with the original query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional + docs: >- + The maximum number of results to return in a single page. This + limit is advisory. The response might contain more or fewer + results. + + If the specified limit is invalid, Square returns a `400 + VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error. The default value + is 100. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + query: + type: optional + docs: >- + The filtering and sorting criteria for the search request. If a + query is not specified, + + Square returns all customer profiles ordered alphabetically by + `given_name` and `family_name`. + count: + type: optional + docs: >- + Indicates whether to return the total count of matching + customers in the `count` field of the response. + + + The default value is `false`. + content-type: application/json + response: + docs: Success + type: root.SearchCustomersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + limit: 2 + query: + filter: + creation_source: + values: + - THIRD_PARTY + rule: INCLUDE + created_at: + start_at: '2018-01-01T00:00:00-00:00' + end_at: '2018-02-01T00:00:00-00:00' + email_address: + fuzzy: example.com + group_ids: + all: + - 545AXB44B4XXWMVQ4W8SBT3HHF + sort: + field: CREATED_AT + order: ASC + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + customers: + - id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2018-01-23T20:21:54.859Z' + updated_at: '2020-04-20T10:02:43.083Z' + given_name: James + family_name: Bond + nickname: nickname + company_name: company_name + email_address: james.bond@example.com + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-555-4250 + birthday: birthday + reference_id: YOUR_REFERENCE_ID_2 + note: note + preferences: + email_unsubscribed: false + creation_source: DIRECTORY + group_ids: + - 545AXB44B4XXWMVQ4W8SBT3HHF + segment_ids: + - 1KB9JE5EGJXCW.REACHABLE + version: 7 + - id: A9641GZW2H7Z56YYSD41Q12HDW + created_at: '2018-01-30T14:10:54.859Z' + updated_at: '2018-03-08T18:25:21.342Z' + given_name: Amelia + family_name: Earhart + nickname: nickname + company_name: company_name + email_address: amelia.earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + phone_number: +1-212-555-9238 + birthday: birthday + reference_id: YOUR_REFERENCE_ID_1 + note: a customer + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + group_ids: + - 545AXB44B4XXWMVQ4W8SBT3HHF + segment_ids: + - 1KB9JE5EGJXCW.REACHABLE + version: 1 + cursor: 9dpS093Uy12AzeE + count: 1000000 + get: + path: /v2/customers/{customer_id} + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: Returns details for a single customer. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCustomer + request: + name: GetCustomersRequest + path-parameters: + customer_id: + type: string + docs: The ID of the customer to retrieve. + response: + docs: Success + type: root.GetCustomerResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + customer: + id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2016-03-23T20:21:54.859Z' + updated_at: '2016-03-23T20:21:54.859Z' + given_name: Amelia + family_name: Earhart + nickname: nickname + company_name: company_name + email_address: Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + phone_number: +1-212-555-4240 + birthday: birthday + reference_id: YOUR_REFERENCE_ID + note: a customer + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + group_ids: + - 545AXB44B4XXWMVQ4W8SBT3HHF + segment_ids: + - 1KB9JE5EGJXCW.REACHABLE + version: 1 + tax_ids: + eu_vat: eu_vat + update: + path: /v2/customers/{customer_id} + method: PUT + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Updates a customer profile. This endpoint supports sparse updates, so + only new or changed fields are required in the request. + + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateCustomer + request: + name: UpdateCustomerRequest + path-parameters: + customer_id: + type: string + docs: The ID of the customer to update. + body: + properties: + given_name: + type: optional> + docs: >- + The given name (that is, the first name) associated with the + customer profile. + + + The maximum length for this value is 300 characters. + family_name: + type: optional> + docs: >- + The family name (that is, the last name) associated with the + customer profile. + + + The maximum length for this value is 300 characters. + company_name: + type: optional> + docs: |- + A business name associated with the customer profile. + + The maximum length for this value is 500 characters. + nickname: + type: optional> + docs: |- + A nickname for the customer profile. + + The maximum length for this value is 100 characters. + email_address: + type: optional> + docs: |- + The email address associated with the customer profile. + + The maximum length for this value is 254 characters. + address: + type: optional + docs: >- + The physical address associated with the customer profile. Only + new or changed fields are required in the request. + + + For maximum length constraints, see [Customer + addresses](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#address). + + The `first_name` and `last_name` fields are ignored if they are + present in the request. + phone_number: + type: optional> + docs: >- + The phone number associated with the customer profile. The phone + number must be valid and can contain + + 9–16 digits, with an optional `+` prefix and country code. For + more information, see + + [Customer phone + numbers](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#phone-number). + reference_id: + type: optional> + docs: >- + An optional second ID used to associate the customer profile + with an + + entity in another system. + + + The maximum length for this value is 100 characters. + note: + type: optional> + docs: A custom note associated with the customer profile. + birthday: + type: optional> + docs: >- + The birthday associated with the customer profile, in + `YYYY-MM-DD` or `MM-DD` format. For example, + + specify `1998-09-21` for September 21, 1998, or `09-21` for + September 21. Birthdays are returned in `YYYY-MM-DD` + + format, where `YYYY` is the specified birth year or `0000` if a + birth year is not specified. + version: + type: optional + docs: >- + The current version of the customer profile. + + + As a best practice, you should include this field to enable + [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + control. For more information, see [Update a customer + profile](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#update-a-customer-profile). + tax_ids: + type: optional + docs: >- + The tax ID associated with the customer profile. This field is + available 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). + content-type: application/json + response: + docs: Success + type: root.UpdateCustomerResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + headers: + Square-Version: '2025-10-16' + request: + email_address: New.Amelia.Earhart@example.com + note: updated customer note + version: 2 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + customer: + id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2016-03-23T20:21:54.859Z' + updated_at: '2016-05-15T20:21:55Z' + given_name: Amelia + family_name: Earhart + nickname: nickname + company_name: company_name + email_address: New.Amelia.Earhart@example.com + address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + phone_number: phone_number + birthday: birthday + reference_id: YOUR_REFERENCE_ID + note: updated customer note + preferences: + email_unsubscribed: false + creation_source: THIRD_PARTY + group_ids: + - group_ids + segment_ids: + - segment_ids + version: 3 + tax_ids: + eu_vat: eu_vat + delete: + path: /v2/customers/{customer_id} + method: DELETE + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteCustomer + request: + name: DeleteCustomersRequest + path-parameters: + customer_id: + type: string + docs: The ID of the customer to delete. + query-parameters: + version: + type: optional> + docs: >- + The current version of the customer profile. + + + As a best practice, you should include this parameter to enable + [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + control. For more information, see [Delete a customer + profile](https://developer.squareup.com/docs/customers-api/use-the-api/keep-records#delete-customer-profile). + response: + docs: Success + type: root.DeleteCustomerResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + query-parameters: + version: 1000000 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/customers/cards.yml b/.mock/definition/customers/cards.yml new file mode 100644 index 00000000..8c26bf02 --- /dev/null +++ b/.mock/definition/customers/cards.yml @@ -0,0 +1,181 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/customers/{customer_id}/cards + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Adds a card on file to an existing customer. + + + As with charges, calls to `CreateCustomerCard` are idempotent. Multiple + + calls with the same card nonce return the same card record that was + created + + with the provided nonce during the _first_ call. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCustomerCard + request: + name: CreateCustomerCardRequest + path-parameters: + customer_id: + type: string + docs: The Square ID of the customer profile the card is linked to. + body: + properties: + card_nonce: + type: string + docs: >- + A card nonce representing the credit card to link to the + customer. + + + Card nonces are generated by the Square payment form when + customers enter + + their card information. For more information, see + + [Walkthrough: Integrate Square Payments in a + Website](https://developer.squareup.com/docs/web-payments/take-card-payment). + + + __NOTE:__ Card nonces generated by digital wallets (such as + Apple Pay) + + cannot be used to create a customer card. + billing_address: + type: optional + docs: >- + Address information for the card on file. + + + __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. + cardholder_name: + type: optional + docs: The full name printed on the credit card. + verification_token: + type: optional + docs: >- + An identifying token generated by + [Payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer). + + Verification tokens encapsulate customer device information and + 3-D Secure + + challenge results to indicate that Square has verified the buyer + identity. + content-type: application/json + response: + docs: Success + type: root.CreateCustomerCardResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + customer_id: customer_id + headers: + Square-Version: '2025-10-16' + request: + card_nonce: YOUR_CARD_NONCE + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + cardholder_name: Amelia Earhart + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + card: + id: icard-card_id + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2018 + cardholder_name: Amelia Earhart + billing_address: + address_line_1: 500 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + fingerprint: fingerprint + customer_id: customer_id + merchant_id: merchant_id + reference_id: reference_id + enabled: true + card_type: UNKNOWN_CARD_TYPE + prepaid_type: UNKNOWN_PREPAID_TYPE + bin: bin + version: 1000000 + card_co_brand: UNKNOWN + issuer_alert: ISSUER_ALERT_CARD_CLOSED + issuer_alert_at: issuer_alert_at + hsa_fsa: true + delete: + path: /v2/customers/{customer_id}/cards/{card_id} + method: DELETE + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: Removes a card on file from a customer. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteCustomerCard + request: + name: DeleteCardsRequest + path-parameters: + customer_id: + type: string + docs: The ID of the customer that the card on file belongs to. + card_id: + type: string + docs: The ID of the card on file to delete. + response: + docs: Success + type: root.DeleteCustomerCardResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + customer_id: customer_id + card_id: card_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/customers/customAttributeDefinitions.yml b/.mock/definition/customers/customAttributeDefinitions.yml new file mode 100644 index 00000000..28ad4ea8 --- /dev/null +++ b/.mock/definition/customers/customAttributeDefinitions.yml @@ -0,0 +1,605 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/customers/custom-attribute-definitions + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Lists the customer-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`. Note that + + seller-defined custom attributes (also known as custom fields) are + always set to `VISIBILITY_READ_WRITE_VALUES`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attribute_definitions + source: + openapi: ../default/openapi/openapi.json + display-name: ListCustomerCustomAttributeDefinitions + request: + name: ListCustomAttributeDefinitionsRequest + query-parameters: + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + response: + docs: Success + type: root.ListCustomerCustomAttributeDefinitionsResponse + status-code: 200 + examples: + - query-parameters: + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definitions: + - key: favoritemovie + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite Movie + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + version: 3 + updated_at: '2022-04-26T15:39:38Z' + created_at: '2022-04-26T15:27:30Z' + - key: ownsmovie + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Boolean + name: Owns Movie + description: Customer owns movie. + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: '2022-04-26T15:49:05Z' + created_at: '2022-04-26T15:49:05Z' + cursor: >- + YEk4UPbUEsu8MUV0xouO5hCiFcD9T5ztB6UWEJq5vZnqBFmoBEi0j1j6HWYTFGMRre4p7T5wAQBj3Th1NX3XgBFcQVEVsIxUQ2NsbwjRitfoEZDml9uxxQXepowyRvCuSThHPbJSn7M7wInl3x8XypQF9ahVVQXegJ0CxEKc0SBH + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/customers/custom-attribute-definitions + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Creates a customer-related [custom attribute + definition](entity:CustomAttributeDefinition) for a Square seller + account. + + Use this endpoint to define a custom attribute that can be associated + with customer profiles. + + + A custom attribute definition specifies the `key`, `visibility`, + `schema`, and other properties + + for a custom attribute. After the definition is created, you can call + + [UpsertCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-UpsertCustomerCustomAttribute) + or + + [BulkUpsertCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-BulkUpsertCustomerCustomAttributes) + + to set the custom attribute for customer profiles in the seller's + Customer Directory. + + + Sellers can view all custom attributes in exported customer data, + including those set to + + `VISIBILITY_HIDDEN`. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCustomerCustomAttributeDefinition + request: + name: CreateCustomerCustomAttributeDefinitionRequest + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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 + + [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`. + idempotency_key: + type: optional + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CreateCustomerCustomAttributeDefinitionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + key: favoritemovie + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite Movie + description: The favorite movie of the customer. + visibility: VISIBILITY_HIDDEN + response: + body: + custom_attribute_definition: + key: favoritemovie + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite Movie + description: The favorite movie of the customer. + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: '2022-04-26T15:27:30Z' + created_at: '2022-04-26T15:27:30Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/customers/custom-attribute-definitions/{key} + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Retrieves a customer-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`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCustomerCustomAttributeDefinition + request: + name: GetCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: >- + The key of the custom attribute definition to retrieve. If the + requesting application + + is not the definition owner, you must use the qualified key. + query-parameters: + version: + type: optional> + docs: >- + The current version of the custom attribute definition, which is + used for strongly consistent + + reads to guarantee that you receive the most up-to-date data. When + included in the request, + + Square returns the specified version or a higher version if one + exists. If the specified version + + is higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.GetCustomerCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + query-parameters: + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definition: + key: favoritemovie + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite Movie + description: The favorite movie of the customer. + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-04-26T15:27:30Z' + created_at: '2022-04-26T15:27:30Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/customers/custom-attribute-definitions/{key} + method: PUT + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Updates a customer-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. Note + that sellers can view + + all custom attributes in exported customer data, including those set to + `VISIBILITY_HIDDEN`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateCustomerCustomAttributeDefinition + request: + name: UpdateCustomerCustomAttributeDefinitionRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to update. + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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 + + [Updatable definition + fields](https://developer.squareup.com/docs/customer-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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdateCustomerCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + response: + body: + custom_attribute_definition: + key: favoritemovie + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Favorite Movie + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + version: 2 + updated_at: '2022-04-26T15:39:38Z' + created_at: '2022-04-26T15:27:30Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/customers/custom-attribute-definitions/{key} + method: DELETE + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Deletes a customer-related [custom attribute + definition](entity:CustomAttributeDefinition) from a Square seller + account. + + + Deleting a custom attribute definition also deletes the corresponding + custom attribute from + + all customer profiles in the seller's Customer Directory. + + + Only the definition owner can delete a custom attribute definition. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteCustomerCustomAttributeDefinition + request: + name: DeleteCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to delete. + response: + docs: Success + type: root.DeleteCustomerCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchUpsert: + path: /v2/customers/custom-attributes/bulk-upsert + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Creates or updates [custom attributes](entity:CustomAttribute) for + customer profiles as a bulk operation. + + + Use this endpoint to set the value of one or more custom attributes for + one or more customer profiles. + + A custom attribute is based on a custom attribute definition in a Square + seller account, which is + + created using the + [CreateCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-CreateCustomerCustomAttributeDefinition) + endpoint. + + + This `BulkUpsertCustomerCustomAttributes` 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 customer 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`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpsertCustomerCustomAttributes + request: + name: BatchUpsertCustomerCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BatchUpsertCustomerCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + id1: + customer_id: N3NCVYY3WS27HF0HKANA3R9FP8 + custom_attribute: + key: favoritemovie + value: Dune + id2: + customer_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + custom_attribute: + key: ownsmovie + value: false + id3: + customer_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + custom_attribute: + key: favoritemovie + value: Star Wars + id4: + customer_id: N3NCVYY3WS27HF0HKANA3R9FP8 + custom_attribute: + key: square:a0f1505a-2aa1-490d-91a8-8d31ff181808 + value: '10.5' + id5: + customer_id: 70548QG1HN43B05G0KCZ4MMC1G + custom_attribute: + key: sq0ids-0evKIskIGaY45fCyNL66aw:backupemail + value: fake-email@squareup.com + response: + body: + values: + id1: + customer_id: N3NCVYY3WS27HF0HKANA3R9FP8 + custom_attribute: + key: favoritemovie + value: Dune + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2021-12-09T00:16:23Z' + created_at: '2021-12-08T23:14:47Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + customer_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + custom_attribute: + key: ownsmovie + value: false + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2021-12-09T00:16:23Z' + created_at: '2021-12-09T00:16:20Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id3: + customer_id: SY8EMWRNDN3TQDP2H4KS1QWMMM + custom_attribute: + key: favoritemovie + value: Star Wars + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2021-12-09T00:16:23Z' + created_at: '2021-12-09T00:16:20Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id4: + customer_id: N3NCVYY3WS27HF0HKANA3R9FP8 + custom_attribute: + key: square:a0f1505a-2aa1-490d-91a8-8d31ff181808 + value: '10.5' + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2021-12-09T00:16:23Z' + created_at: '2021-12-08T23:14:47Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id5: + customer_id: 70548QG1HN43B05G0KCZ4MMC1G + custom_attribute: + key: sq0ids-0evKIskIGaY45fCyNL66aw:backupemail + value: fake-email@squareup.com + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2021-12-09T00:16:23Z' + created_at: '2021-12-09T00:16:20Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/customers/customAttributes.yml b/.mock/definition/customers/customAttributes.yml new file mode 100644 index 00000000..2c4e12a6 --- /dev/null +++ b/.mock/definition/customers/customAttributes.yml @@ -0,0 +1,399 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/customers/{customer_id}/custom-attributes + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Lists the [custom attributes](entity:CustomAttribute) associated with a + customer profile. + + + 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`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attributes + source: + openapi: ../default/openapi/openapi.json + display-name: ListCustomerCustomAttributes + request: + name: ListCustomAttributesRequest + path-parameters: + customer_id: + type: string + docs: The ID of the target [customer profile](entity:Customer). + query-parameters: + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + with_definitions: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of each + + custom attribute. Set this parameter to `true` to get the name and + description of each custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + response: + docs: Success + type: root.ListCustomerCustomAttributesResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + query-parameters: + limit: 1 + cursor: cursor + with_definitions: true + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attributes: + - key: favoritemovie + value: Dune + version: 1 + visibility: VISIBILITY_READ_ONLY + updated_at: '2022-04-26T15:50:27Z' + created_at: '2022-04-26T15:50:27Z' + - key: ownsmovie + value: false + version: 1 + visibility: VISIBILITY_HIDDEN + updated_at: '2022-04-26T15:51:53Z' + created_at: '2022-04-26T15:51:53Z' + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/customers/{customer_id}/custom-attributes/{key} + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Retrieves a [custom attribute](entity:CustomAttribute) associated with a + customer profile. + + + You can use the `with_definition` query parameter to also retrieve the + custom attribute definition + + in the same call. + + + To retrieve a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note that + seller-defined custom attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCustomerCustomAttribute + request: + name: GetCustomAttributesRequest + path-parameters: + customer_id: + type: string + docs: The ID of the target [customer profile](entity:Customer). + key: + type: string + docs: >- + The key of the custom attribute to retrieve. This key must match + the `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + query-parameters: + with_definition: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of + + the custom attribute. Set this parameter to `true` to get the name + and description of the custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + version: + type: optional> + docs: >- + The current version of the custom attribute, which is used for + strongly consistent reads to + + guarantee that you receive the most up-to-date data. When included + in the request, Square + + returns the specified version or a higher version if one exists. + If the specified version is + + higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.GetCustomerCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + key: key + query-parameters: + with_definition: true + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute: + key: favoritemovie + value: Dune + version: 1 + visibility: VISIBILITY_READ_ONLY + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2022-04-26T15:50:27Z' + created_at: '2022-04-26T15:50:27Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + upsert: + path: /v2/customers/{customer_id}/custom-attributes/{key} + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Creates or updates a [custom attribute](entity:CustomAttribute) for a + customer profile. + + + Use this endpoint to set the value of a custom attribute for a specified + customer profile. + + A custom attribute is based on a custom attribute definition in a Square + seller account, which + + is created using the + [CreateCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-CreateCustomerCustomAttributeDefinition) + endpoint. + + + To create or update a custom attribute owned by another application, the + `visibility` setting + + must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertCustomerCustomAttribute + request: + name: UpsertCustomerCustomAttributeRequest + path-parameters: + customer_id: + type: string + docs: The ID of the target [customer profile](entity:Customer). + key: + type: string + docs: >- + The key of the custom attribute to create or update. This key must + match the `key` of a + + custom attribute definition in the Square seller account. If the + requesting application is not + + the definition owner, you must use the qualified key. + body: + properties: + custom_attribute: + type: root.CustomAttribute + docs: >- + The custom attribute to create or update, with the following + fields: + + + - `value`. This value must conform to the `schema` specified by + the definition. + + For more information, see [Value data + types](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attributes#value-data-types). + + + - `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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpsertCustomerCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute: + value: Dune + response: + body: + custom_attribute: + key: favoritemovie + value: Dune + version: 1 + visibility: VISIBILITY_READ_ONLY + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2022-04-26T15:50:27Z' + created_at: '2022-04-26T15:50:27Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/customers/{customer_id}/custom-attributes/{key} + method: DELETE + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: >- + Deletes a [custom attribute](entity:CustomAttribute) associated with a + customer profile. + + + To delete a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteCustomerCustomAttribute + request: + name: DeleteCustomAttributesRequest + path-parameters: + customer_id: + type: string + docs: The ID of the target [customer profile](entity:Customer). + key: + type: string + docs: >- + The key of the custom attribute to delete. This key must match the + `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + response: + docs: Success + type: root.DeleteCustomerCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/customers/groups.yml b/.mock/definition/customers/groups.yml new file mode 100644 index 00000000..e1462a3b --- /dev/null +++ b/.mock/definition/customers/groups.yml @@ -0,0 +1,324 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/customers/groups + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: Retrieves the list of customer groups of a business. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.groups + source: + openapi: ../default/openapi/openapi.json + display-name: ListCustomerGroups + request: + name: ListGroupsRequest + query-parameters: + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this cursor to retrieve the next set of results for your + original query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional> + docs: >- + The maximum number of results to return in a single page. This + limit is advisory. The response might contain more or fewer + results. + + If the limit is less than 1 or greater than 50, Square returns a + `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error. The default + value is 50. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + response: + docs: Success + type: root.ListCustomerGroupsResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + groups: + - id: 2TAT3CMH4Q0A9M87XJZED0WMR3 + name: Loyal Customers + created_at: '2020-04-13T21:54:57.863Z' + updated_at: '2020-04-13T21:54:58Z' + - id: 4XMEHESXJBNE9S9JAKZD2FGB14 + name: Super Loyal Customers + created_at: '2020-04-13T21:55:18.795Z' + updated_at: '2020-04-13T21:55:19Z' + cursor: cursor + create: + path: /v2/customers/groups + method: POST + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: |- + Creates a new customer group for a business. + + The request must include the `name` value of the group. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCustomerGroup + request: + name: CreateCustomerGroupRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + The idempotency key for the request. For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + group: + type: root.CustomerGroup + docs: The customer group to create. + content-type: application/json + response: + docs: Success + type: root.CreateCustomerGroupResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + group: + name: Loyal Customers + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + group: + id: 2TAT3CMH4Q0A9M87XJZED0WMR3 + name: Loyal Customers + created_at: '2020-04-13T21:54:57.863Z' + updated_at: '2020-04-13T21:54:58Z' + get: + path: /v2/customers/groups/{group_id} + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Retrieves a specific customer group as identified by the `group_id` + value. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCustomerGroup + request: + name: GetGroupsRequest + path-parameters: + group_id: + type: string + docs: The ID of the customer group to retrieve. + response: + docs: Success + type: root.GetCustomerGroupResponse + status-code: 200 + examples: + - path-parameters: + group_id: group_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + group: + id: 2TAT3CMH4Q0A9M87XJZED0WMR3 + name: Loyal Customers + created_at: '2020-04-13T21:54:57.863Z' + updated_at: '2020-04-13T21:54:58Z' + update: + path: /v2/customers/groups/{group_id} + method: PUT + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: Updates a customer group as identified by the `group_id` value. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateCustomerGroup + request: + name: UpdateCustomerGroupRequest + path-parameters: + group_id: + type: string + docs: The ID of the customer group to update. + body: + properties: + group: + type: root.CustomerGroup + docs: >- + The `CustomerGroup` object including all the updates you want to + make. + content-type: application/json + response: + docs: Success + type: root.UpdateCustomerGroupResponse + status-code: 200 + examples: + - path-parameters: + group_id: group_id + headers: + Square-Version: '2025-10-16' + request: + group: + name: Loyal Customers + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + group: + id: 2TAT3CMH4Q0A9M87XJZED0WMR3 + name: Loyal Customers + created_at: '2020-04-13T21:54:57.863Z' + updated_at: '2020-04-13T21:54:58Z' + delete: + path: /v2/customers/groups/{group_id} + method: DELETE + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: Deletes a customer group as identified by the `group_id` value. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteCustomerGroup + request: + name: DeleteGroupsRequest + path-parameters: + group_id: + type: string + docs: The ID of the customer group to delete. + response: + docs: Success + type: root.DeleteCustomerGroupResponse + status-code: 200 + examples: + - path-parameters: + group_id: group_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + add: + path: /v2/customers/{customer_id}/groups/{group_id} + method: PUT + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: |- + Adds a group membership to a customer. + + The customer is identified by the `customer_id` value + and the customer group is identified by the `group_id` value. + source: + openapi: ../default/openapi/openapi.json + display-name: AddGroupToCustomer + request: + name: AddGroupsRequest + path-parameters: + customer_id: + type: string + docs: The ID of the customer to add to a group. + group_id: + type: string + docs: The ID of the customer group to add the customer to. + response: + docs: Success + type: root.AddGroupToCustomerResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + group_id: group_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + remove: + path: /v2/customers/{customer_id}/groups/{group_id} + method: DELETE + auth: + - oauth2: + - CUSTOMERS_WRITE + docs: |- + Removes a group membership from a customer. + + The customer is identified by the `customer_id` value + and the customer group is identified by the `group_id` value. + source: + openapi: ../default/openapi/openapi.json + display-name: RemoveGroupFromCustomer + request: + name: RemoveGroupsRequest + path-parameters: + customer_id: + type: string + docs: The ID of the customer to remove from the group. + group_id: + type: string + docs: The ID of the customer group to remove the customer from. + response: + docs: Success + type: root.RemoveGroupFromCustomerResponse + status-code: 200 + examples: + - path-parameters: + customer_id: customer_id + group_id: group_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/customers/segments.yml b/.mock/definition/customers/segments.yml new file mode 100644 index 00000000..6c1ebdce --- /dev/null +++ b/.mock/definition/customers/segments.yml @@ -0,0 +1,124 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/customers/segments + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: Retrieves the list of customer segments of a business. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.segments + source: + openapi: ../default/openapi/openapi.json + display-name: ListCustomerSegments + request: + name: ListSegmentsRequest + query-parameters: + cursor: + type: optional> + docs: >- + A pagination cursor returned by previous calls to + `ListCustomerSegments`. + + This cursor is used to retrieve the next set of query results. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional> + docs: >- + The maximum number of results to return in a single page. This + limit is advisory. The response might contain more or fewer + results. + + If the specified limit is less than 1 or greater than 50, Square + returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error. The + default value is 50. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + response: + docs: Success + type: root.ListCustomerSegmentsResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + segments: + - id: GMNXRZVEXNQDF.CHURN_RISK + name: Lapsed + created_at: '2020-01-09T19:33:24.469Z' + updated_at: '2020-04-13T21:47:04Z' + - id: GMNXRZVEXNQDF.LOYAL + name: Regulars + created_at: '2020-01-09T19:33:24.486Z' + updated_at: '2020-04-13T21:47:04Z' + - id: GMNXRZVEXNQDF.REACHABLE + name: Reachable + created_at: '2020-01-09T19:33:21.813Z' + updated_at: '2020-04-13T21:47:04Z' + - id: gv2:KF92J19VXN5FK30GX2E8HSGQ20 + name: Instant Profile + created_at: '2020-01-09T19:33:25Z' + updated_at: '2020-04-13T23:01:03Z' + cursor: cursor + get: + path: /v2/customers/segments/{segment_id} + method: GET + auth: + - oauth2: + - CUSTOMERS_READ + docs: >- + Retrieves a specific customer segment as identified by the `segment_id` + value. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveCustomerSegment + request: + name: GetSegmentsRequest + path-parameters: + segment_id: + type: string + docs: The Square-issued ID of the customer segment. + response: + docs: Success + type: root.GetCustomerSegmentResponse + status-code: 200 + examples: + - path-parameters: + segment_id: segment_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + segment: + id: GMNXRZVEXNQDF.CHURN_RISK + name: Lapsed + created_at: '2020-01-09T19:33:24.469Z' + updated_at: '2020-04-13T23:01:13Z' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/devices.yml b/.mock/definition/devices.yml new file mode 100644 index 00000000..b3b5d7cf --- /dev/null +++ b/.mock/definition/devices.yml @@ -0,0 +1,212 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/devices + method: GET + auth: + - oauth2: + - DEVICES_READ + docs: |- + List devices associated with the merchant. Currently, only Terminal API + devices are supported. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.devices + source: + openapi: ../default/openapi/openapi.json + display-name: ListDevices + request: + name: ListDevicesRequest + query-parameters: + cursor: + type: optional> + docs: >- + 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. + sort_order: + type: optional> + docs: |- + The order in which results are listed. + - `ASC` - Oldest to newest. + - `DESC` - Newest to oldest (default). + limit: + type: optional> + docs: The number of results to return in a single page. + location_id: + type: optional> + docs: If present, only returns devices at the target location. + response: + docs: Success + type: root.ListDevicesResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + sort_order: DESC + limit: 1 + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + devices: + - id: device:995CS397A6475287 + attributes: + type: TERMINAL + manufacturer: Square + model: Square Terminal (1st Gen, v2) + name: Square Terminal 5287 + manufacturers_id: 995CS397A6475287 + updated_at: '2025-08-19T13:04:56.335762883Z' + version: 5.57.0067 + merchant_token: MLCHNZCBWFDZB + components: + - type: APPLICATION + application_details: + application_type: TERMINAL_API + version: '6.77' + session_location: LMN2K7S3RTOU3 + - type: CARD_READER + card_reader_details: + version: 4.1.51 + - type: BATTERY + battery_details: + visible_percent: 77 + external_power: AVAILABLE_CHARGING + - type: WIFI + wifi_details: + active: true + ssid: Staff Network + ip_address_v4: 10.0.0.7 + secure_connection: WPA/WPA2 PSK + signal_strength: + value: 2 + - type: ETHERNET + ethernet_details: + active: false + status: + category: AVAILABLE + - id: device:998WS21803L03559 + attributes: + type: HANDHELD + manufacturer: Square + model: Square Handheld (1st Gen, v1) + name: Square Terminal 3559 + manufacturers_id: 998WS21803L03559 + updated_at: '2025-08-19T12:39:56.335742073Z' + version: 7.21.0017 + merchant_token: MLCHXZCBWFGDW + components: + - type: APPLICATION + application_details: + application_type: TERMINAL_API + version: '6.77' + session_location: LMN2K7S3RTOU3 + - type: CARD_READER + card_reader_details: + version: 4.5.58 + - type: BATTERY + battery_details: + visible_percent: 22 + external_power: AVAILABLE_CHARGING + - type: WIFI + wifi_details: + active: true + ssid: Staff Network + ip_address_v4: 10.0.0.7 + secure_connection: WPA/WPA2 PSK + signal_strength: + value: 2 + - type: ETHERNET + ethernet_details: + active: false + status: + category: NEEDS_ATTENTION + cursor: GcXjlV2iaizH7R0fMT6wUDbw6l4otigjzx8XOOspUKHo9EPLRByM + get: + path: /v2/devices/{device_id} + method: GET + auth: + - oauth2: + - DEVICES_READ + docs: Retrieves Device with the associated `device_id`. + source: + openapi: ../default/openapi/openapi.json + display-name: GetDevice + request: + name: GetDevicesRequest + path-parameters: + device_id: + type: string + docs: The unique ID for the desired `Device`. + response: + docs: Success + type: root.GetDeviceResponse + status-code: 200 + examples: + - path-parameters: + device_id: device_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + device: + id: device:995CS397A6475287 + attributes: + type: TERMINAL + manufacturer: Square + model: T2 + name: Square Terminal 995 + manufacturers_id: 995CS397A6475287 + updated_at: '2023-09-29T13:12:22.365049321Z' + version: 5.41.0085 + merchant_token: MLCHXZCBWFGDW + components: + - type: APPLICATION + application_details: + application_type: TERMINAL_API + version: '6.25' + session_location: LMN2K7S3RTOU3 + - type: CARD_READER + card_reader_details: + version: 3.53.70 + - type: BATTERY + battery_details: + visible_percent: 5 + external_power: AVAILABLE_CHARGING + - type: WIFI + wifi_details: + active: true + ssid: Staff Network + ip_address_v4: 10.0.0.7 + secure_connection: WPA/WPA2 PSK + signal_strength: + value: 2 + - type: ETHERNET + ethernet_details: + active: false + status: + category: AVAILABLE + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/devices/codes.yml b/.mock/definition/devices/codes.yml new file mode 100644 index 00000000..bfd907e6 --- /dev/null +++ b/.mock/definition/devices/codes.yml @@ -0,0 +1,211 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/devices/codes + method: GET + auth: + - oauth2: + - DEVICE_CREDENTIAL_MANAGEMENT + docs: Lists all DeviceCodes associated with the merchant. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.device_codes + source: + openapi: ../default/openapi/openapi.json + display-name: ListDeviceCodes + request: + name: ListCodesRequest + query-parameters: + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this to retrieve the next set of results for your original + query. + + + See [Paginating + results](https://developer.squareup.com/docs/working-with-apis/pagination) + for more information. + location_id: + type: optional> + docs: |- + If specified, only returns DeviceCodes of the specified location. + Returns DeviceCodes of all locations if empty. + product_type: + type: optional> + docs: >- + If specified, only returns DeviceCodes targeting the specified + product type. + + Returns DeviceCodes of all product types if empty. + status: + type: optional> + docs: |- + If specified, returns DeviceCodes with the specified statuses. + Returns DeviceCodes of status `PAIRED` and `UNPAIRED` if empty. + response: + docs: Success + type: root.ListDeviceCodesResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + location_id: location_id + product_type: TERMINAL_API + status: UNKNOWN + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + device_codes: + - id: B3Z6NAMYQSMTM + name: Counter 1 + code: EBCARJ + device_id: 907CS13101300122 + product_type: TERMINAL_API + location_id: B5E4484SHHNYH + status: PAIRED + pair_by: '2020-02-06T18:49:33.000Z' + created_at: '2020-02-06T18:44:33.000Z' + status_changed_at: '2020-02-06T18:47:28.000Z' + paired_at: paired_at + - id: YKGMJMYK8H4PQ + name: Unused device code + code: GVXNYN + device_id: device_id + product_type: TERMINAL_API + location_id: A6SYFRSV4WAFW + status: UNPAIRED + pair_by: '2020-02-07T20:00:04.000Z' + created_at: '2020-02-07T19:55:04.000Z' + status_changed_at: '2020-02-07T19:55:04.000Z' + paired_at: paired_at + cursor: cursor + create: + path: /v2/devices/codes + method: POST + auth: + - oauth2: + - DEVICE_CREDENTIAL_MANAGEMENT + docs: >- + Creates a DeviceCode that can be used to login to a Square Terminal + device to enter the connected + + terminal mode. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateDeviceCode + request: + name: CreateDeviceCodeRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this CreateDeviceCode request. + Keys can + + be any valid string but must be unique for every + CreateDeviceCode request. + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 128 + device_code: + type: root.DeviceCode + docs: The device code to create. + content-type: application/json + response: + docs: Success + type: root.CreateDeviceCodeResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 01bb00a6-0c86-4770-94ed-f5fca973cd56 + device_code: + name: Counter 1 + product_type: TERMINAL_API + location_id: B5E4484SHHNYH + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + device_code: + id: B3Z6NAMYQSMTM + name: Counter 1 + code: EBCARJ + device_id: device_id + product_type: TERMINAL_API + location_id: B5E4484SHHNYH + status: UNPAIRED + pair_by: '2020-02-06T18:49:33.000Z' + created_at: '2020-02-06T18:44:33.000Z' + status_changed_at: '2020-02-06T18:44:33.000Z' + paired_at: paired_at + get: + path: /v2/devices/codes/{id} + method: GET + auth: + - oauth2: + - DEVICE_CREDENTIAL_MANAGEMENT + docs: Retrieves DeviceCode with the associated ID. + source: + openapi: ../default/openapi/openapi.json + display-name: GetDeviceCode + request: + name: GetCodesRequest + path-parameters: + id: + type: string + docs: The unique identifier for the device code. + response: + docs: Success + type: root.GetDeviceCodeResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + device_code: + id: B3Z6NAMYQSMTM + name: Counter 1 + code: EBCARJ + device_id: 907CS13101300122 + product_type: TERMINAL_API + location_id: B5E4484SHHNYH + status: PAIRED + pair_by: '2020-02-06T18:49:33.000Z' + created_at: '2020-02-06T18:44:33.000Z' + status_changed_at: '2020-02-06T18:47:28.000Z' + paired_at: paired_at + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/disputes.yml b/.mock/definition/disputes.yml new file mode 100644 index 00000000..d78352de --- /dev/null +++ b/.mock/definition/disputes.yml @@ -0,0 +1,422 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/disputes + method: GET + auth: + - oauth2: + - DISPUTES_READ + docs: Returns a list of disputes associated with a particular account. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.disputes + source: + openapi: ../default/openapi/openapi.json + display-name: ListDisputes + request: + name: ListDisputesRequest + query-parameters: + cursor: + type: optional> + docs: >- + 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. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + states: + type: optional> + docs: >- + The dispute states used to filter the result. If not specified, + the endpoint returns all disputes. + location_id: + type: optional> + docs: >- + The ID of the location for which to return a list of disputes. + + If not specified, the endpoint returns disputes associated with + all locations. + response: + docs: Success + type: root.ListDisputesResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + states: INQUIRY_EVIDENCE_REQUIRED + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + disputes: + - dispute_id: dispute_id + id: XDgyFu7yo1E2S5lQGGpYn + amount_money: + amount: 2500 + currency: USD + reason: NO_KNOWLEDGE + state: ACCEPTED + due_at: '2022-07-13T00:00:00.000Z' + disputed_payment: + payment_id: zhyh1ch64kRBrrlfVhwjCEjZWzNZY + evidence_ids: + - evidence_ids + card_brand: VISA + created_at: '2022-06-29T18:45:22.265Z' + updated_at: '2022-07-07T19:14:42.650Z' + brand_dispute_id: '100000809947' + reported_date: reported_date + reported_at: '2022-06-29T00:00:00.000Z' + version: 2 + location_id: L1HN3ZMQK64X9 + - dispute_id: dispute_id + id: jLGg7aXC7lvKPr9PISt0T + amount_money: + amount: 2209 + currency: USD + reason: NOT_AS_DESCRIBED + state: EVIDENCE_REQUIRED + due_at: '2022-05-13T00:00:00.000Z' + disputed_payment: + payment_id: zhyh1ch64kRBrrlfVhwjCEjZWzNZY + evidence_ids: + - evidence_ids + card_brand: VISA + created_at: '2022-04-29T18:45:22.265Z' + updated_at: '2022-04-29T18:45:22.265Z' + brand_dispute_id: r5Of6YaGT7AdeRaVoAGCJw + reported_date: reported_date + reported_at: '2022-04-29T00:00:00.000Z' + version: 1 + location_id: 18YC4JDH91E1H + cursor: G1aSTRm48CLjJsg6Sg3hQN1b1OMaoVuG + get: + path: /v2/disputes/{dispute_id} + method: GET + auth: + - oauth2: + - DISPUTES_READ + docs: Returns details about a specific dispute. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveDispute + request: + name: GetDisputesRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute you want more details about. + response: + docs: Success + type: root.GetDisputeResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + dispute: + dispute_id: dispute_id + id: XDgyFu7yo1E2S5lQGGpYn + amount_money: + amount: 2500 + currency: USD + reason: NO_KNOWLEDGE + state: ACCEPTED + due_at: '2022-07-13T00:00:00.000Z' + disputed_payment: + payment_id: zhyh1ch64kRBrrlfVhwjCEjZWzNZY + evidence_ids: + - evidence_ids + card_brand: VISA + created_at: '2022-06-29T18:45:22.265Z' + updated_at: '2022-07-07T19:14:42.650Z' + brand_dispute_id: '100000809947' + reported_date: reported_date + reported_at: '2022-06-29T00:00:00.000Z' + version: 2 + location_id: L1HN3ZMQK64X9 + accept: + path: /v2/disputes/{dispute_id}/accept + method: POST + auth: + - oauth2: + - DISPUTES_WRITE + docs: >- + Accepts the loss on a dispute. Square returns the disputed amount to the + cardholder and + + updates the dispute state to ACCEPTED. + + + Square debits the disputed amount from the seller’s Square account. If + the Square account + + does not have sufficient funds, Square debits the associated bank + account. + source: + openapi: ../default/openapi/openapi.json + display-name: AcceptDispute + request: + name: AcceptDisputesRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute you want to accept. + response: + docs: Success + type: root.AcceptDisputeResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + dispute: + dispute_id: dispute_id + id: XDgyFu7yo1E2S5lQGGpYn + amount_money: + amount: 2500 + currency: USD + reason: NO_KNOWLEDGE + state: ACCEPTED + due_at: '2022-07-13T00:00:00.000Z' + disputed_payment: + payment_id: zhyh1ch64kRBrrlfVhwjCEjZWzNZY + evidence_ids: + - evidence_ids + card_brand: VISA + created_at: '2022-06-29T18:45:22.265Z' + updated_at: '2022-07-07T19:14:42.650Z' + brand_dispute_id: '100000809947' + reported_date: reported_date + reported_at: '2022-06-29T00:00:00.000Z' + version: 2 + location_id: L1HN3ZMQK64X9 + CreateEvidenceFile: + path: /v2/disputes/{dispute_id}/evidence-files + method: POST + auth: + - oauth2: + - DISPUTES_WRITE + docs: >- + Uploads a file to use as evidence in a dispute challenge. The endpoint + accepts HTTP + + multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF + formats. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateDisputeEvidenceFile + request: + name: CreateEvidenceFileDisputesRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute for which you want to upload evidence. + body: + properties: + request: + type: optional + content-type: application/json; charset=utf-8 + image_file: + type: optional + content-type: image/jpeg + content-type: multipart/form-data + response: + docs: Success + type: root.CreateDisputeEvidenceFileResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + evidence: + evidence_id: evidence_id + id: TOomLInj6iWmP3N8qfCXrB + dispute_id: bVTprrwk0gygTLZ96VX1oB + evidence_file: + filename: customer-interaction.jpg + filetype: image/jpeg + evidence_text: evidence_text + uploaded_at: '2022-05-18T16:01:10.000Z' + evidence_type: GENERIC_EVIDENCE + CreateEvidenceText: + path: /v2/disputes/{dispute_id}/evidence-text + method: POST + auth: + - oauth2: + - DISPUTES_WRITE + docs: Uploads text to use as evidence for a dispute challenge. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateDisputeEvidenceText + request: + name: CreateDisputeEvidenceTextRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute for which you want to upload evidence. + body: + properties: + idempotency_key: + type: string + docs: >- + A unique key identifying the request. For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + minLength: 1 + maxLength: 45 + evidence_type: + type: optional + docs: >- + The type of evidence you are uploading. + + See [DisputeEvidenceType](#type-disputeevidencetype) for + possible values + evidence_text: + type: string + docs: The evidence string. + validation: + minLength: 1 + maxLength: 500 + content-type: application/json + response: + docs: Success + type: root.CreateDisputeEvidenceTextResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: ed3ee3933d946f1514d505d173c82648 + evidence_type: TRACKING_NUMBER + evidence_text: 1Z8888888888888888 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + evidence: + evidence_id: evidence_id + id: TOomLInj6iWmP3N8qfCXrB + dispute_id: bVTprrwk0gygTLZ96VX1oB + evidence_file: + filename: filename + filetype: filetype + evidence_text: >- + The customer purchased the item twice, on April 11 and April + 28. + uploaded_at: '2022-05-18T16:01:10.000Z' + evidence_type: REBUTTAL_EXPLANATION + SubmitEvidence: + path: /v2/disputes/{dispute_id}/submit-evidence + method: POST + auth: + - oauth2: + - DISPUTES_WRITE + docs: >- + Submits evidence to the cardholder's bank. + + + The evidence submitted by this endpoint includes evidence uploaded + + using the + [CreateDisputeEvidenceFile](api-endpoint:Disputes-CreateDisputeEvidenceFile) + and + + [CreateDisputeEvidenceText](api-endpoint:Disputes-CreateDisputeEvidenceText) + endpoints and + + evidence automatically provided by Square, when available. Evidence + cannot be removed from + + a dispute after submission. + source: + openapi: ../default/openapi/openapi.json + display-name: SubmitEvidence + request: + name: SubmitEvidenceDisputesRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute for which you want to submit evidence. + response: + docs: Success + type: root.SubmitEvidenceResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + dispute: + dispute_id: dispute_id + id: EAZoK70gX3fyvibecLwIGB + amount_money: + amount: 4350 + currency: USD + reason: CUSTOMER_REQUESTS_CREDIT + state: PROCESSING + due_at: '2022-06-01T00:00:00.000Z' + disputed_payment: + payment_id: 2yeBUWJzllJTpmnSqtMRAL19taB + evidence_ids: + - evidence_ids + card_brand: VISA + created_at: '2022-05-18T16:02:15.313Z' + updated_at: '2022-05-18T16:02:15.313Z' + brand_dispute_id: '100000399240' + reported_date: reported_date + reported_at: '2022-05-18T00:00:00.000Z' + version: 4 + location_id: LSY8XKGSMMX94 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/disputes/evidence.yml b/.mock/definition/disputes/evidence.yml new file mode 100644 index 00000000..331b22de --- /dev/null +++ b/.mock/definition/disputes/evidence.yml @@ -0,0 +1,168 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/disputes/{dispute_id}/evidence + method: GET + auth: + - oauth2: + - DISPUTES_READ + docs: Returns a list of evidence associated with a dispute. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.evidence + source: + openapi: ../default/openapi/openapi.json + display-name: ListDisputeEvidence + request: + name: ListEvidenceRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute. + query-parameters: + cursor: + type: optional> + docs: >- + 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. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + response: + docs: Success + type: root.ListDisputeEvidenceResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + query-parameters: + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + evidence: + - evidence_id: evidence_id + id: CpfnkwGselCwS8QFvxN6 + dispute_id: bVTprrwk0gygTLZ96VX1oB + evidence_file: + filename: customer-interaction + filetype: JPG + evidence_text: evidence_text + uploaded_at: '2022-05-10T15:57:13.802Z' + evidence_type: CARDHOLDER_COMMUNICATION + - evidence_id: evidence_id + id: TOomLInj6iWmP3N8qfCXrB + dispute_id: bVTprrwk0gygTLZ96VX1oB + evidence_file: + filename: '' + filetype: '' + evidence_text: evidence_text + uploaded_at: '2022-05-18T16:01:10.000Z' + evidence_type: REBUTTAL_EXPLANATION + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cursor: cursor + get: + path: /v2/disputes/{dispute_id}/evidence/{evidence_id} + method: GET + auth: + - oauth2: + - DISPUTES_READ + docs: >- + Returns the metadata for the evidence specified in the request URL path. + + + You must maintain a copy of any evidence uploaded if you want to + reference it later. Evidence cannot be downloaded after you upload it. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveDisputeEvidence + request: + name: GetEvidenceRequest + path-parameters: + dispute_id: + type: string + docs: >- + The ID of the dispute from which you want to retrieve evidence + metadata. + evidence_id: + type: string + docs: The ID of the evidence to retrieve. + response: + docs: Success + type: root.GetDisputeEvidenceResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + evidence_id: evidence_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + evidence: + evidence_id: evidence_id + id: TOomLInj6iWmP3N8qfCXrB + dispute_id: bVTprrwk0gygTLZ96VX1oB + evidence_file: + filename: customer-interaction.jpg + filetype: image/jpeg + evidence_text: evidence_text + uploaded_at: '2022-05-18T16:01:10.000Z' + evidence_type: CARDHOLDER_COMMUNICATION + delete: + path: /v2/disputes/{dispute_id}/evidence/{evidence_id} + method: DELETE + auth: + - oauth2: + - DISPUTES_WRITE + docs: |- + Removes specified evidence from a dispute. + Square does not send the bank any evidence that is removed. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteDisputeEvidence + request: + name: DeleteEvidenceRequest + path-parameters: + dispute_id: + type: string + docs: The ID of the dispute from which you want to remove evidence. + evidence_id: + type: string + docs: The ID of the evidence you want to remove. + response: + docs: Success + type: root.DeleteDisputeEvidenceResponse + status-code: 200 + examples: + - path-parameters: + dispute_id: dispute_id + evidence_id: evidence_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/employees.yml b/.mock/definition/employees.yml new file mode 100644 index 00000000..4d0b376b --- /dev/null +++ b/.mock/definition/employees.yml @@ -0,0 +1,115 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/employees + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: '' + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.employees + source: + openapi: ../default/openapi/openapi.json + display-name: ListEmployees + request: + name: ListEmployeesRequest + query-parameters: + location_id: + type: optional> + docs: '' + status: + type: optional> + docs: Specifies the EmployeeStatus to filter the employee by. + limit: + type: optional> + docs: The number of employees to be returned on each page. + cursor: + type: optional> + docs: The token required to retrieve the specified page of results. + response: + docs: Success + type: root.ListEmployeesResponse + status-code: 200 + availability: deprecated + examples: + - query-parameters: + location_id: location_id + status: ACTIVE + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + employees: + - id: id + first_name: first_name + last_name: last_name + email: email + phone_number: phone_number + location_ids: + - location_ids + status: ACTIVE + is_owner: true + created_at: created_at + updated_at: updated_at + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/employees/{id} + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: '' + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveEmployee + request: + name: GetEmployeesRequest + path-parameters: + id: + type: string + docs: UUID for the employee that was requested. + response: + docs: Success + type: root.GetEmployeeResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + employee: + id: id + first_name: first_name + last_name: last_name + email: email + phone_number: phone_number + location_ids: + - location_ids + status: ACTIVE + is_owner: true + created_at: created_at + updated_at: updated_at + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/events.yml b/.mock/definition/events.yml new file mode 100644 index 00000000..a4483094 --- /dev/null +++ b/.mock/definition/events.yml @@ -0,0 +1,198 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + SearchEvents: + path: /v2/events + method: POST + auth: + - oauth2: [] + docs: Search for Square API events that occur within a 28-day timeframe. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchEvents + request: + name: SearchEventsRequest + body: + properties: + cursor: + type: optional + docs: >- + A pagination cursor returned by a previous call to this + endpoint. Provide this cursor to retrieve the next set of events + for your original query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + validation: + maxLength: 256 + limit: + type: optional + docs: >- + The maximum number of events to return in a single page. The + response might contain fewer events. The default value is 100, + which is also the maximum allowed value. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + + + Default: 100 + validation: + min: 1 + max: 100 + query: + type: optional + docs: >- + The filtering and sorting criteria for the search request. To + retrieve additional pages using a cursor, you must use the + original query. + content-type: application/json + response: + docs: Success + type: root.SearchEventsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + events: + - merchant_id: 0HPGX5JYE6EE1 + location_id: VJDQQP3CG14EY + type: dispute.state.updated + event_id: 73ecd468-0aba-424f-b862-583d44efe7c8 + created_at: '2022-04-26T10:08:40.454726' + data: + type: dispute + id: ORSEVtZAJxb37RA1EiGw + object: + dispute: + amount_money: + amount: 8801 + currency: USD + brand_dispute_id: r9rKGSBBQbywBNnWWIiGFg + card_brand: VISA + created_at: '2020-02-19T21:24:53.258Z' + disputed_payment: + payment_id: fbmsaEOpoARDKxiSGH1fqPuqoqFZY + due_at: '2020-03-04T00:00:00.000Z' + id: ORSEVtZAJxb37RA1EiGw + location_id: VJDQQP3CG14EY + reason: AMOUNT_DIFFERS + reported_at: '2020-02-19T00:00:00.000Z' + state: WON + updated_at: '2020-02-19T21:34:41.851Z' + version: 6 + metadata: + - event_id: 73ecd468-0aba-424f-b862-583d44efe7c8 + api_version: '2022-12-13' + cursor: 6b571fc9773647f= + DisableEvents: + path: /v2/events/disable + method: PUT + auth: + - oauth2: [] + docs: >- + Disables events to prevent them from being searchable. + + All events are disabled by default. You must enable events to make them + searchable. + + Disabling events for a specific time period prevents them from being + searchable, even if you re-enable them later. + source: + openapi: ../default/openapi/openapi.json + display-name: DisableEvents + response: + docs: Success + type: root.DisableEventsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + EnableEvents: + path: /v2/events/enable + method: PUT + auth: + - oauth2: [] + docs: >- + Enables events to make them searchable. Only events that occur while in + the enabled state are searchable. + source: + openapi: ../default/openapi/openapi.json + display-name: EnableEvents + response: + docs: Success + type: root.EnableEventsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + ListEventTypes: + path: /v2/events/types + method: GET + auth: + - oauth2: [] + docs: >- + Lists all event types that you can subscribe to as webhooks or query + using the Events API. + source: + openapi: ../default/openapi/openapi.json + display-name: ListEventTypes + request: + name: ListEventTypesRequest + query-parameters: + api_version: + type: optional> + docs: >- + The API version for which to list event types. Setting this field + overrides the default version used by the application. + response: + docs: Success + type: root.ListEventTypesResponse + status-code: 200 + examples: + - query-parameters: + api_version: api_version + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + event_types: + - inventory.count.updated + metadata: + - event_type: inventory.count.updated + api_version_introduced: '2018-07-12' + release_status: PUBLIC + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/giftCards.yml b/.mock/definition/giftCards.yml new file mode 100644 index 00000000..f10cba35 --- /dev/null +++ b/.mock/definition/giftCards.yml @@ -0,0 +1,502 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/gift-cards + method: GET + auth: + - oauth2: + - GIFTCARDS_READ + docs: >- + Lists all gift cards. You can specify optional filters to retrieve + + a subset of the gift cards. Results are sorted by `created_at` in + ascending order. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.gift_cards + source: + openapi: ../default/openapi/openapi.json + display-name: ListGiftCards + request: + name: ListGiftCardsRequest + query-parameters: + type: + type: optional> + docs: >- + If a [type](entity:GiftCardType) is provided, the endpoint returns + gift cards of the specified type. + + Otherwise, the endpoint returns gift cards of all types. + state: + type: optional> + docs: >- + If a [state](entity:GiftCardStatus) is provided, the endpoint + returns the gift cards in the specified state. + + Otherwise, the endpoint returns the gift cards of all states. + limit: + type: optional> + docs: >- + If a limit is provided, the endpoint returns only the specified + number of results per page. + + The maximum value is 200. The default value is 30. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + cursor: + type: optional> + docs: >- + 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. + + If a cursor is not provided, the endpoint returns the first page + of the results. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + customer_id: + type: optional> + docs: >- + If a customer ID is provided, the endpoint returns only the gift + cards linked to the specified customer. + response: + docs: Success + type: root.ListGiftCardsResponse + status-code: 200 + examples: + - query-parameters: + type: type + state: state + limit: 1 + cursor: cursor + customer_id: customer_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_cards: + - id: gftc:00113070ba5745f0b2377c1b9570cb03 + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 3900 + currency: USD + gan: '7783320008524605' + created_at: '2021-06-09T22:26:54.000Z' + customer_ids: + - customer_ids + - id: gftc:00128a12725b41e58e0de1d20497a9dd + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 2000 + currency: USD + gan: '7783320002692465' + created_at: '2021-05-20T22:26:54.000Z' + customer_ids: + - customer_ids + cursor: JbFmyvUpaNKsfC1hoLSA4WlqkgkZXTWeKuStajR5BkP7OE0ETAbeWSi6U6u7sH + create: + path: /v2/gift-cards + method: POST + auth: + - oauth2: + - GIFTCARDS_WRITE + docs: >- + Creates a digital gift card or registers a physical (plastic) gift card. + The resulting gift card + + has a `PENDING` state. To activate a gift card so that it can be + redeemed for purchases, call + + [CreateGiftCardActivity](api-endpoint:GiftCardActivities-CreateGiftCardActivity) + and create an `ACTIVATE` + + activity with the initial balance. Alternatively, you can use + [RefundPayment](api-endpoint:Refunds-RefundPayment) + + to refund a payment to the new gift card. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateGiftCard + request: + name: CreateGiftCardRequest + body: + properties: + idempotency_key: + type: string + docs: >- + 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). + validation: + minLength: 1 + maxLength: 128 + location_id: + type: string + docs: >- + The ID of the [location](entity:Location) where the gift card + should be registered for + + reporting purposes. Gift cards can be redeemed at any of the + seller's locations. + validation: + minLength: 1 + gift_card: + type: root.GiftCard + docs: >- + The gift card to create. The `type` field is required for this + request. The `gan_source` + + and `gan` fields are included as follows: + + + To direct Square to generate a 16-digit GAN, omit `gan_source` + and `gan`. + + + To provide a custom GAN, include `gan_source` and `gan`. + + - For `gan_source`, specify `OTHER`. + + - For `gan`, provide a custom GAN containing 8 to 20 + alphanumeric characters. The GAN must be + + unique for the seller and cannot start with the same bank + identification number (BIN) as major + + credit cards. Do not use GANs that are easy to guess (such as + 12345678) because they greatly + + increase the risk of fraud. It is the responsibility of the + developer to ensure the security + + of their custom GANs. For more information, see + + [Custom + GANs](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api#custom-gans). + + + To register an unused, physical gift card that the seller + previously ordered from Square, + + include `gan` and provide the GAN that is printed on the gift + card. + content-type: application/json + response: + docs: Success + type: root.CreateGiftCardResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: NC9Tm69EjbjtConu + location_id: 81FN9BNFZTKS4 + gift_card: + type: DIGITAL + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card: + id: gftc:6cbacbb64cf54e2ca9f573d619038059 + type: DIGITAL + gan_source: SQUARE + state: PENDING + balance_money: + amount: 0 + currency: USD + gan: '7783320006753271' + created_at: '2021-05-20T22:26:54.000Z' + customer_ids: + - customer_ids + getFromGAN: + path: /v2/gift-cards/from-gan + method: POST + auth: + - oauth2: + - GIFTCARDS_READ + docs: Retrieves a gift card using the gift card account number (GAN). + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveGiftCardFromGAN + request: + name: GetGiftCardFromGANRequest + body: + properties: + gan: + type: string + docs: >- + The gift card account number (GAN) of the gift card to retrieve. + + The maximum length of a GAN is 255 digits to account for + third-party GANs that have been imported. + + Square-issued gift cards have 16-digit GANs. + validation: + minLength: 1 + maxLength: 255 + content-type: application/json + response: + docs: Success + type: root.GetGiftCardFromGANResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + gan: '7783320001001635' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card: + id: gftc:6944163553804e439d89adb47caf806a + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 5000 + currency: USD + gan: '7783320001001635' + created_at: '2021-05-20T22:26:54.000Z' + customer_ids: + - customer_ids + getFromNonce: + path: /v2/gift-cards/from-nonce + method: POST + auth: + - oauth2: + - GIFTCARDS_READ + docs: >- + Retrieves a gift card using a secure payment token that represents the + gift card. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveGiftCardFromNonce + request: + name: GetGiftCardFromNonceRequest + body: + properties: + nonce: + type: string + docs: >- + The payment token of the gift card to retrieve. Payment tokens + are generated by the + + Web Payments SDK or In-App Payments SDK. + validation: + minLength: 1 + content-type: application/json + response: + docs: Success + type: root.GetGiftCardFromNonceResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + nonce: cnon:7783322135245171 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card: + id: gftc:6944163553804e439d89adb47caf806a + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 5000 + currency: USD + gan: '7783320001001635' + created_at: '2021-05-20T22:26:54.000Z' + customer_ids: + - customer_ids + LinkCustomer: + path: /v2/gift-cards/{gift_card_id}/link-customer + method: POST + auth: + - oauth2: + - GIFTCARDS_WRITE + docs: >- + Links a customer to a gift card, which is also referred to as adding a + card on file. + source: + openapi: ../default/openapi/openapi.json + display-name: LinkCustomerToGiftCard + request: + name: LinkCustomerToGiftCardRequest + path-parameters: + gift_card_id: + type: string + docs: The ID of the gift card to be linked. + body: + properties: + customer_id: + type: string + docs: The ID of the customer to link to the gift card. + validation: + minLength: 1 + maxLength: 191 + content-type: application/json + response: + docs: Success + type: root.LinkCustomerToGiftCardResponse + status-code: 200 + examples: + - path-parameters: + gift_card_id: gift_card_id + headers: + Square-Version: '2025-10-16' + request: + customer_id: GKY0FZ3V717AH8Q2D821PNT2ZW + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card: + id: gftc:71ea002277a34f8a945e284b04822edb + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 2500 + currency: USD + gan: '7783320005440920' + created_at: '2021-03-25T05:13:01Z' + customer_ids: + - GKY0FZ3V717AH8Q2D821PNT2ZW + UnlinkCustomer: + path: /v2/gift-cards/{gift_card_id}/unlink-customer + method: POST + auth: + - oauth2: + - GIFTCARDS_WRITE + docs: >- + Unlinks a customer from a gift card, which is also referred to as + removing a card on file. + source: + openapi: ../default/openapi/openapi.json + display-name: UnlinkCustomerFromGiftCard + request: + name: UnlinkCustomerFromGiftCardRequest + path-parameters: + gift_card_id: + type: string + docs: The ID of the gift card to be unlinked. + body: + properties: + customer_id: + type: string + docs: The ID of the customer to unlink from the gift card. + validation: + minLength: 1 + maxLength: 191 + content-type: application/json + response: + docs: Success + type: root.UnlinkCustomerFromGiftCardResponse + status-code: 200 + examples: + - path-parameters: + gift_card_id: gift_card_id + headers: + Square-Version: '2025-10-16' + request: + customer_id: GKY0FZ3V717AH8Q2D821PNT2ZW + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card: + id: gftc:71ea002277a34f8a945e284b04822edb + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 2500 + currency: USD + gan: '7783320005440920' + created_at: '2021-03-25T05:13:01Z' + customer_ids: + - customer_ids + get: + path: /v2/gift-cards/{id} + method: GET + auth: + - oauth2: + - GIFTCARDS_READ + docs: Retrieves a gift card using the gift card ID. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveGiftCard + request: + name: GetGiftCardsRequest + path-parameters: + id: + type: string + docs: The ID of the gift card to retrieve. + response: + docs: Success + type: root.GetGiftCardResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card: + id: gftc:00113070ba5745f0b2377c1b9570cb03 + type: DIGITAL + gan_source: SQUARE + state: ACTIVE + balance_money: + amount: 1000 + currency: USD + gan: '7783320001001635' + created_at: '2021-05-20T22:26:54.000Z' + customer_ids: + - customer_ids + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/giftCards/activities.yml b/.mock/definition/giftCards/activities.yml new file mode 100644 index 00000000..66e675e8 --- /dev/null +++ b/.mock/definition/giftCards/activities.yml @@ -0,0 +1,337 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/gift-cards/activities + method: GET + auth: + - oauth2: + - GIFTCARDS_READ + docs: >- + Lists gift card activities. By default, you get gift card activities for + all + + gift cards in the seller's account. You can optionally specify query + parameters to + + filter the list. For example, you can get a list of gift card activities + for a gift card, + + for all gift cards in a specific region, or for activities within a time + window. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.gift_card_activities + source: + openapi: ../default/openapi/openapi.json + display-name: ListGiftCardActivities + request: + name: ListActivitiesRequest + query-parameters: + gift_card_id: + type: optional> + docs: >- + If a gift card ID is provided, the endpoint returns activities + related + + to the specified gift card. Otherwise, the endpoint returns all + gift card activities for + + the seller. + type: + type: optional> + docs: >- + If a [type](entity:GiftCardActivityType) is provided, the endpoint + returns gift card activities of the specified type. + + Otherwise, the endpoint returns all types of gift card activities. + location_id: + type: optional> + docs: >- + If a location ID is provided, the endpoint returns gift card + activities for the specified location. + + Otherwise, the endpoint returns gift card activities for all + locations. + begin_time: + type: optional> + docs: >- + The timestamp for the beginning of the reporting period, in RFC + 3339 format. + + This start time is inclusive. The default value is the current + time minus one year. + end_time: + type: optional> + docs: >- + The timestamp for the end of the reporting period, in RFC 3339 + format. + + This end time is inclusive. The default value is the current time. + limit: + type: optional> + docs: >- + If a limit is provided, the endpoint returns the specified number + + of results (or fewer) per page. The maximum value is 100. The + default value is 50. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + cursor: + type: optional> + docs: >- + 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. + + If a cursor is not provided, the endpoint returns the first page + of the results. + + For more information, see + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + sort_order: + type: optional> + docs: >- + The order in which the endpoint returns the activities, based on + `created_at`. + + - `ASC` - Oldest to newest. + + - `DESC` - Newest to oldest (default). + response: + docs: Success + type: root.ListGiftCardActivitiesResponse + status-code: 200 + examples: + - query-parameters: + gift_card_id: gift_card_id + type: type + location_id: location_id + begin_time: begin_time + end_time: end_time + limit: 1 + cursor: cursor + sort_order: sort_order + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card_activities: + - id: gcact_897698f894b44b3db46c6147e26a0e19 + type: REDEEM + location_id: 81FN9BNFZTKS4 + created_at: '2021-06-02T22:26:38.000Z' + gift_card_id: gftc:6d55a72470d940c6ba09c0ab8ad08d20 + gift_card_gan: '7783320002929081' + gift_card_balance_money: + amount: 700 + currency: USD + redeem_activity_details: + amount_money: + amount: 300 + currency: USD + clear_balance_activity_details: + reason: SUSPICIOUS_ACTIVITY + deactivate_activity_details: + reason: SUSPICIOUS_ACTIVITY + adjust_increment_activity_details: + amount_money: {} + reason: COMPLIMENTARY + adjust_decrement_activity_details: + amount_money: {} + reason: SUSPICIOUS_ACTIVITY + unlinked_activity_refund_activity_details: + amount_money: {} + import_activity_details: + amount_money: {} + block_activity_details: + reason: CHARGEBACK_BLOCK + unblock_activity_details: + reason: CHARGEBACK_UNBLOCK + import_reversal_activity_details: + amount_money: {} + transfer_balance_to_activity_details: + transfer_from_gift_card_id: transfer_from_gift_card_id + amount_money: {} + transfer_balance_from_activity_details: + transfer_to_gift_card_id: transfer_to_gift_card_id + amount_money: {} + - id: gcact_b968ebfc7d46437b945be7b9e09123b4 + type: ACTIVATE + location_id: 81FN9BNFZTKS4 + created_at: '2021-05-20T22:26:54.000Z' + gift_card_id: gftc:6d55a72470d940c6ba09c0ab8ad08d20 + gift_card_gan: '7783320002929081' + gift_card_balance_money: + amount: 1000 + currency: USD + activate_activity_details: + amount_money: + amount: 1000 + currency: USD + order_id: jJNGHm4gLI6XkFbwtiSLqK72KkAZY + line_item_uid: eIWl7X0nMuO9Ewbh0ChIx + redeem_activity_details: + amount_money: {} + clear_balance_activity_details: + reason: SUSPICIOUS_ACTIVITY + deactivate_activity_details: + reason: SUSPICIOUS_ACTIVITY + adjust_increment_activity_details: + amount_money: {} + reason: COMPLIMENTARY + adjust_decrement_activity_details: + amount_money: {} + reason: SUSPICIOUS_ACTIVITY + unlinked_activity_refund_activity_details: + amount_money: {} + import_activity_details: + amount_money: {} + block_activity_details: + reason: CHARGEBACK_BLOCK + unblock_activity_details: + reason: CHARGEBACK_UNBLOCK + import_reversal_activity_details: + amount_money: {} + transfer_balance_to_activity_details: + transfer_from_gift_card_id: transfer_from_gift_card_id + amount_money: {} + transfer_balance_from_activity_details: + transfer_to_gift_card_id: transfer_to_gift_card_id + amount_money: {} + cursor: cursor + create: + path: /v2/gift-cards/activities + method: POST + auth: + - oauth2: + - GIFTCARDS_WRITE + docs: >- + Creates a gift card activity to manage the balance or state of a [gift + card](entity:GiftCard). + + For example, create an `ACTIVATE` activity to activate a gift card with + an initial balance before first use. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateGiftCardActivity + request: + name: CreateGiftCardActivityRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies the `CreateGiftCardActivity` + request. + validation: + minLength: 1 + maxLength: 128 + gift_card_activity: + type: root.GiftCardActivity + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.CreateGiftCardActivityResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: U16kfr-kA70er-q4Rsym-7U7NnY + gift_card_activity: + type: ACTIVATE + location_id: 81FN9BNFZTKS4 + gift_card_id: gftc:6d55a72470d940c6ba09c0ab8ad08d20 + activate_activity_details: + order_id: jJNGHm4gLI6XkFbwtiSLqK72KkAZY + line_item_uid: eIWl7X0nMuO9Ewbh0ChIx + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + gift_card_activity: + id: gcact_c8f8cbf1f24b448d8ecf39ed03f97864 + type: ACTIVATE + location_id: 81FN9BNFZTKS4 + created_at: '2021-05-20T22:26:54.000Z' + gift_card_id: gftc:6d55a72470d940c6ba09c0ab8ad08d20 + gift_card_gan: '7783320002929081' + gift_card_balance_money: + amount: 1000 + currency: USD + load_activity_details: + order_id: order_id + line_item_uid: line_item_uid + reference_id: reference_id + buyer_payment_instrument_ids: + - buyer_payment_instrument_ids + activate_activity_details: + amount_money: + amount: 1000 + currency: USD + order_id: jJNGHm4gLI6XkFbwtiSLqK72KkAZY + line_item_uid: eIWl7X0nMuO9Ewbh0ChIx + reference_id: reference_id + buyer_payment_instrument_ids: + - buyer_payment_instrument_ids + redeem_activity_details: + amount_money: {} + payment_id: payment_id + reference_id: reference_id + status: PENDING + clear_balance_activity_details: + reason: SUSPICIOUS_ACTIVITY + deactivate_activity_details: + reason: SUSPICIOUS_ACTIVITY + adjust_increment_activity_details: + amount_money: {} + reason: COMPLIMENTARY + adjust_decrement_activity_details: + amount_money: {} + reason: SUSPICIOUS_ACTIVITY + refund_activity_details: + redeem_activity_id: redeem_activity_id + reference_id: reference_id + payment_id: payment_id + unlinked_activity_refund_activity_details: + amount_money: {} + reference_id: reference_id + payment_id: payment_id + import_activity_details: + amount_money: {} + block_activity_details: + reason: CHARGEBACK_BLOCK + unblock_activity_details: + reason: CHARGEBACK_UNBLOCK + import_reversal_activity_details: + amount_money: {} + transfer_balance_to_activity_details: + transfer_from_gift_card_id: transfer_from_gift_card_id + amount_money: {} + transfer_balance_from_activity_details: + transfer_to_gift_card_id: transfer_to_gift_card_id + amount_money: {} + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/inventory.yml b/.mock/definition/inventory.yml new file mode 100644 index 00000000..9c325676 --- /dev/null +++ b/.mock/definition/inventory.yml @@ -0,0 +1,847 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + DeprecatedGetAdjustment: + path: /v2/inventory/adjustment/{adjustment_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Deprecated version of + [RetrieveInventoryAdjustment](api-endpoint:Inventory-RetrieveInventoryAdjustment) + after the endpoint URL + + is updated to conform to the standard convention. + source: + openapi: ../default/openapi/openapi.json + display-name: DeprecatedRetrieveInventoryAdjustment + request: + name: DeprecatedGetAdjustmentInventoryRequest + path-parameters: + adjustment_id: + type: string + docs: >- + ID of the [InventoryAdjustment](entity:InventoryAdjustment) to + retrieve. + response: + docs: Success + type: root.GetInventoryAdjustmentResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + adjustment_id: adjustment_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + adjustment: + id: UDMOEO78BG6GYWA2XDRYX3KB + reference_id: 4a366069-4096-47a2-99a5-0084ac879509 + from_state: IN_STOCK + to_state: SOLD + location_id: C6W5YS5QM06F5 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + quantity: '7' + total_price_money: + amount: 4550 + currency: USD + occurred_at: '2016-11-16T25:44:22.837Z' + created_at: '2016-11-17T13:02:15.142Z' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + employee_id: employee_id + team_member_id: LRK57NSQ5X7PUD05 + transaction_id: transaction_id + refund_id: refund_id + purchase_order_id: purchase_order_id + goods_receipt_id: goods_receipt_id + adjustment_group: + id: id + root_adjustment_id: root_adjustment_id + from_state: CUSTOM + to_state: CUSTOM + getAdjustment: + path: /v2/inventory/adjustments/{adjustment_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: |- + Returns the [InventoryAdjustment](entity:InventoryAdjustment) object + with the provided `adjustment_id`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveInventoryAdjustment + request: + name: GetAdjustmentInventoryRequest + path-parameters: + adjustment_id: + type: string + docs: >- + ID of the [InventoryAdjustment](entity:InventoryAdjustment) to + retrieve. + response: + docs: Success + type: root.GetInventoryAdjustmentResponse + status-code: 200 + examples: + - path-parameters: + adjustment_id: adjustment_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + adjustment: + id: UDMOEO78BG6GYWA2XDRYX3KB + reference_id: 4a366069-4096-47a2-99a5-0084ac879509 + from_state: IN_STOCK + to_state: SOLD + location_id: C6W5YS5QM06F5 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + quantity: '7' + total_price_money: + amount: 4550 + currency: USD + occurred_at: '2016-11-16T25:44:22.837Z' + created_at: '2016-11-17T13:02:15.142Z' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + employee_id: employee_id + team_member_id: LRK57NSQ5X7PUD05 + transaction_id: transaction_id + refund_id: refund_id + purchase_order_id: purchase_order_id + goods_receipt_id: goods_receipt_id + adjustment_group: + id: id + root_adjustment_id: root_adjustment_id + from_state: CUSTOM + to_state: CUSTOM + DeprecatedBatchChange: + path: /v2/inventory/batch-change + method: POST + auth: + - oauth2: + - INVENTORY_WRITE + docs: >- + Deprecated version of + [BatchChangeInventory](api-endpoint:Inventory-BatchChangeInventory) + after the endpoint URL + + is updated to conform to the standard convention. + source: + openapi: ../default/openapi/openapi.json + display-name: DeprecatedBatchChangeInventory + request: + body: root.BatchChangeInventoryRequest + content-type: application/json + response: + docs: Success + type: root.BatchChangeInventoryResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe + changes: + - type: PHYSICAL_COUNT + physical_count: + reference_id: 1536bfbf-efed-48bf-b17d-a197141b2a92 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '53' + team_member_id: LRK57NSQ5X7PUD05 + occurred_at: '2016-11-16T22:25:24.878Z' + ignore_unchanged_counts: true + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + counts: + - catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '53' + calculated_at: '2016-11-16T22:28:01.223Z' + is_estimated: true + changes: + - type: PHYSICAL_COUNT + measurement_unit_id: measurement_unit_id + DeprecatedBatchGetChanges: + path: /v2/inventory/batch-retrieve-changes + method: POST + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Deprecated version of + [BatchRetrieveInventoryChanges](api-endpoint:Inventory-BatchRetrieveInventoryChanges) + after the endpoint URL + + is updated to conform to the standard convention. + source: + openapi: ../default/openapi/openapi.json + display-name: DeprecatedBatchRetrieveInventoryChanges + request: + body: root.BatchRetrieveInventoryChangesRequest + content-type: application/json + response: + docs: Success + type: root.BatchGetInventoryChangesResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + request: + catalog_object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + location_ids: + - C6W5YS5QM06F5 + types: + - PHYSICAL_COUNT + states: + - IN_STOCK + updated_after: '2016-11-01T00:00:00.000Z' + updated_before: '2016-12-01T00:00:00.000Z' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + changes: + - type: PHYSICAL_COUNT + physical_count: + id: 46YDTW253DWGGK9HMAE6XCAO + reference_id: 22c07cf4-5626-4224-89f9-691112019399 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '86' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + team_member_id: LRK57NSQ5X7PUD05 + occurred_at: '2016-11-16T22:24:49.028Z' + created_at: '2016-11-16T22:25:24.878Z' + measurement_unit_id: measurement_unit_id + cursor: cursor + DeprecatedBatchGetCounts: + path: /v2/inventory/batch-retrieve-counts + method: POST + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Deprecated version of + [BatchRetrieveInventoryCounts](api-endpoint:Inventory-BatchRetrieveInventoryCounts) + after the endpoint URL + + is updated to conform to the standard convention. + source: + openapi: ../default/openapi/openapi.json + display-name: DeprecatedBatchRetrieveInventoryCounts + request: + body: root.BatchGetInventoryCountsRequest + content-type: application/json + response: + docs: Success + type: root.BatchGetInventoryCountsResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + request: + catalog_object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + location_ids: + - 59TNP9SA8VGDA + updated_after: '2016-11-16T00:00:00.000Z' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + counts: + - catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: 59TNP9SA8VGDA + quantity: '79' + calculated_at: '2016-11-16T22:28:01.223Z' + is_estimated: true + cursor: cursor + BatchCreateChanges: + path: /v2/inventory/changes/batch-create + method: POST + auth: + - oauth2: + - INVENTORY_WRITE + docs: |- + Applies adjustments and counts to the provided item quantities. + + On success: returns the current calculated counts for all objects + referenced in the request. + On failure: returns a list of related errors. + source: + openapi: ../default/openapi/openapi.json + display-name: BatchChangeInventory + request: + body: root.BatchChangeInventoryRequest + content-type: application/json + response: + docs: Success + type: root.BatchChangeInventoryResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe + changes: + - type: PHYSICAL_COUNT + physical_count: + reference_id: 1536bfbf-efed-48bf-b17d-a197141b2a92 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '53' + team_member_id: LRK57NSQ5X7PUD05 + occurred_at: '2016-11-16T22:25:24.878Z' + ignore_unchanged_counts: true + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + counts: + - catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '53' + calculated_at: '2016-11-16T22:28:01.223Z' + is_estimated: true + changes: + - type: PHYSICAL_COUNT + measurement_unit_id: measurement_unit_id + BatchGetChanges: + path: /v2/inventory/changes/batch-retrieve + method: POST + auth: + - oauth2: + - INVENTORY_READ + docs: |- + Returns historical physical counts and adjustments based on the + provided filter criteria. + + Results are paginated and sorted in ascending order according their + `occurred_at` timestamp (oldest first). + + BatchRetrieveInventoryChanges is a catch-all query endpoint for queries + that cannot be handled by other, simpler endpoints. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.changes + source: + openapi: ../default/openapi/openapi.json + display-name: BatchRetrieveInventoryChanges + request: + body: root.BatchRetrieveInventoryChangesRequest + content-type: application/json + response: + docs: Success + type: root.BatchGetInventoryChangesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + catalog_object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + location_ids: + - C6W5YS5QM06F5 + types: + - PHYSICAL_COUNT + states: + - IN_STOCK + updated_after: '2016-11-01T00:00:00.000Z' + updated_before: '2016-12-01T00:00:00.000Z' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + changes: + - type: PHYSICAL_COUNT + physical_count: + id: 46YDTW253DWGGK9HMAE6XCAO + reference_id: 22c07cf4-5626-4224-89f9-691112019399 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '86' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + team_member_id: LRK57NSQ5X7PUD05 + occurred_at: '2016-11-16T22:24:49.028Z' + created_at: '2016-11-16T22:25:24.878Z' + measurement_unit_id: measurement_unit_id + cursor: cursor + BatchGetCounts: + path: /v2/inventory/counts/batch-retrieve + method: POST + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Returns current counts for the provided + + [CatalogObject](entity:CatalogObject)s at the requested + + [Location](entity:Location)s. + + + Results are paginated and sorted in descending order according to their + + `calculated_at` timestamp (newest first). + + + When `updated_after` is specified, only counts that have changed since + that + + time (based on the server timestamp for the most recent change) are + + returned. This allows clients to perform a "sync" operation, for example + + in response to receiving a Webhook notification. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.counts + source: + openapi: ../default/openapi/openapi.json + display-name: BatchRetrieveInventoryCounts + request: + body: root.BatchGetInventoryCountsRequest + content-type: application/json + response: + docs: Success + type: root.BatchGetInventoryCountsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + catalog_object_ids: + - W62UWFY35CWMYGVWK6TWJDNI + location_ids: + - 59TNP9SA8VGDA + updated_after: '2016-11-16T00:00:00.000Z' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + counts: + - catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: 59TNP9SA8VGDA + quantity: '79' + calculated_at: '2016-11-16T22:28:01.223Z' + is_estimated: true + cursor: cursor + deprecatedGetPhysicalCount: + path: /v2/inventory/physical-count/{physical_count_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Deprecated version of + [RetrieveInventoryPhysicalCount](api-endpoint:Inventory-RetrieveInventoryPhysicalCount) + after the endpoint URL + + is updated to conform to the standard convention. + source: + openapi: ../default/openapi/openapi.json + display-name: DeprecatedRetrieveInventoryPhysicalCount + request: + name: DeprecatedGetPhysicalCountInventoryRequest + path-parameters: + physical_count_id: + type: string + docs: >- + ID of the + + [InventoryPhysicalCount](entity:InventoryPhysicalCount) to + retrieve. + response: + docs: Success + type: root.GetInventoryPhysicalCountResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + physical_count_id: physical_count_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + count: + id: ANZADNPLKADOJKJIUANKLMLQ + reference_id: f857ec37-f9a0-4458-8e23-5b5e0bea4e53 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '15' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + employee_id: employee_id + team_member_id: LRK57NSQ5X7PUD05 + occurred_at: '2016-11-16T22:25:24.878Z' + created_at: '2016-11-16T22:25:24.878Z' + getPhysicalCount: + path: /v2/inventory/physical-counts/{physical_count_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: |- + Returns the [InventoryPhysicalCount](entity:InventoryPhysicalCount) + object with the provided `physical_count_id`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveInventoryPhysicalCount + request: + name: GetPhysicalCountInventoryRequest + path-parameters: + physical_count_id: + type: string + docs: >- + ID of the + + [InventoryPhysicalCount](entity:InventoryPhysicalCount) to + retrieve. + response: + docs: Success + type: root.GetInventoryPhysicalCountResponse + status-code: 200 + examples: + - path-parameters: + physical_count_id: physical_count_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + count: + id: ANZADNPLKADOJKJIUANKLMLQ + reference_id: f857ec37-f9a0-4458-8e23-5b5e0bea4e53 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '15' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + employee_id: employee_id + team_member_id: LRK57NSQ5X7PUD05 + occurred_at: '2016-11-16T22:25:24.878Z' + created_at: '2016-11-16T22:25:24.878Z' + getTransfer: + path: /v2/inventory/transfers/{transfer_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: |- + Returns the [InventoryTransfer](entity:InventoryTransfer) object + with the provided `transfer_id`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveInventoryTransfer + request: + name: GetTransferInventoryRequest + path-parameters: + transfer_id: + type: string + docs: >- + ID of the [InventoryTransfer](entity:InventoryTransfer) to + retrieve. + response: + docs: Success + type: root.GetInventoryTransferResponse + status-code: 200 + examples: + - path-parameters: + transfer_id: transfer_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + transfer: + id: UDMOEO78BG6GYWA2XDRYX3KB + reference_id: 4a366069-4096-47a2-99a5-0084ac879509 + state: IN_STOCK + from_location_id: C6W5YS5QM06F5 + to_location_id: 59TNP9SA8VGDA + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + quantity: '7' + occurred_at: '2016-11-16T25:44:22.837Z' + created_at: '2016-11-17T13:02:15.142Z' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + employee_id: employee_id + team_member_id: LRK57NSQ5X7PUD05 + get: + path: /v2/inventory/{catalog_object_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: |- + Retrieves the current calculated stock count for a given + [CatalogObject](entity:CatalogObject) at a given set of + [Location](entity:Location)s. Responses are paginated and unsorted. + For more sophisticated queries, use a batch endpoint. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.counts + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveInventoryCount + request: + name: GetInventoryRequest + path-parameters: + catalog_object_id: + type: string + docs: ID of the [CatalogObject](entity:CatalogObject) to retrieve. + query-parameters: + location_ids: + type: optional> + docs: >- + The [Location](entity:Location) IDs to look up as a + comma-separated + + list. An empty list queries all locations. + cursor: + type: optional> + docs: >- + 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 the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + response: + docs: Success + type: root.GetInventoryCountResponse + status-code: 200 + examples: + - path-parameters: + catalog_object_id: catalog_object_id + query-parameters: + location_ids: location_ids + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + counts: + - catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + state: IN_STOCK + location_id: C6W5YS5QM06F5 + quantity: '22' + calculated_at: '2016-11-16T22:28:01.223Z' + is_estimated: true + cursor: cursor + changes: + path: /v2/inventory/{catalog_object_id}/changes + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Returns a set of physical counts and inventory adjustments for the + + provided [CatalogObject](entity:CatalogObject) at the requested + + [Location](entity:Location)s. + + + You can achieve the same result by calling + [BatchRetrieveInventoryChanges](api-endpoint:Inventory-BatchRetrieveInventoryChanges) + + and having the `catalog_object_ids` list contain a single element of the + `CatalogObject` ID. + + + Results are paginated and sorted in descending order according to their + + `occurred_at` timestamp (newest first). + + + There are no limits on how far back the caller can page. This endpoint + can be + + used to display recent changes for a specific item. For more + + sophisticated queries, use a batch endpoint. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.changes + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveInventoryChanges + request: + name: ChangesInventoryRequest + path-parameters: + catalog_object_id: + type: string + docs: ID of the [CatalogObject](entity:CatalogObject) to retrieve. + query-parameters: + location_ids: + type: optional> + docs: >- + The [Location](entity:Location) IDs to look up as a + comma-separated + + list. An empty list queries all locations. + cursor: + type: optional> + docs: >- + 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 the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + response: + docs: Success + type: root.GetInventoryChangesResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + catalog_object_id: catalog_object_id + query-parameters: + location_ids: location_ids + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + changes: + - type: ADJUSTMENT + adjustment: + id: OJKJIUANKLMLQANZADNPLKAD + reference_id: d8207693-168f-4b44-a2fd-a7ff533ddd26 + from_state: IN_STOCK + to_state: SOLD + location_id: C6W5YS5QM06F5 + catalog_object_id: W62UWFY35CWMYGVWK6TWJDNI + catalog_object_type: ITEM_VARIATION + quantity: '3' + total_price_money: + amount: 5000 + currency: USD + occurred_at: '2016-11-16T22:25:24.878Z' + created_at: '2016-11-16T22:25:24.878Z' + source: + product: SQUARE_POS + application_id: 416ff29c-86c4-4feb-b58c-9705f21f3ea0 + name: Square Point of Sale 4.37 + team_member_id: AV7YRCGI2H1J5NQ8E1XIZCNA + transaction_id: 5APV6JYK1SNCZD11AND2RX1Z + measurement_unit_id: measurement_unit_id + cursor: cursor + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/invoices.yml b/.mock/definition/invoices.yml new file mode 100644 index 00000000..644b4564 --- /dev/null +++ b/.mock/definition/invoices.yml @@ -0,0 +1,1236 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/invoices + method: GET + auth: + - oauth2: + - INVOICES_READ + docs: >- + Returns a list of invoices for a given location. The response + + is paginated. If truncated, the response includes a `cursor` that + you + + use in a subsequent request to retrieve the next set of invoices. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.invoices + source: + openapi: ../default/openapi/openapi.json + display-name: ListInvoices + request: + name: ListInvoicesRequest + query-parameters: + location_id: + type: string + docs: The ID of the location for which to list invoices. + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this cursor to retrieve the next set of results for your + original query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional> + docs: >- + The maximum number of invoices to return (200 is the maximum + `limit`). + + If not provided, the server uses a default limit of 100 invoices. + response: + docs: Success + type: root.ListInvoicesResponse + status-code: 200 + examples: + - query-parameters: + location_id: location_id + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + invoices: + - id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 1 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - uid: beebd363-e47f-4075-8785-c235aaa7df11 + relative_scheduled_days: -1 + message: Your invoice is due tomorrow + status: PENDING + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: public_url + status: DRAFT + timezone: America/Los_Angeles + created_at: '2030-01-13T17:45:13Z' + updated_at: '2030-01-13T21:24:10Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - id: inva:0-3bB9ZuDHiziThQhuC4fwWt + filename: file.jpg + description: Service contract + filesize: 102705 + hash: 273ee02cb6f5f8a3a8ca23604930dd53 + mime_type: image/jpeg + uploaded_at: '2030-01-13T21:24:10Z' + creator_team_member_id: creator_team_member_id + - id: inv:0-ChC366qAfskpGrBI_1bozs9mEA3 + version: 3 + location_id: ES0RJRZYEC39A + order_id: a65jnS8NXbfprvGJzY9F4fQTuaB + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + payment_requests: + - uid: 66c3bdfd-5090-4ff9-a8a0-c1e1a2ffa176 + request_type: DEPOSIT + due_date: '2021-01-23' + percentage_requested: '25' + tipping_enabled: false + automatic_payment_source: CARD_ON_FILE + card_id: ccof:IkWfpLj4tNHMyFii3GB + computed_amount_money: + amount: 1000 + currency: USD + total_completed_amount_money: + amount: 1000 + currency: USD + - uid: 120c5e18-4f80-4f6b-b159-774cb9bf8f99 + request_type: BALANCE + due_date: '2021-06-15' + tipping_enabled: false + automatic_payment_source: CARD_ON_FILE + card_id: ccof:IkWfpLj4tNHMyFii3GB + computed_amount_money: + amount: 3000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-455 + title: title + description: description + scheduled_at: scheduled_at + public_url: >- + https://squareup.com/pay-invoice/invtmp:5e22a2c2-47c1-46d6-b061-808764dfe2b9 + next_payment_amount_money: + amount: 3000 + currency: USD + status: PARTIALLY_PAID + timezone: America/Los_Angeles + created_at: '2021-01-23T15:29:12Z' + updated_at: '2021-01-23T15:29:56Z' + accepted_payment_methods: + card: true + square_gift_card: true + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - {} + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + cursor: ChoIDhIWVm54ZVRhLXhySFBOejBBM2xJb2daUQoFCI4IGAE + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/invoices + method: POST + auth: + - oauth2: + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Creates a draft [invoice](entity:Invoice) + + for an order created using the Orders API. + + + A draft invoice remains in your account and no action is taken. + + 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). + source: + openapi: ../default/openapi/openapi.json + display-name: CreateInvoice + request: + name: CreateInvoiceRequest + body: + properties: + invoice: + type: root.Invoice + docs: The invoice to create. + idempotency_key: + type: optional + docs: >- + A unique string that identifies the `CreateInvoice` request. If + you do not + + provide `idempotency_key` (or provide an empty string as the + value), the endpoint + + treats each request as independent. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 128 + content-type: application/json + response: + docs: Success + type: root.CreateInvoiceResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + invoice: + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + payment_requests: + - request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - relative_scheduled_days: -1 + message: Your invoice is due tomorrow + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + sale_or_service_date: '2030-01-24' + store_payment_method_enabled: false + idempotency_key: ce3748f9-5fc1-4762-aa12-aae5e843f1f4 + response: + body: + invoice: + id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 0 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + company_name: company_name + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - uid: beebd363-e47f-4075-8785-c235aaa7df11 + relative_scheduled_days: -1 + message: Your invoice is due tomorrow + status: PENDING + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: public_url + next_payment_amount_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: DRAFT + timezone: America/Los_Angeles + created_at: '2020-06-18T17:45:13Z' + updated_at: '2020-06-18T17:45:13Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + search: + path: /v2/invoices/search + method: POST + auth: + - oauth2: + - INVOICES_READ + docs: >- + Searches for invoices from a location specified in + + the filter. You can optionally specify customers in the filter for whom + to + + retrieve invoices. In the current implementation, you can only specify + one location and + + optionally one customer. + + + The response is paginated. If truncated, the response includes a + `cursor` + + that you use in a subsequent request to retrieve the next set of + invoices. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchInvoices + request: + name: SearchInvoicesRequest + body: + properties: + query: + type: root.InvoiceQuery + docs: Describes the query criteria for searching invoices. + limit: + type: optional + docs: >- + The maximum number of invoices to return (200 is the maximum + `limit`). + + If not provided, the server uses a default limit of 100 + invoices. + cursor: + type: optional + docs: >- + A pagination cursor returned by a previous call to this + endpoint. + + Provide this cursor to retrieve the next set of results for your + original query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + content-type: application/json + response: + docs: Success + type: root.SearchInvoicesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + location_ids: + - ES0RJRZYEC39A + customer_ids: + - JDKYHBWT1D4F8MFH63DBMEN8Y4 + sort: + field: INVOICE_SORT_DATE + order: DESC + limit: 100 + response: + body: + invoices: + - id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 0 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - uid: beebd363-e47f-4075-8785-c235aaa7df11 + relative_scheduled_days: -1 + message: Your invoice is due tomorrow + status: PENDING + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: public_url + status: DRAFT + timezone: America/Los_Angeles + created_at: '2020-06-18T17:45:13Z' + updated_at: '2020-06-18T17:45:13Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + - id: inv:0-ChC366qAfskpGrBI_1bozs9mEA3 + version: 3 + location_id: ES0RJRZYEC39A + order_id: a65jnS8NXbfprvGJzY9F4fQTuaB + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + payment_requests: + - uid: 66c3bdfd-5090-4ff9-a8a0-c1e1a2ffa176 + request_type: DEPOSIT + due_date: '2021-01-23' + percentage_requested: '25' + tipping_enabled: false + automatic_payment_source: CARD_ON_FILE + card_id: ccof:IkWfpLj4tNHMyFii3GB + computed_amount_money: + amount: 1000 + currency: USD + total_completed_amount_money: + amount: 1000 + currency: USD + - uid: 120c5e18-4f80-4f6b-b159-774cb9bf8f99 + request_type: BALANCE + due_date: '2021-06-15' + tipping_enabled: false + automatic_payment_source: CARD_ON_FILE + card_id: ccof:IkWfpLj4tNHMyFii3GB + computed_amount_money: + amount: 3000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-455 + title: title + description: description + scheduled_at: scheduled_at + public_url: >- + https://squareup.com/pay-invoice/invtmp:5e22a2c2-47c1-46d6-b061-808764dfe2b9 + next_payment_amount_money: + amount: 3000 + currency: USD + status: PARTIALLY_PAID + timezone: America/Los_Angeles + created_at: '2021-01-23T15:29:12Z' + updated_at: '2021-01-23T15:29:56Z' + accepted_payment_methods: + card: true + square_gift_card: true + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - {} + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + cursor: ChoIDhIWVm54ZVRhLXhySFBOejBBM2xJb2daUQoFCI4IGAE + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/invoices/{invoice_id} + method: GET + auth: + - oauth2: + - INVOICES_READ + docs: Retrieves an invoice by invoice ID. + source: + openapi: ../default/openapi/openapi.json + display-name: GetInvoice + request: + name: GetInvoicesRequest + path-parameters: + invoice_id: + type: string + docs: The ID of the invoice to retrieve. + response: + docs: Success + type: root.GetInvoiceResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + headers: + Square-Version: '2025-10-16' + response: + body: + invoice: + id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 0 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + company_name: company_name + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - uid: beebd363-e47f-4075-8785-c235aaa7df11 + relative_scheduled_days: -1 + message: Your invoice is due tomorrow + status: PENDING + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: public_url + next_payment_amount_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: DRAFT + timezone: America/Los_Angeles + created_at: '2020-06-18T17:45:13Z' + updated_at: '2020-06-18T17:45:13Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/invoices/{invoice_id} + method: PUT + auth: + - oauth2: + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Updates an invoice. This endpoint supports sparse updates, so you only + need + + to specify the fields you want to change along with the required + `version` field. + + Some restrictions apply to updating invoices. For example, you cannot + change the + + `order_id` or `location_id` field. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateInvoice + request: + name: UpdateInvoiceRequest + path-parameters: + invoice_id: + type: string + docs: The ID of the invoice to update. + body: + properties: + invoice: + type: root.Invoice + docs: >- + The invoice fields to add, change, or clear. Fields can be + cleared using + + null values or the `remove` field (for individual payment + requests or reminders). + + The current invoice `version` is also required. For more + information, including requirements, + + limitations, and more examples, see [Update an + Invoice](https://developer.squareup.com/docs/invoices-api/update-invoices). + idempotency_key: + type: optional> + docs: >- + A unique string that identifies the `UpdateInvoice` request. If + you do not + + provide `idempotency_key` (or provide an empty string as the + value), the endpoint + + treats each request as independent. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 128 + fields_to_clear: + type: optional>> + docs: >- + The list of fields to clear. Although this field is currently + supported, we + + recommend using null values or the `remove` field when possible. + For examples, see + + [Update an + Invoice](https://developer.squareup.com/docs/invoices-api/update-invoices). + content-type: application/json + response: + docs: Success + type: root.UpdateInvoiceResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + headers: + Square-Version: '2025-10-16' + request: + invoice: + version: 1 + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + tipping_enabled: false + idempotency_key: 4ee82288-0910-499e-ab4c-5d0071dad1be + response: + body: + invoice: + id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 2 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + company_name: company_name + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: false + automatic_payment_source: NONE + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: public_url + next_payment_amount_money: + amount: 10000 + currency: USD + status: UNPAID + timezone: America/Los_Angeles + created_at: '2020-06-18T17:45:13Z' + updated_at: '2020-06-18T18:23:11Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/invoices/{invoice_id} + method: DELETE + auth: + - oauth2: + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Deletes the specified invoice. When an invoice is deleted, the + + associated order status changes to CANCELED. You can only delete a + draft + + invoice (you cannot delete a published invoice, including one that is + scheduled for processing). + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteInvoice + request: + name: DeleteInvoicesRequest + path-parameters: + invoice_id: + type: string + docs: The ID of the invoice to delete. + query-parameters: + version: + type: optional> + docs: >- + The version of the [invoice](entity:Invoice) to delete. + + If you do not know the version, you can call + [GetInvoice](api-endpoint:Invoices-GetInvoice) or + + [ListInvoices](api-endpoint:Invoices-ListInvoices). + response: + docs: Success + type: root.DeleteInvoiceResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + query-parameters: + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + CreateInvoiceAttachment: + path: /v2/invoices/{invoice_id}/attachments + method: POST + auth: + - oauth2: + - INVOICES_WRITE + docs: >- + Uploads a file and attaches it to an invoice. This endpoint accepts HTTP + multipart/form-data file uploads + + with a JSON `request` part and a `file` part. The `file` part must be a + `readable stream` that contains a file + + in a supported format: GIF, JPEG, PNG, TIFF, BMP, or PDF. + + + Invoices can have up to 10 attachments with a total file size of 25 MB. + Attachments can be added only to invoices + + in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state. + + + __NOTE:__ When testing in the Sandbox environment, the total file size + is limited to 1 KB. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateInvoiceAttachment + request: + name: CreateInvoiceAttachmentRequest + path-parameters: + invoice_id: + type: string + docs: The ID of the [invoice](entity:Invoice) to attach the file to. + body: + properties: + request: + type: optional + content-type: application/json; charset=utf-8 + image_file: + type: optional + content-type: image/jpeg + content-type: multipart/form-data + response: + docs: Success + type: root.CreateInvoiceAttachmentResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + attachment: + id: inva:0-3bB9ZuDHiziThQhuC4fwWt + filename: file.jpg + description: Service contract + filesize: 102705 + hash: 273ee02cb6f5f8a3a8ca23604930dd53 + mime_type: image/jpeg + uploaded_at: '2023-02-03T20:28:14Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + DeleteInvoiceAttachment: + path: /v2/invoices/{invoice_id}/attachments/{attachment_id} + method: DELETE + auth: + - oauth2: + - INVOICES_WRITE + docs: >- + Removes an attachment from an invoice and permanently deletes the file. + Attachments can be removed only + + from invoices in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` + state. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteInvoiceAttachment + request: + name: DeleteInvoiceAttachmentRequest + path-parameters: + invoice_id: + type: string + docs: >- + The ID of the [invoice](entity:Invoice) to delete the attachment + from. + attachment_id: + type: string + docs: The ID of the [attachment](entity:InvoiceAttachment) to delete. + response: + docs: Success + type: root.DeleteInvoiceAttachmentResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + attachment_id: attachment_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cancel: + path: /v2/invoices/{invoice_id}/cancel + method: POST + auth: + - oauth2: + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Cancels an invoice. The seller cannot collect payments for + + the canceled invoice. + + + You cannot cancel an invoice in the `DRAFT` state or in a terminal + state: `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelInvoice + request: + name: CancelInvoiceRequest + path-parameters: + invoice_id: + type: string + docs: The ID of the [invoice](entity:Invoice) to cancel. + body: + properties: + version: + type: integer + docs: >- + The version of the [invoice](entity:Invoice) to cancel. + + If you do not know the version, you can call + + [GetInvoice](api-endpoint:Invoices-GetInvoice) or + [ListInvoices](api-endpoint:Invoices-ListInvoices). + content-type: application/json + response: + docs: Success + type: root.CancelInvoiceResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + headers: + Square-Version: '2025-10-16' + request: + version: 0 + response: + body: + invoice: + id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 1 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + company_name: company_name + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - uid: beebd363-e47f-4075-8785-c235aaa7df11 + relative_scheduled_days: -1 + message: Your invoice is due tomorrow + status: PENDING + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: public_url + next_payment_amount_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: CANCELED + timezone: America/Los_Angeles + created_at: '2020-06-18T17:45:13Z' + updated_at: '2020-06-18T18:23:11Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + publish: + path: /v2/invoices/{invoice_id}/publish + method: POST + auth: + - oauth2: + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Publishes the specified draft invoice. + + + After an invoice is published, Square + + follows up based on the invoice configuration. For example, Square + + sends the invoice to the customer's email address, charges the + customer's card on file, or does + + nothing. Square also makes the invoice available on a Square-hosted + invoice page. + + + The invoice `status` also changes from `DRAFT` to a status + + based on the invoice configuration. For example, the status changes to + `UNPAID` if + + Square emails the invoice or `PARTIALLY_PAID` if Square charges a card + on file for a portion of the + + invoice amount. + + + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: PublishInvoice + request: + name: PublishInvoiceRequest + path-parameters: + invoice_id: + type: string + docs: The ID of the invoice to publish. + body: + properties: + version: + type: integer + docs: >- + The version of the [invoice](entity:Invoice) to publish. + + This must match the current version of the invoice; otherwise, + the request is rejected. + idempotency_key: + type: optional> + docs: >- + A unique string that identifies the `PublishInvoice` request. If + you do not + + provide `idempotency_key` (or provide an empty string as the + value), the endpoint + + treats each request as independent. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 128 + content-type: application/json + response: + docs: Success + type: root.PublishInvoiceResponse + status-code: 200 + examples: + - path-parameters: + invoice_id: invoice_id + headers: + Square-Version: '2025-10-16' + request: + version: 1 + idempotency_key: 32da42d0-1997-41b0-826b-f09464fc2c2e + response: + body: + invoice: + id: inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + version: 1 + location_id: ES0RJRZYEC39A + order_id: CAISENgvlJ6jLWAzERDzjyHVybY + primary_recipient: + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + given_name: Amelia + family_name: Earhart + email_address: Amelia.Earhart@example.com + phone_number: 1-212-555-4240 + company_name: company_name + payment_requests: + - uid: 2da7964f-f3d2-4f43-81e8-5aa220bf3355 + request_type: BALANCE + due_date: '2030-01-24' + tipping_enabled: true + automatic_payment_source: NONE + reminders: + - uid: beebd363-e47f-4075-8785-c235aaa7df11 + relative_scheduled_days: -1 + message: Your invoice is due tomorrow + status: PENDING + computed_amount_money: + amount: 10000 + currency: USD + total_completed_amount_money: + amount: 0 + currency: USD + delivery_method: EMAIL + invoice_number: inv-100 + title: Event Planning Services + description: We appreciate your business! + scheduled_at: '2030-01-13T10:00:00Z' + public_url: >- + https://squareup.com/pay-invoice/invtmp:5e22a2c2-47c1-46d6-b061-808764dfe2b9 + next_payment_amount_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: SCHEDULED + timezone: America/Los_Angeles + created_at: '2020-06-18T17:45:13Z' + updated_at: '2020-06-18T18:23:11Z' + accepted_payment_methods: + card: true + square_gift_card: false + bank_account: false + buy_now_pay_later: false + cash_app_pay: false + custom_fields: + - label: Event Reference Number + value: 'Ref. #1234' + placement: ABOVE_LINE_ITEMS + - label: Terms of Service + value: The terms of service are... + placement: BELOW_LINE_ITEMS + subscription_id: subscription_id + sale_or_service_date: '2030-01-24' + payment_conditions: payment_conditions + store_payment_method_enabled: false + attachments: + - {} + creator_team_member_id: creator_team_member_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/labor.yml b/.mock/definition/labor.yml new file mode 100644 index 00000000..b4cf1b91 --- /dev/null +++ b/.mock/definition/labor.yml @@ -0,0 +1,1046 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + CreateScheduledShift: + path: /v2/labor/scheduled-shifts + method: POST + auth: + - oauth2: + - TIMECARDS_WRITE + docs: >- + Creates a scheduled shift by providing draft shift details such as job + ID, + + team member assignment, and start and end times. + + + The following `draft_shift_details` fields are required: + + - `location_id` + + - `job_id` + + - `start_at` + + - `end_at` + source: + openapi: ../default/openapi/openapi.json + display-name: CreateScheduledShift + request: + name: CreateScheduledShiftRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique identifier for the `CreateScheduledShift` request, used + to ensure the + + [idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + + of the operation. + validation: + maxLength: 128 + scheduled_shift: + type: root.ScheduledShift + docs: >- + The scheduled shift with `draft_shift_details`. + + If needed, call + [ListLocations](api-endpoint:Locations-ListLocations) to get + location IDs, + + [ListJobs](api-endpoint:Team-ListJobs) to get job IDs, and + [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers) + + to get team member IDs and current job assignments. + + + The `start_at` and `end_at` timestamps must be provided in the + time zone + offset of the + + shift location specified in `location_id`. Example for Pacific + Standard Time: 2024-10-31T12:30:00-08:00 + content-type: application/json + response: + docs: Success + type: root.CreateScheduledShiftResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: HIDSNG5KS478L + scheduled_shift: + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + response: + body: + scheduled_shift: + id: K0YH4CV5462JB + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + timezone: America/New_York + published_shift_details: + team_member_id: team_member_id + location_id: location_id + job_id: job_id + start_at: start_at + end_at: end_at + notes: notes + is_deleted: true + timezone: timezone + version: 1 + created_at: '2019-02-25T03:11:00-05:00' + updated_at: '2019-02-25T03:11:00-05:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + BulkPublishScheduledShifts: + path: /v2/labor/scheduled-shifts/bulk-publish + method: POST + auth: + - oauth2: + - TIMECARDS_WRITE + docs: >- + Publishes 1 - 100 scheduled shifts. This endpoint takes a map of + individual publish + + requests and returns a map of responses. When a scheduled shift is + published, Square keeps + + the `draft_shift_details` field as is and copies it to the + `published_shift_details` field. + + + The minimum `start_at` and maximum `end_at` timestamps of all shifts in + a + + `BulkPublishScheduledShifts` request must fall within a two-week period. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkPublishScheduledShifts + request: + name: BulkPublishScheduledShiftsRequest + body: + properties: + scheduled_shifts: + type: map + docs: >- + A map of 1 to 100 key-value pairs that represent individual + publish requests. + + + - Each key is the ID of a scheduled shift you want to publish. + + - Each value is a `BulkPublishScheduledShiftsData` object that + contains the + + `version` field or is an empty object. + scheduled_shift_notification_audience: + type: optional + docs: >- + Indicates whether Square should send email notifications to team + members and + + which team members should receive the notifications. This + setting applies to all shifts + + specified in the bulk operation. The default value is + `AFFECTED`. + + See + [ScheduledShiftNotificationAudience](#type-scheduledshiftnotificationaudience) + for possible values + content-type: application/json + response: + docs: Success + type: root.BulkPublishScheduledShiftsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + scheduled_shifts: + key: {} + scheduled_shift_notification_audience: AFFECTED + response: + body: + responses: + idp_key_1: + scheduled_shift: + id: K0YH4CV5462JB + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-03-25T03:11:00-05:00' + end_at: '2019-03-25T13:18:00-05:00' + notes: Don't forget to prep the vegetables + is_deleted: false + timezone: America/New_York + published_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-03-25T03:11:00-05:00' + end_at: '2019-03-25T13:18:00-05:00' + notes: Don't forget to prep the vegetables + is_deleted: false + timezone: America/New_York + version: 3 + created_at: '2019-02-25T03:11:00-05:00' + updated_at: '2019-02-25T03:11:15-05:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + idp_key_2: + errors: + - category: INVALID_REQUEST_ERROR + code: INVALID_VALUE + detail: Scheduled shift with id 'scheduled-shift-2' not found + field: scheduled-shifts.scheduled-shift-2 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + SearchScheduledShifts: + path: /v2/labor/scheduled-shifts/search + method: POST + auth: + - oauth2: + - TIMECARDS_READ + docs: >- + Returns a paginated list of scheduled shifts, with optional filter and + sort settings. + + By default, results are sorted by `start_at` in ascending order. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchScheduledShifts + request: + name: SearchScheduledShiftsRequest + body: + properties: + query: + type: optional + docs: Query conditions used to filter and sort the results. + limit: + type: optional + docs: >- + The maximum number of results to return in a single response + page. The default value is 50. + validation: + min: 1 + max: 50 + cursor: + type: optional + docs: >- + The pagination cursor returned by 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). + content-type: application/json + response: + docs: Success + type: root.SearchScheduledShiftsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + assignment_status: ASSIGNED + sort: + field: CREATED_AT + order: ASC + limit: 2 + cursor: xoxp-1234-5678-90123 + response: + body: + scheduled_shifts: + - id: K0YH4CV5462JB + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + timezone: America/New_York + version: 1 + created_at: '2019-02-25T03:11:00-05:00' + updated_at: '2019-02-25T03:11:00-05:00' + cursor: xoxp-123-2123-123232 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + RetrieveScheduledShift: + path: /v2/labor/scheduled-shifts/{id} + method: GET + auth: + - oauth2: + - TIMECARDS_READ + docs: Retrieves a scheduled shift by ID. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveScheduledShift + request: + name: RetrieveScheduledShiftRequest + path-parameters: + id: + type: string + docs: The ID of the scheduled shift to retrieve. + response: + docs: Success + type: root.RetrieveScheduledShiftResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + scheduled_shift: + id: K0YH4CV5462JB + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-03-25T03:11:00-05:00' + end_at: '2019-03-25T13:18:00-05:00' + notes: Don't forget to prep the vegetables + is_deleted: false + timezone: America/New_York + published_shift_details: + team_member_id: team_member_id + location_id: location_id + job_id: job_id + start_at: start_at + end_at: end_at + notes: notes + is_deleted: true + timezone: timezone + version: 2 + created_at: '2019-02-25T03:11:00-05:00' + updated_at: '2019-02-25T03:11:15-05:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + UpdateScheduledShift: + path: /v2/labor/scheduled-shifts/{id} + method: PUT + auth: + - oauth2: + - TIMECARDS_WRITE + docs: >- + Updates the draft shift details for a scheduled shift. This endpoint + supports + + sparse updates, so only new, changed, or removed fields are required in + the request. + + You must publish the shift to make updates public. + + + You can make the following updates to `draft_shift_details`: + + - Change the `location_id`, `job_id`, `start_at`, and `end_at` fields. + + - Add, change, or clear the `team_member_id` and `notes` fields. To + clear these fields, + + set the value to null. + + - Change the `is_deleted` field. To delete a scheduled shift, set + `is_deleted` to true + + and then publish the shift. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateScheduledShift + request: + name: UpdateScheduledShiftRequest + path-parameters: + id: + type: string + docs: The ID of the scheduled shift to update. + body: + properties: + scheduled_shift: + type: root.ScheduledShift + docs: >- + The scheduled shift with any updates in the + `draft_shift_details` field. + + If needed, call + [ListLocations](api-endpoint:Locations-ListLocations) to get + location IDs, + + [ListJobs](api-endpoint:Team-ListJobs) to get job IDs, and + [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers) + + to get team member IDs and current job assignments. Updates made + to `published_shift_details` + + are ignored. + + + If provided, the `start_at` and `end_at` timestamps must be in + the time zone + offset of the + + shift location specified in `location_id`. Example for Pacific + Standard Time: 2024-10-31T12:30:00-08:00 + + + To enable [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control for the request, provide the current version of the + shift in the `version` field. + + If the provided version doesn't match the server version, the + request fails. If `version` is + + omitted, Square executes a blind write, potentially overwriting + data from another publish request. + content-type: application/json + response: + docs: Success + type: root.UpdateScheduledShiftResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + scheduled_shift: + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-03-25T03:11:00-05:00' + end_at: '2019-03-25T13:18:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + version: 1 + response: + body: + scheduled_shift: + id: K0YH4CV5462JB + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-03-25T03:11:00-05:00' + end_at: '2019-03-25T13:18:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + timezone: America/New_York + published_shift_details: + team_member_id: team_member_id + location_id: location_id + job_id: job_id + start_at: start_at + end_at: end_at + notes: notes + is_deleted: true + timezone: timezone + version: 2 + created_at: '2019-02-25T03:11:00-05:00' + updated_at: '2019-02-25T03:11:15-05:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + PublishScheduledShift: + path: /v2/labor/scheduled-shifts/{id}/publish + method: POST + auth: + - oauth2: + - TIMECARDS_WRITE + docs: >- + Publishes a scheduled shift. When a scheduled shift is published, Square + keeps the + + `draft_shift_details` field as is and copies it to the + `published_shift_details` field. + source: + openapi: ../default/openapi/openapi.json + display-name: PublishScheduledShift + request: + name: PublishScheduledShiftRequest + path-parameters: + id: + type: string + docs: The ID of the scheduled shift to publish. + body: + properties: + idempotency_key: + type: string + docs: >- + A unique identifier for the `PublishScheduledShift` request, + used to ensure the + + [idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + + of the operation. + validation: + minLength: 1 + maxLength: 128 + version: + type: optional + docs: >- + The current version of the scheduled shift, used to enable + [optimistic + concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) + + control. If the provided version doesn't match the server + version, the request fails. + + If omitted, Square executes a blind write, potentially + overwriting data from another publish request. + scheduled_shift_notification_audience: + type: optional + docs: >- + Indicates whether Square should send an email notification to + team members and + + which team members should receive the notification. The default + value is `AFFECTED`. + + See + [ScheduledShiftNotificationAudience](#type-scheduledshiftnotificationaudience) + for possible values + content-type: application/json + response: + docs: Success + type: root.PublishScheduledShiftResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: HIDSNG5KS478L + version: 2 + scheduled_shift_notification_audience: ALL + response: + body: + scheduled_shift: + id: K0YH4CV5462JB + draft_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + timezone: America/New_York + published_shift_details: + team_member_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + notes: Dont forget to prep the vegetables + is_deleted: false + timezone: America/New_York + version: 2 + created_at: '2019-02-25T03:11:00-05:00' + updated_at: '2019-02-25T03:11:00-05:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + CreateTimecard: + path: /v2/labor/timecards + method: POST + auth: + - oauth2: + - TIMECARDS_WRITE + docs: >- + Creates a new `Timecard`. + + + A `Timecard` represents a complete workday for a single team member. + + You must provide the following values in your request to this + + endpoint: + + + - `location_id` + + - `team_member_id` + + - `start_at` + + + An attempt to create a new `Timecard` can result in a `BAD_REQUEST` + error when: + + - The `status` of the new `Timecard` is `OPEN` and the team member has + another + + timecard with an `OPEN` status. + + - The `start_at` date is in the future. + + - The `start_at` or `end_at` date overlaps another timecard for the same + team member. + + - The `Break` instances are set in the request and a break `start_at` + + is before the `Timecard.start_at`, a break `end_at` is after + + the `Timecard.end_at`, or both. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateTimecard + request: + name: CreateTimecardRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique string value to ensure the idempotency of the + operation. + validation: + maxLength: 128 + timecard: + type: root.Timecard + docs: The `Timecard` to be created. + content-type: application/json + response: + docs: Success + type: root.CreateTimecardResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: HIDSNG5KS478L + timecard: + location_id: PAA1RJZZKXBFG + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Barista + hourly_rate: + amount: 1100 + currency: USD + tip_eligible: true + breaks: + - start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + response: + body: + timecard: + id: K0YH4CV5462JB + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Barista + hourly_rate: + amount: 1100 + currency: USD + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + tip_eligible: true + breaks: + - id: X7GAQYVVRRG6P + start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + status: CLOSED + version: 1 + created_at: '2019-02-28T00:39:02Z' + updated_at: '2019-02-28T00:39:02Z' + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + SearchTimecards: + path: /v2/labor/timecards/search + method: POST + auth: + - oauth2: + - TIMECARDS_READ + docs: |- + Returns a paginated list of `Timecard` records for a business. + The list to be returned can be filtered by: + - Location IDs + - Team member IDs + - Timecard status (`OPEN` or `CLOSED`) + - Timecard start + - Timecard end + - Workday details + + The list can be sorted by: + - `START_AT` + - `END_AT` + - `CREATED_AT` + - `UPDATED_AT` + source: + openapi: ../default/openapi/openapi.json + display-name: SearchTimecards + request: + name: SearchTimecardsRequest + body: + properties: + query: + type: optional + docs: Query filters. + limit: + type: optional + docs: The number of resources in a page (200 by default). + validation: + min: 1 + max: 200 + cursor: + type: optional + docs: An opaque cursor for fetching the next page. + content-type: application/json + response: + docs: Success + type: root.SearchTimecardsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + workday: + date_range: + start_date: '2019-01-20' + end_date: '2019-02-03' + match_timecards_by: START_AT + default_timezone: America/Los_Angeles + limit: 100 + response: + body: + timecards: + - id: X714F3HA6D1PT + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-21T03:11:00-05:00' + end_at: '2019-01-21T13:11:00-05:00' + wage: + title: Barista + hourly_rate: + amount: 1100 + currency: USD + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + tip_eligible: true + breaks: + - id: SJW7X6AKEJQ65 + start_at: '2019-01-21T06:11:00-05:00' + end_at: '2019-01-21T06:11:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT10M + is_paid: true + status: CLOSED + version: 6 + created_at: '2019-01-24T01:12:03Z' + updated_at: '2019-02-07T22:21:08Z' + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + - id: GDHYBZYWK0P2V + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-22T12:02:00-05:00' + end_at: '2019-01-22T13:02:00-05:00' + wage: + title: Cook + hourly_rate: + amount: 1600 + currency: USD + job_id: gcbz15vKGnMKmaWJJ152kjim + tip_eligible: true + breaks: + - id: BKS6VR7WR748A + start_at: '2019-01-22T14:30:00-05:00' + end_at: '2019-01-22T14:40:00-05:00' + break_type_id: WQX00VR99F53J + name: Tea Break + expected_duration: PT10M + is_paid: true + - id: BQFEZSHFZSC51 + start_at: '2019-01-22T12:30:00-05:00' + end_at: '2019-01-22T12:44:00-05:00' + break_type_id: P6Q468ZFRN1AC + name: Coffee Break + expected_duration: PT15M + is_paid: false + status: CLOSED + version: 16 + created_at: '2019-01-23T23:32:45Z' + updated_at: '2019-01-24T00:56:25Z' + team_member_id: 33fJchumvVdJwxV0H6L9 + declared_cash_tip_money: + amount: 0 + currency: USD + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + RetrieveTimecard: + path: /v2/labor/timecards/{id} + method: GET + auth: + - oauth2: + - TIMECARDS_READ + docs: Returns a single `Timecard` specified by `id`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveTimecard + request: + name: RetrieveTimecardRequest + path-parameters: + id: + type: string + docs: The UUID for the `Timecard` being retrieved. + response: + docs: Success + type: root.RetrieveTimecardResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + timecard: + id: T35HMQSN89SV4 + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-02-23T18:00:00-05:00' + end_at: '2019-02-23T21:00:00-05:00' + wage: + title: Cashier + hourly_rate: + amount: 1457 + currency: USD + job_id: N4YKVLzFj3oGtNocqoYHYpW3 + tip_eligible: true + breaks: + - id: M9BBKEPQAQD2T + start_at: '2019-02-23T19:00:00-05:00' + end_at: '2019-02-23T20:00:00-05:00' + break_type_id: 92EPDRQKJ5088 + name: Lunch Break + expected_duration: PT1H + is_paid: true + status: CLOSED + version: 1 + created_at: '2019-02-27T00:12:12Z' + updated_at: '2019-02-27T00:12:12Z' + team_member_id: D71KRMQof6cXGUW0aAv7 + declared_cash_tip_money: + amount: 500 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + UpdateTimecard: + path: /v2/labor/timecards/{id} + method: PUT + auth: + - oauth2: + - TIMECARDS_WRITE + - TIMECARDS_READ + docs: >- + Updates an existing `Timecard`. + + + When adding a `Break` to a `Timecard`, any earlier `Break` instances in + the `Timecard` have + + the `end_at` property set to a valid RFC-3339 datetime string. + + + When closing a `Timecard`, all `Break` instances in the `Timecard` must + be complete with `end_at` + + set on each `Break`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateTimecard + request: + name: UpdateTimecardRequest + path-parameters: + id: + type: string + docs: The ID of the object being updated. + body: + properties: + timecard: + type: root.Timecard + docs: The updated `Timecard` object. + content-type: application/json + response: + docs: Success + type: root.UpdateTimecardResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + timecard: + location_id: PAA1RJZZKXBFG + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Bartender + hourly_rate: + amount: 1500 + currency: USD + tip_eligible: true + breaks: + - id: X7GAQYVVRRG6P + start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + status: CLOSED + version: 1 + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + response: + body: + timecard: + id: K0YH4CV5462JB + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Bartender + hourly_rate: + amount: 1500 + currency: USD + job_id: dZtrPh5GSDGugyXGByesVp51 + tip_eligible: true + breaks: + - id: X7GAQYVVRRG6P + start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + status: CLOSED + version: 2 + created_at: '2019-02-28T00:39:02Z' + updated_at: '2019-02-28T00:42:41Z' + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + DeleteTimecard: + path: /v2/labor/timecards/{id} + method: DELETE + auth: + - oauth2: + - TIMECARDS_WRITE + docs: Deletes a `Timecard`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteTimecard + request: + name: DeleteTimecardRequest + path-parameters: + id: + type: string + docs: The UUID for the `Timecard` being deleted. + response: + docs: Success + type: root.DeleteTimecardResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/labor/breakTypes.yml b/.mock/definition/labor/breakTypes.yml new file mode 100644 index 00000000..f19f95fe --- /dev/null +++ b/.mock/definition/labor/breakTypes.yml @@ -0,0 +1,290 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/labor/break-types + method: GET + auth: + - oauth2: + - TIMECARDS_SETTINGS_READ + docs: Returns a paginated list of `BreakType` instances for a business. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.break_types + source: + openapi: ../default/openapi/openapi.json + display-name: ListBreakTypes + request: + name: ListBreakTypesRequest + query-parameters: + location_id: + type: optional> + docs: >- + Filter the returned `BreakType` results to only those that are + associated with the + + specified location. + limit: + type: optional> + docs: >- + The maximum number of `BreakType` results to return per page. The + number can range between 1 + + and 200. The default is 200. + cursor: + type: optional> + docs: A pointer to the next page of `BreakType` results to fetch. + response: + docs: Success + type: root.ListBreakTypesResponse + status-code: 200 + examples: + - query-parameters: + location_id: location_id + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + break_types: + - id: REGS1EQR1TPZ5 + location_id: PAA1RJZZKXBFG + break_name: Coffee Break + expected_duration: PT5M + is_paid: false + version: 1 + created_at: '2019-01-22T20:47:37Z' + updated_at: '2019-01-22T20:47:37Z' + - id: 92EPDRQKJ5088 + location_id: PAA1RJZZKXBFG + break_name: Lunch Break + expected_duration: PT1H + is_paid: true + version: 3 + created_at: '2019-01-25T19:26:30Z' + updated_at: '2019-01-25T19:26:30Z' + cursor: 2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/labor/break-types + method: POST + auth: + - oauth2: + - TIMECARDS_SETTINGS_WRITE + docs: >- + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateBreakType + request: + name: CreateBreakTypeRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique string value to ensure the idempotency of the + operation. + validation: + maxLength: 128 + break_type: + type: root.BreakType + docs: The `BreakType` to be created. + content-type: application/json + response: + docs: Success + type: root.CreateBreakTypeResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: PAD3NG5KSN2GL + break_type: + location_id: CGJN03P1D08GF + break_name: Lunch Break + expected_duration: PT30M + is_paid: true + response: + body: + break_type: + id: 49SSVDJG76WF3 + location_id: CGJN03P1D08GF + break_name: Lunch Break + expected_duration: PT30M + is_paid: true + version: 1 + created_at: '2019-02-26T22:42:54Z' + updated_at: '2019-02-26T22:42:54Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/labor/break-types/{id} + method: GET + auth: + - oauth2: + - TIMECARDS_SETTINGS_READ + docs: Returns a single `BreakType` specified by `id`. + source: + openapi: ../default/openapi/openapi.json + display-name: GetBreakType + request: + name: GetBreakTypesRequest + path-parameters: + id: + type: string + docs: The UUID for the `BreakType` being retrieved. + response: + docs: Success + type: root.GetBreakTypeResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + break_type: + id: lA0mj_RSOprNPwMUXdYp + location_id: 059SB0E0WCNWS + break_name: Lunch Break + expected_duration: PT30M + is_paid: true + version: 1 + created_at: '2019-02-21T17:50:00Z' + updated_at: '2019-02-21T17:50:00Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/labor/break-types/{id} + method: PUT + auth: + - oauth2: + - TIMECARDS_SETTINGS_WRITE + - TIMECARDS_SETTINGS_READ + docs: Updates an existing `BreakType`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateBreakType + request: + name: UpdateBreakTypeRequest + path-parameters: + id: + type: string + docs: ' The UUID for the `BreakType` being updated.' + body: + properties: + break_type: + type: root.BreakType + docs: The updated `BreakType`. + content-type: application/json + response: + docs: Success + type: root.UpdateBreakTypeResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + break_type: + location_id: 26M7H24AZ9N6R + break_name: Lunch + expected_duration: PT50M + is_paid: true + version: 1 + response: + body: + break_type: + id: Q6JSJS6D4DBCH + location_id: 26M7H24AZ9N6R + break_name: Lunch + expected_duration: PT50M + is_paid: true + version: 2 + created_at: '2018-06-12T20:19:12Z' + updated_at: '2019-02-26T23:12:59Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/labor/break-types/{id} + method: DELETE + auth: + - oauth2: + - TIMECARDS_SETTINGS_WRITE + docs: |- + Deletes an existing `BreakType`. + + A `BreakType` can be deleted even if it is referenced from a `Shift`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteBreakType + request: + name: DeleteBreakTypesRequest + path-parameters: + id: + type: string + docs: The UUID for the `BreakType` being deleted. + response: + docs: Success + type: root.DeleteBreakTypeResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/labor/employeeWages.yml b/.mock/definition/labor/employeeWages.yml new file mode 100644 index 00000000..08a4aeea --- /dev/null +++ b/.mock/definition/labor/employeeWages.yml @@ -0,0 +1,125 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/labor/employee-wages + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: Returns a paginated list of `EmployeeWage` instances for a business. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.employee_wages + source: + openapi: ../default/openapi/openapi.json + display-name: ListEmployeeWages + request: + name: ListEmployeeWagesRequest + query-parameters: + employee_id: + type: optional> + docs: >- + Filter the returned wages to only those that are associated with + the specified employee. + limit: + type: optional> + docs: >- + The maximum number of `EmployeeWage` results to return per page. + The number can range between + + 1 and 200. The default is 200. + cursor: + type: optional> + docs: A pointer to the next page of `EmployeeWage` results to fetch. + response: + docs: Success + type: root.ListEmployeeWagesResponse + status-code: 200 + availability: deprecated + examples: + - query-parameters: + employee_id: employee_id + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + employee_wages: + - id: pXS3qCv7BERPnEGedM4S8mhm + employee_id: 33fJchumvVdJwxV0H6L9 + title: Manager + hourly_rate: + amount: 3250 + currency: USD + - id: rZduCkzYDUVL3ovh1sQgbue6 + employee_id: 33fJchumvVdJwxV0H6L9 + title: Cook + hourly_rate: + amount: 2600 + currency: USD + - id: FxLbs5KpPUHa8wyt5ctjubDX + employee_id: 33fJchumvVdJwxV0H6L9 + title: Barista + hourly_rate: + amount: 1600 + currency: USD + - id: vD1wCgijMDR3cX5TPnu7VXto + employee_id: 33fJchumvVdJwxV0H6L9 + title: Cashier + hourly_rate: + amount: 1700 + currency: USD + cursor: 2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/labor/employee-wages/{id} + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: Returns a single `EmployeeWage` specified by `id`. + source: + openapi: ../default/openapi/openapi.json + display-name: GetEmployeeWage + request: + name: GetEmployeeWagesRequest + path-parameters: + id: + type: string + docs: The UUID for the `EmployeeWage` being retrieved. + response: + docs: Success + type: root.GetEmployeeWageResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + employee_wage: + id: pXS3qCv7BERPnEGedM4S8mhm + employee_id: 33fJchumvVdJwxV0H6L9 + title: Manager + hourly_rate: + amount: 2000 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/labor/shifts.yml b/.mock/definition/labor/shifts.yml new file mode 100644 index 00000000..02f895fc --- /dev/null +++ b/.mock/definition/labor/shifts.yml @@ -0,0 +1,472 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/labor/shifts + method: POST + auth: + - oauth2: + - TIMECARDS_WRITE + docs: >- + Creates a new `Shift`. + + + A `Shift` represents a complete workday for a single team member. + + You must provide the following values in your request to this + + endpoint: + + + - `location_id` + + - `team_member_id` + + - `start_at` + + + An attempt to create a new `Shift` can result in a `BAD_REQUEST` error + when: + + - The `status` of the new `Shift` is `OPEN` and the team member has + another + + shift with an `OPEN` status. + + - The `start_at` date is in the future. + + - The `start_at` or `end_at` date overlaps another shift for the same + team member. + + - The `Break` instances are set in the request and a break `start_at` + + is before the `Shift.start_at`, a break `end_at` is after + + the `Shift.end_at`, or both. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateShift + request: + name: CreateShiftRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique string value to ensure the idempotency of the + operation. + validation: + maxLength: 128 + shift: + type: root.Shift + docs: The `Shift` to be created. + content-type: application/json + response: + docs: Success + type: root.CreateShiftResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: HIDSNG5KS478L + shift: + location_id: PAA1RJZZKXBFG + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Barista + hourly_rate: + amount: 1100 + currency: USD + tip_eligible: true + breaks: + - start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + response: + body: + shift: + id: K0YH4CV5462JB + employee_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Barista + hourly_rate: + amount: 1100 + currency: USD + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + tip_eligible: true + breaks: + - id: X7GAQYVVRRG6P + start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + status: CLOSED + version: 1 + created_at: '2019-02-28T00:39:02Z' + updated_at: '2019-02-28T00:39:02Z' + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + search: + path: /v2/labor/shifts/search + method: POST + auth: + - oauth2: + - TIMECARDS_READ + docs: |- + Returns a paginated list of `Shift` records for a business. + The list to be returned can be filtered by: + - Location IDs + - Team member IDs + - Shift status (`OPEN` or `CLOSED`) + - Shift start + - Shift end + - Workday details + + The list can be sorted by: + - `START_AT` + - `END_AT` + - `CREATED_AT` + - `UPDATED_AT` + source: + openapi: ../default/openapi/openapi.json + display-name: SearchShifts + request: + name: SearchShiftsRequest + body: + properties: + query: + type: optional + docs: Query filters. + limit: + type: optional + docs: The number of resources in a page (200 by default). + validation: + min: 1 + max: 200 + cursor: + type: optional + docs: An opaque cursor for fetching the next page. + content-type: application/json + response: + docs: Success + type: root.SearchShiftsResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + workday: + date_range: + start_date: '2019-01-20' + end_date: '2019-02-03' + match_shifts_by: START_AT + default_timezone: America/Los_Angeles + limit: 100 + response: + body: + shifts: + - id: X714F3HA6D1PT + employee_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-21T03:11:00-05:00' + end_at: '2019-01-21T13:11:00-05:00' + wage: + title: Barista + hourly_rate: + amount: 1100 + currency: USD + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + tip_eligible: true + breaks: + - id: SJW7X6AKEJQ65 + start_at: '2019-01-21T06:11:00-05:00' + end_at: '2019-01-21T06:11:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT10M + is_paid: true + status: CLOSED + version: 6 + created_at: '2019-01-24T01:12:03Z' + updated_at: '2019-02-07T22:21:08Z' + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + - id: GDHYBZYWK0P2V + employee_id: 33fJchumvVdJwxV0H6L9 + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-22T12:02:00-05:00' + end_at: '2019-01-22T13:02:00-05:00' + wage: + title: Cook + hourly_rate: + amount: 1600 + currency: USD + job_id: gcbz15vKGnMKmaWJJ152kjim + tip_eligible: true + breaks: + - id: BKS6VR7WR748A + start_at: '2019-01-23T14:30:00-05:00' + end_at: '2019-01-23T14:40:00-05:00' + break_type_id: WQX00VR99F53J + name: Tea Break + expected_duration: PT10M + is_paid: true + - id: BQFEZSHFZSC51 + start_at: '2019-01-22T12:30:00-05:00' + end_at: '2019-01-22T12:44:00-05:00' + break_type_id: P6Q468ZFRN1AC + name: Coffee Break + expected_duration: PT15M + is_paid: false + status: CLOSED + version: 16 + created_at: '2019-01-23T23:32:45Z' + updated_at: '2019-01-24T00:56:25Z' + team_member_id: 33fJchumvVdJwxV0H6L9 + declared_cash_tip_money: + amount: 0 + currency: USD + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/labor/shifts/{id} + method: GET + auth: + - oauth2: + - TIMECARDS_READ + docs: Returns a single `Shift` specified by `id`. + source: + openapi: ../default/openapi/openapi.json + display-name: GetShift + request: + name: GetShiftsRequest + path-parameters: + id: + type: string + docs: The UUID for the `Shift` being retrieved. + response: + docs: Success + type: root.GetShiftResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + shift: + id: T35HMQSN89SV4 + employee_id: D71KRMQof6cXGUW0aAv7 + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-02-23T18:00:00-05:00' + end_at: '2019-02-23T21:00:00-05:00' + wage: + title: Cashier + hourly_rate: + amount: 1457 + currency: USD + job_id: N4YKVLzFj3oGtNocqoYHYpW3 + tip_eligible: true + breaks: + - id: M9BBKEPQAQD2T + start_at: '2019-02-23T19:00:00-05:00' + end_at: '2019-02-23T20:00:00-05:00' + break_type_id: 92EPDRQKJ5088 + name: Lunch Break + expected_duration: PT1H + is_paid: true + status: CLOSED + version: 1 + created_at: '2019-02-27T00:12:12Z' + updated_at: '2019-02-27T00:12:12Z' + team_member_id: D71KRMQof6cXGUW0aAv7 + declared_cash_tip_money: + amount: 500 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/labor/shifts/{id} + method: PUT + auth: + - oauth2: + - TIMECARDS_WRITE + - TIMECARDS_READ + docs: >- + Updates an existing `Shift`. + + + When adding a `Break` to a `Shift`, any earlier `Break` instances in the + `Shift` have + + the `end_at` property set to a valid RFC-3339 datetime string. + + + When closing a `Shift`, all `Break` instances in the `Shift` must be + complete with `end_at` + + set on each `Break`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateShift + request: + name: UpdateShiftRequest + path-parameters: + id: + type: string + docs: The ID of the object being updated. + body: + properties: + shift: + type: root.Shift + docs: The updated `Shift` object. + content-type: application/json + response: + docs: Success + type: root.UpdateShiftResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + shift: + location_id: PAA1RJZZKXBFG + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Bartender + hourly_rate: + amount: 1500 + currency: USD + tip_eligible: true + breaks: + - id: X7GAQYVVRRG6P + start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + version: 1 + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + response: + body: + shift: + id: K0YH4CV5462JB + employee_id: ormj0jJJZ5OZIzxrZYJI + location_id: PAA1RJZZKXBFG + timezone: America/New_York + start_at: '2019-01-25T03:11:00-05:00' + end_at: '2019-01-25T13:11:00-05:00' + wage: + title: Bartender + hourly_rate: + amount: 1500 + currency: USD + job_id: dZtrPh5GSDGugyXGByesVp51 + tip_eligible: true + breaks: + - id: X7GAQYVVRRG6P + start_at: '2019-01-25T06:11:00-05:00' + end_at: '2019-01-25T06:16:00-05:00' + break_type_id: REGS1EQR1TPZ5 + name: Tea Break + expected_duration: PT5M + is_paid: true + status: CLOSED + version: 2 + created_at: '2019-02-28T00:39:02Z' + updated_at: '2019-02-28T00:42:41Z' + team_member_id: ormj0jJJZ5OZIzxrZYJI + declared_cash_tip_money: + amount: 500 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/labor/shifts/{id} + method: DELETE + auth: + - oauth2: + - TIMECARDS_WRITE + docs: Deletes a `Shift`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteShift + request: + name: DeleteShiftsRequest + path-parameters: + id: + type: string + docs: The UUID for the `Shift` being deleted. + response: + docs: Success + type: root.DeleteShiftResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/labor/teamMemberWages.yml b/.mock/definition/labor/teamMemberWages.yml new file mode 100644 index 00000000..7e03a131 --- /dev/null +++ b/.mock/definition/labor/teamMemberWages.yml @@ -0,0 +1,135 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/labor/team-member-wages + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: Returns a paginated list of `TeamMemberWage` instances for a business. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.team_member_wages + source: + openapi: ../default/openapi/openapi.json + display-name: ListTeamMemberWages + request: + name: ListTeamMemberWagesRequest + query-parameters: + team_member_id: + type: optional> + docs: >- + Filter the returned wages to only those that are associated with + the + + specified team member. + limit: + type: optional> + docs: >- + The maximum number of `TeamMemberWage` results to return per page. + The number can range between + + 1 and 200. The default is 200. + cursor: + type: optional> + docs: A pointer to the next page of `EmployeeWage` results to fetch. + response: + docs: Success + type: root.ListTeamMemberWagesResponse + status-code: 200 + examples: + - query-parameters: + team_member_id: team_member_id + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + team_member_wages: + - id: pXS3qCv7BERPnEGedM4S8mhm + team_member_id: 33fJchumvVdJwxV0H6L9 + title: Manager + hourly_rate: + amount: 3250 + currency: USD + job_id: jxJNN6eCJsLrhg5UFJrDWDGE + tip_eligible: false + - id: rZduCkzYDUVL3ovh1sQgbue6 + team_member_id: 33fJchumvVdJwxV0H6L9 + title: Cook + hourly_rate: + amount: 2600 + currency: USD + job_id: gcbz15vKGnMKmaWJJ152kjim + tip_eligible: true + - id: FxLbs5KpPUHa8wyt5ctjubDX + team_member_id: 33fJchumvVdJwxV0H6L9 + title: Barista + hourly_rate: + amount: 1600 + currency: USD + job_id: FzbJAtt9qEWncK1BWgVCxQ6M + tip_eligible: true + - id: vD1wCgijMDR3cX5TPnu7VXto + team_member_id: 33fJchumvVdJwxV0H6L9 + title: Cashier + hourly_rate: + amount: 1700 + currency: USD + job_id: N4YKVLzFj3oGtNocqoYHYpW3 + tip_eligible: true + cursor: 2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/labor/team-member-wages/{id} + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: Returns a single `TeamMemberWage` specified by `id`. + source: + openapi: ../default/openapi/openapi.json + display-name: GetTeamMemberWage + request: + name: GetTeamMemberWagesRequest + path-parameters: + id: + type: string + docs: The UUID for the `TeamMemberWage` being retrieved. + response: + docs: Success + type: root.GetTeamMemberWageResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + response: + body: + team_member_wage: + id: pXS3qCv7BERPnEGedM4S8mhm + team_member_id: 33fJchumvVdJwxV0H6L9 + title: Manager + hourly_rate: + amount: 2000 + currency: USD + job_id: jxJNN6eCJsLrhg5UFJrDWDGE + tip_eligible: false + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/labor/workweekConfigs.yml b/.mock/definition/labor/workweekConfigs.yml new file mode 100644 index 00000000..225be007 --- /dev/null +++ b/.mock/definition/labor/workweekConfigs.yml @@ -0,0 +1,109 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/labor/workweek-configs + method: GET + auth: + - oauth2: + - TIMECARDS_SETTINGS_READ + docs: Returns a list of `WorkweekConfig` instances for a business. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.workweek_configs + source: + openapi: ../default/openapi/openapi.json + display-name: ListWorkweekConfigs + request: + name: ListWorkweekConfigsRequest + query-parameters: + limit: + type: optional> + docs: >- + The maximum number of `WorkweekConfigs` results to return per + page. + cursor: + type: optional> + docs: A pointer to the next page of `WorkweekConfig` results to fetch. + response: + docs: Success + type: root.ListWorkweekConfigsResponse + status-code: 200 + examples: + - query-parameters: + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + workweek_configs: + - id: FY4VCAQN700GM + start_of_week: MON + start_of_day_local_time: '10:00' + version: 11 + created_at: '2016-02-04T00:58:24Z' + updated_at: '2019-02-28T01:04:35Z' + cursor: 2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/labor/workweek-configs/{id} + method: PUT + auth: + - oauth2: + - TIMECARDS_SETTINGS_WRITE + - TIMECARDS_SETTINGS_READ + docs: Updates a `WorkweekConfig`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateWorkweekConfig + request: + name: UpdateWorkweekConfigRequest + path-parameters: + id: + type: string + docs: The UUID for the `WorkweekConfig` object being updated. + body: + properties: + workweek_config: + type: root.WorkweekConfig + docs: The updated `WorkweekConfig` object. + content-type: application/json + response: + docs: Success + type: root.UpdateWorkweekConfigResponse + status-code: 200 + examples: + - path-parameters: + id: id + headers: + Square-Version: '2025-10-16' + request: + workweek_config: + start_of_week: MON + start_of_day_local_time: '10:00' + version: 10 + response: + body: + workweek_config: + id: FY4VCAQN700GM + start_of_week: MON + start_of_day_local_time: '10:00' + version: 11 + created_at: '2016-02-04T00:58:24Z' + updated_at: '2019-02-28T01:04:35Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/locations.yml b/.mock/definition/locations.yml new file mode 100644 index 00000000..48bd356d --- /dev/null +++ b/.mock/definition/locations.yml @@ -0,0 +1,807 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/locations + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Provides details about all of the seller's + [locations](https://developer.squareup.com/docs/locations-api), + + including those with an inactive status. Locations are listed + alphabetically by `name`. + source: + openapi: ../default/openapi/openapi.json + display-name: ListLocations + response: + docs: Success + type: root.ListLocationsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + locations: + - id: 18YC4JDH91E1H + name: Grant Park + address: + address_line_1: 123 Main St + locality: San Francisco + administrative_district_level_1: CA + postal_code: '94114' + country: US + timezone: America/Los_Angeles + capabilities: + - CREDIT_CARD_PROCESSING + status: ACTIVE + created_at: '2016-09-19T17:33:12Z' + merchant_id: 3MYCJG5GVYQ8Q + country: US + language_code: en-US + currency: USD + phone_number: +1 650-354-7217 + business_name: Jet Fuel Coffee + type: PHYSICAL + website_url: website_url + business_email: business_email + description: description + twitter_username: twitter_username + instagram_username: instagram_username + facebook_url: facebook_url + logo_url: logo_url + pos_background_url: pos_background_url + mcc: mcc + full_format_logo_url: full_format_logo_url + - id: 3Z4V4WHQK64X9 + name: Midtown + address: + address_line_1: 1234 Peachtree St. NE + locality: Atlanta + administrative_district_level_1: GA + postal_code: '30309' + timezone: America/New_York + capabilities: + - CREDIT_CARD_PROCESSING + status: ACTIVE + created_at: '2022-02-19T17:58:25Z' + merchant_id: 3MYCJG5GVYQ8Q + country: US + language_code: en-US + currency: USD + phone_number: phone_number + business_name: Jet Fuel Coffee + type: PHYSICAL + website_url: website_url + business_email: business_email + description: Midtown Atlanta store + twitter_username: twitter_username + instagram_username: instagram_username + facebook_url: facebook_url + coordinates: + latitude: 33.7889 + longitude: -84.3841 + logo_url: logo_url + pos_background_url: pos_background_url + mcc: '7299' + full_format_logo_url: full_format_logo_url + create: + path: /v2/locations + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Creates a [location](https://developer.squareup.com/docs/locations-api). + + Creating new locations allows for separate configuration of receipt + layouts, item prices, + + and sales reports. Developers can use locations to separate sales + activity through applications + + that integrate with Square from sales activity elsewhere in a seller's + account. + + Locations created programmatically with the Locations API last forever + and + + are visible to the seller for their own management. Therefore, ensure + that + + each location has a sensible and unique name. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateLocation + request: + name: CreateLocationRequest + body: + properties: + location: + type: optional + docs: >- + The initial values of the location being created. The `name` + field is required and must be unique within a seller account. + + All other fields are optional, but any information you care + about for the location should be included. + + The remaining fields are automatically added based on the data + from the [main + location](https://developer.squareup.com/docs/locations-api#about-the-main-location). + content-type: application/json + response: + docs: Success + type: root.CreateLocationResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + location: + name: Midtown + address: + address_line_1: 1234 Peachtree St. NE + locality: Atlanta + administrative_district_level_1: GA + postal_code: '30309' + description: Midtown Atlanta store + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + location: + id: 3Z4V4WHQK64X9 + name: Midtown + address: + address_line_1: 1234 Peachtree St. NE + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: Atlanta + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: GA + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '30309' + country: ZZ + first_name: first_name + last_name: last_name + timezone: America/New_York + capabilities: + - CREDIT_CARD_PROCESSING + status: ACTIVE + created_at: '2022-02-19T17:58:25Z' + merchant_id: 3MYCJG5GVYQ8Q + country: US + language_code: en-US + currency: USD + phone_number: phone_number + business_name: Jet Fuel Coffee + type: PHYSICAL + website_url: website_url + business_hours: + periods: + - {} + business_email: business_email + description: Midtown Atlanta store + twitter_username: twitter_username + instagram_username: instagram_username + facebook_url: facebook_url + coordinates: + latitude: 33.7889 + longitude: -84.3841 + logo_url: logo_url + pos_background_url: pos_background_url + mcc: '7299' + full_format_logo_url: full_format_logo_url + tax_ids: + eu_vat: eu_vat + fr_siret: fr_siret + fr_naf: fr_naf + es_nif: es_nif + jp_qii: jp_qii + get: + path: /v2/locations/{location_id} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Retrieves details of a single location. Specify "main" + + as the location ID to retrieve details of the [main + location](https://developer.squareup.com/docs/locations-api#about-the-main-location). + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLocation + request: + name: GetLocationsRequest + path-parameters: + location_id: + type: string + docs: |- + The ID of the location to retrieve. Specify the string + "main" to return the main location. + response: + docs: Success + type: root.GetLocationResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + location: + id: 18YC4JDH91E1H + name: Grant Park + address: + address_line_1: 123 Main St + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: San Francisco + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: CA + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '94114' + country: US + first_name: first_name + last_name: last_name + timezone: America/Los_Angeles + capabilities: + - CREDIT_CARD_PROCESSING + status: ACTIVE + created_at: '2016-09-19T17:33:12Z' + merchant_id: 3MYCJG5GVYQ8Q + country: US + language_code: en-US + currency: USD + phone_number: +1 650-354-7217 + business_name: Jet Fuel Coffee + type: PHYSICAL + website_url: website_url + business_hours: + periods: + - {} + business_email: business_email + description: description + twitter_username: twitter_username + instagram_username: instagram_username + facebook_url: facebook_url + coordinates: + latitude: 1.1 + longitude: 1.1 + logo_url: logo_url + pos_background_url: pos_background_url + mcc: mcc + full_format_logo_url: full_format_logo_url + tax_ids: + eu_vat: eu_vat + fr_siret: fr_siret + fr_naf: fr_naf + es_nif: es_nif + jp_qii: jp_qii + update: + path: /v2/locations/{location_id} + method: PUT + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: Updates a [location](https://developer.squareup.com/docs/locations-api). + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateLocation + request: + name: UpdateLocationRequest + path-parameters: + location_id: + type: string + docs: The ID of the location to update. + body: + properties: + location: + type: optional + docs: The `Location` object with only the fields to update. + content-type: application/json + response: + docs: Success + type: root.UpdateLocationResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + request: + location: + business_hours: + periods: + - day_of_week: FRI + start_local_time: '07:00' + end_local_time: '18:00' + - day_of_week: SAT + start_local_time: '07:00' + end_local_time: '18:00' + - day_of_week: SUN + start_local_time: '09:00' + end_local_time: '15:00' + description: Midtown Atlanta store - Open weekends + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + location: + id: 3Z4V4WHQK64X9 + name: Midtown + address: + address_line_1: 1234 Peachtree St. NE + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: Atlanta + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: GA + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '30309' + country: ZZ + first_name: first_name + last_name: last_name + timezone: America/New_York + capabilities: + - CREDIT_CARD_PROCESSING + status: ACTIVE + created_at: '2022-02-19T17:58:25Z' + merchant_id: 3MYCJG5GVYQ8Q + country: US + language_code: en-US + currency: USD + phone_number: phone_number + business_name: Jet Fuel Coffee + type: PHYSICAL + website_url: website_url + business_hours: + periods: + - day_of_week: FRI + start_local_time: '07:00' + end_local_time: '18:00' + - day_of_week: SAT + start_local_time: '07:00' + end_local_time: '18:00' + - day_of_week: SUN + start_local_time: '09:00' + end_local_time: '15:00' + business_email: business_email + description: Midtown Atlanta store - Open weekends + twitter_username: twitter_username + instagram_username: instagram_username + facebook_url: facebook_url + coordinates: + latitude: 33.7889 + longitude: -84.3841 + logo_url: logo_url + pos_background_url: pos_background_url + mcc: '7299' + full_format_logo_url: full_format_logo_url + tax_ids: + eu_vat: eu_vat + fr_siret: fr_siret + fr_naf: fr_naf + es_nif: es_nif + jp_qii: jp_qii + checkouts: + path: /v2/locations/{location_id}/checkouts + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + - ORDERS_WRITE + docs: >- + Links a `checkoutId` to a `checkout_page_url` that customers are + + directed to in order to provide their payment information using a + + payment processing workflow hosted on connect.squareup.com. + + + + NOTE: The Checkout API has been updated with new features. + + For more information, see [Checkout API + highlights](https://developer.squareup.com/docs/checkout-api#checkout-api-highlights). + source: + openapi: ../default/openapi/openapi.json + display-name: CreateCheckout + request: + name: CreateCheckoutRequest + path-parameters: + location_id: + type: string + docs: The ID of the business location to associate the checkout with. + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this checkout among others you + have created. It can be + + any valid string but must be unique for every order sent to + Square Checkout for a given location ID. + + + The idempotency key is used to avoid processing the same order + more than once. If you are + + unsure whether a particular checkout was created successfully, + you can attempt it again with + + the same idempotency key and all the same other parameters + without worrying about creating duplicates. + + + You should use a random number/string generator native to the + language + + you are working in to generate strings for your idempotency + keys. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + minLength: 1 + maxLength: 192 + order: + type: root.CreateOrderRequest + docs: The order including line items to be checked out. + ask_for_shipping_address: + type: optional + docs: >- + If `true`, Square Checkout collects shipping information on your + behalf and stores + + that information with the transaction information in the Square + Seller Dashboard. + + + Default: `false`. + merchant_support_email: + type: optional + docs: >- + The email address to display on the Square Checkout confirmation + page + + and confirmation email that the buyer can use to contact the + seller. + + + If this value is not set, the confirmation page and email + display the + + primary email address associated with the seller's Square + account. + + + Default: none; only exists if explicitly set. + validation: + maxLength: 254 + pre_populate_buyer_email: + type: optional + docs: >- + If provided, the buyer's email is prepopulated on the checkout + page + + as an editable text field. + + + Default: none; only exists if explicitly set. + validation: + maxLength: 254 + pre_populate_shipping_address: + type: optional + docs: >- + If provided, the buyer's shipping information is prepopulated on + the + + checkout page as editable text fields. + + + Default: none; only exists if explicitly set. + redirect_url: + type: optional + docs: >- + The URL to redirect to after the checkout is completed with + `checkoutId`, + + `transactionId`, and `referenceId` appended as URL parameters. + For example, + + if the provided redirect URL is + `http://www.example.com/order-complete`, a + + successful transaction redirects the customer to: + + + `http://www.example.com/order-complete?checkoutId=xxxxxx&referenceId=xxxxxx&transactionId=xxxxxx` + + + If you do not provide a redirect URL, Square Checkout displays + an order + + confirmation page on your behalf; however, it is strongly + recommended that + + you provide a redirect URL so you can verify the transaction + results and + + finalize the order through your existing/normal confirmation + workflow. + + + Default: none; only exists if explicitly set. + validation: + maxLength: 800 + additional_recipients: + type: optional> + docs: >- + The basic primitive of a multi-party transaction. The value is + optional. + + The transaction facilitated by you can be split from here. + + + If you provide this value, the `amount_money` value in your + `additional_recipients` field + + cannot be more than 90% of the `total_money` calculated by + Square for your order. + + The `location_id` must be a valid seller location where the + checkout is occurring. + + + This field requires `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth + permission. + + + This field is currently not supported in the Square Sandbox. + note: + type: optional + docs: |- + An optional note to associate with the `checkout` object. + + This value cannot exceed 60 characters. + validation: + maxLength: 60 + content-type: application/json + response: + docs: Success + type: root.CreateCheckoutResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 86ae1696-b1e3-4328-af6d-f1e04d947ad6 + order: + order: + location_id: location_id + reference_id: reference_id + customer_id: customer_id + line_items: + - name: Printed T Shirt + quantity: '2' + applied_taxes: + - tax_uid: 38ze1696-z1e3-5628-af6d-f1e04d947fg3 + applied_discounts: + - discount_uid: 56ae1696-z1e3-9328-af6d-f1e04d947gd4 + base_price_money: + amount: 1500 + currency: USD + - name: Slim Jeans + quantity: '1' + base_price_money: + amount: 2500 + currency: USD + - name: Woven Sweater + quantity: '3' + base_price_money: + amount: 3500 + currency: USD + taxes: + - uid: 38ze1696-z1e3-5628-af6d-f1e04d947fg3 + type: INCLUSIVE + percentage: '7.75' + scope: LINE_ITEM + discounts: + - uid: 56ae1696-z1e3-9328-af6d-f1e04d947gd4 + type: FIXED_AMOUNT + amount_money: + amount: 100 + currency: USD + scope: LINE_ITEM + idempotency_key: 12ae1696-z1e3-4328-af6d-f1e04d947gd4 + ask_for_shipping_address: true + merchant_support_email: merchant+support@website.com + pre_populate_buyer_email: example@email.com + pre_populate_shipping_address: + address_line_1: 1455 Market St. + address_line_2: Suite 600 + locality: San Francisco + administrative_district_level_1: CA + postal_code: '94103' + country: US + first_name: Jane + last_name: Doe + redirect_url: https://merchant.website.com/order-confirm + additional_recipients: + - location_id: 057P5VYJ4A5X1 + description: Application fees + amount_money: + amount: 60 + currency: USD + response: + body: + checkout: + id: CAISEHGimXh-C3RIT4og1a6u1qw + checkout_page_url: >- + https://connect.squareup.com/v2/checkout?c=CAISEHGimXh-C3RIT4og1a6u1qw&l=CYTKRM7R7JMV8 + ask_for_shipping_address: true + merchant_support_email: merchant+support@website.com + pre_populate_buyer_email: example@email.com + pre_populate_shipping_address: + address_line_1: 1455 Market St. + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: San Francisco + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: CA + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '94103' + country: US + first_name: Jane + last_name: Doe + redirect_url: https://merchant.website.com/order-confirm + order: + id: id + location_id: location_id + reference_id: reference_id + customer_id: customer_id + line_items: + - name: Printed T Shirt + quantity: '2' + applied_taxes: + - tax_uid: 38ze1696-z1e3-5628-af6d-f1e04d947fg3 + applied_money: + amount: 103 + currency: USD + applied_discounts: + - discount_uid: 56ae1696-z1e3-9328-af6d-f1e04d947gd4 + applied_money: + amount: 100 + currency: USD + base_price_money: + amount: 1500 + currency: USD + total_tax_money: + amount: 103 + currency: USD + total_discount_money: + amount: 100 + currency: USD + total_money: + amount: 1503 + currency: USD + - name: Slim Jeans + quantity: '1' + base_price_money: + amount: 2500 + currency: USD + total_money: + amount: 2500 + currency: USD + - name: Woven Sweater + quantity: '3' + base_price_money: + amount: 3500 + currency: USD + total_money: + amount: 10500 + currency: USD + taxes: + - uid: 38ze1696-z1e3-5628-af6d-f1e04d947fg3 + type: INCLUSIVE + percentage: '7.75' + scope: LINE_ITEM + discounts: + - uid: 56ae1696-z1e3-9328-af6d-f1e04d947gd4 + type: FIXED_AMOUNT + amount_money: + amount: 100 + currency: USD + applied_money: + amount: 100 + currency: USD + scope: LINE_ITEM + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + created_at: created_at + updated_at: updated_at + closed_at: closed_at + state: OPEN + version: 1 + total_money: + amount: 14503 + currency: USD + total_tax_money: + amount: 103 + currency: USD + total_discount_money: + amount: 100 + currency: USD + ticket_name: ticket_name + rewards: + - id: id + reward_tier_id: reward_tier_id + created_at: '2017-06-16T22:25:35Z' + additional_recipients: + - location_id: 057P5VYJ4A5X1 + description: Application fees + amount_money: + amount: 60 + currency: USD + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/locations/customAttributeDefinitions.yml b/.mock/definition/locations/customAttributeDefinitions.yml new file mode 100644 index 00000000..242bbc85 --- /dev/null +++ b/.mock/definition/locations/customAttributeDefinitions.yml @@ -0,0 +1,419 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/locations/custom-attribute-definitions + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Lists the location-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`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attribute_definitions + source: + openapi: ../default/openapi/openapi.json + display-name: ListLocationCustomAttributeDefinitions + request: + name: ListCustomAttributeDefinitionsRequest + query-parameters: + visibility_filter: + type: optional> + docs: >- + Filters the `CustomAttributeDefinition` results by their + `visibility` values. + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + response: + docs: Success + type: root.ListLocationCustomAttributeDefinitionsResponse + status-code: 200 + examples: + - query-parameters: + visibility_filter: ALL + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definitions: + - key: phone-number + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.PhoneNumber + name: phone number + description: Location's phone number + visibility: VISIBILITY_READ_ONLY + version: 1 + updated_at: '2022-12-02T19:50:21.832Z' + created_at: '2022-12-02T19:50:21.832Z' + - key: bestseller + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Bestseller + description: Bestselling item at location + visibility: VISIBILITY_READ_WRITE_VALUES + version: 4 + updated_at: '2022-12-03T10:17:52.341Z' + created_at: '2022-12-02T19:06:36.559Z' + cursor: >- + ImfNzWVSiAYyiAR4gEcxDJ75KZAOSjX8H2BVHUTR0ofCtp4SdYvrUKbwYY2aCH2WqZ2FsfAuylEVUlTfaINg3ecIlFpP9Y5Ie66w9NSg9nqdI5fCJ6qdH2s0za5m2plFonsjIuFaoN89j78ROUwuSOzD6mFZPcJHhJ0CxEKc0SBH + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/locations/custom-attribute-definitions + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Creates a location-related [custom attribute + definition](entity:CustomAttributeDefinition) for a Square seller + account. + + Use this endpoint to define a custom attribute that can be associated + with locations. + + A custom attribute definition specifies the `key`, `visibility`, + `schema`, and other properties + + for a custom attribute. After the definition is created, you can call + + [UpsertLocationCustomAttribute](api-endpoint:LocationCustomAttributes-UpsertLocationCustomAttribute) + or + + [BulkUpsertLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkUpsertLocationCustomAttributes) + + to set the custom attribute for locations. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateLocationCustomAttributeDefinition + request: + name: CreateLocationCustomAttributeDefinitionRequest + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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`. + idempotency_key: + type: optional + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CreateLocationCustomAttributeDefinitionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + key: bestseller + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Bestseller + description: Bestselling item at location + visibility: VISIBILITY_READ_WRITE_VALUES + response: + body: + custom_attribute_definition: + key: bestseller + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Bestseller + description: Bestselling item at location + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-12-02T19:06:36.559Z' + created_at: '2022-12-02T19:06:36.559Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/locations/custom-attribute-definitions/{key} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Retrieves a location-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`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLocationCustomAttributeDefinition + request: + name: GetCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: >- + The key of the custom attribute definition to retrieve. If the + requesting application + + is not the definition owner, you must use the qualified key. + query-parameters: + version: + type: optional> + docs: >- + The current version of the custom attribute definition, which is + used for strongly consistent + + reads to guarantee that you receive the most up-to-date data. When + included in the request, + + Square returns the specified version or a higher version if one + exists. If the specified version + + is higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.RetrieveLocationCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + query-parameters: + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definition: + key: bestseller + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Bestseller + description: Bestselling item at location + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-12-02T19:06:36.559Z' + created_at: '2022-12-02T19:06:36.559Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/locations/custom-attribute-definitions/{key} + method: PUT + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateLocationCustomAttributeDefinition + request: + name: UpdateLocationCustomAttributeDefinitionRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to update. + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdateLocationCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + response: + body: + custom_attribute_definition: + key: bestseller + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Bestseller + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + version: 2 + updated_at: '2022-12-02T19:34:10.181Z' + created_at: '2022-12-02T19:06:36.559Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/locations/custom-attribute-definitions/{key} + method: DELETE + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteLocationCustomAttributeDefinition + request: + name: DeleteCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to delete. + response: + docs: Success + type: root.DeleteLocationCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/locations/customAttributes.yml b/.mock/definition/locations/customAttributes.yml new file mode 100644 index 00000000..252d2cd3 --- /dev/null +++ b/.mock/definition/locations/customAttributes.yml @@ -0,0 +1,577 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + batchDelete: + path: /v2/locations/custom-attributes/bulk-delete + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkDeleteLocationCustomAttributes + request: + name: BulkDeleteLocationCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + The data used to update the `CustomAttribute` objects. + + The keys must be unique and are used to map to the corresponding + response. + content-type: application/json + response: + docs: Success + type: root.BulkDeleteLocationCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + id1: + key: bestseller + id2: + key: bestseller + id3: + key: phone-number + response: + body: + values: + id1: + location_id: L0TBCBTB7P8RQ + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + location_id: L9XMD04V3STJX + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id3: + location_id: L0TBCBTB7P8RQ + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchUpsert: + path: /v2/locations/custom-attributes/bulk-upsert + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Creates or updates [custom attributes](entity:CustomAttribute) for + locations as a bulk operation. + + Use this endpoint to set the value of one or more custom attributes for + one or more locations. + + A custom attribute is based on a custom attribute definition in a Square + seller account, which is + + created using the + [CreateLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-CreateLocationCustomAttributeDefinition) + endpoint. + + This `BulkUpsertLocationCustomAttributes` 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 location 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpsertLocationCustomAttributes + request: + name: BulkUpsertLocationCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BulkUpsertLocationCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + id1: + location_id: L0TBCBTB7P8RQ + custom_attribute: + key: bestseller + value: hot cocoa + id2: + location_id: L9XMD04V3STJX + custom_attribute: + key: bestseller + value: berry smoothie + id3: + location_id: L0TBCBTB7P8RQ + custom_attribute: + key: phone-number + value: '+12223334444' + response: + body: + values: + id1: + location_id: L0TBCBTB7P8RQ + custom_attribute: + key: bestseller + value: hot cocoa + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2023-01-09T19:21:04.551Z' + created_at: '2023-01-09T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + location_id: L9XMD04V3STJX + custom_attribute: + key: bestseller + value: berry smoothie + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2023-01-09T19:21:04.551Z' + created_at: '2023-01-09T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id3: + location_id: L0TBCBTB7P8RQ + custom_attribute: + key: phone-number + value: '+12239903892' + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2023-01-09T19:21:04.563Z' + created_at: '2023-01-09T19:04:57.985Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + list: + path: /v2/locations/{location_id}/custom-attributes + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Lists the [custom attributes](entity:CustomAttribute) associated with a + location. + + 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`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attributes + source: + openapi: ../default/openapi/openapi.json + display-name: ListLocationCustomAttributes + request: + name: ListCustomAttributesRequest + path-parameters: + location_id: + type: string + docs: The ID of the target [location](entity:Location). + query-parameters: + visibility_filter: + type: optional> + docs: >- + Filters the `CustomAttributeDefinition` results by their + `visibility` values. + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + with_definitions: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of each + + custom attribute. Set this parameter to `true` to get the name and + description of each custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + response: + docs: Success + type: root.ListLocationCustomAttributesResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + query-parameters: + visibility_filter: ALL + limit: 1 + cursor: cursor + with_definitions: true + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attributes: + - key: phone-number + value: '+12223334444' + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-12-12T18:13:03.745Z' + created_at: '2022-12-12T18:13:03.745Z' + - key: bestseller + value: hot cocoa + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-12-12T19:27:57.975Z' + created_at: '2022-12-12T19:27:57.975Z' + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/locations/{location_id}/custom-attributes/{key} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Retrieves a [custom attribute](entity:CustomAttribute) associated with a + location. + + You can use the `with_definition` query parameter to also retrieve the + custom attribute definition + + in the same call. + + To retrieve a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLocationCustomAttribute + request: + name: GetCustomAttributesRequest + path-parameters: + location_id: + type: string + docs: The ID of the target [location](entity:Location). + key: + type: string + docs: >- + The key of the custom attribute to retrieve. This key must match + the `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + query-parameters: + with_definition: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of + + the custom attribute. Set this parameter to `true` to get the name + and description of the custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + version: + type: optional> + docs: >- + The current version of the custom attribute, which is used for + strongly consistent reads to + + guarantee that you receive the most up-to-date data. When included + in the request, Square + + returns the specified version or a higher version if one exists. + If the specified version is + + higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.RetrieveLocationCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + key: key + query-parameters: + with_definition: true + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute: + key: bestseller + value: hot cocoa + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2023-01-09T19:21:04.551Z' + created_at: '2023-01-09T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + upsert: + path: /v2/locations/{location_id}/custom-attributes/{key} + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Creates or updates a [custom attribute](entity:CustomAttribute) for a + location. + + Use this endpoint to set the value of a custom attribute for a specified + location. + + A custom attribute is based on a custom attribute definition in a Square + seller account, which + + is created using the + [CreateLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-CreateLocationCustomAttributeDefinition) + endpoint. + + To create or update a custom attribute owned by another application, the + `visibility` setting + + must be `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertLocationCustomAttribute + request: + name: UpsertLocationCustomAttributeRequest + path-parameters: + location_id: + type: string + docs: The ID of the target [location](entity:Location). + key: + type: string + docs: >- + The key of the custom attribute to create or update. This key must + match the `key` of a + + custom attribute definition in the Square seller account. If the + requesting application is not + + the definition owner, you must use the qualified key. + body: + properties: + custom_attribute: + type: root.CustomAttribute + docs: >- + The custom attribute to create or update, with the following + fields: + + - `value`. This value must conform to the `schema` specified by + the definition. + + For more information, see [Supported data + types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). + + - `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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpsertLocationCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute: + value: hot cocoa + response: + body: + custom_attribute: + key: bestseller + value: hot cocoa + version: 2 + visibility: VISIBILITY_READ_WRITE_VALUES + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2023-01-09T19:21:04.551Z' + created_at: '2023-01-09T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/locations/{location_id}/custom-attributes/{key} + method: DELETE + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteLocationCustomAttribute + request: + name: DeleteCustomAttributesRequest + path-parameters: + location_id: + type: string + docs: The ID of the target [location](entity:Location). + key: + type: string + docs: >- + The key of the custom attribute to delete. This key must match the + `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + response: + docs: Success + type: root.DeleteLocationCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + location_id: location_id + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/locations/transactions.yml b/.mock/definition/locations/transactions.yml new file mode 100644 index 00000000..605e1b42 --- /dev/null +++ b/.mock/definition/locations/transactions.yml @@ -0,0 +1,344 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/locations/{location_id}/transactions + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Lists transactions for a particular location. + + + Transactions include payment information from sales and exchanges and + refund + + information from returns and exchanges. + + + Max results per + [page](https://developer.squareup.com/docs/working-with-apis/pagination): + 50 + source: + openapi: ../default/openapi/openapi.json + display-name: ListTransactions + request: + name: ListTransactionsRequest + path-parameters: + location_id: + type: string + docs: The ID of the location to list transactions for. + query-parameters: + begin_time: + type: optional> + docs: >- + The beginning of the requested reporting period, in RFC 3339 + format. + + + See [Date + ranges](https://developer.squareup.com/docs/build-basics/working-with-dates) + for details on date inclusivity/exclusivity. + + + Default value: The current time minus one year. + end_time: + type: optional> + docs: >- + The end of the requested reporting period, in RFC 3339 format. + + + See [Date + ranges](https://developer.squareup.com/docs/build-basics/working-with-dates) + for details on date inclusivity/exclusivity. + + + Default value: The current time. + sort_order: + type: optional> + docs: |- + The order in which results are listed in the response (`ASC` for + oldest first, `DESC` for newest first). + + Default value: `DESC` + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this to retrieve the next set of results for your original + query. + + + See [Paginating + results](https://developer.squareup.com/docs/working-with-apis/pagination) + for more information. + response: + docs: Success + type: root.ListTransactionsResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + query-parameters: + begin_time: begin_time + end_time: end_time + sort_order: DESC + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + transactions: + - id: KnL67ZIwXCPtzOrqj0HrkxMF + location_id: 18YC4JDH91E1H + created_at: '2016-01-20T22:57:56Z' + tenders: + - id: MtZRYYdDrYNQbOvV7nbuBvMF + location_id: 18YC4JDH91E1H + transaction_id: KnL67ZIwXCPtzOrqj0HrkxMF + created_at: '2016-01-20T22:57:56Z' + note: some optional note + amount_money: + amount: 5000 + currency: USD + processing_fee_money: + amount: 138 + currency: USD + type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + entry_method: KEYED + additional_recipients: + - location_id: 057P5VYJ4A5X1 + description: Application fees + amount_money: + amount: 20 + currency: USD + refunds: + - id: 7a5RcVI0CxbOcJ2wMOkE + location_id: 18YC4JDH91E1H + transaction_id: KnL67ZIwXCPtzOrqj0HrkxMF + tender_id: MtZRYYdDrYNQbOvV7nbuBvMF + created_at: '2016-01-20T22:59:20Z' + reason: some reason why + amount_money: + amount: 5000 + currency: USD + status: APPROVED + processing_fee_money: + amount: 138 + currency: USD + additional_recipients: + - location_id: 057P5VYJ4A5X1 + description: Application fees + amount_money: + amount: 100 + currency: USD + reference_id: some optional reference id + product: EXTERNAL_API + client_id: client_id + order_id: order_id + cursor: cursor + get: + path: /v2/locations/{location_id}/transactions/{transaction_id} + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: Retrieves details for a single transaction. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveTransaction + request: + name: GetTransactionsRequest + path-parameters: + location_id: + type: string + docs: The ID of the transaction's associated location. + transaction_id: + type: string + docs: The ID of the transaction to retrieve. + response: + docs: Success + type: root.GetTransactionResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + transaction_id: transaction_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + transaction: + id: KnL67ZIwXCPtzOrqj0HrkxMF + location_id: 18YC4JDH91E1H + created_at: '2016-03-10T22:57:56Z' + tenders: + - id: MtZRYYdDrYNQbOvV7nbuBvMF + location_id: 18YC4JDH91E1H + transaction_id: KnL67ZIwXCPtzOrqj0HrkxMF + created_at: '2016-03-10T22:57:56Z' + note: some optional note + amount_money: + amount: 5000 + currency: USD + processing_fee_money: + amount: 138 + currency: USD + type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + entry_method: KEYED + additional_recipients: + - location_id: 057P5VYJ4A5X1 + description: Application fees + amount_money: + amount: 20 + currency: USD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + reference_id: some optional reference id + product: EXTERNAL_API + client_id: client_id + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + order_id: order_id + capture: + path: /v2/locations/{location_id}/transactions/{transaction_id}/capture + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Captures a transaction that was created with the + [Charge](api-endpoint:Transactions-Charge) + + endpoint with a `delay_capture` value of `true`. + + + + See [Delayed capture + transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) + + for more information. + source: + openapi: ../default/openapi/openapi.json + display-name: CaptureTransaction + request: + name: CaptureTransactionsRequest + path-parameters: + location_id: + type: string + docs: '' + transaction_id: + type: string + docs: '' + response: + docs: Success + type: root.CaptureTransactionResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + transaction_id: transaction_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + void: + path: /v2/locations/{location_id}/transactions/{transaction_id}/void + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Cancels a transaction that was created with the + [Charge](api-endpoint:Transactions-Charge) + + endpoint with a `delay_capture` value of `true`. + + + + See [Delayed capture + transactions](https://developer.squareup.com/docs/payments/transactions/overview#delayed-capture) + + for more information. + source: + openapi: ../default/openapi/openapi.json + display-name: VoidTransaction + request: + name: VoidTransactionsRequest + path-parameters: + location_id: + type: string + docs: '' + transaction_id: + type: string + docs: '' + response: + docs: Success + type: root.VoidTransactionResponse + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + transaction_id: transaction_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/loyalty.yml b/.mock/definition/loyalty.yml new file mode 100644 index 00000000..5a9e2484 --- /dev/null +++ b/.mock/definition/loyalty.yml @@ -0,0 +1,139 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + searchEvents: + path: /v2/loyalty/events/search + method: POST + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Searches for loyalty events. + + + A Square loyalty program maintains a ledger of events that occur during + the lifetime of a + + buyer's loyalty account. Each change in the point balance + + (for example, points earned, points redeemed, and points expired) is + + recorded in the ledger. Using this endpoint, you can search the ledger + for events. + + + Search results are sorted by `created_at` in descending order. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchLoyaltyEvents + request: + name: SearchLoyaltyEventsRequest + body: + properties: + query: + type: optional + docs: >- + A set of one or more predefined query filters to apply when + + searching for loyalty events. The endpoint performs a logical + AND to + + evaluate multiple filters and performs a logical OR on arrays + + that specifies multiple field values. + limit: + type: optional + docs: |- + The maximum number of results to include in the response. + The last page might contain fewer events. + The default is 30 events. + validation: + min: 1 + max: 30 + cursor: + type: optional + docs: >- + A pagination cursor returned by a previous call to this + endpoint. + + Provide this to retrieve the next set of results for your + original query. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + content-type: application/json + response: + docs: Success + type: root.SearchLoyaltyEventsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + order_filter: + order_id: PyATxhYLfsMqpVkcKJITPydgEYfZY + limit: 30 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + events: + - id: c27c8465-806e-36f2-b4b3-71f5887b5ba8 + type: ACCUMULATE_POINTS + created_at: '2020-05-08T22:01:30Z' + accumulate_points: + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + points: 5 + order_id: PyATxhYLfsMqpVkcKJITPydgEYfZY + adjust_points: + points: 1 + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + location_id: P034NEENMD09F + source: LOYALTY_API + expire_points: + points: 1 + other_event: + points: 1 + - id: e4a5cbc3-a4d0-3779-98e9-e578885d9430 + type: REDEEM_REWARD + created_at: '2020-05-08T22:01:15Z' + redeem_reward: + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + reward_id: d03f79f4-815f-3500-b851-cc1e68a457f9 + order_id: PyATxhYLfsMqpVkcKJITPydgEYfZY + adjust_points: + points: 1 + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + location_id: P034NEENMD09F + source: LOYALTY_API + expire_points: + points: 1 + other_event: + points: 1 + - id: 5e127479-0b03-3671-ab1e-15faea8b7188 + type: CREATE_REWARD + created_at: '2020-05-08T22:00:44Z' + create_reward: + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + reward_id: d03f79f4-815f-3500-b851-cc1e68a457f9 + points: -10 + adjust_points: + points: 1 + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + location_id: location_id + source: LOYALTY_API + expire_points: + points: 1 + other_event: + points: 1 + cursor: cursor + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/loyalty/accounts.yml b/.mock/definition/loyalty/accounts.yml new file mode 100644 index 00000000..a5103eda --- /dev/null +++ b/.mock/definition/loyalty/accounts.yml @@ -0,0 +1,482 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/loyalty/accounts + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Creates a loyalty account. To create a loyalty account, you must provide + the `program_id` and a `mapping` with the `phone_number` of the buyer. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateLoyaltyAccount + request: + name: CreateLoyaltyAccountRequest + body: + properties: + loyalty_account: + type: root.LoyaltyAccount + docs: The loyalty account to create. + idempotency_key: + type: string + docs: >- + A unique string that identifies this `CreateLoyaltyAccount` + request. + + Keys can be any valid string, but must be unique for every + request. + validation: + minLength: 1 + maxLength: 128 + content-type: application/json + response: + docs: Success + type: root.CreateLoyaltyAccountResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + loyalty_account: + program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + mapping: + phone_number: '+14155551234' + idempotency_key: ec78c477-b1c3-4899-a209-a4e71337c996 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_account: + id: 79b807d2-d786-46a9-933b-918028d7a8c5 + program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + balance: 0 + lifetime_points: 0 + customer_id: QPTXM8PQNX3Q726ZYHPMNP46XC + enrolled_at: enrolled_at + created_at: '2020-05-08T21:44:32Z' + updated_at: '2020-05-08T21:44:32Z' + mapping: + id: 66aaab3f-da99-49ed-8b19-b87f851c844f + created_at: '2020-05-08T21:44:32Z' + phone_number: '+14155551234' + expiring_point_deadlines: + - points: 1 + expires_at: expires_at + search: + path: /v2/loyalty/accounts/search + method: POST + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Searches for loyalty accounts in a loyalty program. + + + You can search for a loyalty account using the phone number or customer + ID associated with the account. To return all loyalty accounts, specify + an empty `query` object or omit it entirely. + + + Search results are sorted by `created_at` in ascending order. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchLoyaltyAccounts + request: + name: SearchLoyaltyAccountsRequest + body: + properties: + query: + type: optional + docs: The search criteria for the request. + limit: + type: optional + docs: >- + The maximum number of results to include in the response. The + default value is 30. + validation: + min: 1 + max: 200 + cursor: + type: optional + docs: >- + A pagination cursor returned by a previous call to + + this endpoint. Provide this to retrieve the next set of + + results for the original query. + + + For more information, + + see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + content-type: application/json + response: + docs: Success + type: root.SearchLoyaltyAccountsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + mappings: + - phone_number: '+14155551234' + limit: 10 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_accounts: + - id: 79b807d2-d786-46a9-933b-918028d7a8c5 + program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + balance: 10 + lifetime_points: 20 + customer_id: Q8002FAM9V1EZ0ADB2T5609X6NET1H0 + enrolled_at: enrolled_at + created_at: '2020-05-08T21:44:32Z' + updated_at: '2020-05-08T21:44:32Z' + mapping: + id: 66aaab3f-da99-49ed-8b19-b87f851c844f + created_at: '2020-05-08T21:44:32Z' + phone_number: '+14155551234' + expiring_point_deadlines: + - points: 1 + expires_at: expires_at + cursor: cursor + get: + path: /v2/loyalty/accounts/{account_id} + method: GET + auth: + - oauth2: + - LOYALTY_READ + docs: Retrieves a loyalty account. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLoyaltyAccount + request: + name: GetAccountsRequest + path-parameters: + account_id: + type: string + docs: >- + The ID of the [loyalty account](entity:LoyaltyAccount) to + retrieve. + response: + docs: Success + type: root.GetLoyaltyAccountResponse + status-code: 200 + examples: + - path-parameters: + account_id: account_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_account: + id: 79b807d2-d786-46a9-933b-918028d7a8c5 + program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + balance: 10 + lifetime_points: 20 + customer_id: Q8002FAM9V1EZ0ADB2T5609X6NET1H0 + enrolled_at: enrolled_at + created_at: '2020-05-08T21:44:32Z' + updated_at: '2020-05-08T21:44:32Z' + mapping: + id: 66aaab3f-da99-49ed-8b19-b87f851c844f + created_at: '2020-05-08T21:44:32Z' + phone_number: '+14155551234' + expiring_point_deadlines: + - points: 1 + expires_at: expires_at + accumulatePoints: + path: /v2/loyalty/accounts/{account_id}/accumulate + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Adds points earned from a purchase to a [loyalty + account](entity:LoyaltyAccount). + + + - If you are using the Orders API to manage orders, provide the + `order_id`. Square reads the order + + to compute the points earned from both the base loyalty program and an + associated + + [loyalty promotion](entity:LoyaltyPromotion). For purchases that qualify + for multiple accrual + + rules, Square computes points based on the accrual rule that grants the + most points. + + For purchases that qualify for multiple promotions, Square computes + points based on the most + + recently created promotion. A purchase must first qualify for program + points to be eligible for promotion points. + + + - If you are not using the Orders API to manage orders, provide `points` + with the number of points to add. + + You must first perform a client-side computation of the points earned + from the loyalty program and + + loyalty promotion. For spend-based and visit-based programs, you can + call + [CalculateLoyaltyPoints](api-endpoint:Loyalty-CalculateLoyaltyPoints) + + to compute the points earned from the base loyalty program. For + information about computing points earned from a loyalty promotion, see + + [Calculating promotion + points](https://developer.squareup.com/docs/loyalty-api/loyalty-promotions#calculate-promotion-points). + source: + openapi: ../default/openapi/openapi.json + display-name: AccumulateLoyaltyPoints + request: + name: AccumulateLoyaltyPointsRequest + path-parameters: + account_id: + type: string + docs: The ID of the target [loyalty account](entity:LoyaltyAccount). + body: + properties: + accumulate_points: + type: root.LoyaltyEventAccumulatePoints + docs: >- + 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. + idempotency_key: + type: string + docs: >- + A unique string that identifies the `AccumulateLoyaltyPoints` + request. + + Keys can be any valid string but must be unique for every + request. + validation: + minLength: 1 + maxLength: 128 + location_id: + type: string + docs: The [location](entity:Location) where the purchase was made. + content-type: application/json + response: + docs: Success + type: root.AccumulateLoyaltyPointsResponse + status-code: 200 + examples: + - path-parameters: + account_id: account_id + headers: + Square-Version: '2025-10-16' + request: + accumulate_points: + order_id: RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY + idempotency_key: 58b90739-c3e8-4b11-85f7-e636d48d72cb + location_id: P034NEENMD09F + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + event: + id: id + type: ACCUMULATE_POINTS + created_at: created_at + accumulate_points: + loyalty_program_id: loyalty_program_id + points: 1 + order_id: order_id + create_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + points: 1 + redeem_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + order_id: order_id + delete_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + points: 1 + adjust_points: + loyalty_program_id: loyalty_program_id + points: 1 + reason: reason + loyalty_account_id: loyalty_account_id + location_id: location_id + source: SQUARE + expire_points: + loyalty_program_id: loyalty_program_id + points: 1 + other_event: + loyalty_program_id: loyalty_program_id + points: 1 + accumulate_promotion_points: + loyalty_program_id: loyalty_program_id + loyalty_promotion_id: loyalty_promotion_id + points: 1 + order_id: order_id + events: + - id: ee46aafd-1af6-3695-a385-276e2ef0be26 + type: ACCUMULATE_POINTS + created_at: '2020-05-08T21:41:12Z' + accumulate_points: + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + points: 6 + order_id: RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY + adjust_points: + points: 1 + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + location_id: P034NEENMD09F + source: LOYALTY_API + expire_points: + points: 1 + other_event: + points: 1 + adjust: + path: /v2/loyalty/accounts/{account_id}/adjust + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Adds points to or subtracts points from a buyer's account. + + + Use this endpoint only when you need to manually adjust points. + Otherwise, in your application flow, you call + + [AccumulateLoyaltyPoints](api-endpoint:Loyalty-AccumulateLoyaltyPoints) + + to add points when a buyer pays for the purchase. + source: + openapi: ../default/openapi/openapi.json + display-name: AdjustLoyaltyPoints + request: + name: AdjustLoyaltyPointsRequest + path-parameters: + account_id: + type: string + docs: The ID of the target [loyalty account](entity:LoyaltyAccount). + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this `AdjustLoyaltyPoints` + request. + + Keys can be any valid string, but must be unique for every + request. + validation: + minLength: 1 + maxLength: 128 + adjust_points: + type: root.LoyaltyEventAdjustPoints + docs: >- + 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. + allow_negative_balance: + type: optional> + docs: >- + 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`. + content-type: application/json + response: + docs: Success + type: root.AdjustLoyaltyPointsResponse + status-code: 200 + examples: + - path-parameters: + account_id: account_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: bc29a517-3dc9-450e-aa76-fae39ee849d1 + adjust_points: + points: 10 + reason: Complimentary points + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + event: + id: 613a6fca-8d67-39d0-bad2-3b4bc45c8637 + type: ADJUST_POINTS + created_at: '2020-05-08T21:42:32Z' + accumulate_points: + loyalty_program_id: loyalty_program_id + points: 1 + order_id: order_id + create_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + points: 1 + redeem_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + order_id: order_id + delete_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + points: 1 + adjust_points: + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + points: 10 + reason: Complimentary points + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + location_id: location_id + source: LOYALTY_API + expire_points: + loyalty_program_id: loyalty_program_id + points: 1 + other_event: + loyalty_program_id: loyalty_program_id + points: 1 + accumulate_promotion_points: + loyalty_program_id: loyalty_program_id + loyalty_promotion_id: loyalty_promotion_id + points: 1 + order_id: order_id + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/loyalty/programs.yml b/.mock/definition/loyalty/programs.yml new file mode 100644 index 00000000..ff17dbb9 --- /dev/null +++ b/.mock/definition/loyalty/programs.yml @@ -0,0 +1,280 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/loyalty/programs + method: GET + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Returns a list of loyalty programs in the seller's account. + + Loyalty programs define how buyers can earn points and redeem points for + rewards. Square sellers can have only one loyalty program, which is + created and managed from the Seller Dashboard. For more information, see + [Loyalty Program + Overview](https://developer.squareup.com/docs/loyalty/overview). + + + + Replaced with + [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) + when used with the keyword `main`. + source: + openapi: ../default/openapi/openapi.json + display-name: ListLoyaltyPrograms + response: + docs: Success + type: root.ListLoyaltyProgramsResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + programs: + - id: d619f755-2d17-41f3-990d-c04ecedd64dd + status: ACTIVE + reward_tiers: + - id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + name: 10% off entire sale + created_at: '2020-04-20T16:55:11Z' + pricing_rule_reference: + object_id: 74C4JSHESNLTB2A7ITO5HO6F + catalog_version: 1000000 + expiration_policy: + expiration_duration: expiration_duration + terminology: + one: Point + other: Points + location_ids: + - P034NEENMD09F + created_at: '2020-04-20T16:55:11Z' + updated_at: '2020-05-01T02:00:02Z' + accrual_rules: + - accrual_type: SPEND + points: 1 + spend_data: + amount_money: + amount: 100 + currency: USD + excluded_category_ids: + - 7ZERJKO5PVYXCVUHV2JCZ2UG + - FQKAOJE5C4FIMF5A2URMLW6V + excluded_item_variation_ids: + - CBZXBUVVTYUBZGQO44RHMR6B + - EDILT24Z2NISEXDKGY6HP7XV + tax_mode: BEFORE_TAX + get: + path: /v2/loyalty/programs/{program_id} + method: GET + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Retrieves the loyalty program in a seller's account, specified by the + program ID or the keyword `main`. + + + Loyalty programs define how buyers can earn points and redeem points for + rewards. Square sellers can have only one loyalty program, which is + created and managed from the Seller Dashboard. For more information, see + [Loyalty Program + Overview](https://developer.squareup.com/docs/loyalty/overview). + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLoyaltyProgram + request: + name: GetProgramsRequest + path-parameters: + program_id: + type: string + docs: >- + The ID of the loyalty program or the keyword `main`. Either value + can be used to retrieve the single loyalty program that belongs to + the seller. + response: + docs: Success + type: root.GetLoyaltyProgramResponse + status-code: 200 + examples: + - path-parameters: + program_id: program_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + program: + id: d619f755-2d17-41f3-990d-c04ecedd64dd + status: ACTIVE + reward_tiers: + - id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + name: 10% off entire sale + created_at: '2020-04-20T16:55:11Z' + pricing_rule_reference: + object_id: 74C4JSHESNLTB2A7ITO5HO6F + catalog_version: 1000000 + expiration_policy: + expiration_duration: expiration_duration + terminology: + one: Point + other: Points + location_ids: + - P034NEENMD09F + created_at: '2020-04-20T16:55:11Z' + updated_at: '2020-05-01T02:00:02Z' + accrual_rules: + - accrual_type: SPEND + points: 1 + spend_data: + amount_money: + amount: 100 + currency: USD + excluded_category_ids: + - 7ZERJKO5PVYXCVUHV2JCZ2UG + - FQKAOJE5C4FIMF5A2URMLW6V + excluded_item_variation_ids: + - CBZXBUVVTYUBZGQO44RHMR6B + - EDILT24Z2NISEXDKGY6HP7XV + tax_mode: BEFORE_TAX + calculate: + path: /v2/loyalty/programs/{program_id}/calculate + method: POST + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Calculates the number of points a buyer can earn from a purchase. + Applications might call this endpoint + + to display the points to the buyer. + + + - If you are using the Orders API to manage orders, provide the + `order_id` and (optional) `loyalty_account_id`. + + Square reads the order to compute the points earned from the base + loyalty program and an associated + + [loyalty promotion](entity:LoyaltyPromotion). + + + - If you are not using the Orders API to manage orders, provide + `transaction_amount_money` with the + + purchase amount. Square uses this amount to calculate the points earned + from the base loyalty program, + + but not points earned from a loyalty promotion. For spend-based and + visit-based programs, the `tax_mode` + + setting of the accrual rule indicates how taxes should be treated for + loyalty points accrual. + + If the purchase qualifies for program points, call + + [ListLoyaltyPromotions](api-endpoint:Loyalty-ListLoyaltyPromotions) and + perform a client-side computation + + to calculate whether the purchase also qualifies for promotion points. + For more information, see + + [Calculating promotion + points](https://developer.squareup.com/docs/loyalty-api/loyalty-promotions#calculate-promotion-points). + source: + openapi: ../default/openapi/openapi.json + display-name: CalculateLoyaltyPoints + request: + name: CalculateLoyaltyPointsRequest + path-parameters: + program_id: + type: string + docs: >- + The ID of the [loyalty program](entity:LoyaltyProgram), which + defines the rules for accruing points. + body: + properties: + order_id: + type: optional> + docs: >- + The [order](entity:Order) ID for which to calculate the points. + + Specify this field if your application uses the Orders API to + process orders. + + Otherwise, specify the `transaction_amount_money`. + transaction_amount_money: + type: optional + docs: >- + 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`. + loyalty_account_id: + type: optional> + docs: >- + The ID of the target [loyalty account](entity:LoyaltyAccount). + Optionally specify this field + + if your application uses the Orders API to process orders. + + + If specified, the `promotion_points` field in the response shows + the number of points the buyer would + + earn from the purchase. In this case, Square uses the account ID + to determine whether the promotion's + + `trigger_limit` (the maximum number of times that a buyer can + trigger the promotion) has been reached. + + If not specified, the `promotion_points` field shows the number + of points the purchase qualifies + + for regardless of the trigger limit. + validation: + minLength: 1 + maxLength: 36 + content-type: application/json + response: + docs: Success + type: root.CalculateLoyaltyPointsResponse + status-code: 200 + examples: + - path-parameters: + program_id: program_id + headers: + Square-Version: '2025-10-16' + request: + order_id: RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY + loyalty_account_id: 79b807d2-d786-46a9-933b-918028d7a8c5 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + points: 6 + promotion_points: 12 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/loyalty/programs/promotions.yml b/.mock/definition/loyalty/programs/promotions.yml new file mode 100644 index 00000000..086deb5e --- /dev/null +++ b/.mock/definition/loyalty/programs/promotions.yml @@ -0,0 +1,476 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/loyalty/programs/{program_id}/promotions + method: GET + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Lists the loyalty promotions associated with a [loyalty + program](entity:LoyaltyProgram). + + Results are sorted by the `created_at` date in descending order (newest + to oldest). + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.loyalty_promotions + source: + openapi: ../default/openapi/openapi.json + display-name: ListLoyaltyPromotions + request: + name: ListPromotionsRequest + path-parameters: + program_id: + type: string + docs: >- + The ID of the base [loyalty program](entity:LoyaltyProgram). To + get the program ID, + + call + [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) + using the `main` keyword. + query-parameters: + status: + type: optional> + docs: >- + 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. + cursor: + type: optional> + docs: >- + 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). + limit: + type: optional> + docs: >- + The maximum number of results to return in a single paged + response. + + The minimum value is 1 and the maximum value is 30. The default + value is 30. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + response: + docs: Success + type: root.ListLoyaltyPromotionsResponse + status-code: 200 + examples: + - path-parameters: + program_id: program_id + query-parameters: + status: ACTIVE + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_promotions: + - id: loypromo_f0f9b849-725e-378d-b810-511237e07b67 + name: Tuesday Happy Hour Promo + incentive: + type: POINTS_MULTIPLIER + points_multiplier_data: + points_multiplier: 3 + multiplier: '3.000' + available_time: + start_date: '2022-08-16' + time_periods: + - |- + BEGIN:VEVENT + DTSTART:20220816T160000 + DURATION:PT2H + RRULE:FREQ=WEEKLY;BYDAY=TU + END:VEVENT + trigger_limit: + times: 1 + interval: DAY + status: ACTIVE + created_at: '2022-08-16T08:38:54Z' + canceled_at: canceled_at + updated_at: '2022-08-16T08:38:54Z' + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + qualifying_item_variation_ids: + - CJ3RYL56ITAKMD4VRCM7XERS + - AT3RYLR3TUA9C34VRCB7X5RR + qualifying_category_ids: + - qualifying_category_ids + - id: loypromo_e696f057-2286-35ff-8108-132241328106 + name: July Special + incentive: + type: POINTS_MULTIPLIER + points_multiplier_data: + points_multiplier: 2 + multiplier: '2.000' + available_time: + start_date: '2022-07-01' + end_date: '2022-08-01' + time_periods: + - |- + BEGIN:VEVENT + DTSTART:20220704T090000 + DURATION:PT8H + RRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=MO + END:VEVENT + - |- + BEGIN:VEVENT + DTSTART:20220705T090000 + DURATION:PT8H + RRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=TU + END:VEVENT + - |- + BEGIN:VEVENT + DTSTART:20220706T090000 + DURATION:PT8H + RRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=WE + END:VEVENT + - |- + BEGIN:VEVENT + DTSTART:20220707T090000 + DURATION:PT8H + RRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=TH + END:VEVENT + - |- + BEGIN:VEVENT + DTSTART:20220701T090000 + DURATION:PT8H + RRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=FR + END:VEVENT + trigger_limit: + times: 5 + interval: ALL_TIME + status: ENDED + created_at: '2022-06-27T15:37:38Z' + canceled_at: canceled_at + updated_at: '2022-06-27T15:37:38Z' + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + minimum_spend_amount_money: + amount: 2000 + currency: USD + qualifying_item_variation_ids: + - qualifying_item_variation_ids + qualifying_category_ids: + - XTQPYLR3IIU9C44VRCB3XD12 + cursor: cursor + create: + path: /v2/loyalty/programs/{program_id}/promotions + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Creates a loyalty promotion for a [loyalty + program](entity:LoyaltyProgram). A loyalty promotion + + enables buyers to earn points in addition to those earned from the base + loyalty program. + + + This endpoint sets the loyalty promotion to the `ACTIVE` or `SCHEDULED` + status, depending on the + + `available_time` setting. A loyalty program can have a maximum of 10 + loyalty promotions with an + + `ACTIVE` or `SCHEDULED` status. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateLoyaltyPromotion + request: + name: CreateLoyaltyPromotionRequest + path-parameters: + program_id: + type: string + docs: >- + The ID of the [loyalty program](entity:LoyaltyProgram) to + associate with the promotion. + + To get the program ID, call + [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) + + using the `main` keyword. + body: + properties: + loyalty_promotion: + type: root.LoyaltyPromotion + docs: The loyalty promotion to create. + idempotency_key: + type: string + docs: >- + 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). + validation: + minLength: 1 + maxLength: 128 + content-type: application/json + response: + docs: Success + type: root.CreateLoyaltyPromotionResponse + status-code: 200 + examples: + - path-parameters: + program_id: program_id + headers: + Square-Version: '2025-10-16' + request: + loyalty_promotion: + name: Tuesday Happy Hour Promo + incentive: + type: POINTS_MULTIPLIER + points_multiplier_data: + multiplier: '3.0' + available_time: + time_periods: + - |- + BEGIN:VEVENT + DTSTART:20220816T160000 + DURATION:PT2H + RRULE:FREQ=WEEKLY;BYDAY=TU + END:VEVENT + trigger_limit: + times: 1 + interval: DAY + minimum_spend_amount_money: + amount: 2000 + currency: USD + qualifying_category_ids: + - XTQPYLR3IIU9C44VRCB3XD12 + idempotency_key: ec78c477-b1c3-4899-a209-a4e71337c996 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_promotion: + id: loypromo_f0f9b849-725e-378d-b810-511237e07b67 + name: Tuesday Happy Hour Promo + incentive: + type: POINTS_MULTIPLIER + points_multiplier_data: + points_multiplier: 3 + multiplier: '3.000' + points_addition_data: + points_addition: 1 + available_time: + start_date: '2022-08-16' + end_date: end_date + time_periods: + - |- + BEGIN:VEVENT + DTSTART:20220816T160000 + DURATION:PT2H + RRULE:FREQ=WEEKLY;BYDAY=TU + END:VEVENT + trigger_limit: + times: 1 + interval: DAY + status: ACTIVE + created_at: '2022-08-16T08:38:54Z' + canceled_at: canceled_at + updated_at: '2022-08-16T08:38:54Z' + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + minimum_spend_amount_money: + amount: 2000 + currency: USD + qualifying_item_variation_ids: + - qualifying_item_variation_ids + qualifying_category_ids: + - XTQPYLR3IIU9C44VRCB3XD12 + get: + path: /v2/loyalty/programs/{program_id}/promotions/{promotion_id} + method: GET + auth: + - oauth2: + - LOYALTY_READ + docs: Retrieves a loyalty promotion. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLoyaltyPromotion + request: + name: GetPromotionsRequest + path-parameters: + program_id: + type: string + docs: >- + The ID of the base [loyalty program](entity:LoyaltyProgram). To + get the program ID, + + call + [RetrieveLoyaltyProgram](api-endpoint:Loyalty-RetrieveLoyaltyProgram) + using the `main` keyword. + promotion_id: + type: string + docs: >- + The ID of the [loyalty promotion](entity:LoyaltyPromotion) to + retrieve. + response: + docs: Success + type: root.GetLoyaltyPromotionResponse + status-code: 200 + examples: + - path-parameters: + program_id: program_id + promotion_id: promotion_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_promotion: + id: loypromo_f0f9b849-725e-378d-b810-511237e07b67 + name: Tuesday Happy Hour Promo + incentive: + type: POINTS_MULTIPLIER + points_multiplier_data: + points_multiplier: 3 + multiplier: '3.000' + points_addition_data: + points_addition: 1 + available_time: + start_date: '2022-08-16' + end_date: end_date + time_periods: + - |- + BEGIN:VEVENT + DTSTART:20220816T160000 + DURATION:PT2H + RRULE:FREQ=WEEKLY;BYDAY=TU + END:VEVENT + trigger_limit: + times: 1 + interval: DAY + status: ACTIVE + created_at: '2022-08-16T08:38:54Z' + canceled_at: canceled_at + updated_at: '2022-08-16T08:38:54Z' + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + minimum_spend_amount_money: + amount: 2000 + currency: USD + qualifying_item_variation_ids: + - CJ3RYL56ITAKMD4VRCM7XERS + - AT3RYLR3TUA9C34VRCB7X5RR + qualifying_category_ids: + - qualifying_category_ids + cancel: + path: /v2/loyalty/programs/{program_id}/promotions/{promotion_id}/cancel + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` + promotion earlier than the + + end date, cancel an `ACTIVE` promotion when an end date is not + specified, or cancel a `SCHEDULED` promotion. + + Because updating a promotion is not supported, you can also use this + endpoint to cancel a promotion before + + you create a new one. + + + This endpoint sets the loyalty promotion to the `CANCELED` state + source: + openapi: ../default/openapi/openapi.json + display-name: CancelLoyaltyPromotion + request: + name: CancelPromotionsRequest + path-parameters: + program_id: + type: string + docs: The ID of the base [loyalty program](entity:LoyaltyProgram). + promotion_id: + type: string + docs: >- + The ID of the [loyalty promotion](entity:LoyaltyPromotion) to + cancel. You can cancel a + + promotion that has an `ACTIVE` or `SCHEDULED` status. + response: + docs: Success + type: root.CancelLoyaltyPromotionResponse + status-code: 200 + examples: + - path-parameters: + program_id: program_id + promotion_id: promotion_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + loyalty_promotion: + id: loypromo_f0f9b849-725e-378d-b810-511237e07b67 + name: Tuesday Happy Hour Promo + incentive: + type: POINTS_MULTIPLIER + points_multiplier_data: + points_multiplier: 3 + multiplier: '3.000' + points_addition_data: + points_addition: 1 + available_time: + start_date: '2022-08-16' + end_date: end_date + time_periods: + - |- + BEGIN:VEVENT + DTSTART:20220816T160000 + DURATION:PT2H + RRULE:FREQ=WEEKLY;BYDAY=TU + END:VEVENT + trigger_limit: + times: 1 + interval: DAY + status: CANCELED + created_at: '2022-08-16T08:38:54Z' + canceled_at: '2022-08-17T12:42:49Z' + updated_at: '2022-08-17T12:42:49Z' + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + minimum_spend_amount_money: + amount: 2000 + currency: USD + qualifying_item_variation_ids: + - qualifying_item_variation_ids + qualifying_category_ids: + - XTQPYLR3IIU9C44VRCB3XD12 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/loyalty/rewards.yml b/.mock/definition/loyalty/rewards.yml new file mode 100644 index 00000000..4e153c2e --- /dev/null +++ b/.mock/definition/loyalty/rewards.yml @@ -0,0 +1,390 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/loyalty/rewards + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Creates a loyalty reward. In the process, the endpoint does following: + + + - Uses the `reward_tier_id` in the request to determine the number of + points + + to lock for this reward. + + - If the request includes `order_id`, it adds the reward and related + discount to the order. + + + After a reward is created, the points are locked and + + not available for the buyer to redeem another reward. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateLoyaltyReward + request: + name: CreateLoyaltyRewardRequest + body: + properties: + reward: + type: root.LoyaltyReward + docs: The reward to create. + idempotency_key: + type: string + docs: >- + A unique string that identifies this `CreateLoyaltyReward` + request. + + Keys can be any valid string, but must be unique for every + request. + validation: + minLength: 1 + maxLength: 128 + content-type: application/json + response: + docs: Success + type: root.CreateLoyaltyRewardResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + reward: + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + order_id: RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY + idempotency_key: 18c2e5ea-a620-4b1f-ad60-7b167285e451 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + reward: + id: a8f43ebe-2ad6-3001-bdd5-7d7c2da08943 + status: ISSUED + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + order_id: RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY + created_at: '2020-05-01T21:49:54Z' + updated_at: '2020-05-01T21:49:54Z' + redeemed_at: redeemed_at + search: + path: /v2/loyalty/rewards/search + method: POST + auth: + - oauth2: + - LOYALTY_READ + docs: >- + Searches for loyalty rewards. This endpoint accepts a request with no + query filters and returns results for all loyalty accounts. + + If you include a `query` object, `loyalty_account_id` is required and + `status` is optional. + + + If you know a reward ID, use the + + [RetrieveLoyaltyReward](api-endpoint:Loyalty-RetrieveLoyaltyReward) + endpoint. + + + Search results are sorted by `updated_at` in descending order. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchLoyaltyRewards + request: + name: SearchLoyaltyRewardsRequest + body: + properties: + query: + type: optional + docs: >- + The search criteria for the request. + + If empty, the endpoint retrieves all loyalty rewards in the + loyalty program. + limit: + type: optional + docs: >- + The maximum number of results to return in the response. The + default value is 30. + validation: + min: 1 + max: 30 + cursor: + type: optional + docs: >- + A pagination cursor returned by a previous call to + + this endpoint. Provide this to retrieve the next set of + + results for the original query. + + For more information, + + see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + content-type: application/json + response: + docs: Success + type: root.SearchLoyaltyRewardsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + limit: 10 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + rewards: + - id: d03f79f4-815f-3500-b851-cc1e68a457f9 + status: REDEEMED + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + order_id: PyATxhYLfsMqpVkcKJITPydgEYfZY + created_at: '2020-05-08T22:00:44Z' + updated_at: '2020-05-08T22:01:17Z' + redeemed_at: '2020-05-08T22:01:17Z' + - id: 9f18ac21-233a-31c3-be77-b45840f5a810 + status: REDEEMED + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + order_id: order_id + created_at: '2020-05-08T21:55:42Z' + updated_at: '2020-05-08T21:56:00Z' + redeemed_at: '2020-05-08T21:56:00Z' + - id: a8f43ebe-2ad6-3001-bdd5-7d7c2da08943 + status: DELETED + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + order_id: 5NB69ZNh3FbsOs1ox43bh1xrli6YY + created_at: '2020-05-01T21:49:54Z' + updated_at: '2020-05-08T21:55:10Z' + redeemed_at: redeemed_at + - id: a051254c-f840-3b45-8cf1-50bcd38ff92a + status: ISSUED + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + order_id: LQQ16znvi2VIUKPVhUfJefzr1eEZY + created_at: '2020-05-01T20:20:37Z' + updated_at: '2020-05-01T20:20:40Z' + redeemed_at: redeemed_at + cursor: cursor + get: + path: /v2/loyalty/rewards/{reward_id} + method: GET + auth: + - oauth2: + - LOYALTY_READ + docs: Retrieves a loyalty reward. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveLoyaltyReward + request: + name: GetRewardsRequest + path-parameters: + reward_id: + type: string + docs: The ID of the [loyalty reward](entity:LoyaltyReward) to retrieve. + response: + docs: Success + type: root.GetLoyaltyRewardResponse + status-code: 200 + examples: + - path-parameters: + reward_id: reward_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + reward: + id: 9f18ac21-233a-31c3-be77-b45840f5a810 + status: REDEEMED + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + reward_tier_id: e1b39225-9da5-43d1-a5db-782cdd8ad94f + points: 10 + order_id: order_id + created_at: '2020-05-08T21:55:42Z' + updated_at: '2020-05-08T21:56:00Z' + redeemed_at: '2020-05-08T21:56:00Z' + delete: + path: /v2/loyalty/rewards/{reward_id} + method: DELETE + auth: + - oauth2: + - LOYALTY_WRITE + docs: >- + Deletes a loyalty reward by doing the following: + + + - Returns the loyalty points back to the loyalty account. + + - If an order ID was specified when the reward was created + + (see [CreateLoyaltyReward](api-endpoint:Loyalty-CreateLoyaltyReward)), + + it updates the order by removing the reward and related + + discounts. + + + You cannot delete a reward that has reached the terminal state + (REDEEMED). + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteLoyaltyReward + request: + name: DeleteRewardsRequest + path-parameters: + reward_id: + type: string + docs: The ID of the [loyalty reward](entity:LoyaltyReward) to delete. + response: + docs: Success + type: root.DeleteLoyaltyRewardResponse + status-code: 200 + examples: + - path-parameters: + reward_id: reward_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + redeem: + path: /v2/loyalty/rewards/{reward_id}/redeem + method: POST + auth: + - oauth2: + - LOYALTY_WRITE + docs: |- + Redeems a loyalty reward. + + The endpoint sets the reward to the `REDEEMED` terminal state. + + If you are using your own order processing system (not using the + Orders API), you call this endpoint after the buyer paid for the + purchase. + + After the reward reaches the terminal state, it cannot be deleted. + In other words, points used for the reward cannot be returned + to the account. + source: + openapi: ../default/openapi/openapi.json + display-name: RedeemLoyaltyReward + request: + name: RedeemLoyaltyRewardRequest + path-parameters: + reward_id: + type: string + docs: The ID of the [loyalty reward](entity:LoyaltyReward) to redeem. + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this `RedeemLoyaltyReward` + request. + + Keys can be any valid string, but must be unique for every + request. + validation: + minLength: 1 + maxLength: 128 + location_id: + type: string + docs: >- + The ID of the [location](entity:Location) where the reward is + redeemed. + validation: + minLength: 1 + content-type: application/json + response: + docs: Success + type: root.RedeemLoyaltyRewardResponse + status-code: 200 + examples: + - path-parameters: + reward_id: reward_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 98adc7f7-6963-473b-b29c-f3c9cdd7d994 + location_id: P034NEENMD09F + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + event: + id: 67377a6e-dbdc-369d-aa16-2e7ed422e71f + type: REDEEM_REWARD + created_at: '2020-05-08T21:56:00Z' + accumulate_points: + loyalty_program_id: loyalty_program_id + points: 1 + order_id: order_id + create_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + points: 1 + redeem_reward: + loyalty_program_id: d619f755-2d17-41f3-990d-c04ecedd64dd + reward_id: 9f18ac21-233a-31c3-be77-b45840f5a810 + order_id: order_id + delete_reward: + loyalty_program_id: loyalty_program_id + reward_id: reward_id + points: 1 + adjust_points: + loyalty_program_id: loyalty_program_id + points: 1 + reason: reason + loyalty_account_id: 5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd + location_id: P034NEENMD09F + source: LOYALTY_API + expire_points: + loyalty_program_id: loyalty_program_id + points: 1 + other_event: + loyalty_program_id: loyalty_program_id + points: 1 + accumulate_promotion_points: + loyalty_program_id: loyalty_program_id + loyalty_promotion_id: loyalty_promotion_id + points: 1 + order_id: order_id + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/merchants.yml b/.mock/definition/merchants.yml new file mode 100644 index 00000000..e8ab22a9 --- /dev/null +++ b/.mock/definition/merchants.yml @@ -0,0 +1,122 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/merchants + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Provides details about the merchant associated with a given access + token. + + + The access token used to connect your application to a Square seller is + associated + + with a single merchant. That means that `ListMerchants` returns a list + + with a single `Merchant` object. You can specify your personal access + token + + to get your own merchant information or specify an OAuth token to get + the + + information for the merchant that granted your application access. + + + If you know the merchant ID, you can also use the + [RetrieveMerchant](api-endpoint:Merchants-RetrieveMerchant) + + endpoint to retrieve the merchant information. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.merchant + source: + openapi: ../default/openapi/openapi.json + display-name: ListMerchants + request: + name: ListMerchantsRequest + query-parameters: + cursor: + type: optional> + docs: The cursor generated by the previous response. + response: + docs: Success + type: root.ListMerchantsResponse + status-code: 200 + examples: + - query-parameters: + cursor: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + merchant: + - id: DM7VKY8Q63GNP + business_name: Apple A Day + country: US + language_code: en-US + currency: USD + status: ACTIVE + main_location_id: 9A65CGC72ZQG1 + created_at: '2021-12-10T19:25:52.484Z' + cursor: 1 + get: + path: /v2/merchants/{merchant_id} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: Retrieves the `Merchant` object for the given `merchant_id`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveMerchant + request: + name: GetMerchantsRequest + path-parameters: + merchant_id: + type: string + docs: >- + The ID of the merchant to retrieve. If the string "me" is supplied + as the ID, + + then retrieve the merchant that is currently accessible to this + call. + response: + docs: Success + type: root.GetMerchantResponse + status-code: 200 + examples: + - path-parameters: + merchant_id: merchant_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + merchant: + id: DM7VKY8Q63GNP + business_name: Apple A Day + country: US + language_code: en-US + currency: USD + status: ACTIVE + main_location_id: 9A65CGC72ZQG1 + created_at: '2021-12-10T19:25:52.484Z' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/merchants/customAttributeDefinitions.yml b/.mock/definition/merchants/customAttributeDefinitions.yml new file mode 100644 index 00000000..cb19194a --- /dev/null +++ b/.mock/definition/merchants/customAttributeDefinitions.yml @@ -0,0 +1,421 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/merchants/custom-attribute-definitions + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + 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`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attribute_definitions + source: + openapi: ../default/openapi/openapi.json + display-name: ListMerchantCustomAttributeDefinitions + request: + name: ListCustomAttributeDefinitionsRequest + query-parameters: + visibility_filter: + type: optional> + docs: >- + Filters the `CustomAttributeDefinition` results by their + `visibility` values. + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + response: + docs: Success + type: root.ListMerchantCustomAttributeDefinitionsResponse + status-code: 200 + examples: + - query-parameters: + visibility_filter: ALL + limit: 1 + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definitions: + - key: has_seen_tutorial + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Boolean + name: NAME + description: >- + Whether the merchant has seen the tutorial screen for using + the app. + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2023-05-05T16:50:21.832Z' + created_at: '2023-05-05T16:50:21.832Z' + - key: alternative_seller_name + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Alternative Merchant Name + description: This is the other name this merchant goes by. + visibility: VISIBILITY_READ_ONLY + version: 4 + updated_at: '2023-05-05T10:17:52.341Z' + created_at: '2023-05-05T19:06:36.559Z' + cursor: >- + ImfNzWVSiAYyiAR4gEcxDJ75KZAOSjX8H2BVHUTR0ofCtp4SdYvrUKbwYY2aCH2WqZ2FsfAuylEVUlTfaINg3ecIlFpP9Y5Ie66w9NSg9nqdI5fCJ6qdH2s0za5m2plFonsjIuFaoN89j78ROUwuSOzD6mFZPcJHhJ0CxEKc0SBH + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/merchants/custom-attribute-definitions + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateMerchantCustomAttributeDefinition + request: + name: CreateMerchantCustomAttributeDefinitionRequest + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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`. + idempotency_key: + type: optional + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CreateMerchantCustomAttributeDefinitionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + key: alternative_seller_name + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Alternative Merchant Name + description: This is the other name this merchant goes by. + visibility: VISIBILITY_READ_ONLY + response: + body: + custom_attribute_definition: + key: alternative_seller_name + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Alternative Merchant Name + description: This is the other name this merchant goes by. + visibility: VISIBILITY_READ_ONLY + version: 1 + updated_at: '2023-05-05T19:06:36.559Z' + created_at: '2023-05-05T19:06:36.559Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/merchants/custom-attribute-definitions/{key} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveMerchantCustomAttributeDefinition + request: + name: GetCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: >- + The key of the custom attribute definition to retrieve. If the + requesting application + + is not the definition owner, you must use the qualified key. + query-parameters: + version: + type: optional> + docs: >- + The current version of the custom attribute definition, which is + used for strongly consistent + + reads to guarantee that you receive the most up-to-date data. When + included in the request, + + Square returns the specified version or a higher version if one + exists. If the specified version + + is higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.RetrieveMerchantCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + query-parameters: + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definition: + key: alternative_seller_name + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Alternative Merchant Name + description: This is the other name this merchant goes by. + visibility: VISIBILITY_READ_ONLY + version: 1 + updated_at: '2023-05-05T19:06:36.559Z' + created_at: '2023-05-05T19:06:36.559Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/merchants/custom-attribute-definitions/{key} + method: PUT + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Updates a merchant-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. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateMerchantCustomAttributeDefinition + request: + name: UpdateMerchantCustomAttributeDefinitionRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to update. + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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 merchant custom attribute + definition](https://developer.squareup.com/docs/merchant-custom-attributes-api/custom-attribute-definitions#update-custom-attribute-definition). + + 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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdateMerchantCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + response: + body: + custom_attribute_definition: + key: alternative_seller_name + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String + name: Alternative Merchant Name + description: Update the description as desired. + visibility: VISIBILITY_READ_ONLY + version: 2 + updated_at: '2023-05-05T19:34:10.181Z' + created_at: '2023-05-05T19:06:36.559Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/merchants/custom-attribute-definitions/{key} + method: DELETE + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Deletes a merchant-related [custom attribute + definition](entity:CustomAttributeDefinition) from a Square seller + account. + + Deleting a custom attribute definition also deletes the corresponding + custom attribute from + + the merchant. + + Only the definition owner can delete a custom attribute definition. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteMerchantCustomAttributeDefinition + request: + name: DeleteCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to delete. + response: + docs: Success + type: root.DeleteMerchantCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/merchants/customAttributes.yml b/.mock/definition/merchants/customAttributes.yml new file mode 100644 index 00000000..f1105769 --- /dev/null +++ b/.mock/definition/merchants/customAttributes.yml @@ -0,0 +1,552 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + batchDelete: + path: /v2/merchants/custom-attributes/bulk-delete + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkDeleteMerchantCustomAttributes + request: + name: BulkDeleteMerchantCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + The data used to update the `CustomAttribute` objects. + + The keys must be unique and are used to map to the corresponding + response. + content-type: application/json + response: + docs: Success + type: root.BulkDeleteMerchantCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + id1: + key: alternative_seller_name + id2: + key: has_seen_tutorial + response: + body: + values: + id1: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchUpsert: + path: /v2/merchants/custom-attributes/bulk-upsert + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpsertMerchantCustomAttributes + request: + name: BulkUpsertMerchantCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + 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. + content-type: application/json + response: + docs: Success + type: root.BulkUpsertMerchantCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + id1: + merchant_id: DM7VKY8Q63GNP + custom_attribute: + key: alternative_seller_name + value: Ultimate Sneaker Store + id2: + merchant_id: DM7VKY8Q63GNP + custom_attribute: + key: has_seen_tutorial + value: true + response: + body: + values: + id1: + merchant_id: DM7VKY8Q63GNP + custom_attribute: + key: alternative_seller_name + value: Ultimate Sneaker Store + version: 2 + visibility: VISIBILITY_READ_ONLY + updated_at: '2023-05-06T19:21:04.551Z' + created_at: '2023-05-06T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id2: + merchant_id: DM7VKY8Q63GNP + custom_attribute: + key: has_seen_tutorial + value: true + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2023-05-06T19:21:04.551Z' + created_at: '2023-05-06T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + list: + path: /v2/merchants/{merchant_id}/custom-attributes + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + 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`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attributes + source: + openapi: ../default/openapi/openapi.json + display-name: ListMerchantCustomAttributes + request: + name: ListCustomAttributesRequest + path-parameters: + merchant_id: + type: string + docs: The ID of the target [merchant](entity:Merchant). + query-parameters: + visibility_filter: + type: optional> + docs: >- + Filters the `CustomAttributeDefinition` results by their + `visibility` values. + limit: + type: optional> + docs: >- + 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). + cursor: + type: optional> + docs: >- + 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). + with_definitions: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of each + + custom attribute. Set this parameter to `true` to get the name and + description of each custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + response: + docs: Success + type: root.ListMerchantCustomAttributesResponse + status-code: 200 + examples: + - path-parameters: + merchant_id: merchant_id + query-parameters: + visibility_filter: ALL + limit: 1 + cursor: cursor + with_definitions: true + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attributes: + - key: has_seen_tutorial + value: true + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2023-05-05T18:13:03.745Z' + created_at: '2023-05-05T18:13:03.745Z' + - key: alternative_seller_name + value: Ultimate Sneaker Store + version: 1 + visibility: VISIBILITY_READ_ONLY + updated_at: '2023-05-05T19:27:57.975Z' + created_at: '2023-05-05T19:27:57.975Z' + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/merchants/{merchant_id}/custom-attributes/{key} + method: GET + auth: + - oauth2: + - MERCHANT_PROFILE_READ + docs: >- + Retrieves a [custom attribute](entity:CustomAttribute) associated with a + merchant. + + You can use the `with_definition` query parameter to also retrieve the + custom attribute definition + + in the same call. + + To retrieve a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveMerchantCustomAttribute + request: + name: GetCustomAttributesRequest + path-parameters: + merchant_id: + type: string + docs: The ID of the target [merchant](entity:Merchant). + key: + type: string + docs: >- + The key of the custom attribute to retrieve. This key must match + the `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + query-parameters: + with_definition: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of + + the custom attribute. Set this parameter to `true` to get the name + and description of the custom + + attribute, information about the data type, or other definition + details. The default value is `false`. + version: + type: optional> + docs: >- + The current version of the custom attribute, which is used for + strongly consistent reads to + + guarantee that you receive the most up-to-date data. When included + in the request, Square + + returns the specified version or a higher version if one exists. + If the specified version is + + higher than the current version, Square returns a `BAD_REQUEST` + error. + response: + docs: Success + type: root.RetrieveMerchantCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + merchant_id: merchant_id + key: key + query-parameters: + with_definition: true + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute: + key: alternative_seller_name + value: Ultimate Sneaker Store + version: 2 + visibility: VISIBILITY_READ_ONLY + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2023-05-06T19:21:04.551Z' + created_at: '2023-05-06T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + upsert: + path: /v2/merchants/{merchant_id}/custom-attributes/{key} + method: POST + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Creates or updates a [custom attribute](entity:CustomAttribute) for a + merchant. + + Use this endpoint to set the value of a custom attribute for a specified + 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. + + To create or update a custom attribute owned by another application, the + `visibility` setting + + must be `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertMerchantCustomAttribute + request: + name: UpsertMerchantCustomAttributeRequest + path-parameters: + merchant_id: + type: string + docs: The ID of the target [merchant](entity:Merchant). + key: + type: string + docs: >- + The key of the custom attribute to create or update. This key must + match the `key` of a + + custom attribute definition in the Square seller account. If the + requesting application is not + + the definition owner, you must use the qualified key. + body: + properties: + custom_attribute: + type: root.CustomAttribute + docs: >- + The custom attribute to create or update, with the following + fields: + + - `value`. This value must conform to the `schema` specified by + the definition. + + For more information, see [Supported data + types](https://developer.squareup.com/docs/devtools/customattributes/overview#supported-data-types). + + - 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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpsertMerchantCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + merchant_id: merchant_id + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute: + value: Ultimate Sneaker Store + response: + body: + custom_attribute: + key: alternative_seller_name + value: Ultimate Sneaker Store + version: 2 + visibility: VISIBILITY_READ_ONLY + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2023-05-06T19:21:04.551Z' + created_at: '2023-05-06T19:02:58.647Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/merchants/{merchant_id}/custom-attributes/{key} + method: DELETE + auth: + - oauth2: + - MERCHANT_PROFILE_WRITE + docs: >- + Deletes a [custom attribute](entity:CustomAttribute) associated with a + merchant. + + To delete a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteMerchantCustomAttribute + request: + name: DeleteCustomAttributesRequest + path-parameters: + merchant_id: + type: string + docs: The ID of the target [merchant](entity:Merchant). + key: + type: string + docs: >- + The key of the custom attribute to delete. This key must match the + `key` of a custom + + attribute definition in the Square seller account. If the + requesting application is not the + + definition owner, you must use the qualified key. + response: + docs: Success + type: root.DeleteMerchantCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + merchant_id: merchant_id + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/mobile.yml b/.mock/definition/mobile.yml new file mode 100644 index 00000000..7dc82048 --- /dev/null +++ b/.mock/definition/mobile.yml @@ -0,0 +1,80 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + authorizationCode: + path: /mobile/authorization-code + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE_IN_PERSON + docs: >- + __Note:__ This endpoint is used by the deprecated Reader SDK. + + Developers should update their integration to use the [Mobile Payments + SDK](https://developer.squareup.com/docs/mobile-payments-sdk), which + includes its own authorization methods. + + + Generates code to authorize a mobile application to connect to a Square + card reader. + + + Authorization codes are one-time-use codes and expire 60 minutes after + being issued. + + + The `Authorization` header you provide to this endpoint must have the + following format: + + + ``` + + Authorization: Bearer ACCESS_TOKEN + + ``` + + + Replace `ACCESS_TOKEN` with a + + [valid production authorization + credential](https://developer.squareup.com/docs/build-basics/access-tokens). + source: + openapi: ../default/openapi/openapi.json + display-name: CreateMobileAuthorizationCode + request: + name: CreateMobileAuthorizationCodeRequest + body: + properties: + location_id: + type: optional + docs: >- + The Square location ID that the authorization code should be + tied to. + validation: + minLength: 1 + maxLength: 191 + content-type: application/json + response: + docs: Success + type: root.CreateMobileAuthorizationCodeResponse + status-code: 200 + availability: deprecated + examples: + - headers: + Square-Version: '2025-10-16' + request: + location_id: YOUR_LOCATION_ID + response: + body: + authorization_code: YOUR_MOBILE_AUTHORIZATION_CODE + expires_at: '2019-01-10T19:42:08Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/oAuth.yml b/.mock/definition/oAuth.yml new file mode 100644 index 00000000..dcd74e96 --- /dev/null +++ b/.mock/definition/oAuth.yml @@ -0,0 +1,376 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + revokeToken: + path: /oauth2/revoke + method: POST + auth: + - {} + docs: >- + Revokes an access token generated with the OAuth flow. + + + If an account has more than one OAuth access token for your application, + this + + endpoint revokes all of them, regardless of which token you specify. + + + __Important:__ The `Authorization` header for this endpoint must have + the + + following format: + + + ``` + + Authorization: Client APPLICATION_SECRET + + ``` + + + Replace `APPLICATION_SECRET` with the application secret on the + **OAuth** + + page for your application in the Developer Dashboard. + source: + openapi: ../default/openapi/openapi.json + display-name: RevokeToken + request: + name: RevokeTokenRequest + body: + properties: + client_id: + type: optional> + docs: >- + The Square-issued ID for your application, which is available on + the **OAuth** page in the + + [Developer Dashboard](https://developer.squareup.com/apps). + validation: + maxLength: 191 + access_token: + type: optional> + docs: >- + The access token of the merchant whose token you want to revoke. + + Do not provide a value for `merchant_id` if you provide this + parameter. + validation: + minLength: 2 + maxLength: 1024 + merchant_id: + type: optional> + docs: >- + The ID of the merchant whose token you want to revoke. + + Do not provide a value for `access_token` if you provide this + parameter. + revoke_only_access_token: + type: optional> + docs: |- + If `true`, terminate the given single access token, but do not + terminate the entire authorization. + Default: `false` + content-type: application/json + response: + docs: Success + type: root.RevokeTokenResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + client_id: CLIENT_ID + access_token: ACCESS_TOKEN + response: + body: + success: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + obtainToken: + path: /oauth2/token + method: POST + docs: >- + Returns an OAuth access token and refresh token using the + `authorization_code` + + or `refresh_token` grant type. + + + When `grant_type` is `authorization_code`: + + - With the [code + flow](https://developer.squareup.com/docs/oauth-api/overview#code-flow), + + provide `code`, `client_id`, and `client_secret`. + + - With the [PKCE + flow](https://developer.squareup.com/docs/oauth-api/overview#pkce-flow), + + provide `code`, `client_id`, and `code_verifier`. + + + When `grant_type` is `refresh_token`: + + - With the code flow, provide `refresh_token`, `client_id`, and + `client_secret`. + + The response returns the same refresh token provided in the request. + + - With the PKCE flow, provide `refresh_token` and `client_id`. The + response returns + + a new refresh token. + + + You can use the `scopes` parameter to limit the set of permissions + authorized by the + + access token. You can use the `short_lived` parameter to create an + access token that + + expires in 24 hours. + + + __Important:__ OAuth tokens should be encrypted and stored on a secure + server. + + Application clients should never interact directly with OAuth tokens. + source: + openapi: ../default/openapi/openapi.json + display-name: ObtainToken + request: + name: ObtainTokenRequest + body: + properties: + client_id: + type: string + docs: >- + The Square-issued ID of your application, which is available as + the **Application ID** + + on the **OAuth** page in the [Developer + Console](https://developer.squareup.com/apps). + + + Required for the code flow and PKCE flow for any grant type. + validation: + maxLength: 191 + client_secret: + type: optional> + docs: >- + The secret key for your application, which is available as the + **Application secret** + + on the **OAuth** page in the [Developer + Console](https://developer.squareup.com/apps). + + + Required for the code flow for any grant type. Don't confuse + your client secret with your + + personal access token. + validation: + minLength: 2 + maxLength: 1024 + code: + type: optional> + docs: >- + The authorization code to exchange for an OAuth access token. + This is the `code` + + value that Square sent to your redirect URL in the authorization + response. + + + Required for the code flow and PKCE flow if `grant_type` is + `authorization_code`. + validation: + maxLength: 191 + redirect_uri: + type: optional> + docs: >- + The redirect URL for your application, which you registered as + the **Redirect URL** + + on the **OAuth** page in the [Developer + Console](https://developer.squareup.com/apps). + + + Required for the code flow and PKCE flow if `grant_type` is + `authorization_code` and + + you provided the `redirect_uri` parameter in your authorization + URL. + validation: + maxLength: 2048 + grant_type: + type: string + docs: >- + The method used to obtain an OAuth access token. The request + must include the + + credential that corresponds to the specified grant type. Valid + values are: + + - `authorization_code` - Requires the `code` field. + + - `refresh_token` - Requires the `refresh_token` field. + + - `migration_token` - LEGACY for access tokens obtained using a + Square API version prior + + to 2019-03-13. Requires the `migration_token` field. + validation: + minLength: 10 + maxLength: 20 + refresh_token: + type: optional> + docs: >- + A valid refresh token used to generate a new OAuth access token. + This is a + + refresh token that was returned in a previous `ObtainToken` + response. + + + Required for the code flow and PKCE flow if `grant_type` is + `refresh_token`. + validation: + minLength: 2 + maxLength: 1024 + migration_token: + type: optional> + docs: >- + __LEGACY__ A valid access token (obtained using a Square API + version prior to 2019-03-13) + + used to generate a new OAuth access token. + + + Required if `grant_type` is `migration_token`. For more + information, see + + [Migrate to Using Refresh + Tokens](https://developer.squareup.com/docs/oauth-api/migrate-to-refresh-tokens). + validation: + minLength: 2 + maxLength: 1024 + scopes: + type: optional>> + docs: >- + The list of permissions that are explicitly requested for the + access token. + + For example, + ["MERCHANT_PROFILE_READ","PAYMENTS_READ","BANK_ACCOUNTS_READ"]. + + + The returned access token is limited to the permissions that are + the intersection + + of these requested permissions and those authorized by the + provided `refresh_token`. + + + Optional for the code flow and PKCE flow if `grant_type` is + `refresh_token`. + short_lived: + type: optional> + docs: >- + Indicates whether the returned access token should expire in 24 + hours. + + + Optional for the code flow and PKCE flow for any grant type. The + default value is `false`. + code_verifier: + type: optional> + docs: >- + The secret your application generated for the authorization + request used to + + obtain the authorization code. This is the source of the + `code_challenge` hash you + + provided in your authorization URL. + + + Required for the PKCE flow if `grant_type` is + `authorization_code`. + content-type: application/json + response: + docs: Success + type: root.ObtainTokenResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + client_id: sq0idp-uaPHILoPzWZk3tlJqlML0g + client_secret: sq0csp-30a-4C_tVOnTh14Piza2BfTPBXyLafLPWSzY1qAjeBfM + code: sq0cgb-l0SBqxs4uwxErTVyYOdemg + grant_type: authorization_code + response: + body: + access_token: EAAl3ikZIe18J-2-cHlV2bL4-EaZHGoJUhtEBT7QA6-7AgwIHw8Xe1IoUvGsNxA + token_type: bearer + expires_at: '2025-04-03T18:31:06Z' + merchant_id: MLQW2MYBY81PZ + subscription_id: subscription_id + plan_id: plan_id + id_token: id_token + refresh_token: EQAAl0OcByu3IYJYScGGg-8E5YNf0r0b6jCTCMy5nOcRZ4ok0wbWAL8vY3tZWNcc + short_lived: false + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refresh_token_expires_at: refresh_token_expires_at + RetrieveTokenStatus: + path: /oauth2/token/status + method: POST + auth: + - oauth2: [] + docs: "Returns information about an [OAuth access token](https://developer.squareup.com/docs/build-basics/access-tokens#get-an-oauth-access-token)\_or an application’s [personal access token](https://developer.squareup.com/docs/build-basics/access-tokens#get-a-personal-access-token).\n\nAdd the access token to the Authorization header of the request.\n\n__Important:__ The `Authorization` header you provide to this endpoint must have the following format:\n\n```\nAuthorization: Bearer ACCESS_TOKEN\n```\n\nwhere `ACCESS_TOKEN` is a\n[valid production authorization credential](https://developer.squareup.com/docs/build-basics/access-tokens).\n\nIf the access token is expired or not a valid access token, the endpoint returns an `UNAUTHORIZED` error." + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveTokenStatus + response: + docs: Success + type: root.RetrieveTokenStatusResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + scopes: + - PAYMENTS_READ + - PAYMENTS_WRITE + expires_at: '2022-10-14T14:44:00Z' + client_id: CLIENT_ID + merchant_id: MERCHANT_ID + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + authorize: + path: /oauth2/authorize + method: GET + source: + openapi: ../default/openapi/openapi.json + examples: + - headers: + Square-Version: '2025-10-16' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/orders.yml b/.mock/definition/orders.yml new file mode 100644 index 00000000..f5e91a55 --- /dev/null +++ b/.mock/definition/orders.yml @@ -0,0 +1,1734 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/orders + method: POST + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Creates a new [order](entity:Order) that can include information about + products for + + purchase and settings to apply to the purchase. + + + To pay for a created order, see + + [Pay for + Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders). + + + You can modify open orders using the + [UpdateOrder](api-endpoint:Orders-UpdateOrder) endpoint. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateOrder + request: + body: root.CreateOrderRequest + content-type: application/json + response: + docs: Success + type: root.CreateOrderResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + order: + location_id: 057P5VYJ4A5X1 + reference_id: my-order-001 + line_items: + - name: New York Strip Steak + quantity: '1' + base_price_money: + amount: 1599 + currency: USD + - quantity: '2' + catalog_object_id: BEMYCSMIJL46OCDV4KYIKXIB + modifiers: + - catalog_object_id: CHQX7Y4KY6N5KINJKZCFURPZ + applied_discounts: + - discount_uid: one-dollar-off + taxes: + - uid: state-sales-tax + name: State Sales Tax + percentage: '9' + scope: ORDER + discounts: + - uid: labor-day-sale + name: Labor Day Sale + percentage: '5' + scope: ORDER + - uid: membership-discount + catalog_object_id: DB7L55ZH2BGWI4H23ULIWOQ7 + scope: ORDER + - uid: one-dollar-off + name: Sale - $1.00 off + amount_money: + amount: 100 + currency: USD + scope: LINE_ITEM + idempotency_key: 8193148c-9586-11e6-99f9-28cfe92138cf + response: + body: + order: + id: CAISENgvlJ6jLWAzERDzjyHVybY + location_id: 057P5VYJ4A5X1 + reference_id: my-order-001 + source: + name: My App + customer_id: customer_id + line_items: + - uid: 8uSwfzvUImn3IRrvciqlXC + name: New York Strip Steak + quantity: '1' + applied_taxes: + - uid: aKG87ArnDpvMLSZJHxWUl + tax_uid: state-sales-tax + applied_money: + amount: 136 + currency: USD + applied_discounts: + - uid: jWdgP1TpHPFBuVrz81mXVC + discount_uid: membership-discount + applied_money: + amount: 8 + currency: USD + - uid: jnZOjjVY57eRcQAVgEwFuC + discount_uid: labor-day-sale + applied_money: + amount: 79 + currency: USD + base_price_money: + amount: 1599 + currency: USD + variation_total_price_money: + amount: 1599 + currency: USD + gross_sales_money: + amount: 1599 + currency: USD + total_tax_money: + amount: 136 + currency: USD + total_discount_money: + amount: 87 + currency: USD + total_money: + amount: 1648 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + - uid: v8ZuEXpOJpb0bazLuvrLDB + name: New York Steak + quantity: '2' + catalog_object_id: BEMYCSMIJL46OCDV4KYIKXIB + variation_name: Larger + modifiers: + - uid: Lo3qMMckDluu9Qsb58d4CC + catalog_object_id: CHQX7Y4KY6N5KINJKZCFURPZ + name: Well + base_price_money: + amount: 50 + currency: USD + total_price_money: + amount: 100 + currency: USD + applied_taxes: + - uid: v1dAgrfUVUPTnVTf9sRPz + tax_uid: state-sales-tax + applied_money: + amount: 374 + currency: USD + applied_discounts: + - uid: nUXvdsIItfKko0dbYtY58C + discount_uid: membership-discount + applied_money: + amount: 22 + currency: USD + - uid: qSdkOOOernlVQqsJ94SPjB + discount_uid: labor-day-sale + applied_money: + amount: 224 + currency: USD + - uid: y7bVl4njrWAnfDwmz19izB + discount_uid: one-dollar-off + applied_money: + amount: 100 + currency: USD + base_price_money: + amount: 2200 + currency: USD + variation_total_price_money: + amount: 4400 + currency: USD + gross_sales_money: + amount: 4500 + currency: USD + total_tax_money: + amount: 374 + currency: USD + total_discount_money: + amount: 346 + currency: USD + total_money: + amount: 4528 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + taxes: + - uid: state-sales-tax + name: State Sales Tax + type: ADDITIVE + percentage: '9' + applied_money: + amount: 510 + currency: USD + scope: ORDER + discounts: + - uid: membership-discount + catalog_object_id: DB7L55ZH2BGWI4H23ULIWOQ7 + name: Membership Discount + type: FIXED_PERCENTAGE + percentage: '0.5' + applied_money: + amount: 30 + currency: USD + scope: ORDER + - uid: labor-day-sale + name: Labor Day Sale + type: FIXED_PERCENTAGE + percentage: '5' + applied_money: + amount: 303 + currency: USD + scope: ORDER + - uid: one-dollar-off + name: Sale - $1.00 off + type: FIXED_AMOUNT + amount_money: + amount: 100 + currency: USD + applied_money: + amount: 100 + currency: USD + scope: LINE_ITEM + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + net_amounts: + total_money: + amount: 6176 + currency: USD + tax_money: + amount: 510 + currency: USD + discount_money: + amount: 433 + currency: USD + tip_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + rounding_adjustment: + uid: uid + name: name + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + metadata: + key: value + created_at: '2020-01-17T20:47:53.293Z' + updated_at: '2020-01-17T20:47:53.293Z' + closed_at: closed_at + state: OPEN + version: 1 + total_money: + amount: 6176 + currency: USD + total_tax_money: + amount: 510 + currency: USD + total_discount_money: + amount: 433 + currency: USD + total_tip_money: + amount: 0 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + ticket_name: ticket_name + pricing_options: + auto_apply_discounts: true + auto_apply_taxes: true + rewards: + - id: id + reward_tier_id: reward_tier_id + net_amount_due_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchGet: + path: /v2/orders/batch-retrieve + method: POST + auth: + - oauth2: + - ORDERS_READ + docs: >- + Retrieves a set of [orders](entity:Order) by their IDs. + + + If a given order ID does not exist, the ID is ignored instead of + generating an error. + source: + openapi: ../default/openapi/openapi.json + display-name: BatchRetrieveOrders + request: + name: BatchGetOrdersRequest + body: + properties: + location_id: + type: optional> + docs: >- + The ID of the location for these orders. This field is optional: + omit it to retrieve + + orders within the scope of the current authorization's merchant + ID. + order_ids: + docs: >- + The IDs of the orders to retrieve. A maximum of 100 orders can + be retrieved per request. + type: list + content-type: application/json + response: + docs: Success + type: root.BatchGetOrdersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + location_id: 057P5VYJ4A5X1 + order_ids: + - CAISEM82RcpmcFBM0TfOyiHV3es + - CAISENgvlJ6jLWAzERDzjyHVybY + response: + body: + orders: + - id: CAISEM82RcpmcFBM0TfOyiHV3es + location_id: 057P5VYJ4A5X1 + reference_id: my-order-001 + customer_id: customer_id + line_items: + - uid: 945986d1-9586-11e6-ad5a-28cfe92138cf + name: Awesome product + quantity: '1' + base_price_money: + amount: 1599 + currency: USD + total_money: + amount: 1599 + currency: USD + - uid: a8f4168c-9586-11e6-bdf0-28cfe92138cf + name: Another awesome product + quantity: '3' + base_price_money: + amount: 2000 + currency: USD + total_money: + amount: 6000 + currency: USD + taxes: + - {} + discounts: + - {} + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + created_at: created_at + updated_at: updated_at + closed_at: closed_at + state: OPEN + version: 1 + total_money: + amount: 7599 + currency: USD + ticket_name: ticket_name + rewards: + - id: id + reward_tier_id: reward_tier_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + calculate: + path: /v2/orders/calculate + method: POST + auth: + - oauth2: [] + docs: Enables applications to preview order pricing without creating an order. + source: + openapi: ../default/openapi/openapi.json + display-name: CalculateOrder + request: + name: CalculateOrderRequest + body: + properties: + order: + type: root.Order + docs: >- + The order to be calculated. Expects the entire order, not a + sparse update. + proposed_rewards: + type: optional>> + docs: >- + Identifies one or more loyalty reward tiers to apply during the + order calculation. + + The discounts defined by the reward tiers are added to the order + only to preview the + + effect of applying the specified rewards. The rewards do not + correspond to actual + + redemptions; that is, no `reward`s are created. Therefore, the + reward `id`s are + + random strings used only to reference the reward tier. + content-type: application/json + response: + docs: Success + type: root.CalculateOrderResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + order: + location_id: D7AVYMEAPJ3A3 + line_items: + - name: Item 1 + quantity: '1' + base_price_money: + amount: 500 + currency: USD + - name: Item 2 + quantity: '2' + base_price_money: + amount: 300 + currency: USD + discounts: + - name: 50% Off + percentage: '50' + scope: ORDER + response: + body: + order: + id: id + location_id: D7AVYMEAPJ3A3 + reference_id: reference_id + source: + name: name + customer_id: customer_id + line_items: + - uid: ULkg0tQTRK2bkU9fNv3IJD + name: Item 1 + quantity: '1' + applied_discounts: + - uid: 9zr9S4dxvPAixvn0lpa1VC + discount_uid: zGsRZP69aqSSR9lq9euSPB + applied_money: + amount: 250 + currency: USD + base_price_money: + amount: 500 + currency: USD + variation_total_price_money: + amount: 500 + currency: USD + gross_sales_money: + amount: 500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 250 + currency: USD + total_money: + amount: 250 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + - uid: mumY8Nun4BC5aKe2yyx5a + name: Item 2 + quantity: '2' + applied_discounts: + - uid: qa8LwwZK82FgSEkQc2HYVC + discount_uid: zGsRZP69aqSSR9lq9euSPB + applied_money: + amount: 300 + currency: USD + base_price_money: + amount: 300 + currency: USD + variation_total_price_money: + amount: 600 + currency: USD + gross_sales_money: + amount: 600 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 300 + currency: USD + total_money: + amount: 300 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + taxes: + - {} + discounts: + - uid: zGsRZP69aqSSR9lq9euSPB + name: 50% Off + type: FIXED_PERCENTAGE + percentage: '50' + applied_money: + amount: 550 + currency: USD + scope: ORDER + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + net_amounts: + total_money: + amount: 550 + currency: USD + tax_money: + amount: 0 + currency: USD + discount_money: + amount: 550 + currency: USD + tip_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + rounding_adjustment: + uid: uid + name: name + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + metadata: + key: value + created_at: '2020-05-18T16:30:49.614Z' + updated_at: '2020-05-18T16:30:49.614Z' + closed_at: closed_at + state: OPEN + version: 1 + total_money: + amount: 550 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 550 + currency: USD + total_tip_money: + amount: 0 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + ticket_name: ticket_name + pricing_options: + auto_apply_discounts: true + auto_apply_taxes: true + rewards: + - id: id + reward_tier_id: reward_tier_id + net_amount_due_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + clone: + path: /v2/orders/clone + method: POST + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Creates a new order, in the `DRAFT` state, by duplicating an existing + order. The newly created order has + + only the core fields (such as line items, taxes, and discounts) copied + from the original order. + source: + openapi: ../default/openapi/openapi.json + display-name: CloneOrder + request: + name: CloneOrderRequest + body: + properties: + order_id: + type: string + docs: The ID of the order to clone. + version: + type: optional + docs: >- + An optional order version for concurrency protection. + + + If a version is provided, it must match the latest stored + version of the order to clone. + + If a version is not provided, the API clones the latest version. + idempotency_key: + type: optional> + docs: >- + A value you specify that uniquely identifies this clone request. + + + If you are unsure whether a particular order was cloned + successfully, + + you can reattempt the call with the same idempotency key without + + worrying about creating duplicate cloned orders. + + The originally cloned order is returned. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + content-type: application/json + response: + docs: Success + type: root.CloneOrderResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + order_id: ZAISEM52YcpmcWAzERDOyiWS123 + version: 3 + idempotency_key: UNIQUE_STRING + response: + body: + order: + id: CAISENgvlJ6jLWAzERDzjyHVybY + location_id: 057P5VYJ4A5X1 + reference_id: my-order-001 + source: + name: My App + customer_id: customer_id + line_items: + - uid: 8uSwfzvUImn3IRrvciqlXC + name: New York Strip Steak + quantity: '1' + applied_taxes: + - uid: aKG87ArnDpvMLSZJHxWUl + tax_uid: state-sales-tax + applied_money: + amount: 136 + currency: USD + applied_discounts: + - uid: jWdgP1TpHPFBuVrz81mXVC + discount_uid: membership-discount + applied_money: + amount: 8 + currency: USD + - uid: jnZOjjVY57eRcQAVgEwFuC + discount_uid: labor-day-sale + applied_money: + amount: 79 + currency: USD + base_price_money: + amount: 1599 + currency: USD + variation_total_price_money: + amount: 1599 + currency: USD + gross_sales_money: + amount: 1599 + currency: USD + total_tax_money: + amount: 136 + currency: USD + total_discount_money: + amount: 87 + currency: USD + total_money: + amount: 1648 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + - uid: v8ZuEXpOJpb0bazLuvrLDB + name: New York Steak + quantity: '2' + catalog_object_id: BEMYCSMIJL46OCDV4KYIKXIB + variation_name: Larger + modifiers: + - uid: Lo3qMMckDluu9Qsb58d4CC + catalog_object_id: CHQX7Y4KY6N5KINJKZCFURPZ + name: Well + base_price_money: + amount: 50 + currency: USD + total_price_money: + amount: 100 + currency: USD + applied_taxes: + - uid: v1dAgrfUVUPTnVTf9sRPz + tax_uid: state-sales-tax + applied_money: + amount: 374 + currency: USD + applied_discounts: + - uid: nUXvdsIItfKko0dbYtY58C + discount_uid: membership-discount + applied_money: + amount: 22 + currency: USD + - uid: qSdkOOOernlVQqsJ94SPjB + discount_uid: labor-day-sale + applied_money: + amount: 224 + currency: USD + - uid: y7bVl4njrWAnfDwmz19izB + discount_uid: one-dollar-off + applied_money: + amount: 100 + currency: USD + base_price_money: + amount: 2200 + currency: USD + variation_total_price_money: + amount: 4400 + currency: USD + gross_sales_money: + amount: 4500 + currency: USD + total_tax_money: + amount: 374 + currency: USD + total_discount_money: + amount: 346 + currency: USD + total_money: + amount: 4528 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + taxes: + - uid: state-sales-tax + name: State Sales Tax + type: ADDITIVE + percentage: '9' + applied_money: + amount: 510 + currency: USD + scope: ORDER + discounts: + - uid: membership-discount + catalog_object_id: DB7L55ZH2BGWI4H23ULIWOQ7 + name: Membership Discount + type: FIXED_PERCENTAGE + percentage: '0.5' + applied_money: + amount: 30 + currency: USD + scope: ORDER + - uid: labor-day-sale + name: Labor Day Sale + type: FIXED_PERCENTAGE + percentage: '5' + applied_money: + amount: 303 + currency: USD + scope: ORDER + - uid: one-dollar-off + name: Sale - $1.00 off + type: FIXED_AMOUNT + amount_money: + amount: 100 + currency: USD + applied_money: + amount: 100 + currency: USD + scope: LINE_ITEM + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + net_amounts: + total_money: + amount: 6176 + currency: USD + tax_money: + amount: 510 + currency: USD + discount_money: + amount: 433 + currency: USD + tip_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + rounding_adjustment: + uid: uid + name: name + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + metadata: + key: value + created_at: '2020-01-17T20:47:53.293Z' + updated_at: '2020-01-17T20:47:53.293Z' + closed_at: closed_at + state: DRAFT + version: 1 + total_money: + amount: 6176 + currency: USD + total_tax_money: + amount: 510 + currency: USD + total_discount_money: + amount: 433 + currency: USD + total_tip_money: + amount: 0 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + ticket_name: ticket_name + pricing_options: + auto_apply_discounts: true + auto_apply_taxes: true + rewards: + - id: id + reward_tier_id: reward_tier_id + net_amount_due_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + search: + path: /v2/orders/search + method: POST + auth: + - oauth2: + - ORDERS_READ + docs: >- + Search all orders for one or more locations. Orders include all sales, + + returns, and exchanges regardless of how or when they entered the Square + + ecosystem (such as Point of Sale, Invoices, and Connect APIs). + + + `SearchOrders` requests need to specify which locations to search and + define a + + [SearchOrdersQuery](entity:SearchOrdersQuery) object that controls + + how to sort or filter the results. Your `SearchOrdersQuery` can: + + Set filter criteria. + Set the sort order. + Determine whether to return results as complete `Order` objects or as + [OrderEntry](entity:OrderEntry) objects. + + + Note that details for orders processed with Square Point of Sale while + in + + offline mode might not be transmitted to Square for up to 72 hours. + Offline + + orders have a `created_at` value that reflects the time the order was + created, + + not the time it was subsequently transmitted to Square. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchOrders + request: + name: SearchOrdersRequest + body: + properties: + location_ids: + type: optional> + docs: >- + The location IDs for the orders to query. All locations must + belong to + + the same merchant. + + + Max: 10 location IDs. + cursor: + type: optional + docs: >- + A pagination cursor returned by a previous call to this + endpoint. + + Provide this cursor to retrieve the next set of results for your + original query. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + query: + type: optional + docs: >- + Query conditions used to filter or sort the results. Note that + when + + retrieving additional pages using a cursor, you must use the + original query. + limit: + type: optional + docs: |- + The maximum number of results to be returned in a single page. + + Default: `500` + Max: `1000` + return_entries: + type: optional + docs: >- + A Boolean that controls the format of the search results. If + `true`, + + `SearchOrders` returns [OrderEntry](entity:OrderEntry) objects. + If `false`, `SearchOrders` + + returns complete order objects. + + + Default: `false`. + content-type: application/json + response: + docs: Success + type: root.SearchOrdersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + location_ids: + - 057P5VYJ4A5X1 + - 18YC4JDH91E1H + query: + filter: + state_filter: + states: + - COMPLETED + date_time_filter: + closed_at: + start_at: '2018-03-03T20:00:00+00:00' + end_at: '2019-03-04T21:54:45+00:00' + sort: + sort_field: CLOSED_AT + sort_order: DESC + limit: 3 + return_entries: true + response: + body: + order_entries: + - order_id: CAISEM82RcpmcFBM0TfOyiHV3es + version: 1 + location_id: 057P5VYJ4A5X1 + - order_id: CAISENgvlJ6jLWAzERDzjyHVybY + version: 1 + location_id: 18YC4JDH91E1H + - order_id: CAISEM52YcpmcWAzERDOyiWS3ty + version: 1 + location_id: 057P5VYJ4A5X1 + orders: + - id: id + location_id: location_id + reference_id: reference_id + customer_id: customer_id + line_items: + - quantity: quantity + taxes: + - {} + discounts: + - {} + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + created_at: created_at + updated_at: updated_at + closed_at: closed_at + state: OPEN + version: 1 + ticket_name: ticket_name + rewards: + - id: id + reward_tier_id: reward_tier_id + cursor: '123' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/orders/{order_id} + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: Retrieves an [Order](entity:Order) by ID. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveOrder + request: + name: GetOrdersRequest + path-parameters: + order_id: + type: string + docs: The ID of the order to retrieve. + response: + docs: Success + type: root.GetOrderResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + headers: + Square-Version: '2025-10-16' + response: + body: + order: + id: CAISENgvlJ6jLWAzERDzjyHVybY + location_id: D7AVYMEAPJ3A3 + reference_id: reference_id + source: + name: name + customer_id: customer_id + line_items: + - uid: ULkg0tQTRK2bkU9fNv3IJD + name: Item 1 + quantity: '1' + applied_discounts: + - uid: 9zr9S4dxvPAixvn0lpa1VC + discount_uid: zGsRZP69aqSSR9lq9euSPB + applied_money: + amount: 250 + currency: USD + base_price_money: + amount: 500 + currency: USD + variation_total_price_money: + amount: 500 + currency: USD + gross_sales_money: + amount: 500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 250 + currency: USD + total_money: + amount: 250 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + - uid: mumY8Nun4BC5aKe2yyx5a + name: Item 2 + quantity: '2' + applied_discounts: + - uid: qa8LwwZK82FgSEkQc2HYVC + discount_uid: zGsRZP69aqSSR9lq9euSPB + applied_money: + amount: 300 + currency: USD + base_price_money: + amount: 300 + currency: USD + variation_total_price_money: + amount: 600 + currency: USD + gross_sales_money: + amount: 600 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 300 + currency: USD + total_money: + amount: 300 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + taxes: + - {} + discounts: + - uid: zGsRZP69aqSSR9lq9euSPB + name: 50% Off + type: FIXED_PERCENTAGE + percentage: '50' + applied_money: + amount: 550 + currency: USD + scope: ORDER + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + net_amounts: + total_money: + amount: 550 + currency: USD + tax_money: + amount: 0 + currency: USD + discount_money: + amount: 550 + currency: USD + tip_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + rounding_adjustment: + uid: uid + name: name + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + metadata: + key: value + created_at: '2020-05-18T16:30:49.614Z' + updated_at: '2020-05-18T16:30:49.614Z' + closed_at: closed_at + state: OPEN + version: 1 + total_money: + amount: 550 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 550 + currency: USD + total_tip_money: + amount: 0 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + ticket_name: ticket_name + pricing_options: + auto_apply_discounts: true + auto_apply_taxes: true + rewards: + - id: id + reward_tier_id: reward_tier_id + net_amount_due_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/orders/{order_id} + method: PUT + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Updates an open [order](entity:Order) by adding, replacing, or deleting + + fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated. + + + An `UpdateOrder` request requires the following: + + + - The `order_id` in the endpoint path, identifying the order to update. + + - The latest `version` of the order to update. + + - The [sparse + order](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#sparse-order-objects) + + containing only the fields to update and the version to which the update + is + + being applied. + + - If deleting fields, the [dot notation + paths](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#identifying-fields-to-delete) + + identifying the fields to clear. + + + To pay for an order, see + + [Pay for + Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders). + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateOrder + request: + name: UpdateOrderRequest + path-parameters: + order_id: + type: string + docs: The ID of the order to update. + body: + properties: + order: + type: optional + docs: >- + The [sparse + order](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#sparse-order-objects) + + containing only the fields to update and the version to which + the update is + + being applied. + fields_to_clear: + type: optional>> + docs: >- + The [dot notation + paths](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#identifying-fields-to-delete) + + fields to clear. For example, `line_items[uid].note`. + + For more information, see [Deleting + fields](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#deleting-fields). + idempotency_key: + type: optional> + docs: >- + A value you specify that uniquely identifies this update + request. + + + If you are unsure whether a particular update was applied to an + order successfully, + + you can reattempt it with the same idempotency key without + + worrying about creating duplicate updates to the order. + + The latest order version is returned. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + maxLength: 192 + content-type: application/json + response: + docs: Success + type: root.UpdateOrderResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + headers: + Square-Version: '2025-10-16' + request: + order: + location_id: location_id + line_items: + - uid: cookie_uid + name: COOKIE + quantity: '2' + base_price_money: + amount: 200 + currency: USD + version: 1 + fields_to_clear: + - discounts + idempotency_key: UNIQUE_STRING + response: + body: + order: + id: DREk7wJcyXNHqULq8JJ2iPAsluJZY + location_id: MXVQSVNDGN3C8 + reference_id: reference_id + source: + name: Cookies + customer_id: customer_id + line_items: + - uid: EuYkakhmu3ksHIds5Hiot + name: Small Coffee + quantity: '1' + base_price_money: + amount: 500 + currency: USD + variation_total_price_money: + amount: 500 + currency: USD + gross_sales_money: + amount: 500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_money: + amount: 500 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + - uid: cookie_uid + name: COOKIE + quantity: '2' + base_price_money: + amount: 200 + currency: USD + variation_total_price_money: + amount: 400 + currency: USD + gross_sales_money: + amount: 400 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_money: + amount: 400 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + taxes: + - {} + discounts: + - {} + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + net_amounts: + total_money: + amount: 900 + currency: USD + tax_money: + amount: 0 + currency: USD + discount_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + rounding_adjustment: + uid: uid + name: name + tenders: + - type: CARD + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + metadata: + key: value + created_at: '2019-08-23T18:26:18.243Z' + updated_at: '2019-08-23T18:33:47.523Z' + closed_at: closed_at + state: OPEN + version: 2 + total_money: + amount: 900 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + total_service_charge_money: + amount: 0 + currency: USD + ticket_name: ticket_name + pricing_options: + auto_apply_discounts: true + auto_apply_taxes: true + rewards: + - id: id + reward_tier_id: reward_tier_id + net_amount_due_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + pay: + path: /v2/orders/{order_id}/pay + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + - ORDERS_WRITE + docs: >- + Pay for an [order](entity:Order) using one or more approved + [payments](entity:Payment) + + or settle an order with a total of `0`. + + + The total of the `payment_ids` listed in the request must be equal to + the order + + total. Orders with a total amount of `0` can be marked as paid by + specifying an empty + + array of `payment_ids` in the request. + + + To be used with `PayOrder`, a payment must: + + + - Reference the order by specifying the `order_id` when [creating the + payment](api-endpoint:Payments-CreatePayment). + + Any approved payments that reference the same `order_id` not specified + in the + + `payment_ids` is canceled. + + - Be approved with [delayed + capture](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture). + + Using a delayed capture payment with `PayOrder` completes the approved + payment. + source: + openapi: ../default/openapi/openapi.json + display-name: PayOrder + request: + name: PayOrderRequest + path-parameters: + order_id: + type: string + docs: The ID of the order being paid. + body: + properties: + idempotency_key: + type: string + docs: >- + A value you specify that uniquely identifies this request among + requests you have sent. If + + you are unsure whether a particular payment request was + completed successfully, you can reattempt + + it with the same idempotency key without worrying about + duplicate payments. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + minLength: 1 + maxLength: 192 + order_version: + type: optional> + docs: >- + The version of the order being paid. If not supplied, the latest + version will be paid. + payment_ids: + type: optional>> + docs: |- + The IDs of the [payments](entity:Payment) to collect. + The payment total must match the order total. + content-type: application/json + response: + docs: Success + type: root.PayOrderResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: c043a359-7ad9-4136-82a9-c3f1d66dcbff + payment_ids: + - EnZdNAlWCmfh6Mt5FMNST1o7taB + - 0LRiVlbXVwe8ozu4KbZxd12mvaB + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + order: + id: lgwOlEityYPJtcuvKTVKT1pA986YY + location_id: P3CCK6HSNDAS7 + reference_id: reference_id + source: + name: Source Name + customer_id: customer_id + line_items: + - uid: QW6kofLHJK7JEKMjlSVP5C + name: Item 1 + quantity: '1' + base_price_money: + amount: 500 + currency: USD + gross_sales_money: + amount: 500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_money: + amount: 500 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + - uid: zhw8MNfRGdFQMI2WE1UBJD + name: Item 2 + quantity: '2' + base_price_money: + amount: 750 + currency: USD + gross_sales_money: + amount: 1500 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_money: + amount: 1500 + currency: USD + total_service_charge_money: + amount: 0 + currency: USD + taxes: + - {} + discounts: + - {} + service_charges: + - {} + fulfillments: + - {} + returns: + - {} + net_amounts: + total_money: + amount: 2000 + currency: USD + tax_money: + amount: 0 + currency: USD + discount_money: + amount: 0 + currency: USD + tip_money: + amount: 0 + currency: USD + service_charge_money: + amount: 0 + currency: USD + rounding_adjustment: + uid: uid + name: name + tenders: + - id: EnZdNAlWCmfh6Mt5FMNST1o7taB + location_id: P3CCK6HSNDAS7 + transaction_id: lgwOlEityYPJtcuvKTVKT1pA986YY + created_at: '2019-08-06T02:47:36.293Z' + amount_money: + amount: 1000 + currency: USD + type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + exp_month: 2 + exp_year: 2022 + fingerprint: >- + sq-1-n_BL15KP87ClDa4-h2nXOI0fp5VnxNH6hfhzqhptTfAgxgLuGFcg6jIPngDz4IkkTQ + entry_method: KEYED + payment_id: EnZdNAlWCmfh6Mt5FMNST1o7taB + - id: 0LRiVlbXVwe8ozu4KbZxd12mvaB + location_id: P3CCK6HSNDAS7 + transaction_id: lgwOlEityYPJtcuvKTVKT1pA986YY + created_at: '2019-08-06T02:47:36.809Z' + amount_money: + amount: 1000 + currency: USD + type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + exp_month: 2 + exp_year: 2022 + fingerprint: >- + sq-1-n_BL15KP87ClDa4-h2nXOI0fp5VnxNH6hfhzqhptTfAgxgLuGFcg6jIPngDz4IkkTQ + entry_method: KEYED + payment_id: 0LRiVlbXVwe8ozu4KbZxd12mvaB + refunds: + - id: id + location_id: location_id + reason: reason + amount_money: {} + status: PENDING + metadata: + key: value + created_at: '2019-08-06T02:47:35.693Z' + updated_at: '2019-08-06T02:47:37.140Z' + closed_at: '2019-08-06T02:47:37.140Z' + state: COMPLETED + version: 4 + total_money: + amount: 2000 + currency: USD + total_tax_money: + amount: 0 + currency: USD + total_discount_money: + amount: 0 + currency: USD + total_tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + total_service_charge_money: + amount: 0 + currency: USD + ticket_name: ticket_name + pricing_options: + auto_apply_discounts: true + auto_apply_taxes: true + rewards: + - id: id + reward_tier_id: reward_tier_id + net_amount_due_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/orders/customAttributeDefinitions.yml b/.mock/definition/orders/customAttributeDefinitions.yml new file mode 100644 index 00000000..19c58414 --- /dev/null +++ b/.mock/definition/orders/customAttributeDefinitions.yml @@ -0,0 +1,404 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/orders/custom-attribute-definitions + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: >- + Lists the order-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`. Note that + + seller-defined custom attributes (also known as custom fields) are + always set to `VISIBILITY_READ_WRITE_VALUES`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attribute_definitions + source: + openapi: ../default/openapi/openapi.json + display-name: ListOrderCustomAttributeDefinitions + request: + name: ListCustomAttributeDefinitionsRequest + query-parameters: + visibility_filter: + type: optional> + docs: >- + Requests that all of the custom attributes be returned, or only + those that are read-only or read-write. + cursor: + type: optional> + docs: >- + 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). + limit: + type: optional> + docs: >- + 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/working-with-apis/pagination). + response: + docs: Success + type: root.ListOrderCustomAttributeDefinitionsResponse + status-code: 200 + examples: + - query-parameters: + visibility_filter: ALL + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definitions: + - key: cover-count + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Cover count + description: The number of people seated at a table + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-11-16T18:03:44.051Z' + created_at: '2022-11-16T18:03:44.051Z' + - key: seat-number + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Seat number + description: The identifier for a particular seat + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-11-16T18:04:32.059Z' + created_at: '2022-11-16T18:04:32.059Z' + - key: table-number + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Table number + description: The identifier for a particular table + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-11-16T18:04:21.912Z' + created_at: '2022-11-16T18:04:21.912Z' + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + create: + path: /v2/orders/custom-attribute-definitions + method: POST + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Creates an order-related custom attribute definition. Use this endpoint + to + + define a custom attribute that can be associated with orders. + + + After creating a custom attribute definition, you can set the custom + attribute for orders + + in the Square seller account. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateOrderCustomAttributeDefinition + request: + name: CreateOrderCustomAttributeDefinitionRequest + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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 + + [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`. + idempotency_key: + type: optional + docs: >- + 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). + validation: + minLength: 1 + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CreateOrderCustomAttributeDefinitionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + key: cover-count + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Cover count + description: The number of people seated at a table + visibility: VISIBILITY_READ_WRITE_VALUES + idempotency_key: IDEMPOTENCY_KEY + response: + body: + custom_attribute_definition: + key: cover-count + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Cover count + description: The number of people seated at a table + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-10-06T16:53:23.141Z' + created_at: '2022-10-06T16:53:23.141Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/orders/custom-attribute-definitions/{key} + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: >- + Retrieves an order-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`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveOrderCustomAttributeDefinition + request: + name: GetCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to retrieve. + query-parameters: + version: + type: optional> + docs: >- + 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. + response: + docs: Success + type: root.RetrieveOrderCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + query-parameters: + version: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute_definition: + key: cover-count + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Cover count + description: The number of people seated at a table + visibility: VISIBILITY_READ_WRITE_VALUES + version: 1 + updated_at: '2022-10-06T16:53:23.141Z' + created_at: '2022-10-06T16:53:23.141Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/orders/custom-attribute-definitions/{key} + method: PUT + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Updates an order-related custom attribute definition for a Square seller + account. + + + Only the definition owner can update a custom attribute definition. Note + that sellers can view all custom attributes in exported customer data, + including those set to `VISIBILITY_HIDDEN`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateOrderCustomAttributeDefinition + request: + name: UpdateOrderCustomAttributeDefinitionRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to update. + body: + properties: + custom_attribute_definition: + type: root.CustomAttributeDefinition + docs: >- + 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. For more information, see + + [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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + minLength: 1 + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdateOrderCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute_definition: + key: cover-count + visibility: VISIBILITY_READ_ONLY + version: 1 + idempotency_key: IDEMPOTENCY_KEY + response: + body: + custom_attribute_definition: + key: cover-count + schema: + \$ref: >- + https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number + name: Cover count + description: The number of people seated at a table + visibility: VISIBILITY_READ_ONLY + version: 2 + updated_at: '2022-11-16T17:44:11.436Z' + created_at: '2022-11-16T16:53:23.141Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/orders/custom-attribute-definitions/{key} + method: DELETE + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Deletes an order-related [custom attribute + definition](entity:CustomAttributeDefinition) from a Square seller + account. + + + Only the definition owner can delete a custom attribute definition. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteOrderCustomAttributeDefinition + request: + name: DeleteCustomAttributeDefinitionsRequest + path-parameters: + key: + type: string + docs: The key of the custom attribute definition to delete. + response: + docs: Success + type: root.DeleteOrderCustomAttributeDefinitionResponse + status-code: 200 + examples: + - path-parameters: + key: key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/orders/customAttributes.yml b/.mock/definition/orders/customAttributes.yml new file mode 100644 index 00000000..68af7d57 --- /dev/null +++ b/.mock/definition/orders/customAttributes.yml @@ -0,0 +1,581 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + batchDelete: + path: /v2/orders/custom-attributes/bulk-delete + method: POST + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Deletes order [custom attributes](entity:CustomAttribute) as a bulk + operation. + + + Use this endpoint to delete one or more custom attributes from one or + more orders. + + A custom attribute is based on a custom attribute definition in a Square + seller account. (To create a + + custom attribute definition, use the + [CreateOrderCustomAttributeDefinition](api-endpoint:OrderCustomAttributes-CreateOrderCustomAttributeDefinition) + endpoint.) + + + This `BulkDeleteOrderCustomAttributes` endpoint accepts a map of 1 to 25 + individual delete + + requests and returns a map of individual delete responses. Each delete + request has a unique ID + + and provides an order ID and custom attribute. Each delete response is + returned with the ID + + of the corresponding request. + + + To delete a custom attribute owned by another application, the + `visibility` setting + + must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkDeleteOrderCustomAttributes + request: + name: BulkDeleteOrderCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + A map of requests that correspond to individual delete + operations for custom attributes. + content-type: application/json + response: + docs: Success + type: root.BulkDeleteOrderCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + cover-count: + key: cover-count + order_id: 7BbXGEIWNldxAzrtGf9GPVZTwZ4F + table-number: + key: table-number + order_id: 7BbXGEIWNldxAzrtGf9GPVZTwZ4F + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + values: + cover-count: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + table-number: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + batchUpsert: + path: /v2/orders/custom-attributes/bulk-upsert + method: POST + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Creates or updates order [custom attributes](entity:CustomAttribute) as + a bulk operation. + + + Use this endpoint to delete one or more custom attributes from one or + more orders. + + A custom attribute is based on a custom attribute definition in a Square + seller account. (To create a + + custom attribute definition, use the + [CreateOrderCustomAttributeDefinition](api-endpoint:OrderCustomAttributes-CreateOrderCustomAttributeDefinition) + endpoint.) + + + This `BulkUpsertOrderCustomAttributes` 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 an order 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`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpsertOrderCustomAttributes + request: + name: BulkUpsertOrderCustomAttributesRequest + body: + properties: + values: + type: >- + map + docs: >- + A map of requests that correspond to individual upsert + operations for custom attributes. + content-type: application/json + response: + docs: Success + type: root.BulkUpsertOrderCustomAttributesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + values: + cover-count: + custom_attribute: + key: cover-count + value: '6' + version: 2 + order_id: 7BbXGEIWNldxAzrtGf9GPVZTwZ4F + table-number: + custom_attribute: + key: table-number + value: '11' + version: 4 + order_id: 7BbXGEIWNldxAzrtGf9GPVZTwZ4F + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + values: + cover-count: + custom_attribute: + key: cover-count + value: '6' + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-22T21:28:35.721Z' + created_at: '2022-11-22T21:27:33.429Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + table-number: + custom_attribute: + key: table-number + value: '11' + visibility: VISIBILITY_HIDDEN + updated_at: '2022-11-22T21:28:35.726Z' + created_at: '2022-11-22T21:24:57.823Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + list: + path: /v2/orders/{order_id}/custom-attributes + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: >- + Lists the [custom attributes](entity:CustomAttribute) associated with an + order. + + + 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`. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.custom_attributes + source: + openapi: ../default/openapi/openapi.json + display-name: ListOrderCustomAttributes + request: + name: ListCustomAttributesRequest + path-parameters: + order_id: + type: string + docs: The ID of the target [order](entity:Order). + query-parameters: + visibility_filter: + type: optional> + docs: >- + Requests that all of the custom attributes be returned, or only + those that are read-only or read-write. + cursor: + type: optional> + docs: >- + 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). + limit: + type: optional> + docs: >- + 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/working-with-apis/pagination). + with_definitions: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of each + + custom attribute. Set this parameter to `true` to get the name and + description of each custom attribute, + + information about the data type, or other definition details. The + default value is `false`. + response: + docs: Success + type: root.ListOrderCustomAttributesResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + query-parameters: + visibility_filter: ALL + cursor: cursor + limit: 1 + with_definitions: true + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attributes: + - key: wayne-test-15 + value: TEST + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + updated_at: '2022-11-10T17:31:36.111Z' + created_at: '2022-11-10T17:31:36.111Z' + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/orders/{order_id}/custom-attributes/{custom_attribute_key} + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: >- + Retrieves a [custom attribute](entity:CustomAttribute) associated with + an order. + + + You can use the `with_definition` query parameter to also retrieve the + custom attribute definition + + in the same call. + + + To retrieve a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note that + seller-defined custom attributes + + also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveOrderCustomAttribute + request: + name: GetCustomAttributesRequest + path-parameters: + order_id: + type: string + docs: The ID of the target [order](entity:Order). + custom_attribute_key: + type: string + docs: >- + The key of the custom attribute to retrieve. This key must match + the key of an + + existing custom attribute definition. + query-parameters: + version: + type: optional> + docs: >- + 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. + with_definition: + type: optional> + default: false + docs: >- + Indicates whether to return the [custom attribute + definition](entity:CustomAttributeDefinition) in the `definition` + field of each + + custom attribute. Set this parameter to `true` to get the name and + description of each custom attribute, + + information about the data type, or other definition details. The + default value is `false`. + response: + docs: Success + type: root.RetrieveOrderCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + custom_attribute_key: custom_attribute_key + query-parameters: + version: 1 + with_definition: true + headers: + Square-Version: '2025-10-16' + response: + body: + custom_attribute: + key: cover-count + value: '6' + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2022-11-22T21:28:35.721Z' + created_at: '2022-11-22T21:27:33.429Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + upsert: + path: /v2/orders/{order_id}/custom-attributes/{custom_attribute_key} + method: POST + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Creates or updates a [custom attribute](entity:CustomAttribute) for an + order. + + + Use this endpoint to set the value of a custom attribute for a specific + order. + + A custom attribute is based on a custom attribute definition in a Square + seller account. (To create a + + custom attribute definition, use the + [CreateOrderCustomAttributeDefinition](api-endpoint:OrderCustomAttributes-CreateOrderCustomAttributeDefinition) + endpoint.) + + + To create or update a custom attribute owned by another application, the + `visibility` setting + + must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertOrderCustomAttribute + request: + name: UpsertOrderCustomAttributeRequest + path-parameters: + order_id: + type: string + docs: The ID of the target [order](entity:Order). + custom_attribute_key: + type: string + docs: >- + The key of the custom attribute to create or update. This key + must match the key + + of an existing custom attribute definition. + body: + properties: + custom_attribute: + type: root.CustomAttribute + docs: >- + The custom attribute to create or update, with the following + fields: + + + - `value`. This value must conform to the `schema` specified by + the definition. + + For more information, see [Value data + types](https://developer.squareup.com/docs/customer-custom-attributes-api/custom-attributes#value-data-types). + + + - `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. + idempotency_key: + type: optional> + docs: >- + 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). + validation: + minLength: 1 + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpsertOrderCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + custom_attribute_key: custom_attribute_key + headers: + Square-Version: '2025-10-16' + request: + custom_attribute: + key: table-number + value: '42' + version: 1 + response: + body: + custom_attribute: + key: table-number + value: '42' + version: 1 + visibility: VISIBILITY_READ_WRITE_VALUES + definition: + key: key + schema: + key: value + name: name + description: description + visibility: VISIBILITY_HIDDEN + version: 1 + updated_at: updated_at + created_at: created_at + updated_at: '2022-10-06T20:41:22.673Z' + created_at: '2022-10-06T20:41:22.673Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/orders/{order_id}/custom-attributes/{custom_attribute_key} + method: DELETE + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Deletes a [custom attribute](entity:CustomAttribute) associated with a + customer profile. + + + To delete a custom attribute owned by another application, the + `visibility` setting must be + + `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom + attributes + + (also known as custom fields) are always set to + `VISIBILITY_READ_WRITE_VALUES`. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteOrderCustomAttribute + request: + name: DeleteCustomAttributesRequest + path-parameters: + order_id: + type: string + docs: The ID of the target [order](entity:Order). + custom_attribute_key: + type: string + docs: >- + The key of the custom attribute to delete. This key must match + the key of an + + existing custom attribute definition. + response: + docs: Success + type: root.DeleteOrderCustomAttributeResponse + status-code: 200 + examples: + - path-parameters: + order_id: order_id + custom_attribute_key: custom_attribute_key + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/payments.yml b/.mock/definition/payments.yml new file mode 100644 index 00000000..eee9cf90 --- /dev/null +++ b/.mock/definition/payments.yml @@ -0,0 +1,1646 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/payments + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves a list of payments taken by the account making the request. + + + Results are eventually consistent, and new payments or changes to + payments might take several + + seconds to appear. + + + The maximum results per page is 100. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.payments + source: + openapi: ../default/openapi/openapi.json + display-name: ListPayments + request: + name: ListPaymentsRequest + query-parameters: + begin_time: + type: optional> + docs: >- + Indicates the start of the time range to retrieve payments for, in + RFC 3339 format. + + The range is determined using the `created_at` field for each + Payment. + + Inclusive. Default: The current time minus one year. + end_time: + type: optional> + docs: >- + Indicates the end of the time range to retrieve payments for, in + RFC 3339 format. The + + range is determined using the `created_at` field for each Payment. + + + Default: The current time. + sort_order: + type: optional> + docs: >- + The order in which results are listed by + `ListPaymentsRequest.sort_field`: + + - `ASC` - Oldest to newest. + + - `DESC` - Newest to oldest (default). + cursor: + type: optional> + docs: >- + 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. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + location_id: + type: optional> + docs: >- + Limit results to the location supplied. By default, results are + returned + + for the default (main) location associated with the seller. + total: + type: optional> + docs: The exact amount in the `total_money` for a payment. + last_4: + type: optional> + docs: The last four digits of a payment card. + card_brand: + type: optional> + docs: The brand of the payment card (for example, VISA). + limit: + type: optional> + docs: >- + 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. If the + provided value is + + greater than 100, it is ignored and the default value is used + instead. + + + Default: `100` + is_offline_payment: + type: optional> + default: false + docs: Whether the payment was taken offline or not. + offline_begin_time: + type: optional> + docs: >- + Indicates the start of the time range for which to retrieve + offline payments, in RFC 3339 + + format for timestamps. The range is determined using the + + `offline_payment_details.client_created_at` field for each + Payment. If set, payments without a + + value set in `offline_payment_details.client_created_at` will not + be returned. + + + Default: The current time. + offline_end_time: + type: optional> + docs: >- + Indicates the end of the time range for which to retrieve offline + payments, in RFC 3339 + + format for timestamps. The range is determined using the + + `offline_payment_details.client_created_at` field for each + Payment. If set, payments without a + + value set in `offline_payment_details.client_created_at` will not + be returned. + + + Default: The current time. + updated_at_begin_time: + type: optional> + docs: >- + Indicates the start of the time range to retrieve payments for, in + RFC 3339 format. The + + range is determined using the `updated_at` field for each Payment. + updated_at_end_time: + type: optional> + docs: >- + Indicates the end of the time range to retrieve payments for, in + RFC 3339 format. The + + range is determined using the `updated_at` field for each Payment. + sort_field: + type: optional> + docs: The field used to sort results by. The default is `CREATED_AT`. + response: + docs: Success + type: root.ListPaymentsResponse + status-code: 200 + examples: + - query-parameters: + begin_time: begin_time + end_time: end_time + sort_order: sort_order + cursor: cursor + location_id: location_id + total: 1000000 + last_4: last_4 + card_brand: card_brand + limit: 1 + is_offline_payment: true + offline_begin_time: offline_begin_time + offline_end_time: offline_end_time + updated_at_begin_time: updated_at_begin_time + updated_at_end_time: updated_at_end_time + sort_field: CREATED_AT + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payments: + - id: bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + created_at: '2021-10-13T19:34:33.524Z' + updated_at: '2021-10-13T19:34:37.261Z' + amount_money: + amount: 555 + currency: USD + total_money: + amount: 555 + currency: USD + approved_money: + amount: 555 + currency: USD + processing_fee: + - effective_at: '2021-10-13T21:34:35.000Z' + type: INITIAL + amount_money: + amount: 34 + currency: USD + status: COMPLETED + delay_duration: PT168H + delay_action: CANCEL + delayed_until: '2021-10-20T19:34:33.524Z' + source_type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + fingerprint: >- + sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ + card_type: DEBIT + prepaid_type: NOT_PREPAID + bin: '411111' + entry_method: KEYED + cvv_status: CVV_ACCEPTED + avs_status: AVS_ACCEPTED + auth_result_code: 2Nkw7q + statement_description: SQ *EXAMPLE TEST GOSQ.C + card_payment_timeline: + authorized_at: '2021-10-13T19:34:33.680Z' + captured_at: '2021-10-13T19:34:34.340Z' + cash_details: + buyer_supplied_money: {} + external_details: + type: type + source: source + location_id: L88917AVBK2S5 + order_id: d7eKah653Z579f3gVtjlxpSlmUcZY + reference_id: reference_id + customer_id: customer_id + employee_id: TMoK_ogh6rH1o4dV + team_member_id: TMoK_ogh6rH1o4dV + refund_ids: + - refund_ids + terminal_checkout_id: terminal_checkout_id + buyer_email_address: buyer_email_address + note: Test Note + statement_description_identifier: statement_description_identifier + capabilities: + - capabilities + receipt_number: bP9m + receipt_url: >- + https://squareup.com/receipt/preview/bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + application_details: + square_product: VIRTUAL_TERMINAL + application_id: sq0ids-Pw67AZAlLVB7hsRmwlJPuA + is_offline_payment: true + version_token: vguW2km0KpVCdAXZcNTZ438qg5LlVPTP4HO5OpiHNfa6o + cursor: cursor + create: + path: /v2/payments + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Creates a payment using the provided source. You can use this endpoint + + to charge a card (credit/debit card or + + Square gift card) or record a payment that the seller received outside + of Square + + (cash payment from a buyer or a payment that an external entity + + processed on behalf of the seller). + + + The endpoint creates a + + `Payment` object and returns it in the response. + source: + openapi: ../default/openapi/openapi.json + display-name: CreatePayment + request: + name: CreatePaymentRequest + body: + properties: + source_id: + type: string + docs: >- + The ID for the source of funds for this payment. + + This could be a payment token generated by the Web Payments SDK + for any of its + + [supported + methods](https://developer.squareup.com/docs/web-payments/overview#explore-payment-methods), + + including cards, bank transfers, Afterpay or Cash App Pay. If + recording a payment + + that the seller received outside of Square, specify either + "CASH" or "EXTERNAL". + + For more information, see + + [Take + Payments](https://developer.squareup.com/docs/payments-api/take-payments). + validation: + minLength: 1 + idempotency_key: + type: string + docs: >- + A unique string that identifies this `CreatePayment` request. + Keys can be any valid string + + but must be unique for every `CreatePayment` request. + + + Note: The number of allowed characters might be less than the + stated maximum, if multi-byte + + characters are used. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + minLength: 1 + maxLength: 45 + amount_money: + type: optional + docs: >- + The amount of money to accept for this payment, not including + `tip_money`. + + + The amount must be specified in the smallest denomination of the + applicable currency + + (for example, US dollar amounts are specified in cents). For + more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + + + The currency code must match the currency associated with the + business + + that is accepting the payment. + tip_money: + type: optional + docs: >- + The amount designated as a tip, in addition to `amount_money`. + + + The amount must be specified in the smallest denomination of the + applicable currency + + (for example, US dollar amounts are specified in cents). For + more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + + + The currency code must match the currency associated with the + business + + that is accepting the payment. + app_fee_money: + type: optional + docs: >- + The amount of money that the developer is taking as a fee + + for facilitating the payment on behalf of the seller. + + + The amount cannot be more than 90% of the total amount of the + payment. + + + The amount must be specified in the smallest denomination of the + applicable currency + + (for example, US dollar amounts are specified in cents). For + more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + + + The fee currency code must match the currency associated with + the seller + + that is accepting the payment. The application must be from a + developer + + account in the same country and using the same currency code as + the seller. + + + For more information about the application fee scenario, see + + [Take Payments and Collect + Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). + + + To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth + permission is required. + + For more information, see + [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions). + delay_duration: + type: optional + docs: >- + The duration of time after the payment's creation when Square + automatically + + either completes or cancels the payment depending on the + `delay_action` field value. + + For more information, see + + [Time + threshold](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold). + + + This parameter should be specified as a time duration, in RFC + 3339 format. + + + 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. + delay_action: + type: optional + docs: >- + The action to be applied to the payment when the + `delay_duration` has elapsed. The action must be + + CANCEL or COMPLETE. For more information, see + + [Time + Threshold](https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold). + + + Default: CANCEL + autocomplete: + type: optional + docs: >- + If set to `true`, this payment will be completed when possible. + If + + set to `false`, this payment is held in an approved state until + either + + explicitly completed (captured) or canceled (voided). For more + information, see + + [Delayed + capture](https://developer.squareup.com/docs/payments-api/take-payments/card-payments#delayed-capture-of-a-card-payment). + + + Default: true + order_id: + type: optional + docs: Associates a previously created order with this payment. + customer_id: + type: optional + docs: >- + The [Customer](entity:Customer) ID of the customer associated + with the payment. + + + This is required if the `source_id` refers to a card on file + created using the Cards API. + location_id: + type: optional + docs: >- + The location ID to associate with the payment. If not specified, + the [main + location](https://developer.squareup.com/docs/locations-api#about-the-main-location) + is + + used. + team_member_id: + type: optional + docs: |- + An optional [TeamMember](entity:TeamMember) ID to associate with + this payment. + reference_id: + type: optional + docs: >- + A user-defined ID to associate with the payment. + + + You can use this field to associate the payment to an entity in + an external system + + (for example, you might specify an order ID that is generated by + a third-party shopping cart). + validation: + maxLength: 40 + verification_token: + type: optional + docs: >- + An identifying token generated by + [payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer). + + Verification tokens encapsulate customer device information and + 3-D Secure + + challenge results to indicate that Square has verified the buyer + identity. + + + For more information, see [SCA + Overview](https://developer.squareup.com/docs/sca-overview). + accept_partial_authorization: + type: optional + docs: >- + 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 + + a Square Gift Card with a balance of $5 results in an APPROVED + payment of $5. You might choose + + 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`. + + + For more information, see + + [Partial amount with Square Gift + Cards](https://developer.squareup.com/docs/payments-api/take-payments#partial-payment-gift-card). + + + Default: false + buyer_email_address: + type: optional + docs: The buyer's email address. + validation: + maxLength: 255 + buyer_phone_number: + type: optional + docs: >- + The buyer's phone number. + + Must follow the following format: + + 1. A leading + symbol (followed by a country code) + + 2. The phone number can contain spaces and the special + characters `(` , `)` , `-` , and `.`. + + Alphabetical characters aren't allowed. + + 3. The phone number must contain between 9 and 16 digits. + billing_address: + type: optional + docs: The buyer's billing address. + shipping_address: + type: optional + docs: The buyer's shipping address. + note: + type: optional + docs: >- + An optional note to be entered by the developer when creating a + payment. + validation: + maxLength: 500 + statement_description_identifier: + type: optional + docs: >- + Optional additional payment information to include on the + customer's card statement + + as part of the statement description. This can be, for example, + an invoice number, ticket number, + + or short description that uniquely identifies the purchase. + + + Note that the `statement_description_identifier` might get + truncated on the statement description + + to fit the required information including the Square identifier + (SQ *) and name of the + + seller taking the payment. + validation: + maxLength: 20 + cash_details: + type: optional + docs: >- + Additional details required when recording a cash payment + (`source_id` is CASH). + external_details: + type: optional + docs: >- + Additional details required when recording an external payment + (`source_id` is EXTERNAL). + customer_details: + type: optional + docs: Details about the customer making the payment. + offline_payment_details: + type: optional + docs: >- + An optional field for specifying the offline payment details. + This is intended for + + internal 1st-party callers only. + content-type: application/json + response: + docs: Success + type: root.CreatePaymentResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + source_id: ccof:GaJGNaZa8x4OgDJn4GB + idempotency_key: 7b0f3ec5-086a-4871-8f13-3c81b3875218 + amount_money: + amount: 1000 + currency: USD + app_fee_money: + amount: 10 + currency: USD + autocomplete: true + customer_id: W92WH6P11H4Z77CTET0RNTGFW8 + location_id: L88917AVBK2S5 + reference_id: '123456' + note: Brief description + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment: + id: R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY + created_at: '2021-10-13T21:14:29.577Z' + updated_at: '2021-10-13T21:14:30.504Z' + amount_money: + amount: 1000 + currency: USD + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + total_money: + amount: 1000 + currency: USD + app_fee_money: + amount: 10 + currency: USD + approved_money: + amount: 1000 + currency: USD + processing_fee: + - {} + refunded_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: COMPLETED + delay_duration: PT168H + delay_action: CANCEL + delayed_until: '2021-10-20T21:14:29.577Z' + source_type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + fingerprint: >- + sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ + card_type: DEBIT + prepaid_type: NOT_PREPAID + bin: '411111' + entry_method: ON_FILE + cvv_status: CVV_ACCEPTED + avs_status: AVS_ACCEPTED + auth_result_code: vNEn2f + application_identifier: application_identifier + application_name: application_name + application_cryptogram: application_cryptogram + verification_method: verification_method + verification_results: verification_results + statement_description: SQ *EXAMPLE TEST GOSQ.C + card_payment_timeline: + authorized_at: '2021-10-13T21:14:29.732Z' + captured_at: '2021-10-13T21:14:30.504Z' + refund_requires_card_presence: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + cash_details: + buyer_supplied_money: {} + bank_account_details: + bank_name: bank_name + transfer_type: transfer_type + account_ownership_type: account_ownership_type + fingerprint: fingerprint + country: country + statement_description: statement_description + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + external_details: + type: type + source: source + source_id: source_id + wallet_details: + status: status + brand: brand + buy_now_pay_later_details: + brand: brand + square_account_details: + payment_source_token: payment_source_token + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + location_id: L88917AVBK2S5 + order_id: pRsjRTgFWATl7so6DxdKBJa7ssbZY + reference_id: '123456' + customer_id: W92WH6P11H4Z77CTET0RNTGFW8 + employee_id: employee_id + team_member_id: team_member_id + refund_ids: + - refund_ids + risk_evaluation: + created_at: '2021-10-13T21:14:30.423Z' + risk_level: NORMAL + terminal_checkout_id: terminal_checkout_id + buyer_email_address: buyer_email_address + billing_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + note: Brief Description + statement_description_identifier: statement_description_identifier + capabilities: + - capabilities + receipt_number: R2B3 + receipt_url: https://squareup.com/receipt/preview/EXAMPLE_RECEIPT_ID + device_details: + device_id: device_id + device_installation_id: device_installation_id + device_name: device_name + application_details: + square_product: ECOMMERCE_API + application_id: sq0ids-TcgftTEtKxJTRF1lCFJ9TA + is_offline_payment: true + offline_payment_details: + client_created_at: client_created_at + version_token: TPtNEOBOa6Qq6E3C3IjckSVOM6b3hMbfhjvTxHBQUsB6o + cancelByIdempotencyKey: + path: /v2/payments/cancel + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + 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. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelPaymentByIdempotencyKey + request: + name: CancelPaymentByIdempotencyKeyRequest + body: + properties: + idempotency_key: + type: string + docs: The `idempotency_key` identifying the payment to be canceled. + validation: + minLength: 1 + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CancelPaymentByIdempotencyKeyResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: a7e36d40-d24b-11e8-b568-0800200c9a66 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/payments/{payment_id} + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: Retrieves details for a specific payment. + source: + openapi: ../default/openapi/openapi.json + display-name: GetPayment + request: + name: GetPaymentsRequest + path-parameters: + payment_id: + type: string + docs: A unique ID for the desired payment. + response: + docs: Success + type: root.GetPaymentResponse + status-code: 200 + examples: + - path-parameters: + payment_id: payment_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment: + id: bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + created_at: '2021-10-13T19:34:33.524Z' + updated_at: '2021-10-13T19:34:34.339Z' + amount_money: + amount: 555 + currency: USD + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + total_money: + amount: 555 + currency: USD + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + approved_money: + amount: 555 + currency: USD + processing_fee: + - effective_at: '2021-10-13T21:34:35.000Z' + type: INITIAL + amount_money: + amount: 34 + currency: USD + refunded_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: COMPLETED + delay_duration: PT168H + delay_action: CANCEL + delayed_until: '2021-10-20T19:34:33.524Z' + source_type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + fingerprint: >- + sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ + card_type: DEBIT + prepaid_type: NOT_PREPAID + bin: '411111' + entry_method: KEYED + cvv_status: CVV_ACCEPTED + avs_status: AVS_ACCEPTED + auth_result_code: 2Nkw7q + application_identifier: application_identifier + application_name: application_name + application_cryptogram: application_cryptogram + verification_method: verification_method + verification_results: verification_results + statement_description: SQ *EXAMPLE TEST GOSQ.C + card_payment_timeline: + authorized_at: '2021-10-13T19:34:33.680Z' + captured_at: '2021-10-13T19:34:34.340Z' + refund_requires_card_presence: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + cash_details: + buyer_supplied_money: {} + bank_account_details: + bank_name: bank_name + transfer_type: transfer_type + account_ownership_type: account_ownership_type + fingerprint: fingerprint + country: country + statement_description: statement_description + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + external_details: + type: type + source: source + source_id: source_id + wallet_details: + status: status + brand: brand + buy_now_pay_later_details: + brand: brand + square_account_details: + payment_source_token: payment_source_token + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + location_id: L88917AVBK2S5 + order_id: d7eKah653Z579f3gVtjlxpSlmUcZY + reference_id: reference_id + customer_id: customer_id + employee_id: TMoK_ogh6rH1o4dV + team_member_id: TMoK_ogh6rH1o4dV + refund_ids: + - refund_ids + risk_evaluation: + created_at: created_at + risk_level: PENDING + terminal_checkout_id: terminal_checkout_id + buyer_email_address: buyer_email_address + billing_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + note: Test Note + statement_description_identifier: statement_description_identifier + capabilities: + - capabilities + receipt_number: bP9m + receipt_url: >- + https://squareup.com/receipt/preview/bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + device_details: + device_id: device_id + device_installation_id: device_installation_id + device_name: device_name + application_details: + square_product: VIRTUAL_TERMINAL + application_id: sq0ids-Pw67AZAlLVB7hsRmwlJPuA + is_offline_payment: true + offline_payment_details: + client_created_at: client_created_at + version_token: 56pRkL3slrzet2iQrTp9n0bdJVYTB9YEWdTNjQfZOPV6o + update: + path: /v2/payments/{payment_id} + method: PUT + auth: + - oauth2: + - PAYMENTS_WRITE + docs: |- + Updates a payment with the APPROVED status. + You can update the `amount_money` and `tip_money` using this endpoint. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdatePayment + request: + name: UpdatePaymentRequest + path-parameters: + payment_id: + type: string + docs: The ID of the payment to update. + body: + properties: + payment: + type: optional + docs: The updated `Payment` object. + idempotency_key: + type: string + docs: >- + A unique string that identifies this `UpdatePayment` request. + Keys can be any valid string + + but must be unique for every `UpdatePayment` request. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + minLength: 1 + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdatePaymentResponse + status-code: 200 + examples: + - path-parameters: + payment_id: payment_id + headers: + Square-Version: '2025-10-16' + request: + payment: + amount_money: + amount: 1000 + currency: USD + tip_money: + amount: 100 + currency: USD + version_token: ODhwVQ35xwlzRuoZEwKXucfu7583sPTzK48c5zoGd0g6o + idempotency_key: 956f8b13-e4ec-45d6-85e8-d1d95ef0c5de + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment: + id: 1QjqpBVyrI9S4H9sTGDWU9JeiWdZY + created_at: '2021-10-13T20:26:44.191Z' + updated_at: '2021-10-13T20:26:44.364Z' + amount_money: + amount: 1000 + currency: USD + tip_money: + amount: 100 + currency: USD + total_money: + amount: 1100 + currency: USD + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + approved_money: + amount: 1000 + currency: USD + processing_fee: + - {} + refunded_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: APPROVED + delay_duration: PT168H + delay_action: CANCEL + delayed_until: '2021-10-20T20:26:44.191Z' + source_type: CARD + card_details: + status: AUTHORIZED + card: + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + fingerprint: >- + sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ + card_type: DEBIT + prepaid_type: NOT_PREPAID + bin: '411111' + entry_method: ON_FILE + cvv_status: CVV_ACCEPTED + avs_status: AVS_ACCEPTED + auth_result_code: 68aLBM + application_identifier: application_identifier + application_name: application_name + application_cryptogram: application_cryptogram + verification_method: verification_method + verification_results: verification_results + statement_description: SQ *EXAMPLE TEST GOSQ.C + card_payment_timeline: + authorized_at: '2021-10-13T20:26:44.364Z' + refund_requires_card_presence: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + cash_details: + buyer_supplied_money: {} + bank_account_details: + bank_name: bank_name + transfer_type: transfer_type + account_ownership_type: account_ownership_type + fingerprint: fingerprint + country: country + statement_description: statement_description + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + external_details: + type: type + source: source + source_id: source_id + wallet_details: + status: status + brand: brand + buy_now_pay_later_details: + brand: brand + square_account_details: + payment_source_token: payment_source_token + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + location_id: L88917AVBK2S5 + order_id: nUSN9TdxpiK3SrQg3wzmf6r8LP9YY + reference_id: reference_id + customer_id: W92WH6P11H4Z77CTET0RNTGFW8 + employee_id: employee_id + team_member_id: team_member_id + refund_ids: + - refund_ids + risk_evaluation: + created_at: '2021-10-13T20:26:45.271Z' + risk_level: NORMAL + terminal_checkout_id: terminal_checkout_id + buyer_email_address: buyer_email_address + billing_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + note: Example Note + statement_description_identifier: statement_description_identifier + capabilities: + - EDIT_AMOUNT_UP + - EDIT_AMOUNT_DOWN + - EDIT_TIP_AMOUNT_UP + - EDIT_TIP_AMOUNT_DOWN + receipt_number: 1Qjq + receipt_url: receipt_url + device_details: + device_id: device_id + device_installation_id: device_installation_id + device_name: device_name + application_details: + square_product: ECOMMERCE_API + application_id: sq0ids-TcgftTEtKxJTRF1lCFJ9TA + is_offline_payment: true + offline_payment_details: + client_created_at: client_created_at + version_token: rDrXnqiS7fJgexccgdpzmwqTiXui1aIKCp9EchZ7trE6o + cancel: + path: /v2/payments/{payment_id}/cancel + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Cancels (voids) a payment. You can use this endpoint to cancel a payment + with + + the APPROVED `status`. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelPayment + request: + name: CancelPaymentsRequest + path-parameters: + payment_id: + type: string + docs: The ID of the payment to cancel. + response: + docs: Success + type: root.CancelPaymentResponse + status-code: 200 + examples: + - path-parameters: + payment_id: payment_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment: + id: 1QjqpBVyrI9S4H9sTGDWU9JeiWdZY + created_at: '2021-10-13T20:26:44.191Z' + updated_at: '2021-10-13T20:31:21.597Z' + amount_money: + amount: 1000 + currency: USD + tip_money: + amount: 100 + currency: USD + total_money: + amount: 1100 + currency: USD + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + approved_money: + amount: 1000 + currency: USD + processing_fee: + - {} + refunded_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: CANCELED + delay_duration: PT168H + delay_action: CANCEL + delayed_until: '2021-10-20T20:26:44.191Z' + source_type: CARD + card_details: + status: VOIDED + card: + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + fingerprint: >- + sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ + card_type: DEBIT + prepaid_type: NOT_PREPAID + bin: '411111' + entry_method: ON_FILE + cvv_status: CVV_ACCEPTED + avs_status: AVS_ACCEPTED + auth_result_code: 68aLBM + application_identifier: application_identifier + application_name: application_name + application_cryptogram: application_cryptogram + verification_method: verification_method + verification_results: verification_results + statement_description: SQ *EXAMPLE TEST GOSQ.C + card_payment_timeline: + authorized_at: '2021-10-13T20:26:44.364Z' + voided_at: '2021-10-13T20:31:21.597Z' + refund_requires_card_presence: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + cash_details: + buyer_supplied_money: {} + bank_account_details: + bank_name: bank_name + transfer_type: transfer_type + account_ownership_type: account_ownership_type + fingerprint: fingerprint + country: country + statement_description: statement_description + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + external_details: + type: type + source: source + source_id: source_id + wallet_details: + status: status + brand: brand + buy_now_pay_later_details: + brand: brand + square_account_details: + payment_source_token: payment_source_token + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + location_id: L88917AVBK2S5 + order_id: nUSN9TdxpiK3SrQg3wzmf6r8LP9YY + reference_id: reference_id + customer_id: W92WH6P11H4Z77CTET0RNTGFW8 + employee_id: employee_id + team_member_id: team_member_id + refund_ids: + - refund_ids + risk_evaluation: + created_at: '2021-10-13T20:26:45.271Z' + risk_level: NORMAL + terminal_checkout_id: terminal_checkout_id + buyer_email_address: buyer_email_address + billing_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + note: Example Note + statement_description_identifier: statement_description_identifier + capabilities: + - capabilities + receipt_number: receipt_number + receipt_url: receipt_url + device_details: + device_id: device_id + device_installation_id: device_installation_id + device_name: device_name + application_details: + square_product: ECOMMERCE_API + application_id: sq0ids-TcgftTEtKxJTRF1lCFJ9TA + is_offline_payment: true + offline_payment_details: + client_created_at: client_created_at + version_token: N8AGYgEjCiY9Q57Jw7aVHEpBq8bzGCDCQMRX8Vs56N06o + complete: + path: /v2/payments/{payment_id}/complete + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + 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`. + source: + openapi: ../default/openapi/openapi.json + display-name: CompletePayment + request: + name: CompletePaymentRequest + path-parameters: + payment_id: + type: string + docs: The unique ID identifying the payment to be completed. + body: + properties: + version_token: + type: optional> + docs: >- + Used for optimistic concurrency. This opaque token identifies + the current `Payment` + + version that the caller expects. If the server has a different + version of the Payment, + + the update fails and a response with a VERSION_MISMATCH error is + returned. + content-type: application/json + response: + docs: Success + type: root.CompletePaymentResponse + status-code: 200 + examples: + - path-parameters: + payment_id: payment_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + payment: + id: bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + created_at: '2021-10-13T19:34:33.524Z' + updated_at: '2021-10-13T19:34:34.339Z' + amount_money: + amount: 555 + currency: USD + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + total_money: + amount: 555 + currency: USD + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + approved_money: + amount: 555 + currency: USD + processing_fee: + - effective_at: '2021-10-13T21:34:35.000Z' + type: INITIAL + amount_money: + amount: 34 + currency: USD + refunded_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + status: COMPLETED + delay_duration: PT168H + delay_action: CANCEL + delayed_until: '2021-10-20T19:34:33.524Z' + source_type: CARD + card_details: + status: CAPTURED + card: + card_brand: VISA + last_4: '1111' + exp_month: 11 + exp_year: 2022 + fingerprint: >- + sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ + card_type: DEBIT + prepaid_type: NOT_PREPAID + bin: '411111' + entry_method: KEYED + cvv_status: CVV_ACCEPTED + avs_status: AVS_ACCEPTED + auth_result_code: 2Nkw7q + application_identifier: application_identifier + application_name: application_name + application_cryptogram: application_cryptogram + verification_method: verification_method + verification_results: verification_results + statement_description: SQ *EXAMPLE TEST GOSQ.C + card_payment_timeline: + authorized_at: '2021-10-13T19:34:33.680Z' + captured_at: '2021-10-13T19:34:34.340Z' + refund_requires_card_presence: true + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + cash_details: + buyer_supplied_money: {} + bank_account_details: + bank_name: bank_name + transfer_type: transfer_type + account_ownership_type: account_ownership_type + fingerprint: fingerprint + country: country + statement_description: statement_description + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + external_details: + type: type + source: source + source_id: source_id + wallet_details: + status: status + brand: brand + buy_now_pay_later_details: + brand: brand + square_account_details: + payment_source_token: payment_source_token + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + location_id: L88917AVBK2S5 + order_id: d7eKah653Z579f3gVtjlxpSlmUcZY + reference_id: reference_id + customer_id: customer_id + employee_id: TMoK_ogh6rH1o4dV + team_member_id: TMoK_ogh6rH1o4dV + refund_ids: + - refund_ids + risk_evaluation: + created_at: created_at + risk_level: PENDING + terminal_checkout_id: terminal_checkout_id + buyer_email_address: buyer_email_address + billing_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + note: Test Note + statement_description_identifier: statement_description_identifier + capabilities: + - capabilities + receipt_number: bP9m + receipt_url: >- + https://squareup.com/receipt/preview/bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + device_details: + device_id: device_id + device_installation_id: device_installation_id + device_name: device_name + application_details: + square_product: VIRTUAL_TERMINAL + application_id: sq0ids-Pw67AZAlLVB7hsRmwlJPuA + is_offline_payment: true + offline_payment_details: + client_created_at: client_created_at + version_token: 56pRkL3slrzet2iQrTp9n0bdJVYTB9YEWdTNjQfZOPV6o + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/payouts.yml b/.mock/definition/payouts.yml new file mode 100644 index 00000000..480551e1 --- /dev/null +++ b/.mock/definition/payouts.yml @@ -0,0 +1,297 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/payouts + method: GET + auth: + - oauth2: [] + docs: >- + Retrieves a list of all payouts for the default location. + + You can filter payouts by location ID, status, time range, and order + them in ascending or descending order. + + To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.payouts + source: + openapi: ../default/openapi/openapi.json + display-name: ListPayouts + request: + name: ListPayoutsRequest + query-parameters: + location_id: + type: optional> + docs: >- + The ID of the location for which to list the payouts. + + By default, payouts are returned for the default (main) location + associated with the seller. + status: + type: optional> + docs: If provided, only payouts with the given status are returned. + begin_time: + type: optional> + docs: >- + The timestamp for the beginning of the payout creation time, in + RFC 3339 format. + + Inclusive. Default: The current time minus one year. + end_time: + type: optional> + docs: >- + The timestamp for the end of the payout creation time, in RFC 3339 + format. + + Default: The current time. + sort_order: + type: optional> + docs: The order in which payouts are listed. + cursor: + type: optional> + docs: >- + 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. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + + If request parameters change between requests, subsequent results + may contain duplicates or missing records. + limit: + type: optional> + docs: >- + 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. If the + provided value is + + greater than 100, it is ignored and the default value is used + instead. + + Default: `100` + response: + docs: Success + type: root.ListPayoutsResponse + status-code: 200 + examples: + - query-parameters: + location_id: location_id + status: SENT + begin_time: begin_time + end_time: end_time + sort_order: DESC + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + payouts: + - id: po_b345d2c7-90b3-4f0b-a2aa-df1def7f8afc + status: PAID + location_id: L88917AVBK2S5 + created_at: '2022-03-29T16:12:31Z' + updated_at: '2022-03-30T01:07:22.875Z' + amount_money: + amount: 6259 + destination: + type: CARD + id: ccof:ZPp3oedR3AeEUNd3z7 + version: 2 + type: BATCH + payout_fee: + - amount_money: + amount: 95 + effective_at: '2022-03-29T16:12:31Z' + type: TRANSFER_FEE + arrival_date: '2022-03-29' + end_to_end_id: L2100000005 + - id: po_f3c0fb38-a5ce-427d-b858-52b925b72e45 + status: PAID + location_id: L88917AVBK2S5 + created_at: '2022-03-24T03:07:09Z' + updated_at: '2022-03-24T03:07:09Z' + amount_money: + amount: -103 + destination: + type: BANK_ACCOUNT + id: bact:ZPp3oedR3AeEUNd3z7 + version: 1 + type: BATCH + payout_fee: + - {} + arrival_date: '2022-03-24' + end_to_end_id: L2100000006 + cursor: >- + EMPCyStibo64hS8wLayZPp3oedR3AeEUNd3z7u6zphi72LQZFIEMbkKVvot9eefpU + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/payouts/{payout_id} + method: GET + auth: + - oauth2: [] + docs: |- + Retrieves details of a specific payout identified by a payout ID. + To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. + source: + openapi: ../default/openapi/openapi.json + display-name: GetPayout + request: + name: GetPayoutsRequest + path-parameters: + payout_id: + type: string + docs: The ID of the payout to retrieve the information for. + response: + docs: Success + type: root.GetPayoutResponse + status-code: 200 + examples: + - path-parameters: + payout_id: payout_id + headers: + Square-Version: '2025-10-16' + response: + body: + payout: + id: po_f3c0fb38-a5ce-427d-b858-52b925b72e45 + status: PAID + location_id: L88917AVBK2S5 + created_at: '2022-03-24T03:07:09Z' + updated_at: '2022-03-24T03:07:09Z' + amount_money: + amount: -103 + currency: UNKNOWN_CURRENCY + destination: + type: BANK_ACCOUNT + id: bact:ZPp3oedR3AeEUNd3z7 + version: 1 + type: BATCH + payout_fee: + - {} + arrival_date: '2022-03-24' + end_to_end_id: end_to_end_id + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + ListEntries: + path: /v2/payouts/{payout_id}/payout-entries + method: GET + auth: + - oauth2: [] + docs: |- + Retrieves a list of all payout entries for a specific payout. + To call this endpoint, set `PAYOUTS_READ` for the OAuth scope. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.payout_entries + source: + openapi: ../default/openapi/openapi.json + display-name: ListPayoutEntries + request: + name: ListEntriesPayoutsRequest + path-parameters: + payout_id: + type: string + docs: The ID of the payout to retrieve the information for. + query-parameters: + sort_order: + type: optional> + docs: The order in which payout entries are listed. + cursor: + type: optional> + docs: >- + 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. + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + + If request parameters change between requests, subsequent results + may contain duplicates or missing records. + limit: + type: optional> + docs: >- + 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. If the + provided value is + + greater than 100, it is ignored and the default value is used + instead. + + Default: `100` + response: + docs: Success + type: root.ListPayoutEntriesResponse + status-code: 200 + examples: + - path-parameters: + payout_id: payout_id + query-parameters: + sort_order: DESC + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + payout_entries: + - id: poe_ZQWcw41d0SGJS6IWd4cSi8mKHk + payout_id: po_4d28e6c4-7dd5-4de4-8ec9-a059277646a6 + effective_at: '2021-12-14T23:31:49Z' + type: REFUND + gross_amount_money: + amount: -50 + fee_amount_money: + amount: -2 + net_amount_money: + amount: -48 + type_refund_details: + payment_id: HVdG62HeMlti8YYf94oxrN + refund_id: HVdG62HeMlti8YYf94oxrN_dR8Nztxg7umf94oxrN12Ji5r2KW14FAY + - id: poe_EibbY9Ob1d0SGJS6IWd4cSiSi6wkaPk + payout_id: po_4d28e6c4-7dd5-4de4-8ec9-a059277646a6 + effective_at: '2021-12-14T23:31:49Z' + type: CHARGE + gross_amount_money: + amount: 100 + fee_amount_money: + amount: 19 + net_amount_money: + amount: 81 + type_charge_details: + payment_id: HVdG62H5K3291d0SGJS6IWd4cSi8YY + cursor: >- + TbfI80z98Xc2LdApCyZ2NvCYLpkPurYLR16GRIttpMJ55mrSIMzHgtkcRQdT0mOnTtfHO + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/refunds.yml b/.mock/definition/refunds.yml new file mode 100644 index 00000000..913be908 --- /dev/null +++ b/.mock/definition/refunds.yml @@ -0,0 +1,507 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/refunds + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves a list of refunds for the account making the request. + + + Results are eventually consistent, and new refunds or changes to refunds + might take several + + seconds to appear. + + + The maximum results per page is 100. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.refunds + source: + openapi: ../default/openapi/openapi.json + display-name: ListPaymentRefunds + request: + name: ListRefundsRequest + query-parameters: + begin_time: + type: optional> + docs: >- + Indicates the start of the time range to retrieve each + `PaymentRefund` for, in RFC 3339 + + format. The range is determined using the `created_at` field for + each `PaymentRefund`. + + + Default: The current time minus one year. + end_time: + type: optional> + docs: >- + Indicates the end of the time range to retrieve each + `PaymentRefund` for, in RFC 3339 + + format. The range is determined using the `created_at` field for + each `PaymentRefund`. + + + Default: The current time. + sort_order: + type: optional> + docs: >- + The order in which results are listed by + `PaymentRefund.created_at`: + + - `ASC` - Oldest to newest. + + - `DESC` - Newest to oldest (default). + cursor: + type: optional> + docs: >- + 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. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + location_id: + type: optional> + docs: >- + Limit results to the location supplied. By default, results are + returned + + for all locations associated with the seller. + status: + type: optional> + docs: >- + If provided, only refunds with the given status are returned. + + For a list of refund status values, see + [PaymentRefund](entity:PaymentRefund). + + + Default: If omitted, refunds are returned regardless of their + status. + source_type: + type: optional> + docs: >- + If provided, only returns refunds whose payments have the + indicated source type. + + Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, + and `EXTERNAL`. + + For information about these payment source types, see + + [Take + Payments](https://developer.squareup.com/docs/payments-api/take-payments). + + + Default: If omitted, refunds are returned regardless of the source + type. + limit: + type: optional> + docs: >- + 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. + + + If the supplied value is greater than 100, no more than 100 + results are returned. + + + Default: 100 + updated_at_begin_time: + type: optional> + docs: >- + Indicates the start of the time range to retrieve each + `PaymentRefund` for, in RFC 3339 + + format. The range is determined using the `updated_at` field for + each `PaymentRefund`. + + + Default: If omitted, the time range starts at `begin_time`. + updated_at_end_time: + type: optional> + docs: >- + Indicates the end of the time range to retrieve each + `PaymentRefund` for, in RFC 3339 + + format. The range is determined using the `updated_at` field for + each `PaymentRefund`. + + + Default: The current time. + sort_field: + type: optional> + docs: The field used to sort results by. The default is `CREATED_AT`. + response: + docs: Success + type: root.ListPaymentRefundsResponse + status-code: 200 + examples: + - query-parameters: + begin_time: begin_time + end_time: end_time + sort_order: sort_order + cursor: cursor + location_id: location_id + status: status + source_type: source_type + limit: 1 + updated_at_begin_time: updated_at_begin_time + updated_at_end_time: updated_at_end_time + sort_field: CREATED_AT + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refunds: + - id: >- + bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY_69MmgHubkLqx9wGhnmenRUHOaKitE6llfZuxcWYjGxd + status: COMPLETED + location_id: L88917AVBK2S5 + unlinked: true + destination_type: destination_type + amount_money: + amount: 555 + currency: USD + processing_fee: + - effective_at: '2021-10-13T21:34:35.000Z' + type: INITIAL + amount_money: + amount: -34 + currency: USD + payment_id: bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + order_id: 9ltv0bx5PuvGXUYHYHxYSKEqC3IZY + reason: Example Refund + created_at: '2021-10-13T19:59:05.342Z' + updated_at: '2021-10-13T20:00:03.497Z' + team_member_id: team_member_id + terminal_refund_id: terminal_refund_id + cursor: >- + 5evquW1YswHoT4EoyUhzMmTsCnsSXBU9U0WJ4FU4623nrMQcocH0RGU6Up1YkwfiMcF59ood58EBTEGgzMTGHQJpocic7ExOL0NtrTXCeWcv0UJIJNk8eXb + RefundPayment: + path: /v2/refunds + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Refunds a payment. You can refund the entire payment amount or a + + portion of it. You can use this endpoint to refund a card payment or + record a + + refund of a cash or external payment. For more information, see + + [Refund + Payment](https://developer.squareup.com/docs/payments-api/refund-payments). + source: + openapi: ../default/openapi/openapi.json + display-name: RefundPayment + request: + name: RefundPaymentRequest + body: + properties: + idempotency_key: + type: string + docs: >2- + A unique string that identifies this `RefundPayment` request. The key can be any valid string + but must be unique for every `RefundPayment` request. + + + Keys are limited to a max of 45 characters - however, the number + of allowed characters might be + + less than 45, if multi-byte characters are used. + + + For more information, see + [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). + validation: + minLength: 1 + amount_money: + type: root.Money + docs: >- + The amount of money to refund. + + + This amount cannot be more than the `total_money` value of the + payment minus the total + + amount of all previously completed refunds for this payment. + + + This amount must be specified in the smallest denomination of + the applicable currency + + (for example, US dollar amounts are specified in cents). For + more information, see + + [Working with Monetary + Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts). + + + The currency code must match the currency associated with the + business + + that is charging the card. + app_fee_money: + type: optional + docs: >- + The amount of money the developer contributes to help cover the + refunded amount. + + This amount is specified in the smallest denomination of the + applicable currency (for example, + + US dollar amounts are specified in cents). + + + The value cannot be more than the `amount_money`. + + + You can specify this parameter in a refund request only if the + same parameter was also included + + when taking the payment. This is part of the application fee + scenario the API supports. For more + + information, see [Take Payments and Collect + Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees). + + + To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth + permission is required. + + For more information, see + [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions). + payment_id: + type: optional> + docs: |- + The unique ID of the payment being refunded. + Required when unlinked=false, otherwise must not be set. + destination_id: + type: optional> + docs: >- + The ID indicating where funds will be refunded to. Required for + unlinked refunds. For more + + information, see [Process an Unlinked + Refund](https://developer.squareup.com/docs/refunds-api/unlinked-refunds). + + + For refunds linked to Square payments, `destination_id` is + usually omitted; in this case, funds + + will be returned to the original payment source. The field may + be specified in order to request + + a cross-method refund to a gift card. For more information, + + see [Cross-method refunds to gift + cards](https://developer.squareup.com/docs/payments-api/refund-payments#cross-method-refunds-to-gift-cards). + unlinked: + type: optional> + docs: >- + Indicates that the refund is not linked to a Square payment. + + If set to true, `destination_id` and `location_id` must be + supplied while `payment_id` must not + + be provided. + location_id: + type: optional> + docs: >- + The location ID associated with the unlinked refund. + + Required for requests specifying `unlinked=true`. + + Otherwise, if included when `unlinked=false`, will throw an + error. + validation: + maxLength: 50 + customer_id: + type: optional> + docs: >- + The [Customer](entity:Customer) ID of the customer associated + with the refund. + + This is required if the `destination_id` refers to a card on + file created using the Cards + + API. Only allowed when `unlinked=true`. + reason: + type: optional> + docs: A description of the reason for the refund. + validation: + maxLength: 192 + payment_version_token: + type: optional> + docs: >2- + Used for optimistic concurrency. This opaque token identifies the current `Payment` + version that the caller expects. If the server has a different + version of the Payment, + + the update fails and a response with a VERSION_MISMATCH error is + returned. + + If the versions match, or the field is not provided, the refund + proceeds as normal. + team_member_id: + type: optional> + docs: >- + An optional [TeamMember](entity:TeamMember) ID to associate with + this refund. + validation: + maxLength: 192 + cash_details: + type: optional + docs: >- + Additional details required when recording an unlinked cash + refund (`destination_id` is CASH). + external_details: + type: optional + docs: >- + Additional details required when recording an unlinked external + refund + + (`destination_id` is EXTERNAL). + content-type: application/json + response: + docs: Success + type: root.RefundPaymentResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 9b7f2dcf-49da-4411-b23e-a2d6af21333a + amount_money: + amount: 1000 + currency: USD + app_fee_money: + amount: 10 + currency: USD + payment_id: R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY + reason: Example + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refund: + id: >- + R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY_KlWP8IC1557ddwc9QWTKrCVU6m0JXDz15R2Qym5eQfR + status: PENDING + location_id: L88917AVBK2S5 + unlinked: true + destination_type: destination_type + destination_details: + cash_details: + seller_supplied_money: {} + external_details: + type: type + source: source + amount_money: + amount: 1000 + currency: USD + app_fee_money: + amount: 10 + currency: USD + processing_fee: + - {} + payment_id: R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY + order_id: 1JLEUZeEooAIX8HMqm9kvWd69aQZY + reason: Example + created_at: '2021-10-13T21:23:19.116Z' + updated_at: '2021-10-13T21:23:19.508Z' + team_member_id: team_member_id + terminal_refund_id: terminal_refund_id + get: + path: /v2/refunds/{refund_id} + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: Retrieves a specific refund using the `refund_id`. + source: + openapi: ../default/openapi/openapi.json + display-name: GetPaymentRefund + request: + name: GetRefundsRequest + path-parameters: + refund_id: + type: string + docs: The unique ID for the desired `PaymentRefund`. + response: + docs: Success + type: root.GetPaymentRefundResponse + status-code: 200 + examples: + - path-parameters: + refund_id: refund_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refund: + id: >- + bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY_69MmgHubkLqx9wGhnmenRUHOaKitE6llfZuxcWYjGxd + status: COMPLETED + location_id: L88917AVBK2S5 + unlinked: true + destination_type: destination_type + destination_details: + cash_details: + seller_supplied_money: {} + external_details: + type: type + source: source + amount_money: + amount: 555 + currency: USD + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + processing_fee: + - effective_at: '2021-10-13T21:34:35.000Z' + type: INITIAL + amount_money: + amount: -34 + currency: USD + payment_id: bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY + order_id: 9ltv0bx5PuvGXUYHYHxYSKEqC3IZY + reason: Example Refund + created_at: '2021-10-13T19:59:05.073Z' + updated_at: '2021-10-13T20:00:02.442Z' + team_member_id: team_member_id + terminal_refund_id: terminal_refund_id + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/sites.yml b/.mock/definition/sites.yml new file mode 100644 index 00000000..ea44092e --- /dev/null +++ b/.mock/definition/sites.yml @@ -0,0 +1,54 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/sites + method: GET + auth: + - oauth2: + - ONLINE_STORE_SITE_READ + docs: >- + Lists the Square Online sites that belong to a seller. Sites are listed + in descending order by the `created_at` date. + + + + __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). + source: + openapi: ../default/openapi/openapi.json + display-name: ListSites + response: + docs: Success + type: root.ListSitesResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + sites: + - id: site_278075276488921835 + site_title: My Second Site + domain: mysite2.square.site + is_published: false + created_at: '2020-10-28T13:22:51.000000Z' + updated_at: '2020-10-28T13:22:51.000000Z' + - id: site_102725345836253849 + site_title: My First Site + domain: mysite1.square.site + is_published: true + created_at: '2020-06-18T17:45:13.000000Z' + updated_at: '2020-11-23T02:19:10.000000Z' + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/snippets.yml b/.mock/definition/snippets.yml new file mode 100644 index 00000000..eb5b45ad --- /dev/null +++ b/.mock/definition/snippets.yml @@ -0,0 +1,168 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v2/sites/{site_id}/snippet + method: GET + auth: + - oauth2: + - ONLINE_STORE_SNIPPETS_READ + docs: >- + Retrieves your snippet from a Square Online site. A site can contain + snippets from multiple snippet applications, but you can retrieve only + the snippet that was added by your application. + + + You can call [ListSites](api-endpoint:Sites-ListSites) to get the IDs of + the sites that belong to a seller. + + + + __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). + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveSnippet + request: + name: GetSnippetsRequest + path-parameters: + site_id: + type: string + docs: The ID of the site that contains the snippet. + response: + docs: Success + type: root.GetSnippetResponse + status-code: 200 + examples: + - path-parameters: + site_id: site_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + snippet: + id: snippet_5d178150-a6c0-11eb-a9f1-437e6a2881e7 + site_id: site_278075276488921835 + content: + created_at: '2021-03-11T25:40:09.000000Z' + updated_at: '2021-03-11T25:40:09.000000Z' + upsert: + path: /v2/sites/{site_id}/snippet + method: POST + auth: + - oauth2: + - ONLINE_STORE_SNIPPETS_WRITE + docs: >- + Adds a snippet to a Square Online site or updates the existing snippet + on the site. + + The snippet code is appended to the end of the `head` element on every + page of the site, except checkout pages. A snippet application can add + one snippet to a given site. + + + You can call [ListSites](api-endpoint:Sites-ListSites) to get the IDs of + the sites that belong to a seller. + + + + __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). + source: + openapi: ../default/openapi/openapi.json + display-name: UpsertSnippet + request: + name: UpsertSnippetRequest + path-parameters: + site_id: + type: string + docs: The ID of the site where you want to add or update the snippet. + body: + properties: + snippet: + type: root.Snippet + docs: The snippet for the site. + content-type: application/json + response: + docs: Success + type: root.UpsertSnippetResponse + status-code: 200 + examples: + - path-parameters: + site_id: site_id + headers: + Square-Version: '2025-10-16' + request: + snippet: + content: + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + snippet: + id: snippet_5d178150-a6c0-11eb-a9f1-437e6a2881e7 + site_id: site_278075276488921835 + content: + created_at: '2021-03-11T25:40:09.000000Z' + updated_at: '2021-03-11T25:40:09.000000Z' + delete: + path: /v2/sites/{site_id}/snippet + method: DELETE + auth: + - oauth2: + - ONLINE_STORE_SNIPPETS_WRITE + docs: >- + Removes your snippet from a Square Online site. + + + You can call [ListSites](api-endpoint:Sites-ListSites) to get the IDs of + the sites that belong to a seller. + + + + __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). + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteSnippet + request: + name: DeleteSnippetsRequest + path-parameters: + site_id: + type: string + docs: The ID of the site that contains the snippet. + response: + docs: Success + type: root.DeleteSnippetResponse + status-code: 200 + examples: + - path-parameters: + site_id: site_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/subscriptions.yml b/.mock/definition/subscriptions.yml new file mode 100644 index 00000000..d15b2cd6 --- /dev/null +++ b/.mock/definition/subscriptions.yml @@ -0,0 +1,1309 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/subscriptions + method: POST + auth: + - oauth2: + - CUSTOMERS_READ + - PAYMENTS_WRITE + - SUBSCRIPTIONS_WRITE + - ITEMS_READ + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Enrolls a customer in a subscription. + + + If you provide a card on file in the request, Square charges the card + for + + the subscription. Otherwise, Square sends an invoice to the customer's + email + + address. The subscription starts immediately, unless the request + includes + + the optional `start_date`. Each individual subscription is associated + with a particular location. + + + For more information, see [Create a + subscription](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#create-a-subscription). + source: + openapi: ../default/openapi/openapi.json + display-name: CreateSubscription + request: + name: CreateSubscriptionRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique string that identifies this `CreateSubscription` + request. + + If you do not provide a unique string (or provide an empty + string as the value), + + the endpoint treats each request as independent. + + + For more information, see [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + location_id: + type: string + docs: The ID of the location the subscription is associated with. + validation: + minLength: 1 + plan_variation_id: + type: optional + docs: >- + The ID of the [subscription plan + variation](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations#plan-variations) + created using the Catalog API. + customer_id: + type: string + docs: >- + The ID of the [customer](entity:Customer) subscribing to the + subscription plan variation. + validation: + minLength: 1 + start_date: + type: optional + docs: |- + The `YYYY-MM-DD`-formatted date to start the subscription. + If it is unspecified, the subscription starts immediately. + canceled_date: + type: optional + docs: >- + The `YYYY-MM-DD`-formatted date when the newly created + subscription is scheduled for cancellation. + + + This date overrides the cancellation date set in the plan + variation configuration. + + If the cancellation date is earlier than the end date of a + subscription cycle, the subscription stops + + at the canceled date and the subscriber is sent a prorated + invoice at the beginning of the canceled cycle. + + + When the subscription plan of the newly created subscription has + a fixed number of cycles and the `canceled_date` + + occurs before the subscription plan completes, the specified + `canceled_date` sets the date when the subscription + + stops through the end of the last cycle. + tax_percentage: + type: optional + docs: >- + The tax to add when billing the subscription. + + The percentage is expressed in decimal form, using a `'.'` as + the decimal + + separator and without a `'%'` sign. For example, a value of 7.5 + + corresponds to 7.5%. + validation: + maxLength: 10 + price_override_money: + type: optional + docs: >- + A custom price which overrides the cost of a subscription plan + variation with `STATIC` pricing. + + This field does not affect itemized subscriptions with + `RELATIVE` pricing. Instead, + + you should edit the Subscription's [order + template](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#phases-and-order-templates). + card_id: + type: optional + docs: >- + The ID of the [subscriber's](entity:Customer) + [card](entity:Card) to charge. + + If it is not specified, the subscriber receives an invoice via + email with a link to pay for their subscription. + timezone: + type: optional + docs: >- + The timezone that is used in date calculations for the + subscription. If unset, defaults to + + the location timezone. If a timezone is not configured for the + location, defaults to "America/New_York". + + Format: the IANA Timezone Database identifier for the location + timezone. For + + a list of time zones, see [List of tz database time + zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + source: + type: optional + docs: The origination details of the subscription. + monthly_billing_anchor_date: + type: optional + docs: The day-of-the-month to change the billing date to. + validation: + min: 1 + max: 31 + phases: + type: optional> + docs: array of phases for this subscription + content-type: application/json + response: + docs: Success + type: root.CreateSubscriptionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 8193148c-9586-11e6-99f9-28cfe92138cf + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2023-06-20' + card_id: ccof:qy5x8hHGYsgLrp4Q4GB + timezone: America/Los_Angeles + source: + name: My Application + phases: + - ordinal: 0 + order_template_id: U2NaowWxzXwpsZU697x7ZHOAnCNZY + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 56214fb2-cc85-47a1-93bc-44f3766bb56f + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2023-06-20' + canceled_date: canceled_date + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + price_override_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + version: 1 + created_at: '2023-06-20T21:53:10Z' + card_id: ccof:qy5x8hHGYsgLrp4Q4GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - uid: 873451e0-745b-4e87-ab0b-c574933fe616 + ordinal: 0 + order_template_id: U2NaowWxzXwpsZU697x7ZHOAnCNZY + plan_phase_uid: X2Q2AONPB3RB64Y27S25QCZP + completed_date: completed_date + BulkSwapPlan: + path: /v2/subscriptions/bulk-swap-plan + method: POST + auth: + - oauth2: + - SUBSCRIPTIONS_WRITE + - SUBSCRIPTIONS_READ + - ITEMS_READ + docs: >- + Schedules a plan variation change for all active subscriptions under a + given plan + + variation. For more information, see [Swap Subscription Plan + Variations](https://developer.squareup.com/docs/subscriptions-api/swap-plan-variations). + source: + openapi: ../default/openapi/openapi.json + display-name: BulkSwapPlan + request: + name: BulkSwapPlanRequest + body: + properties: + new_plan_variation_id: + type: string + docs: |- + The ID of the new subscription plan variation. + + This field is required. + validation: + minLength: 1 + old_plan_variation_id: + type: string + docs: >- + The ID of the plan variation whose subscriptions should be + swapped. Active subscriptions + + using this plan variation will be subscribed to the new plan + variation on their next billing + + day. + validation: + minLength: 1 + location_id: + type: string + docs: >- + The ID of the location to associate with the swapped + subscriptions. + validation: + minLength: 1 + content-type: application/json + response: + docs: Success + type: root.BulkSwapPlanResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + new_plan_variation_id: FQ7CDXXWSLUJRPM3GFJSJGZ7 + old_plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + location_id: S8GWD5R9QB376 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + affected_subscriptions: 12 + search: + path: /v2/subscriptions/search + method: POST + auth: + - oauth2: + - SUBSCRIPTIONS_READ + docs: >- + Searches for subscriptions. + + + Results are ordered chronologically by subscription creation date. If + + the request specifies more than one location ID, + + the endpoint orders the result + + by location ID, and then by creation date within each location. If no + locations are given + + in the query, all locations are searched. + + + You can also optionally specify `customer_ids` to search by customer. + + If left unset, all customers + + associated with the specified locations are returned. + + If the request specifies customer IDs, the endpoint orders results + + first by location, within location by customer ID, and within + + customer by subscription creation date. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchSubscriptions + request: + name: SearchSubscriptionsRequest + body: + properties: + cursor: + type: optional + docs: >- + When the total number of resulting subscriptions exceeds the + limit of a paged response, + + specify the cursor returned from a preceding response here to + fetch the next set of results. + + If the cursor is unset, the response contains the last page of + the results. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional + docs: |- + The upper limit on the number of subscriptions to return + in a paged response. + validation: + min: 1 + query: + type: optional + docs: >- + A subscription query consisting of specified filtering + conditions. + + + If this `query` field is unspecified, the `SearchSubscriptions` + call will return all subscriptions. + include: + type: optional> + docs: >- + An option to include related information in the response. + + + The supported values are: + + + - `actions`: to include scheduled actions on the targeted + subscriptions. + content-type: application/json + response: + docs: Success + type: root.SearchSubscriptionsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + customer_ids: + - CHFGVKYY8RSV93M5KCYTG4PN0G + location_ids: + - S8GWD5R9QB376 + source_names: + - My App + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscriptions: + - id: de86fc96-8664-474b-af1a-abbe59cacf0e + location_id: S8GWD5R9QB376 + plan_variation_id: L3TJVDHVBEQEGQDEZL2JJM7R + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2021-10-20' + canceled_date: '2021-10-30' + charged_through_date: '2021-11-20' + status: CANCELED + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + version: 1000000 + created_at: '2021-10-20T21:53:10Z' + card_id: ccof:mueUsvgajChmjEbp4GB + timezone: UTC + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - {} + completed_date: completed_date + - id: 56214fb2-cc85-47a1-93bc-44f3766bb56f + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2022-01-19' + canceled_date: canceled_date + charged_through_date: '2022-08-19' + status: PAUSED + tax_percentage: '5' + invoice_ids: + - grebK0Q_l8H4fqoMMVvt-Q + - rcX_i3sNmHTGKhI4W2mceA + price_override_money: + amount: 1000 + currency: USD + version: 2 + created_at: '2022-01-19T21:53:10Z' + card_id: card_id + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - {} + completed_date: completed_date + - id: 56214fb2-cc85-47a1-93bc-44f3766bb56f + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2023-06-20' + canceled_date: canceled_date + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + version: 1 + created_at: '2023-06-20T21:53:10Z' + card_id: ccof:qy5x8hHGYsgLrp4Q4GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - uid: 873451e0-745b-4e87-ab0b-c574933fe616 + ordinal: 0 + order_template_id: U2NaowWxzXwpsZU697x7ZHOAnCNZY + plan_phase_uid: X2Q2AONPB3RB64Y27S25QCZP + completed_date: completed_date + cursor: cursor + get: + path: /v2/subscriptions/{subscription_id} + method: GET + auth: + - oauth2: + - SUBSCRIPTIONS_READ + docs: Retrieves a specific subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveSubscription + request: + name: GetSubscriptionsRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to retrieve. + query-parameters: + include: + type: optional> + docs: >- + A query parameter to specify related information to be included in + the response. + + + The supported query parameter values are: + + + - `actions`: to include scheduled actions on the targeted + subscription. + response: + docs: Success + type: root.GetSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + query-parameters: + include: include + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 8151fc89-da15-4eb9-a685-1a70883cebfc + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + start_date: '2022-07-27' + canceled_date: canceled_date + charged_through_date: '2023-11-20' + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + - inv:0-ChrcX_i3sNmfsHTGKhI4Wg2mceA + price_override_money: + amount: 25000 + currency: USD + version: 1000000 + created_at: '2022-07-27T21:53:10Z' + card_id: ccof:IkWfpLj4tNHMyFii3GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - {} + completed_date: completed_date + update: + path: /v2/subscriptions/{subscription_id} + method: PUT + auth: + - oauth2: + - CUSTOMERS_READ + - PAYMENTS_WRITE + - SUBSCRIPTIONS_WRITE + - ITEMS_READ + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Updates a subscription by modifying or clearing `subscription` field + values. + + To clear a field, set its value to `null`. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateSubscription + request: + name: UpdateSubscriptionRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to update. + body: + properties: + subscription: + type: optional + docs: >- + The subscription object containing the current version, and + fields to update. + + Unset fields will be left at their current server values, and + JSON `null` values will + + be treated as a request to clear the relevant data. + content-type: application/json + response: + docs: Success + type: root.UpdateSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: + subscription: + card_id: '{NEW CARD ID}' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 7217d8ca-1fee-4446-a9e5-8540b5d8c9bb + location_id: LPJKHYR7WFDKN + plan_variation_id: XOUNEKCE6NSXQW5NTSQ73MMX + customer_id: AM69AB81FT4479YH9HGWS1HZY8 + start_date: '2023-01-30' + canceled_date: canceled_date + charged_through_date: '2023-03-13' + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - inv:0-ChAPSfVYvNewckgf3x4iigN_ENMM + - inv:0-ChBQaCCLfjcm9WEUBGxvuydJENMM + price_override_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + version: 3 + created_at: '2023-01-30T19:27:32Z' + card_id: '{NEW CARD ID}' + timezone: UTC + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - {} + completed_date: completed_date + DeleteAction: + path: /v2/subscriptions/{subscription_id}/actions/{action_id} + method: DELETE + auth: + - oauth2: + - SUBSCRIPTIONS_WRITE + docs: Deletes a scheduled action for a subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteSubscriptionAction + request: + name: DeleteActionSubscriptionsRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription the targeted action is to act upon. + action_id: + type: string + docs: The ID of the targeted action to be deleted. + response: + docs: Success + type: root.DeleteSubscriptionActionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + action_id: action_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 8151fc89-da15-4eb9-a685-1a70883cebfc + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: JDKYHBWT1D4F8MFH63DBMEN8Y4 + start_date: '2022-07-27' + canceled_date: canceled_date + charged_through_date: '2023-11-20' + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + - inv:0-ChrcX_i3sNmfsHTGKhI4Wg2mceA + price_override_money: + amount: 25000 + currency: USD + version: 1000000 + created_at: '2022-07-27T21:53:10Z' + card_id: ccof:IkWfpLj4tNHMyFii3GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - {} + completed_date: completed_date + ChangeBillingAnchorDate: + path: /v2/subscriptions/{subscription_id}/billing-anchor + method: POST + auth: + - oauth2: + - SUBSCRIPTIONS_WRITE + - SUBSCRIPTIONS_READ + - ITEMS_READ + docs: >- + Changes the [billing anchor + date](https://developer.squareup.com/docs/subscriptions-api/subscription-billing#billing-dates) + + for a subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: ChangeBillingAnchorDate + request: + name: ChangeBillingAnchorDateRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to update the billing anchor date. + body: + properties: + monthly_billing_anchor_date: + type: optional> + docs: The anchor day for the billing cycle. + validation: + min: 1 + max: 31 + effective_date: + type: optional> + docs: >- + The `YYYY-MM-DD`-formatted date when the scheduled + `BILLING_ANCHOR_CHANGE` action takes + + place on the subscription. + + + When this date is unspecified or falls within the current + billing cycle, the billing anchor date + + is changed immediately. + content-type: application/json + response: + docs: Success + type: root.ChangeBillingAnchorDateResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: + monthly_billing_anchor_date: 1 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 9ba40961-995a-4a3d-8c53-048c40cafc13 + location_id: S8GWD5R9QB376 + plan_variation_id: FQ7CDXXWSLUJRPM3GFJSJGZ7 + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: start_date + canceled_date: canceled_date + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + price_override_money: + amount: 2000 + currency: USD + version: 3 + created_at: '2023-06-20T21:53:10Z' + card_id: card_id + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 20 + phases: + - uid: 98d6f53b-40e1-4714-8827-032fd923be25 + ordinal: 0 + order_template_id: E6oBY5WfQ2eN4pkYZwq4ka6n7KeZY + plan_phase_uid: C66BKH3ASTDYGJJCEZXQQSS7 + completed_date: completed_date + actions: + - id: f0a1dfdc-675b-3a14-a640-99f7ac1cee83 + type: CHANGE_BILLING_ANCHOR_DATE + effective_date: '2023-11-01' + monthly_billing_anchor_date: 1 + phases: + - {} + new_plan_variation_id: new_plan_variation_id + cancel: + path: /v2/subscriptions/{subscription_id}/cancel + method: POST + auth: + - oauth2: + - SUBSCRIPTIONS_WRITE + docs: >- + Schedules a `CANCEL` action to cancel an active subscription. This + + sets the `canceled_date` field to the end of the active billing period. + After this date, + + the subscription status changes from ACTIVE to CANCELED. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelSubscription + request: + name: CancelSubscriptionsRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to cancel. + response: + docs: Success + type: root.CancelSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 910afd30-464a-4e00-a8d8-2296e + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2022-01-19' + canceled_date: '2023-06-05' + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - inv:0-ChCHu2mZEabLeeHahQnXDjZQECY + - inv:0-ChrcX_i3sNmfsHTGKhI4Wg2mceA + price_override_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + version: 3 + created_at: '2022-01-19T21:53:10Z' + card_id: ccof:qy5x8hHGYsgLrp4Q4GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - {} + completed_date: completed_date + actions: + - id: id + type: CANCEL + effective_date: effective_date + monthly_billing_anchor_date: 1 + phases: + - {} + new_plan_variation_id: new_plan_variation_id + listEvents: + path: /v2/subscriptions/{subscription_id}/events + method: GET + auth: + - oauth2: + - SUBSCRIPTIONS_READ + docs: >- + Lists all + [events](https://developer.squareup.com/docs/subscriptions-api/actions-events) + for a specific subscription. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.subscription_events + source: + openapi: ../default/openapi/openapi.json + display-name: ListSubscriptionEvents + request: + name: ListEventsSubscriptionsRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to retrieve the events for. + query-parameters: + cursor: + type: optional> + docs: >- + When the total number of resulting subscription events exceeds the + limit of a paged response, + + specify the cursor returned from a preceding response here to + fetch the next set of results. + + If the cursor is unset, the response contains the last page of the + results. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + limit: + type: optional> + docs: |- + The upper limit on the number of subscription events to return + in a paged response. + response: + docs: Success + type: root.ListSubscriptionEventsResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + query-parameters: + cursor: cursor + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription_events: + - id: 06809161-3867-4598-8269-8aea5be4f9de + subscription_event_type: START_SUBSCRIPTION + effective_date: '2020-04-24' + monthly_billing_anchor_date: 1 + phases: + - {} + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + - id: f2736603-cd2e-47ec-8675-f815fff54f88 + subscription_event_type: DEACTIVATE_SUBSCRIPTION + effective_date: '2020-05-01' + monthly_billing_anchor_date: 1 + info: + detail: >- + The customer with ID `V74BMG0GPS2KNCWJE1BTYJ37Y0` does not + have a name on record. + code: CUSTOMER_NO_NAME + phases: + - {} + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + - id: b426fc85-6859-450b-b0d0-fe3a5d1b565f + subscription_event_type: RESUME_SUBSCRIPTION + effective_date: '2022-05-01' + monthly_billing_anchor_date: 1 + phases: + - {} + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + - id: 09f14de1-2f53-4dae-9091-49aa53f83d01 + subscription_event_type: PAUSE_SUBSCRIPTION + effective_date: '2022-09-01' + monthly_billing_anchor_date: 1 + phases: + - {} + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + - id: f28a73ac-1a1b-4b0f-8eeb-709a72945776 + subscription_event_type: RESUME_SUBSCRIPTION + effective_date: '2022-12-01' + monthly_billing_anchor_date: 1 + phases: + - {} + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + - id: 1eee8790-472d-4efe-8c69-8ad84e9cefe0 + subscription_event_type: PLAN_CHANGE + effective_date: '2023-04-01' + monthly_billing_anchor_date: 1 + phases: + - {} + plan_variation_id: 02CD53CFA4d1498AFAD42 + - id: a0c08083-5db0-4800-85c7-d398de4fbb6e + subscription_event_type: STOP_SUBSCRIPTION + effective_date: '2023-06-21' + monthly_billing_anchor_date: 1 + phases: + - {} + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + cursor: cursor + pause: + path: /v2/subscriptions/{subscription_id}/pause + method: POST + auth: + - oauth2: + - CUSTOMERS_READ + - PAYMENTS_WRITE + - SUBSCRIPTIONS_WRITE + - ITEMS_READ + - ORDERS_WRITE + - INVOICES_WRITE + docs: Schedules a `PAUSE` action to pause an active subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: PauseSubscription + request: + name: PauseSubscriptionRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to pause. + body: + properties: + pause_effective_date: + type: optional> + docs: >- + The `YYYY-MM-DD`-formatted date when the scheduled `PAUSE` + action takes place on the subscription. + + + When this date is unspecified or falls within the current + billing cycle, the subscription is paused + + on the starting date of the next billing cycle. + pause_cycle_duration: + type: optional> + docs: >- + The number of billing cycles the subscription will be paused + before it is reactivated. + + + When this is set, a `RESUME` action is also scheduled to take + place on the subscription at + + the end of the specified pause cycle duration. In this case, + neither `resume_effective_date` + + nor `resume_change_timing` may be specified. + resume_effective_date: + type: optional> + docs: >- + The date when the subscription is reactivated by a scheduled + `RESUME` action. + + This date must be at least one billing cycle ahead of + `pause_effective_date`. + resume_change_timing: + type: optional + docs: >- + The timing whether the subscription is reactivated immediately + or at the end of the billing cycle, relative to + + `resume_effective_date`. + + See [ChangeTiming](#type-changetiming) for possible values + pause_reason: + type: optional> + docs: The user-provided reason to pause the subscription. + validation: + maxLength: 255 + content-type: application/json + response: + docs: Success + type: root.PauseSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 56214fb2-cc85-47a1-93bc-44f3766bb56f + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2023-06-20' + canceled_date: canceled_date + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + price_override_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + version: 1 + created_at: '2023-06-20T21:53:10Z' + card_id: ccof:qy5x8hHGYsgLrp4Q4GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - uid: 873451e0-745b-4e87-ab0b-c574933fe616 + ordinal: 0 + order_template_id: U2NaowWxzXwpsZU697x7ZHOAnCNZY + plan_phase_uid: X2Q2AONPB3RB64Y27S25QCZP + completed_date: completed_date + actions: + - id: 99b2439e-63f7-3ad5-95f7-ab2447a80673 + type: PAUSE + effective_date: '2023-11-17' + monthly_billing_anchor_date: 1 + phases: + - {} + new_plan_variation_id: new_plan_variation_id + resume: + path: /v2/subscriptions/{subscription_id}/resume + method: POST + auth: + - oauth2: + - CUSTOMERS_READ + - PAYMENTS_WRITE + - SUBSCRIPTIONS_WRITE + - ITEMS_READ + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Schedules a `RESUME` action to resume a paused or a deactivated + subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: ResumeSubscription + request: + name: ResumeSubscriptionRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to resume. + body: + properties: + resume_effective_date: + type: optional> + docs: >- + The `YYYY-MM-DD`-formatted date when the subscription + reactivated. + resume_change_timing: + type: optional + docs: |- + The timing to resume a subscription, relative to the specified + `resume_effective_date` attribute value. + See [ChangeTiming](#type-changetiming) for possible values + content-type: application/json + response: + docs: Success + type: root.ResumeSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 56214fb2-cc85-47a1-93bc-44f3766bb56f + location_id: S8GWD5R9QB376 + plan_variation_id: 6JHXF3B2CW3YKHDV4XEM674H + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: '2023-06-20' + canceled_date: canceled_date + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + price_override_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + version: 1 + created_at: '2023-06-20T21:53:10Z' + card_id: ccof:qy5x8hHGYsgLrp4Q4GB + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - uid: 873451e0-745b-4e87-ab0b-c574933fe616 + ordinal: 0 + order_template_id: U2NaowWxzXwpsZU697x7ZHOAnCNZY + plan_phase_uid: X2Q2AONPB3RB64Y27S25QCZP + completed_date: completed_date + actions: + - id: 18ff74f4-3da4-30c5-929f-7d6fca84f115 + type: RESUME + effective_date: '2023-09-01' + monthly_billing_anchor_date: 1 + phases: + - {} + new_plan_variation_id: new_plan_variation_id + SwapPlan: + path: /v2/subscriptions/{subscription_id}/swap-plan + method: POST + auth: + - oauth2: + - CUSTOMERS_READ + - PAYMENTS_WRITE + - SUBSCRIPTIONS_WRITE + - ITEMS_READ + - ORDERS_WRITE + - INVOICES_WRITE + docs: >- + Schedules a `SWAP_PLAN` action to swap a subscription plan variation in + an existing subscription. + + For more information, see [Swap Subscription Plan + Variations](https://developer.squareup.com/docs/subscriptions-api/swap-plan-variations). + source: + openapi: ../default/openapi/openapi.json + display-name: SwapPlan + request: + name: SwapPlanRequest + path-parameters: + subscription_id: + type: string + docs: The ID of the subscription to swap the subscription plan for. + body: + properties: + new_plan_variation_id: + type: optional> + docs: |- + The ID of the new subscription plan variation. + + This field is required. + phases: + type: optional>> + docs: >- + A list of PhaseInputs, to pass phase-specific information used + in the swap. + content-type: application/json + response: + docs: Success + type: root.SwapPlanResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: + new_plan_variation_id: FQ7CDXXWSLUJRPM3GFJSJGZ7 + phases: + - ordinal: 0 + order_template_id: uhhnjH9osVv3shUADwaC0b3hNxQZY + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: 9ba40961-995a-4a3d-8c53-048c40cafc13 + location_id: S8GWD5R9QB376 + plan_variation_id: FQ7CDXXWSLUJRPM3GFJSJGZ7 + customer_id: CHFGVKYY8RSV93M5KCYTG4PN0G + start_date: start_date + canceled_date: canceled_date + charged_through_date: charged_through_date + status: ACTIVE + tax_percentage: tax_percentage + invoice_ids: + - invoice_ids + price_override_money: + amount: 2000 + currency: USD + version: 3 + created_at: '2023-06-20T21:53:10Z' + card_id: card_id + timezone: America/Los_Angeles + source: + name: My Application + actions: + - {} + monthly_billing_anchor_date: 1 + phases: + - uid: 98d6f53b-40e1-4714-8827-032fd923be25 + ordinal: 0 + order_template_id: E6oBY5WfQ2eN4pkYZwq4ka6n7KeZY + plan_phase_uid: C66BKH3ASTDYGJJCEZXQQSS7 + completed_date: completed_date + actions: + - id: f0a1dfdc-675b-3a14-a640-99f7ac1cee83 + type: SWAP_PLAN + effective_date: '2023-11-17' + monthly_billing_anchor_date: 1 + phases: + - ordinal: 0 + order_template_id: uhhnjH9osVv3shUADwaC0b3hNxQZY + new_plan_variation_id: FQ7CDXXWSLUJRPM3GFJSJGZ7 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/team.yml b/.mock/definition/team.yml new file mode 100644 index 00000000..a6440452 --- /dev/null +++ b/.mock/definition/team.yml @@ -0,0 +1,228 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + ListJobs: + path: /v2/team-members/jobs + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: >- + Lists jobs in a seller account. Results are sorted by title in ascending + order. + source: + openapi: ../default/openapi/openapi.json + display-name: ListJobs + request: + name: ListJobsRequest + query-parameters: + cursor: + type: optional> + docs: >- + The pagination cursor returned by 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). + response: + docs: Success + type: root.ListJobsResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + headers: + Square-Version: '2025-10-16' + response: + body: + jobs: + - id: VDNpRv8da51NU8qZFC5zDWpF + title: Cashier + is_tip_eligible: true + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + version: 2 + - id: FjS8x95cqHiMenw4f1NAUH4P + title: Chef + is_tip_eligible: false + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + version: 1 + cursor: cursor + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + CreateJob: + path: /v2/team-members/jobs + method: POST + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Creates a job in a seller account. A job defines a title and tip + eligibility. Note that + + compensation is defined in a [job assignment](entity:JobAssignment) in a + team member's wage setting. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateJob + request: + name: CreateJobRequest + body: + properties: + job: + type: root.Job + docs: >- + The job to create. The `title` field is required and + `is_tip_eligible` defaults to true. + idempotency_key: + type: string + docs: >- + A unique identifier for the `CreateJob` request. Keys can be any + valid string, + + but must be unique for each request. For more information, see + + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). + validation: + minLength: 1 + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.CreateJobResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + job: + title: Cashier + is_tip_eligible: true + idempotency_key: idempotency-key-0 + response: + body: + job: + id: 1yJlHapkseYnNPETIU1B + title: Cashier + is_tip_eligible: true + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + version: 1 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + RetrieveJob: + path: /v2/team-members/jobs/{job_id} + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: Retrieves a specified job. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveJob + request: + name: RetrieveJobRequest + path-parameters: + job_id: + type: string + docs: The ID of the job to retrieve. + response: + docs: Success + type: root.RetrieveJobResponse + status-code: 200 + examples: + - path-parameters: + job_id: job_id + headers: + Square-Version: '2025-10-16' + response: + body: + job: + id: 1yJlHapkseYnNPETIU1B + title: Cashier 1 + is_tip_eligible: true + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + version: 2 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + UpdateJob: + path: /v2/team-members/jobs/{job_id} + method: PUT + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Updates the title or tip eligibility of a job. Changes to the title + propagate to all + + `JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference + the job ID. Changes to + + tip eligibility propagate to all `TeamMemberWage` objects that reference + the job ID. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateJob + request: + name: UpdateJobRequest + path-parameters: + job_id: + type: string + docs: The ID of the job to update. + body: + properties: + job: + type: root.Job + docs: >- + The job with the updated fields, either `title`, + `is_tip_eligible`, or both. Only changed fields need + + to be included in the request. Optionally include `version` to + enable optimistic concurrency control. + content-type: application/json + response: + docs: Success + type: root.UpdateJobResponse + status-code: 200 + examples: + - path-parameters: + job_id: job_id + headers: + Square-Version: '2025-10-16' + request: + job: + title: Cashier 1 + is_tip_eligible: true + response: + body: + job: + id: 1yJlHapkseYnNPETIU1B + title: Cashier 1 + is_tip_eligible: true + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-13T12:55:45Z' + version: 2 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/teamMembers.yml b/.mock/definition/teamMembers.yml new file mode 100644 index 00000000..a5c96534 --- /dev/null +++ b/.mock/definition/teamMembers.yml @@ -0,0 +1,789 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/team-members + method: POST + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Creates a single `TeamMember` object. The `TeamMember` object is + returned on successful creates. + + You must provide the following values in your request to this endpoint: + + - `given_name` + + - `family_name` + + + Learn about [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#createteammember). + source: + openapi: ../default/openapi/openapi.json + display-name: CreateTeamMember + request: + body: root.CreateTeamMemberRequest + content-type: application/json + response: + docs: Success + type: root.CreateTeamMemberResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: idempotency-key-0 + team_member: + reference_id: reference_id_1 + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@gmail.com + phone_number: '+14159283333' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - YSGH2WBKG94QZ + - GA2Y9HSJ8KRYT + wage_setting: + job_assignments: + - pay_type: SALARY + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + job_id: FjS8x95cqHiMenw4f1NAUH4P + - pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + response: + body: + team_member: + id: 1yJlHapkseYnNPETIU1B + reference_id: reference_id_1 + is_owner: false + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@example.com + phone_number: '+14159283333' + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - GA2Y9HSJ8KRYT + - YSGH2WBKG94QZ + wage_setting: + team_member_id: 1yJlHapkseYnNPETIU1B + job_assignments: + - job_title: Manager + pay_type: SALARY + hourly_rate: + amount: 1443 + currency: USD + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + job_id: FjS8x95cqHiMenw4f1NAUH4P + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchCreate: + path: /v2/team-members/bulk-create + method: POST + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Creates multiple `TeamMember` objects. The created `TeamMember` objects + are returned on successful creates. + + This process is non-transactional and processes as much of the request + as possible. If one of the creates in + + the request cannot be successfully processed, the request is not marked + as failed, but the body of the response + + contains explicit error information for the failed create. + + + Learn about [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#bulk-create-team-members). + source: + openapi: ../default/openapi/openapi.json + display-name: BulkCreateTeamMembers + request: + name: BatchCreateTeamMembersRequest + body: + properties: + team_members: + type: map + docs: >- + The data used to create the `TeamMember` objects. Each key is + the `idempotency_key` that maps to the + `CreateTeamMemberRequest`. + + The maximum number of create objects is 25. + + + If you include a team member's `wage_setting`, you must provide + `job_id` for each job assignment. To get job IDs, + + call [ListJobs](api-endpoint:Team-ListJobs). + content-type: application/json + response: + docs: Success + type: root.BatchCreateTeamMembersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + team_members: + idempotency-key-1: + team_member: + reference_id: reference_id_1 + given_name: Joe + family_name: Doe + email_address: joe_doe@gmail.com + phone_number: '+14159283333' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - YSGH2WBKG94QZ + - GA2Y9HSJ8KRYT + idempotency-key-2: + team_member: + reference_id: reference_id_2 + given_name: Jane + family_name: Smith + email_address: jane_smith@gmail.com + phone_number: '+14159223334' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + response: + body: + team_members: + idempotency-key-1: + team_member: + id: ywhG1qfIOoqsHfVRubFV + reference_id: reference_id_1 + is_owner: false + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@gmail.com + phone_number: '+14159283333' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - GA2Y9HSJ8KRYT + - YSGH2WBKG94QZ + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + idempotency-key-2: + team_member: + id: IF_Ncrg7fHhCqxVI9T6R + reference_id: reference_id_2 + is_owner: false + status: ACTIVE + given_name: Jane + family_name: Smith + email_address: jane_smith@gmail.com + phone_number: '+14159223334' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + batchUpdate: + path: /v2/team-members/bulk-update + method: POST + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Updates multiple `TeamMember` objects. The updated `TeamMember` objects + are returned on successful updates. + + This process is non-transactional and processes as much of the request + as possible. If one of the updates in + + the request cannot be successfully processed, the request is not marked + as failed, but the body of the response + + contains explicit error information for the failed update. + + Learn about [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#bulk-update-team-members). + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpdateTeamMembers + request: + name: BatchUpdateTeamMembersRequest + body: + properties: + team_members: + type: map + docs: >- + The data used to update the `TeamMember` objects. Each key is + the `team_member_id` that maps to the `UpdateTeamMemberRequest`. + + The maximum number of update objects is 25. + + + For each team member, include the fields to add, change, or + clear. Fields can be cleared using a null value. + + To update `wage_setting.job_assignments`, you must provide the + complete list of job assignments. If needed, + + call [ListJobs](api-endpoint:Team-ListJobs) to get the required + `job_id` values. + content-type: application/json + response: + docs: Success + type: root.BatchUpdateTeamMembersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + team_members: + AFMwA08kR-MIF-3Vs0OE: + team_member: + reference_id: reference_id_2 + is_owner: false + status: ACTIVE + given_name: Jane + family_name: Smith + email_address: jane_smith@gmail.com + phone_number: '+14159223334' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + fpgteZNMaf0qOK-a4t6P: + team_member: + reference_id: reference_id_1 + is_owner: false + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@gmail.com + phone_number: '+14159283333' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - YSGH2WBKG94QZ + - GA2Y9HSJ8KRYT + response: + body: + team_members: + AFMwA08kR-MIF-3Vs0OE: + team_member: + id: AFMwA08kR-MIF-3Vs0OE + reference_id: reference_id_2 + is_owner: false + status: ACTIVE + given_name: Jane + family_name: Smith + email_address: jane_smith@example.com + phone_number: '+14159223334' + created_at: '2020-03-24T18:14:00Z' + updated_at: '2020-03-24T18:18:00Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + fpgteZNMaf0qOK-a4t6P: + team_member: + id: fpgteZNMaf0qOK-a4t6P + reference_id: reference_id_1 + is_owner: false + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@example.com + phone_number: '+14159283333' + created_at: '2020-03-24T18:14:00Z' + updated_at: '2020-03-24T18:18:00Z' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - GA2Y9HSJ8KRYT + - YSGH2WBKG94QZ + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + search: + path: /v2/team-members/search + method: POST + auth: + - oauth2: + - EMPLOYEES_READ + docs: >- + Returns a paginated list of `TeamMember` objects for a business. + + The list can be filtered by location IDs, `ACTIVE` or `INACTIVE` status, + or whether + + the team member is the Square account owner. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchTeamMembers + request: + name: SearchTeamMembersRequest + body: + properties: + query: + type: optional + docs: The query parameters. + limit: + type: optional + docs: >- + The maximum number of `TeamMember` objects in a page (100 by + default). + validation: + min: 1 + max: 200 + cursor: + type: optional + docs: >- + The opaque cursor for fetching the next page. For more + information, see + + [pagination](https://developer.squareup.com/docs/working-with-apis/pagination). + content-type: application/json + response: + docs: Success + type: root.SearchTeamMembersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + location_ids: + - 0G5P3VGACMMQZ + status: ACTIVE + limit: 10 + response: + body: + team_members: + - id: '-3oZQKPKVk6gUXU_V5Qa' + reference_id: '12345678' + is_owner: false + status: ACTIVE + given_name: Johnny + family_name: Cash + email_address: johnny_cash@squareup.com + phone_number: phone_number + created_at: '2019-07-10T17:26:48Z' + updated_at: '2020-04-28T21:49:28Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + wage_setting: + team_member_id: '-3oZQKPKVk6gUXU_V5Qa' + job_assignments: + - job_title: Manager + pay_type: SALARY + hourly_rate: + amount: 1443 + currency: USD + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + job_id: FjS8x95cqHiMenw4f1NAUH4P + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + - id: 1AVJj0DjkzbmbJw5r4KK + reference_id: abcded + is_owner: false + status: ACTIVE + given_name: Lombard + family_name: Smith + email_address: email_address + phone_number: '+14155552671' + created_at: '2020-03-24T18:14:01Z' + updated_at: '2020-06-09T17:38:05Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + wage_setting: + team_member_id: 1AVJj0DjkzbmbJw5r4KK + job_assignments: + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2400 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 2 + created_at: '2020-03-24T18:14:01Z' + updated_at: '2020-06-09T17:38:05Z' + - id: 2JCmiJol_KKFs9z2Evim + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Monica + family_name: Sway + email_address: email_address + phone_number: phone_number + created_at: '2020-03-24T01:09:25Z' + updated_at: '2020-03-24T01:11:25Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + wage_setting: + team_member_id: 2JCmiJol_KKFs9z2Evim + job_assignments: + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2400 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2020-03-24T01:09:25Z' + updated_at: '2020-03-24T01:09:25Z' + - id: 4uXcJQSLtbk3F0UQHFNQ + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Elton + family_name: Ipsum + email_address: email_address + phone_number: phone_number + created_at: '2020-03-24T01:09:23Z' + updated_at: '2020-03-24T01:15:23Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + - id: 5CoUpyrw1YwGWcRd-eDL + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Steven + family_name: Lo + email_address: email_address + phone_number: phone_number + created_at: '2020-03-24T01:09:23Z' + updated_at: '2020-03-24T01:19:23Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + - id: 5MRPTTp8MMBLVSmzrGha + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Patrick + family_name: Steward + email_address: email_address + phone_number: '+14155552671' + created_at: '2020-03-24T18:14:03Z' + updated_at: '2020-03-24T18:18:03Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + wage_setting: + team_member_id: 5MRPTTp8MMBLVSmzrGha + job_assignments: + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2020-03-24T18:14:03Z' + updated_at: '2020-03-24T18:14:03Z' + - id: 7F5ZxsfRnkexhu1PTbfh + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Ivy + family_name: Manny + email_address: email_address + phone_number: phone_number + created_at: '2020-03-24T01:09:25Z' + updated_at: '2020-03-24T01:09:25Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + - id: 808X9HR72yKvVaigQXf4 + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: John + family_name: Smith + email_address: john_smith@example.com + phone_number: '+14155552671' + created_at: '2020-03-24T18:14:02Z' + updated_at: '2020-03-24T18:14:02Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + - id: 9MVDVoY4hazkWKGo_OuZ + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Robert + family_name: Wen + email_address: r_wen@example.com + phone_number: '+14155552671' + created_at: '2020-03-24T18:14:00Z' + updated_at: '2020-03-24T18:14:00Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + - id: 9UglUjOXQ13-hMFypCft + reference_id: reference_id + is_owner: false + status: ACTIVE + given_name: Ashley + family_name: Simpson + email_address: asimpson@example.com + phone_number: '+14155552671' + created_at: '2020-03-24T18:14:00Z' + updated_at: '2020-03-24T18:18:00Z' + assigned_locations: + assignment_type: ALL_CURRENT_AND_FUTURE_LOCATIONS + wage_setting: + team_member_id: 9UglUjOXQ13-hMFypCft + job_assignments: + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2020-03-24T18:14:00Z' + updated_at: '2020-03-24T18:14:03Z' + cursor: N:9UglUjOXQ13-hMFypCft + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/team-members/{team_member_id} + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: >- + Retrieves a `TeamMember` object for the given `TeamMember.id`. + + Learn about [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#retrieve-a-team-member). + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveTeamMember + request: + name: GetTeamMembersRequest + path-parameters: + team_member_id: + type: string + docs: The ID of the team member to retrieve. + response: + docs: Success + type: root.GetTeamMemberResponse + status-code: 200 + examples: + - path-parameters: + team_member_id: team_member_id + headers: + Square-Version: '2025-10-16' + response: + body: + team_member: + id: 1yJlHapkseYnNPETIU1B + reference_id: reference_id_1 + is_owner: false + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@example.com + phone_number: '+14159283333' + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-15T17:38:05Z' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - GA2Y9HSJ8KRYT + - YSGH2WBKG94QZ + wage_setting: + team_member_id: 1yJlHapkseYnNPETIU1B + job_assignments: + - job_title: Manager + pay_type: SALARY + hourly_rate: + amount: 1443 + currency: USD + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + job_id: FjS8x95cqHiMenw4f1NAUH4P + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/team-members/{team_member_id} + method: PUT + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Updates a single `TeamMember` object. The `TeamMember` object is + returned on successful updates. + + Learn about [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#update-a-team-member). + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateTeamMember + request: + body: root.UpdateTeamMemberRequest + path-parameters: + team_member_id: + type: string + docs: The ID of the team member to update. + name: UpdateTeamMembersRequest + content-type: application/json + response: + docs: Success + type: root.UpdateTeamMemberResponse + status-code: 200 + examples: + - path-parameters: + team_member_id: team_member_id + headers: + Square-Version: '2025-10-16' + request: + team_member: + reference_id: reference_id_1 + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@gmail.com + phone_number: '+14159283333' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - YSGH2WBKG94QZ + - GA2Y9HSJ8KRYT + wage_setting: + job_assignments: + - pay_type: SALARY + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + job_id: FjS8x95cqHiMenw4f1NAUH4P + - pay_type: HOURLY + hourly_rate: + amount: 1200 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + response: + body: + team_member: + id: 1yJlHapkseYnNPETIU1B + reference_id: reference_id_1 + is_owner: false + status: ACTIVE + given_name: Joe + family_name: Doe + email_address: joe_doe@example.com + phone_number: '+14159283333' + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-15T17:38:05Z' + assigned_locations: + assignment_type: EXPLICIT_LOCATIONS + location_ids: + - GA2Y9HSJ8KRYT + - YSGH2WBKG94QZ + wage_setting: + team_member_id: 1yJlHapkseYnNPETIU1B + job_assignments: + - job_title: Manager + pay_type: SALARY + hourly_rate: + amount: 1443 + currency: USD + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + job_id: FjS8x95cqHiMenw4f1NAUH4P + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 1200 + currency: USD + job_id: VDNpRv8da51NU8qZFC5zDWpF + is_overtime_exempt: true + version: 1 + created_at: '2021-06-11T22:55:45Z' + updated_at: '2021-06-11T22:55:45Z' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/teamMembers/wageSetting.yml b/.mock/definition/teamMembers/wageSetting.yml new file mode 100644 index 00000000..3f99fb89 --- /dev/null +++ b/.mock/definition/teamMembers/wageSetting.yml @@ -0,0 +1,178 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v2/team-members/{team_member_id}/wage-setting + method: GET + auth: + - oauth2: + - EMPLOYEES_READ + docs: >- + Retrieves a `WageSetting` object for a team member specified + + by `TeamMember.id`. For more information, see + + [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#retrievewagesetting). + + + Square recommends using + [RetrieveTeamMember](api-endpoint:Team-RetrieveTeamMember) or + [SearchTeamMembers](api-endpoint:Team-SearchTeamMembers) + + to get this information directly from the `TeamMember.wage_setting` + field. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveWageSetting + request: + name: GetWageSettingRequest + path-parameters: + team_member_id: + type: string + docs: The ID of the team member for which to retrieve the wage setting. + response: + docs: Success + type: root.GetWageSettingResponse + status-code: 200 + examples: + - path-parameters: + team_member_id: team_member_id + headers: + Square-Version: '2025-10-16' + response: + body: + wage_setting: + team_member_id: 1yJlHapkseYnNPETIU1B + job_assignments: + - job_title: Manager + pay_type: SALARY + hourly_rate: + amount: 2164 + currency: USD + annual_rate: + amount: 4500000 + currency: USD + weekly_hours: 40 + is_overtime_exempt: false + version: 1 + created_at: '2020-06-11T23:01:21+00:00' + updated_at: '2020-06-11T23:01:21+00:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/team-members/{team_member_id}/wage-setting + method: PUT + auth: + - oauth2: + - EMPLOYEES_WRITE + docs: >- + Creates or updates a `WageSetting` object. The object is created if a + + `WageSetting` with the specified `team_member_id` doesn't exist. + Otherwise, + + it fully replaces the `WageSetting` object for the team member. + + The `WageSetting` is returned on a successful update. For more + information, see + + [Troubleshooting the Team + API](https://developer.squareup.com/docs/team/troubleshooting#create-or-update-a-wage-setting). + + + Square recommends using + [CreateTeamMember](api-endpoint:Team-CreateTeamMember) or + [UpdateTeamMember](api-endpoint:Team-UpdateTeamMember) + + to manage the `TeamMember.wage_setting` field directly. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateWageSetting + request: + name: UpdateWageSettingRequest + path-parameters: + team_member_id: + type: string + docs: >- + The ID of the team member for which to update the `WageSetting` + object. + body: + properties: + wage_setting: + type: root.WageSetting + docs: >- + The complete `WageSetting` object. For all job assignments, + specify one of the following: + + - `job_id` (recommended) - If needed, call + [ListJobs](api-endpoint:Team-ListJobs) to get a list of all + jobs. + + 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. + content-type: application/json + response: + docs: Success + type: root.UpdateWageSettingResponse + status-code: 200 + examples: + - path-parameters: + team_member_id: team_member_id + headers: + Square-Version: '2025-10-16' + request: + wage_setting: + job_assignments: + - job_title: Manager + pay_type: SALARY + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + is_overtime_exempt: true + response: + body: + wage_setting: + team_member_id: '-3oZQKPKVk6gUXU_V5Qa' + job_assignments: + - job_title: Manager + pay_type: SALARY + hourly_rate: + amount: 1443 + currency: USD + annual_rate: + amount: 3000000 + currency: USD + weekly_hours: 40 + - job_title: Cashier + pay_type: HOURLY + hourly_rate: + amount: 2000 + currency: USD + is_overtime_exempt: true + version: 1 + created_at: '2019-07-10T17:26:48+00:00' + updated_at: '2020-06-11T23:12:04+00:00' + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/terminal.yml b/.mock/definition/terminal.yml new file mode 100644 index 00000000..7b99750d --- /dev/null +++ b/.mock/definition/terminal.yml @@ -0,0 +1,241 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + DismissTerminalAction: + path: /v2/terminals/actions/{action_id}/dismiss + method: POST + auth: + - oauth2: [] + docs: >- + Dismisses a Terminal action request if the status and type of the + request permits it. + + + See [Link and Dismiss + Actions](https://developer.squareup.com/docs/terminal-api/advanced-features/custom-workflows/link-and-dismiss-actions) + for more details. + source: + openapi: ../default/openapi/openapi.json + display-name: DismissTerminalAction + request: + name: DismissTerminalActionRequest + path-parameters: + action_id: + type: string + docs: >- + Unique ID for the `TerminalAction` associated with the action to + be dismissed. + response: + docs: Success + type: root.DismissTerminalActionResponse + status-code: 200 + examples: + - path-parameters: + action_id: action_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + action: + id: termapia:abcdefg1234567 + device_id: DEVICE_ID + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + created_at: '2021-07-28T23:22:07.476Z' + updated_at: '2021-07-28T23:22:29.511Z' + app_id: APP_ID + location_id: location_id + type: CONFIRMATION + qr_code_options: + title: title + body: body + barcode_contents: barcode_contents + save_card_options: + customer_id: customer_id + card_id: card_id + reference_id: reference_id + signature_options: + title: title + body: body + signature: + - {} + confirmation_options: + title: Marketing communications + body: >- + I agree to receive promotional emails about future events + and activities. + agree_button_text: Agree + disagree_button_text: Decline + decision: + has_agreed: true + receipt_options: + payment_id: payment_id + print_only: true + is_duplicate: true + data_collection_options: + title: title + body: body + input_type: EMAIL + select_options: + title: title + body: body + options: + - reference_id: reference_id + title: title + selected_option: + reference_id: reference_id + title: title + device_metadata: + battery_percentage: battery_percentage + charging_state: charging_state + location_id: location_id + merchant_id: merchant_id + network_connection_type: network_connection_type + payment_region: payment_region + serial_number: serial_number + os_version: os_version + app_version: app_version + wifi_network_name: wifi_network_name + wifi_network_strength: wifi_network_strength + ip_address: ip_address + await_next_action: true + await_next_action_duration: PT5M + DismissTerminalCheckout: + path: /v2/terminals/checkouts/{checkout_id}/dismiss + method: POST + auth: + - oauth2: [] + docs: >- + Dismisses a Terminal checkout request if the status and type of the + request permits it. + source: + openapi: ../default/openapi/openapi.json + display-name: DismissTerminalCheckout + request: + name: DismissTerminalCheckoutRequest + path-parameters: + checkout_id: + type: string + docs: >- + Unique ID for the `TerminalCheckout` associated with the checkout + to be dismissed. + response: + docs: Success + type: root.DismissTerminalCheckoutResponse + status-code: 200 + examples: + - path-parameters: + checkout_id: checkout_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + checkout: + id: LmZEKbo3SBfqO + amount_money: + amount: 2610 + currency: USD + reference_id: reference_id + note: note + order_id: order_id + payment_options: + autocomplete: true + delay_duration: delay_duration + accept_partial_authorization: true + delay_action: CANCEL + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + skip_receipt_screen: false + collect_signature: true + tip_settings: + allow_tipping: true + separate_tip_screen: true + custom_tip_field: false + show_itemized_cart: true + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + payment_ids: + - D7vLJqMkvSoAlX4yyFzUitOy4EPZY + created_at: '2023-11-29T14:59:50.682Z' + updated_at: '2023-11-29T15:00:18.936Z' + app_id: APP_ID + location_id: LOCATION_ID + payment_type: CARD_PRESENT + team_member_id: team_member_id + customer_id: customer_id + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + statement_description_identifier: statement_description_identifier + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + DismissTerminalRefund: + path: /v2/terminals/refunds/{terminal_refund_id}/dismiss + method: POST + auth: + - oauth2: [] + docs: >- + Dismisses a Terminal refund request if the status and type of the + request permits it. + source: + openapi: ../default/openapi/openapi.json + display-name: DismissTerminalRefund + request: + name: DismissTerminalRefundRequest + path-parameters: + terminal_refund_id: + type: string + docs: >- + Unique ID for the `TerminalRefund` associated with the refund to + be dismissed. + response: + docs: Success + type: root.DismissTerminalRefundResponse + status-code: 200 + examples: + - path-parameters: + terminal_refund_id: terminal_refund_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refund: + id: vjkNb2HD-xq5kiWWiJ7RhwrQnkxIn2N0l1nPZY + refund_id: refund_id + payment_id: xq5kiWWiJ7RhwrQnkxIn2N0l1nPZY + order_id: s8OMhQcpEp1b61YywlccSHWqUaQZY + amount_money: + amount: 111 + currency: CAD + reason: Returning item + device_id: 47776348fd8b32b9 + deadline_duration: PT5M + status: IN_PROGRESS + cancel_reason: BUYER_CANCELED + created_at: '2023-11-30T16:16:39.299Z' + updated_at: '2023-11-30T16:16:57.863Z' + app_id: APP_ID + location_id: location_id + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/terminal/actions.yml b/.mock/definition/terminal/actions.yml new file mode 100644 index 00000000..04084427 --- /dev/null +++ b/.mock/definition/terminal/actions.yml @@ -0,0 +1,464 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/terminals/actions + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: Creates a Terminal action request and sends it to the specified device. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateTerminalAction + request: + name: CreateTerminalActionRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this `CreateAction` request. + Keys can be any valid string + + but must be unique for every `CreateAction` request. + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more + + information. + validation: + minLength: 1 + maxLength: 64 + action: + type: root.TerminalAction + docs: The Action to create. + content-type: application/json + response: + docs: Success + type: root.CreateTerminalActionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e + action: + device_id: '{{DEVICE_ID}}' + deadline_duration: PT5M + type: SAVE_CARD + save_card_options: + customer_id: '{{CUSTOMER_ID}}' + reference_id: user-id-1 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + action: + id: termapia:jveJIAkkAjILHkdCE + device_id: DEVICE_ID + deadline_duration: PT5M + status: PENDING + cancel_reason: BUYER_CANCELED + created_at: '2021-07-28T23:22:07.476Z' + updated_at: '2021-07-28T23:22:07.476Z' + app_id: APP_ID + location_id: LOCATION_ID + type: SAVE_CARD + qr_code_options: + title: title + body: body + barcode_contents: barcode_contents + save_card_options: + customer_id: CUSTOMER_ID + card_id: card_id + reference_id: user-id-1 + signature_options: + title: title + body: body + signature: + - {} + confirmation_options: + title: title + body: body + agree_button_text: agree_button_text + disagree_button_text: disagree_button_text + receipt_options: + payment_id: payment_id + print_only: true + is_duplicate: true + data_collection_options: + title: title + body: body + input_type: EMAIL + select_options: + title: title + body: body + options: + - reference_id: reference_id + title: title + selected_option: + reference_id: reference_id + title: title + device_metadata: + battery_percentage: battery_percentage + charging_state: charging_state + location_id: location_id + merchant_id: merchant_id + network_connection_type: network_connection_type + payment_region: payment_region + serial_number: serial_number + os_version: os_version + app_version: app_version + wifi_network_name: wifi_network_name + wifi_network_strength: wifi_network_strength + ip_address: ip_address + await_next_action: true + await_next_action_duration: await_next_action_duration + search: + path: /v2/terminals/actions/search + method: POST + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves a filtered list of Terminal action requests created by the + account making the request. Terminal action requests are available for + 30 days. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchTerminalActions + request: + name: SearchTerminalActionsRequest + body: + properties: + query: + type: optional + docs: >- + Queries terminal actions based on given conditions and sort + order. + + Leaving this unset will return all actions with the default sort + order. + cursor: + type: optional + docs: >- + 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 + + information. + limit: + type: optional + docs: Limit the number of results returned for a single request. + validation: + min: 1 + max: 100 + content-type: application/json + response: + docs: Success + type: root.SearchTerminalActionsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + created_at: + start_at: '2022-04-01T00:00:00.000Z' + sort: + sort_order: DESC + limit: 2 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + action: + - id: termapia:oBGWlAats8xWCiCE + device_id: DEVICE_ID + deadline_duration: PT5M + status: IN_PROGRESS + cancel_reason: BUYER_CANCELED + created_at: '2022-04-08T15:14:04.895Z' + updated_at: '2022-04-08T15:14:05.446Z' + app_id: APP_ID + location_id: LOCATION_ID + type: SAVE_CARD + qr_code_options: + title: title + body: body + barcode_contents: barcode_contents + save_card_options: + customer_id: CUSTOMER_ID + reference_id: user-id-1 + signature_options: + title: title + body: body + confirmation_options: + title: title + body: body + agree_button_text: agree_button_text + receipt_options: + payment_id: payment_id + data_collection_options: + title: title + body: body + input_type: EMAIL + select_options: + title: title + body: body + options: + - reference_id: reference_id + title: title + await_next_action: true + await_next_action_duration: await_next_action_duration + - id: termapia:K2NY2YSSml3lTiCE + device_id: DEVICE_ID + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + created_at: '2022-04-08T15:14:01.210Z' + updated_at: '2022-04-08T15:14:09.861Z' + app_id: APP_ID + location_id: LOCATION_ID + type: SAVE_CARD + qr_code_options: + title: title + body: body + barcode_contents: barcode_contents + save_card_options: + customer_id: CUSTOMER_ID + card_id: ccof:CARD_ID + reference_id: user-id-1 + signature_options: + title: title + body: body + confirmation_options: + title: title + body: body + agree_button_text: agree_button_text + receipt_options: + payment_id: payment_id + data_collection_options: + title: title + body: body + input_type: EMAIL + select_options: + title: title + body: body + options: + - reference_id: reference_id + title: title + await_next_action: true + await_next_action_duration: await_next_action_duration + cursor: CURSOR + get: + path: /v2/terminals/actions/{action_id} + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves a Terminal action request by `action_id`. Terminal action + requests are available for 30 days. + source: + openapi: ../default/openapi/openapi.json + display-name: GetTerminalAction + request: + name: GetActionsRequest + path-parameters: + action_id: + type: string + docs: Unique ID for the desired `TerminalAction`. + response: + docs: Success + type: root.GetTerminalActionResponse + status-code: 200 + examples: + - path-parameters: + action_id: action_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + action: + id: termapia:jveJIAkkAjILHkdCE + device_id: DEVICE_ID + deadline_duration: PT5M + status: IN_PROGRESS + cancel_reason: BUYER_CANCELED + created_at: '2021-07-28T23:22:07.476Z' + updated_at: '2021-07-28T23:22:08.301Z' + app_id: APP_ID + location_id: LOCATION_ID + type: SAVE_CARD + qr_code_options: + title: title + body: body + barcode_contents: barcode_contents + save_card_options: + customer_id: CUSTOMER_ID + card_id: card_id + reference_id: user-id-1 + signature_options: + title: title + body: body + signature: + - {} + confirmation_options: + title: title + body: body + agree_button_text: agree_button_text + disagree_button_text: disagree_button_text + receipt_options: + payment_id: payment_id + print_only: true + is_duplicate: true + data_collection_options: + title: title + body: body + input_type: EMAIL + select_options: + title: title + body: body + options: + - reference_id: reference_id + title: title + selected_option: + reference_id: reference_id + title: title + device_metadata: + battery_percentage: battery_percentage + charging_state: charging_state + location_id: location_id + merchant_id: merchant_id + network_connection_type: network_connection_type + payment_region: payment_region + serial_number: serial_number + os_version: os_version + app_version: app_version + wifi_network_name: wifi_network_name + wifi_network_strength: wifi_network_strength + ip_address: ip_address + await_next_action: true + await_next_action_duration: await_next_action_duration + cancel: + path: /v2/terminals/actions/{action_id}/cancel + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Cancels a Terminal action request if the status of the request permits + it. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelTerminalAction + request: + name: CancelActionsRequest + path-parameters: + action_id: + type: string + docs: Unique ID for the desired `TerminalAction`. + response: + docs: Success + type: root.CancelTerminalActionResponse + status-code: 200 + examples: + - path-parameters: + action_id: action_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + action: + id: termapia:jveJIAkkAjILHkdCE + device_id: DEVICE_ID + deadline_duration: PT5M + status: CANCELED + cancel_reason: SELLER_CANCELED + created_at: '2021-07-28T23:22:07.476Z' + updated_at: '2021-07-28T23:22:29.511Z' + app_id: APP_ID + location_id: LOCATION_ID + type: SAVE_CARD + qr_code_options: + title: title + body: body + barcode_contents: barcode_contents + save_card_options: + customer_id: CUSTOMER_ID + card_id: card_id + reference_id: user-id-1 + signature_options: + title: title + body: body + signature: + - {} + confirmation_options: + title: title + body: body + agree_button_text: agree_button_text + disagree_button_text: disagree_button_text + receipt_options: + payment_id: payment_id + print_only: true + is_duplicate: true + data_collection_options: + title: title + body: body + input_type: EMAIL + select_options: + title: title + body: body + options: + - reference_id: reference_id + title: title + selected_option: + reference_id: reference_id + title: title + device_metadata: + battery_percentage: battery_percentage + charging_state: charging_state + location_id: location_id + merchant_id: merchant_id + network_connection_type: network_connection_type + payment_region: payment_region + serial_number: serial_number + os_version: os_version + app_version: app_version + wifi_network_name: wifi_network_name + wifi_network_strength: wifi_network_strength + ip_address: ip_address + await_next_action: true + await_next_action_duration: await_next_action_duration + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/terminal/checkouts.yml b/.mock/definition/terminal/checkouts.yml new file mode 100644 index 00000000..fa5acf5d --- /dev/null +++ b/.mock/definition/terminal/checkouts.yml @@ -0,0 +1,370 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/terminals/checkouts + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Creates a Terminal checkout request and sends it to the specified device + to take a payment + + for the requested amount. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateTerminalCheckout + request: + name: CreateTerminalCheckoutRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this `CreateCheckout` request. + Keys can be any valid string but + + must be unique for every `CreateCheckout` request. + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 64 + checkout: + type: root.TerminalCheckout + docs: The checkout to create. + content-type: application/json + response: + docs: Success + type: root.CreateTerminalCheckoutResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 28a0c3bc-7839-11ea-bc55-0242ac130003 + checkout: + amount_money: + amount: 2610 + currency: USD + reference_id: id11572 + note: A brief note + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + checkout: + id: 08YceKh7B3ZqO + amount_money: + amount: 2610 + currency: USD + reference_id: id11572 + note: A brief note + order_id: order_id + payment_options: + autocomplete: true + delay_duration: delay_duration + accept_partial_authorization: true + delay_action: CANCEL + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + skip_receipt_screen: false + collect_signature: true + tip_settings: + allow_tipping: false + show_itemized_cart: true + deadline_duration: PT5M + status: PENDING + cancel_reason: BUYER_CANCELED + payment_ids: + - payment_ids + created_at: '2020-04-06T16:39:32.545Z' + updated_at: '2020-04-06T16:39:32.545Z' + app_id: APP_ID + location_id: LOCATION_ID + payment_type: CARD_PRESENT + team_member_id: team_member_id + customer_id: customer_id + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + statement_description_identifier: statement_description_identifier + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + search: + path: /v2/terminals/checkouts/search + method: POST + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Returns a filtered list of Terminal checkout requests created by the + application making the request. Only Terminal checkout requests created + for the merchant scoped to the OAuth token are returned. Terminal + checkout requests are available for 30 days. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchTerminalCheckouts + request: + name: SearchTerminalCheckoutsRequest + body: + properties: + query: + type: optional + docs: >- + Queries Terminal checkouts based on given conditions and the + sort order. + + Leaving these unset returns all checkouts with the default sort + order. + cursor: + type: optional + docs: >- + 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. + limit: + type: optional + docs: Limits the number of results returned for a single request. + validation: + min: 1 + max: 100 + content-type: application/json + response: + docs: Success + type: root.SearchTerminalCheckoutsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + status: COMPLETED + limit: 2 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + checkouts: + - id: tsQPvzwBpMqqO + amount_money: + amount: 2610 + currency: USD + reference_id: id14467 + note: A brief note + order_id: order_id + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + skip_receipt_screen: false + tip_settings: + allow_tipping: false + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + payment_ids: + - rXnhZzywrEk4vR6pw76fPZfgvaB + created_at: '2020-03-31T18:13:15.921Z' + updated_at: '2020-03-31T18:13:52.725Z' + app_id: APP_ID + location_id: location_id + payment_type: CARD_PRESENT + team_member_id: team_member_id + customer_id: customer_id + statement_description_identifier: statement_description_identifier + - id: XlOPTgcEhrbqO + amount_money: + amount: 2610 + currency: USD + reference_id: id41623 + note: A brief note + order_id: order_id + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + skip_receipt_screen: true + tip_settings: + allow_tipping: false + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + payment_ids: + - VYBF861PaoKPP7Pih0TlbZiNvaB + created_at: '2020-03-31T18:08:31.882Z' + updated_at: '2020-03-31T18:08:41.635Z' + app_id: APP_ID + location_id: location_id + payment_type: CARD_PRESENT + team_member_id: team_member_id + customer_id: customer_id + statement_description_identifier: statement_description_identifier + cursor: RiTJqBoTuXlbLmmrPvEkX9iG7XnQ4W4RjGnH + get: + path: /v2/terminals/checkouts/{checkout_id} + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves a Terminal checkout request by `checkout_id`. Terminal + checkout requests are available for 30 days. + source: + openapi: ../default/openapi/openapi.json + display-name: GetTerminalCheckout + request: + name: GetCheckoutsRequest + path-parameters: + checkout_id: + type: string + docs: The unique ID for the desired `TerminalCheckout`. + response: + docs: Success + type: root.GetTerminalCheckoutResponse + status-code: 200 + examples: + - path-parameters: + checkout_id: checkout_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + checkout: + id: 08YceKh7B3ZqO + amount_money: + amount: 2610 + currency: USD + reference_id: id11572 + note: A brief note + order_id: order_id + payment_options: + autocomplete: true + delay_duration: delay_duration + accept_partial_authorization: true + delay_action: CANCEL + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + skip_receipt_screen: false + collect_signature: true + tip_settings: + allow_tipping: false + show_itemized_cart: true + deadline_duration: PT5M + status: IN_PROGRESS + cancel_reason: BUYER_CANCELED + payment_ids: + - payment_ids + created_at: '2020-04-06T16:39:32.545Z' + updated_at: 2020-04-06T16:39:323.001Z + app_id: APP_ID + location_id: LOCATION_ID + payment_type: CARD_PRESENT + team_member_id: team_member_id + customer_id: customer_id + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + statement_description_identifier: statement_description_identifier + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + cancel: + path: /v2/terminals/checkouts/{checkout_id}/cancel + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Cancels a Terminal checkout request if the status of the request permits + it. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelTerminalCheckout + request: + name: CancelCheckoutsRequest + path-parameters: + checkout_id: + type: string + docs: The unique ID for the desired `TerminalCheckout`. + response: + docs: Success + type: root.CancelTerminalCheckoutResponse + status-code: 200 + examples: + - path-parameters: + checkout_id: checkout_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + checkout: + id: S1yDlPQx7slqO + amount_money: + amount: 123 + currency: USD + reference_id: id36815 + note: note + order_id: order_id + payment_options: + autocomplete: true + delay_duration: delay_duration + accept_partial_authorization: true + delay_action: CANCEL + device_options: + device_id: dbb5d83a-7838-11ea-bc55-0242ac130003 + skip_receipt_screen: true + collect_signature: true + tip_settings: + allow_tipping: true + show_itemized_cart: true + deadline_duration: PT5M + status: CANCELED + cancel_reason: SELLER_CANCELED + payment_ids: + - payment_ids + created_at: '2020-03-16T15:31:19.934Z' + updated_at: '2020-03-16T15:31:45.787Z' + app_id: APP_ID + location_id: LOCATION_ID + payment_type: CARD_PRESENT + team_member_id: team_member_id + customer_id: customer_id + app_fee_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + statement_description_identifier: statement_description_identifier + tip_money: + amount: 1000000 + currency: UNKNOWN_CURRENCY + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/terminal/refunds.yml b/.mock/definition/terminal/refunds.yml new file mode 100644 index 00000000..d5b842ba --- /dev/null +++ b/.mock/definition/terminal/refunds.yml @@ -0,0 +1,269 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/terminals/refunds + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Creates a request to refund an Interac payment completed on a Square + Terminal. Refunds for Interac payments on a Square Terminal are + supported only for Interac debit cards in Canada. Other refunds for + Terminal payments should use the Refunds API. For more information, see + [Refunds API](api:Refunds). + source: + openapi: ../default/openapi/openapi.json + display-name: CreateTerminalRefund + request: + name: CreateTerminalRefundRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this `CreateRefund` request. + Keys can be any valid string but + + must be unique for every `CreateRefund` request. + + + See [Idempotency + keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + for more information. + validation: + minLength: 1 + maxLength: 64 + refund: + type: optional + docs: The refund to create. + content-type: application/json + response: + docs: Success + type: root.CreateTerminalRefundResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 402a640b-b26f-401f-b406-46f839590c04 + refund: + payment_id: 5O5OvgkcNUhl7JBuINflcjKqUzXZY + amount_money: + amount: 111 + currency: CAD + reason: Returning items + device_id: f72dfb8e-4d65-4e56-aade-ec3fb8d33291 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refund: + id: 009DP5HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY + refund_id: refund_id + payment_id: 5O5OvgkcNUhl7JBuINflcjKqUzXZY + order_id: kcuKDKreRaI4gF4TjmEgZjHk8Z7YY + amount_money: + amount: 111 + currency: CAD + reason: Returning items + device_id: f72dfb8e-4d65-4e56-aade-ec3fb8d33291 + deadline_duration: PT5M + status: PENDING + cancel_reason: BUYER_CANCELED + created_at: '2020-09-29T15:21:46.771Z' + updated_at: '2020-09-29T15:21:46.771Z' + app_id: sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ + location_id: 76C9W6K8CNNQ5 + search: + path: /v2/terminals/refunds/search + method: POST + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves a filtered list of Interac Terminal refund requests created by + the seller making the request. Terminal refund requests are available + for 30 days. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchTerminalRefunds + request: + name: SearchTerminalRefundsRequest + body: + properties: + query: + type: optional + docs: >- + 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. + cursor: + type: optional + docs: >- + 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. + limit: + type: optional + docs: Limits the number of results returned for a single request. + validation: + min: 1 + max: 100 + content-type: application/json + response: + docs: Success + type: root.SearchTerminalRefundsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + status: COMPLETED + limit: 1 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refunds: + - id: 009DP5HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY + refund_id: >- + 5O5OvgkcNUhl7JBuINflcjKqUzXZY_43Q4iGp7sNeATiWrUruA1EYeMRUXaddXXlDDJ1EQLvb + payment_id: 5O5OvgkcNUhl7JBuINflcjKqUzXZY + order_id: kcuKDKreRaI4gF4TjmEgZjHk8Z7YY + amount_money: + amount: 111 + currency: CAD + reason: Returning item + device_id: f72dfb8e-4d65-4e56-aade-ec3fb8d33291 + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + created_at: '2020-09-29T15:21:46.771Z' + updated_at: '2020-09-29T15:21:48.675Z' + app_id: sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ + location_id: 76C9W6K8CNNQ5 + cursor: cursor + get: + path: /v2/terminals/refunds/{terminal_refund_id} + method: GET + auth: + - oauth2: + - PAYMENTS_READ + docs: >- + Retrieves an Interac Terminal refund object by ID. Terminal refund + objects are available for 30 days. + source: + openapi: ../default/openapi/openapi.json + display-name: GetTerminalRefund + request: + name: GetRefundsRequest + path-parameters: + terminal_refund_id: + type: string + docs: The unique ID for the desired `TerminalRefund`. + response: + docs: Success + type: root.GetTerminalRefundResponse + status-code: 200 + examples: + - path-parameters: + terminal_refund_id: terminal_refund_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refund: + id: 009DP5HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY + refund_id: >- + 5O5OvgkcNUhl7JBuINflcjKqUzXZY_43Q4iGp7sNeATiWrUruA1EYeMRUXaddXXlDDJ1EQLvb + payment_id: 5O5OvgkcNUhl7JBuINflcjKqUzXZY + order_id: kcuKDKreRaI4gF4TjmEgZjHk8Z7YY + amount_money: + amount: 111 + currency: CAD + reason: Returning item + device_id: f72dfb8e-4d65-4e56-aade-ec3fb8d33291 + deadline_duration: PT5M + status: COMPLETED + cancel_reason: BUYER_CANCELED + created_at: '2020-09-29T15:21:46.771Z' + updated_at: '2020-09-29T15:21:48.675Z' + app_id: sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ + location_id: 76C9W6K8CNNQ5 + cancel: + path: /v2/terminals/refunds/{terminal_refund_id}/cancel + method: POST + auth: + - oauth2: + - PAYMENTS_WRITE + docs: >- + Cancels an Interac Terminal refund request by refund request ID if the + status of the request permits it. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelTerminalRefund + request: + name: CancelRefundsRequest + path-parameters: + terminal_refund_id: + type: string + docs: The unique ID for the desired `TerminalRefund`. + response: + docs: Success + type: root.CancelTerminalRefundResponse + status-code: 200 + examples: + - path-parameters: + terminal_refund_id: terminal_refund_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + refund: + id: g6ycb6HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY + refund_id: refund_id + payment_id: 5O5OvgkcNUhl7JBuINflcjKqUzXZY + order_id: kcuKDKreRaI4gF4TjmEgZjHk8Z7YY + amount_money: + amount: 100 + currency: CAD + reason: reason + device_id: 42690809-faa2-4701-a24b-19d3d34c9aaa + deadline_duration: PT5M + status: CANCELED + cancel_reason: SELLER_CANCELED + created_at: '2020-10-21T22:47:23.241Z' + updated_at: '2020-10-21T22:47:30.096Z' + app_id: sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ + location_id: 76C9W6K8CNNQ5 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/transferOrders.yml b/.mock/definition/transferOrders.yml new file mode 100644 index 00000000..251cdeb3 --- /dev/null +++ b/.mock/definition/transferOrders.yml @@ -0,0 +1,807 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v2/transfer-orders + method: POST + auth: + - oauth2: + - INVENTORY_READ + - INVENTORY_WRITE + docs: >- + Creates a new transfer order in [DRAFT](entity:TransferOrderStatus) + status. A transfer order represents the intent + + to move [CatalogItemVariation](entity:CatalogItemVariation)s from one + [Location](entity:Location) to another. + + The source and destination locations must be different and must belong + to your Square account. + + + In [DRAFT](entity:TransferOrderStatus) status, you can: + + - Add or remove items + + - Modify quantities + + - Update shipping information + + - Delete the entire order via + [DeleteTransferOrder](api-endpoint:TransferOrders-DeleteTransferOrder) + + + The request requires source_location_id and destination_location_id. + + Inventory levels are not affected until the order is started via + + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder). + + + Common integration points: + + - Sync with warehouse management systems + + - Automate regular stock transfers + + - Initialize transfers from inventory optimization systems + + + Creates a [transfer_order.created](webhook:transfer_order.created) + webhook event. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateTransferOrder + request: + name: CreateTransferOrderRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this CreateTransferOrder + request. Keys can be + + any valid string but must be unique for every + CreateTransferOrder request. + validation: + minLength: 1 + transfer_order: + type: root.CreateTransferOrderData + docs: The transfer order to create + content-type: application/json + response: + docs: Success + type: root.CreateTransferOrderResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 65cc0586-3e82-384s-b524-3885cffd52 + transfer_order: + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + expected_at: '2025-11-09T05:00:00Z' + notes: >- + Example transfer order for inventory redistribution between + locations + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + - item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '3' + response: + body: + transfer_order: + id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: DRAFT + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T10:30:00Z' + expected_at: '2025-11-09T05:00:00Z' + completed_at: completed_at + notes: >- + Example transfer order for inventory redistribution between + locations + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + quantity_pending: '5' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + - uid: '2' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '3' + quantity_pending: '3' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + version: 1753109537351 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + search: + path: /v2/transfer-orders/search + method: POST + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Searches for transfer orders using filters. Returns a paginated list of + matching + + [TransferOrder](entity:TransferOrder)s sorted by creation date. + + + Common search scenarios: + + - Find orders for a source [Location](entity:Location) + + - Find orders for a destination [Location](entity:Location) + + - Find orders in a particular + [TransferOrderStatus](entity:TransferOrderStatus) + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.transfer_orders + source: + openapi: ../default/openapi/openapi.json + display-name: SearchTransferOrders + request: + name: SearchTransferOrdersRequest + body: + properties: + query: + type: optional + docs: The search query + cursor: + type: optional + docs: Pagination cursor from a previous search response + limit: + type: optional + docs: Maximum number of results to return (1-100) + validation: + min: 1 + max: 100 + content-type: application/json + response: + docs: Success + type: root.SearchTransferOrdersResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + query: + filter: + source_location_ids: + - EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_ids: + - EXAMPLE_DEST_LOCATION_ID_456 + statuses: + - STARTED + - PARTIALLY_RECEIVED + sort: + field: UPDATED_AT + order: DESC + cursor: eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9 + limit: 10 + response: + body: + transfer_orders: + - id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: STARTED + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T10:32:00Z' + expected_at: '2025-11-09T05:00:00Z' + completed_at: completed_at + notes: Inventory rebalance between stores + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + quantity_pending: '5' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + version: 1753118664873 + - id: EXAMPLE_TRANSFER_ORDER_ID_456 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: PARTIALLY_RECEIVED + created_at: '2025-01-14T14:20:00Z' + updated_at: '2025-01-15T09:45:00Z' + expected_at: '2025-11-08T12:00:00Z' + completed_at: completed_at + notes: Seasonal stock transfer + tracking_number: tracking_number + created_by_team_member_id: created_by_team_member_id + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '10' + quantity_pending: '3' + quantity_received: '7' + quantity_damaged: '0' + quantity_canceled: '0' + version: 1753115540123 + cursor: eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTU1NDBfMTIzfQ== + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + get: + path: /v2/transfer-orders/{transfer_order_id} + method: GET + auth: + - oauth2: + - INVENTORY_READ + docs: >- + Retrieves a specific [TransferOrder](entity:TransferOrder) by ID. + Returns the complete + + order details including: + + + - Basic information (status, dates, notes) + + - Line items with ordered and received quantities + + - Source and destination [Location](entity:Location)s + + - Tracking information (if available) + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveTransferOrder + request: + name: GetTransferOrdersRequest + path-parameters: + transfer_order_id: + type: string + docs: The ID of the transfer order to retrieve + response: + docs: Success + type: root.RetrieveTransferOrderResponse + status-code: 200 + examples: + - path-parameters: + transfer_order_id: transfer_order_id + headers: + Square-Version: '2025-10-16' + response: + body: + transfer_order: + id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: STARTED + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T10:35:00Z' + expected_at: '2025-11-09T05:00:00Z' + completed_at: completed_at + notes: >- + Example transfer order for inventory redistribution between + locations + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + quantity_pending: '5' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + - uid: '2' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '3' + quantity_pending: '3' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + version: 1753117449752 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + update: + path: /v2/transfer-orders/{transfer_order_id} + method: PUT + auth: + - oauth2: + - INVENTORY_READ + - INVENTORY_WRITE + docs: >- + Updates an existing transfer order. This endpoint supports sparse + updates, + + allowing you to modify specific fields without affecting others. + + + Creates a [transfer_order.updated](webhook:transfer_order.updated) + webhook event. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateTransferOrder + request: + name: UpdateTransferOrderRequest + path-parameters: + transfer_order_id: + type: string + docs: The ID of the transfer order to update + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this UpdateTransferOrder + request. Keys must contain only alphanumeric characters, dashes + and underscores + validation: + minLength: 1 + transfer_order: + type: root.UpdateTransferOrderData + docs: The transfer order updates to apply + version: + type: optional + docs: Version for optimistic concurrency + content-type: application/json + response: + docs: Success + type: root.UpdateTransferOrderResponse + status-code: 200 + examples: + - path-parameters: + transfer_order_id: transfer_order_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: f47ac10b-58cc-4372-a567-0e02b2c3d479 + transfer_order: + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_789 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_101 + expected_at: '2025-11-10T08:00:00Z' + notes: 'Updated: Priority transfer due to low stock at destination' + tracking_number: TRACK987654321 + line_items: + - uid: '1' + quantity_ordered: '7' + - item_variation_id: EXAMPLE_NEW_ITEM_VARIATION_ID_003 + quantity_ordered: '2' + - uid: '2' + remove: true + version: 1753109537351 + response: + body: + transfer_order: + id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_789 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_101 + status: DRAFT + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T11:15:00Z' + expected_at: '2025-11-10T08:00:00Z' + completed_at: completed_at + notes: 'Updated: Priority transfer due to low stock at destination' + tracking_number: TRACK987654321 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '7' + quantity_pending: '7' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + - uid: '3' + item_variation_id: EXAMPLE_NEW_ITEM_VARIATION_ID_003 + quantity_ordered: '2' + quantity_pending: '2' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + version: 1753122900456 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + delete: + path: /v2/transfer-orders/{transfer_order_id} + method: DELETE + auth: + - oauth2: + - INVENTORY_WRITE + docs: >- + Deletes a transfer order in [DRAFT](entity:TransferOrderStatus) status. + + Only draft orders can be deleted. Once an order is started via + + [StartTransferOrder](api-endpoint:TransferOrders-StartTransferOrder), it + can no longer be deleted. + + + Creates a [transfer_order.deleted](webhook:transfer_order.deleted) + webhook event. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteTransferOrder + request: + name: DeleteTransferOrdersRequest + path-parameters: + transfer_order_id: + type: string + docs: The ID of the transfer order to delete + query-parameters: + version: + type: optional> + docs: Version for optimistic concurrency + response: + docs: Success + type: root.DeleteTransferOrderResponse + status-code: 200 + examples: + - path-parameters: + transfer_order_id: transfer_order_id + query-parameters: + version: 1000000 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + cancel: + path: /v2/transfer-orders/{transfer_order_id}/cancel + method: POST + auth: + - oauth2: + - INVENTORY_READ + - INVENTORY_WRITE + docs: >- + Cancels a transfer order in [STARTED](entity:TransferOrderStatus) or + + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. Any unreceived + quantities will no + + longer be receivable and will be immediately returned to the source + [Location](entity:Location)'s inventory. + + + Common reasons for cancellation: + + - Items no longer needed at destination + + - Source location needs the inventory + + - Order created in error + + + Creates a [transfer_order.updated](webhook:transfer_order.updated) + webhook event. + source: + openapi: ../default/openapi/openapi.json + display-name: CancelTransferOrder + request: + name: CancelTransferOrderRequest + path-parameters: + transfer_order_id: + type: string + docs: >- + The ID of the transfer order to cancel. Must be in STARTED or + PARTIALLY_RECEIVED status. + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this UpdateTransferOrder + request. Keys can be + + any valid string but must be unique for every + UpdateTransferOrder request. + validation: + minLength: 1 + version: + type: optional + docs: Version for optimistic concurrency + content-type: application/json + response: + docs: Success + type: root.CancelTransferOrderResponse + status-code: 200 + examples: + - path-parameters: + transfer_order_id: transfer_order_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 65cc0586-3e82-4d08-b524-3885cffd52 + version: 1753117449752 + response: + body: + transfer_order: + id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: CANCELED + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T10:45:00Z' + expected_at: '2025-11-09T05:00:00Z' + completed_at: '2025-01-15T10:45:00Z' + notes: >- + Example transfer order for inventory redistribution between + locations + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + quantity_pending: '0' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '5' + - uid: '2' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '3' + quantity_pending: '0' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '3' + version: 1753117461842 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + receive: + path: /v2/transfer-orders/{transfer_order_id}/receive + method: POST + auth: + - oauth2: + - INVENTORY_READ + - INVENTORY_WRITE + docs: >- + Records receipt of [CatalogItemVariation](entity:CatalogItemVariation)s + for a transfer order. + + This endpoint supports partial receiving - you can receive items in + multiple batches. + + + For each line item, you can specify: + + - Quantity received in good condition (added to destination inventory + with [InventoryState](entity:InventoryState) of IN_STOCK) + + - Quantity damaged during transit/handling (added to destination + inventory with [InventoryState](entity:InventoryState) of WASTE) + + - Quantity canceled (returned to source location's inventory) + + + The order must be in [STARTED](entity:TransferOrderStatus) or + [PARTIALLY_RECEIVED](entity:TransferOrderStatus) status. + + Received quantities are added to the destination + [Location](entity:Location)'s inventory according to their condition. + + Canceled quantities are immediately returned to the source + [Location](entity:Location)'s inventory. + + + When all items are either received, damaged, or canceled, the order + moves to + + [COMPLETED](entity:TransferOrderStatus) status. + + + Creates a [transfer_order.updated](webhook:transfer_order.updated) + webhook event. + source: + openapi: ../default/openapi/openapi.json + display-name: ReceiveTransferOrder + request: + name: ReceiveTransferOrderRequest + path-parameters: + transfer_order_id: + type: string + docs: The ID of the transfer order to receive items for + body: + properties: + idempotency_key: + type: string + docs: A unique key to make this request idempotent + validation: + minLength: 1 + receipt: + type: root.TransferOrderGoodsReceipt + docs: The receipt details + version: + type: optional + docs: Version for optimistic concurrency + content-type: application/json + response: + docs: Success + type: root.ReceiveTransferOrderResponse + status-code: 200 + examples: + - path-parameters: + transfer_order_id: transfer_order_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: EXAMPLE_IDEMPOTENCY_KEY_101 + receipt: + line_items: + - transfer_order_line_uid: transfer_order_line_uid + quantity_received: '3' + quantity_damaged: '1' + quantity_canceled: '1' + - transfer_order_line_uid: transfer_order_line_uid + quantity_received: '2' + quantity_canceled: '1' + version: 1753118664873 + response: + body: + transfer_order: + id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: COMPLETED + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T10:55:00Z' + expected_at: '2025-11-09T05:00:00Z' + completed_at: '2025-01-15T10:55:00Z' + notes: >- + Example transfer order for inventory redistribution between + locations + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + quantity_pending: '0' + quantity_received: '3' + quantity_damaged: '1' + quantity_canceled: '1' + - uid: '2' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '3' + quantity_pending: '0' + quantity_received: '2' + quantity_damaged: '0' + quantity_canceled: '1' + version: 1753118667248 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + start: + path: /v2/transfer-orders/{transfer_order_id}/start + method: POST + auth: + - oauth2: + - INVENTORY_READ + - INVENTORY_WRITE + docs: >- + Changes a [DRAFT](entity:TransferOrderStatus) transfer order to + [STARTED](entity:TransferOrderStatus) status. + + This decrements inventory at the source [Location](entity:Location) and + marks it as in-transit. + + + The order must be in [DRAFT](entity:TransferOrderStatus) status and have + all required fields populated. + + Once started, the order can no longer be deleted, but it can be canceled + via + + [CancelTransferOrder](api-endpoint:TransferOrders-CancelTransferOrder). + + + Creates a [transfer_order.updated](webhook:transfer_order.updated) + webhook event. + source: + openapi: ../default/openapi/openapi.json + display-name: StartTransferOrder + request: + name: StartTransferOrderRequest + path-parameters: + transfer_order_id: + type: string + docs: The ID of the transfer order to start. Must be in DRAFT status. + body: + properties: + idempotency_key: + type: string + docs: >- + A unique string that identifies this UpdateTransferOrder + request. Keys can be + + any valid string but must be unique for every + UpdateTransferOrder request. + validation: + minLength: 1 + version: + type: optional + docs: Version for optimistic concurrency + content-type: application/json + response: + docs: Success + type: root.StartTransferOrderResponse + status-code: 200 + examples: + - path-parameters: + transfer_order_id: transfer_order_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: EXAMPLE_IDEMPOTENCY_KEY_789 + version: 1753109537351 + response: + body: + transfer_order: + id: EXAMPLE_TRANSFER_ORDER_ID_123 + source_location_id: EXAMPLE_SOURCE_LOCATION_ID_123 + destination_location_id: EXAMPLE_DEST_LOCATION_ID_456 + status: STARTED + created_at: '2025-01-15T10:30:00Z' + updated_at: '2025-01-15T10:32:00Z' + expected_at: '2025-11-09T05:00:00Z' + completed_at: completed_at + notes: >- + Example transfer order for inventory redistribution between + locations + tracking_number: TRACK123456789 + created_by_team_member_id: EXAMPLE_TEAM_MEMBER_ID_789 + line_items: + - uid: '1' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_001 + quantity_ordered: '5' + quantity_pending: '5' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + - uid: '2' + item_variation_id: EXAMPLE_ITEM_VARIATION_ID_002 + quantity_ordered: '3' + quantity_pending: '3' + quantity_received: '0' + quantity_damaged: '0' + quantity_canceled: '0' + version: 1753118664873 + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/v1Transactions.yml b/.mock/definition/v1Transactions.yml new file mode 100644 index 00000000..76b0f5b7 --- /dev/null +++ b/.mock/definition/v1Transactions.yml @@ -0,0 +1,382 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + V1ListOrders: + path: /v1/{location_id}/orders + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: Provides summary information for a merchant's online store orders. + source: + openapi: ../default/openapi/openapi.json + display-name: V1ListOrders + request: + name: V1ListOrdersRequest + path-parameters: + location_id: + type: string + docs: The ID of the location to list online store orders for. + query-parameters: + order: + type: optional> + docs: The order in which payments are listed in the response. + limit: + type: optional> + docs: >- + The maximum number of payments to return in a single response. + This value cannot exceed 200. + batch_token: + type: optional> + docs: |- + A pagination cursor to retrieve the next set of results for your + original query to the endpoint. + response: + docs: Success + type: list + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + query-parameters: + order: DESC + limit: 1 + batch_token: batch_token + headers: + Square-Version: '2025-10-16' + response: + body: + - errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + id: id + buyer_email: buyer_email + recipient_name: recipient_name + recipient_phone_number: recipient_phone_number + state: PENDING + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + subtotal_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_shipping_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_tax_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_price_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_discount_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + created_at: created_at + updated_at: updated_at + expires_at: expires_at + payment_id: payment_id + buyer_note: buyer_note + completed_note: completed_note + refunded_note: refunded_note + canceled_note: canceled_note + tender: + id: id + type: CREDIT_CARD + name: name + employee_id: employee_id + receipt_url: receipt_url + card_brand: OTHER_BRAND + pan_suffix: pan_suffix + entry_method: MANUAL + payment_note: payment_note + tendered_at: tendered_at + settled_at: settled_at + is_exchange: true + order_history: + - {} + promo_code: promo_code + btc_receive_address: btc_receive_address + btc_price_satoshi: 1.1 + V1RetrieveOrder: + path: /v1/{location_id}/orders/{order_id} + method: GET + auth: + - oauth2: + - ORDERS_READ + docs: >- + Provides comprehensive information for a single online store order, + including the order's history. + source: + openapi: ../default/openapi/openapi.json + display-name: V1RetrieveOrder + request: + name: V1RetrieveOrderRequest + path-parameters: + location_id: + type: string + docs: The ID of the order's associated location. + order_id: + type: string + docs: >- + The order's Square-issued ID. You obtain this value from Order + objects returned by the List Orders endpoint + response: + docs: Success + type: root.V1Order + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + order_id: order_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + id: id + buyer_email: buyer_email + recipient_name: recipient_name + recipient_phone_number: recipient_phone_number + state: PENDING + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + subtotal_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_shipping_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_tax_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_price_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_discount_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + created_at: created_at + updated_at: updated_at + expires_at: expires_at + payment_id: payment_id + buyer_note: buyer_note + completed_note: completed_note + refunded_note: refunded_note + canceled_note: canceled_note + tender: + id: id + type: CREDIT_CARD + name: name + employee_id: employee_id + receipt_url: receipt_url + card_brand: OTHER_BRAND + pan_suffix: pan_suffix + entry_method: MANUAL + payment_note: payment_note + total_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + tendered_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + tendered_at: tendered_at + settled_at: settled_at + change_back_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + refunded_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + is_exchange: true + order_history: + - action: ORDER_PLACED + created_at: created_at + promo_code: promo_code + btc_receive_address: btc_receive_address + btc_price_satoshi: 1.1 + V1UpdateOrder: + path: /v1/{location_id}/orders/{order_id} + method: PUT + auth: + - oauth2: + - ORDERS_WRITE + docs: >- + Updates the details of an online store order. Every update you perform + on an order corresponds to one of three actions: + source: + openapi: ../default/openapi/openapi.json + display-name: V1UpdateOrder + request: + name: V1UpdateOrderRequest + path-parameters: + location_id: + type: string + docs: The ID of the order's associated location. + order_id: + type: string + docs: >- + The order's Square-issued ID. You obtain this value from Order + objects returned by the List Orders endpoint + body: + properties: + action: + type: root.V1UpdateOrderRequestAction + docs: >- + The action to perform on the order (COMPLETE, CANCEL, or + REFUND). + + See + [V1UpdateOrderRequestAction](#type-v1updateorderrequestaction) + for possible values + shipped_tracking_number: + type: optional> + docs: >- + The tracking number of the shipment associated with the order. + Only valid if action is COMPLETE. + completed_note: + type: optional> + docs: >- + A merchant-specified note about the completion of the order. + Only valid if action is COMPLETE. + refunded_note: + type: optional> + docs: >- + A merchant-specified note about the refunding of the order. Only + valid if action is REFUND. + canceled_note: + type: optional> + docs: >- + A merchant-specified note about the canceling of the order. Only + valid if action is CANCEL. + content-type: application/json + response: + docs: Success + type: root.V1Order + status-code: 200 + availability: deprecated + examples: + - path-parameters: + location_id: location_id + order_id: order_id + headers: + Square-Version: '2025-10-16' + request: + action: COMPLETE + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + id: id + buyer_email: buyer_email + recipient_name: recipient_name + recipient_phone_number: recipient_phone_number + state: PENDING + shipping_address: + address_line_1: address_line_1 + address_line_2: address_line_2 + address_line_3: address_line_3 + locality: locality + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: administrative_district_level_1 + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: postal_code + country: ZZ + first_name: first_name + last_name: last_name + subtotal_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_shipping_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_tax_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_price_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + total_discount_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + created_at: created_at + updated_at: updated_at + expires_at: expires_at + payment_id: payment_id + buyer_note: buyer_note + completed_note: completed_note + refunded_note: refunded_note + canceled_note: canceled_note + tender: + id: id + type: CREDIT_CARD + name: name + employee_id: employee_id + receipt_url: receipt_url + card_brand: OTHER_BRAND + pan_suffix: pan_suffix + entry_method: MANUAL + payment_note: payment_note + total_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + tendered_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + tendered_at: tendered_at + settled_at: settled_at + change_back_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + refunded_money: + amount: 1 + currency_code: UNKNOWN_CURRENCY + is_exchange: true + order_history: + - action: ORDER_PLACED + created_at: created_at + promo_code: promo_code + btc_receive_address: btc_receive_address + btc_price_satoshi: 1.1 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/vendors.yml b/.mock/definition/vendors.yml new file mode 100644 index 00000000..70569772 --- /dev/null +++ b/.mock/definition/vendors.yml @@ -0,0 +1,558 @@ +imports: + root: __package__.yml +service: + auth: false + base-path: '' + endpoints: + batchCreate: + path: /v2/vendors/bulk-create + method: POST + auth: + - oauth2: + - VENDOR_WRITE + docs: >- + Creates one or more [Vendor](entity:Vendor) objects to represent + suppliers to a seller. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkCreateVendors + request: + name: BatchCreateVendorsRequest + body: + properties: + vendors: + type: map + docs: >- + Specifies a set of new [Vendor](entity:Vendor) objects as + represented by a collection of idempotency-key/`Vendor`-object + pairs. + content-type: application/json + response: + docs: Success + type: root.BatchCreateVendorsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + vendors: + 8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe: + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + contacts: + - name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + responses: + 8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T10:21:54.859Z' + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + version: 0 + status: ACTIVE + batchGet: + path: /v2/vendors/bulk-retrieve + method: POST + auth: + - oauth2: + - VENDOR_READ + docs: Retrieves one or more vendors of specified [Vendor](entity:Vendor) IDs. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkRetrieveVendors + request: + name: BatchGetVendorsRequest + body: + properties: + vendor_ids: + type: optional>> + docs: IDs of the [Vendor](entity:Vendor) objects to retrieve. + content-type: application/json + response: + docs: Success + type: root.BatchGetVendorsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + vendor_ids: + - INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + responses: + INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T10:21:54.859Z' + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + version: 1 + status: ACTIVE + batchUpdate: + path: /v2/vendors/bulk-update + method: PUT + auth: + - oauth2: + - VENDOR_WRITE + docs: >- + Updates one or more of existing [Vendor](entity:Vendor) objects as + suppliers to a seller. + source: + openapi: ../default/openapi/openapi.json + display-name: BulkUpdateVendors + request: + name: BatchUpdateVendorsRequest + body: + properties: + vendors: + type: map + docs: >- + A set of [UpdateVendorRequest](entity:UpdateVendorRequest) + objects encapsulating to-be-updated [Vendor](entity:Vendor) + + objects. The set is represented by a collection of + `Vendor`-ID/`UpdateVendorRequest`-object pairs. + content-type: application/json + response: + docs: Success + type: root.BatchUpdateVendorsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + vendors: + FMCYHBWT1TPL8MFH52PBMEN92A: + vendor: {} + INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4: + vendor: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + responses: + INV_V_FMCYHBWT1TPL8MFH52PBMEN92A: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + vendor: + id: INV_V_FMCYHBWT1TPL8MFH52PBMEN92A + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T20:21:54.859Z' + name: Annie’s Hot Sauce + address: + address_line_1: 202 Mill St + locality: Moorestown + administrative_district_level_1: NJ + postal_code: '08057' + country: US + contacts: + - id: INV_VC_ABYYHBWT1TPL8MFH52PBMENPJ4 + name: Annie Thomas + email_address: annie@annieshotsauce.com + phone_number: 1-212-555-4250 + ordinal: 0 + version: 11 + status: ACTIVE + INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:10:54.859Z' + updated_at: '2022-03-16T20:21:54.859Z' + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 0 + account_number: '4025391' + note: favorite vendor + version: 31 + status: ACTIVE + create: + path: /v2/vendors/create + method: POST + auth: + - oauth2: + - VENDOR_WRITE + docs: >- + Creates a single [Vendor](entity:Vendor) object to represent a supplier + to a seller. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateVendor + request: + name: CreateVendorRequest + body: + properties: + idempotency_key: + type: string + docs: >- + A client-supplied, universally unique identifier (UUID) to make + this [CreateVendor](api-endpoint:Vendors-CreateVendor) call + idempotent. + + + See + [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) + in the + + [API Development + 101](https://developer.squareup.com/docs/buildbasics) section + for more + + information. + validation: + minLength: 1 + maxLength: 128 + vendor: + type: optional + docs: The requested [Vendor](entity:Vendor) to be created. + content-type: application/json + response: + docs: Success + type: root.CreateVendorResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe + vendor: + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + contacts: + - name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T10:21:54.859Z' + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + version: 1 + status: ACTIVE + search: + path: /v2/vendors/search + method: POST + auth: + - oauth2: + - VENDOR_READ + docs: >- + Searches for vendors using a filter against supported + [Vendor](entity:Vendor) properties and a supported sorter. + source: + openapi: ../default/openapi/openapi.json + display-name: SearchVendors + request: + name: SearchVendorsRequest + body: + properties: + filter: + type: optional + docs: Specifies a filter used to search for vendors. + sort: + type: optional + docs: Specifies a sorter used to sort the returned vendors. + cursor: + type: optional + docs: >- + 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 the + [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) + guide for more information. + content-type: application/json + response: + docs: Success + type: root.SearchVendorsResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: {} + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + vendors: + - id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T10:21:54.859Z' + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + locality: New York + administrative_district_level_1: NY + postal_code: '10003' + country: US + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + version: 1 + status: ACTIVE + cursor: cursor + get: + path: /v2/vendors/{vendor_id} + method: GET + auth: + - oauth2: + - VENDOR_READ + docs: Retrieves the vendor of a specified [Vendor](entity:Vendor) ID. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveVendor + request: + name: GetVendorsRequest + path-parameters: + vendor_id: + type: string + docs: ID of the [Vendor](entity:Vendor) to retrieve. + response: + docs: Success + type: root.GetVendorResponse + status-code: 200 + examples: + - path-parameters: + vendor_id: vendor_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T10:21:54.859Z' + name: Joe's Fresh Seafood + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 1 + account_number: '4025391' + note: a vendor + version: 1 + status: ACTIVE + update: + path: /v2/vendors/{vendor_id} + method: PUT + auth: + - oauth2: + - VENDOR_WRITE + docs: >- + Updates an existing [Vendor](entity:Vendor) object as a supplier to a + seller. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateVendor + request: + body: root.UpdateVendorRequest + path-parameters: + vendor_id: + type: string + docs: ID of the [Vendor](entity:Vendor) to retrieve. + name: UpdateVendorsRequest + content-type: application/json + response: + docs: Success + type: root.UpdateVendorResponse + status-code: 200 + examples: + - path-parameters: + vendor_id: vendor_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + name: Jack's Chicken Shack + version: 1 + status: ACTIVE + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + vendor: + id: INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4 + created_at: '2022-03-16T10:21:54.859Z' + updated_at: '2022-03-16T20:21:54.859Z' + name: Jack's Chicken Shack + address: + address_line_1: 505 Electric Ave + address_line_2: Suite 600 + address_line_3: address_line_3 + locality: New York + sublocality: sublocality + sublocality_2: sublocality_2 + sublocality_3: sublocality_3 + administrative_district_level_1: NY + administrative_district_level_2: administrative_district_level_2 + administrative_district_level_3: administrative_district_level_3 + postal_code: '10003' + country: US + first_name: first_name + last_name: last_name + contacts: + - id: INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A + name: Joe Burrow + email_address: joe@joesfreshseafood.com + phone_number: 1-212-555-4250 + ordinal: 0 + account_number: '4025391' + note: note + version: 2 + status: ACTIVE + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/webhooks/eventTypes.yml b/.mock/definition/webhooks/eventTypes.yml new file mode 100644 index 00000000..8d6b9aa9 --- /dev/null +++ b/.mock/definition/webhooks/eventTypes.yml @@ -0,0 +1,47 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/webhooks/event-types + method: GET + auth: + - oauth2: [] + docs: Lists all webhook event types that can be subscribed to. + source: + openapi: ../default/openapi/openapi.json + display-name: ListWebhookEventTypes + request: + name: ListEventTypesRequest + query-parameters: + api_version: + type: optional> + docs: >- + The API version for which to list event types. Setting this field + overrides the default version used by the application. + response: + docs: Success + type: root.ListWebhookEventTypesResponse + status-code: 200 + examples: + - query-parameters: + api_version: api_version + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + event_types: + - inventory.count.updated + metadata: + - event_type: inventory.count.updated + api_version_introduced: '2018-07-12' + release_status: PUBLIC + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/definition/webhooks/subscriptions.yml b/.mock/definition/webhooks/subscriptions.yml new file mode 100644 index 00000000..718601a5 --- /dev/null +++ b/.mock/definition/webhooks/subscriptions.yml @@ -0,0 +1,395 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v2/webhooks/subscriptions + method: GET + auth: + - oauth2: [] + docs: Lists all webhook subscriptions owned by your application. + pagination: + cursor: $request.cursor + next_cursor: $response.cursor + results: $response.subscriptions + source: + openapi: ../default/openapi/openapi.json + display-name: ListWebhookSubscriptions + request: + name: ListSubscriptionsRequest + query-parameters: + cursor: + type: optional> + docs: >- + A pagination cursor returned by a previous call to this endpoint. + + Provide this to retrieve the next set of results for your original + query. + + + For more information, see + [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). + include_disabled: + type: optional> + default: false + docs: >- + Includes disabled [Subscription](entity:WebhookSubscription)s. + + By default, all enabled + [Subscription](entity:WebhookSubscription)s are returned. + sort_order: + type: optional> + docs: >- + Sorts the returned list by when the + [Subscription](entity:WebhookSubscription) was created with the + specified order. + + This field defaults to ASC. + limit: + type: optional> + docs: >- + 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. + + + Default: 100 + response: + docs: Success + type: root.ListWebhookSubscriptionsResponse + status-code: 200 + examples: + - query-parameters: + cursor: cursor + include_disabled: true + sort_order: DESC + limit: 1 + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscriptions: + - id: wbhk_b35f6b3145074cf9ad513610786c19d5 + name: Example Webhook Subscription + enabled: true + event_types: + - payment.created + - payment.updated + notification_url: https://example-webhook-url.com + api_version: '2021-12-15' + signature_key: signature_key + created_at: 2022-01-10 23:29:48 +0000 UTC + updated_at: 2022-01-10 23:29:48 +0000 UTC + cursor: cursor + create: + path: /v2/webhooks/subscriptions + method: POST + auth: + - oauth2: [] + docs: Creates a webhook subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: CreateWebhookSubscription + request: + name: CreateWebhookSubscriptionRequest + body: + properties: + idempotency_key: + type: optional + docs: >- + A unique string that identifies the + [CreateWebhookSubscription](api-endpoint:WebhookSubscriptions-CreateWebhookSubscription) + request. + validation: + maxLength: 45 + subscription: + type: root.WebhookSubscription + docs: The [Subscription](entity:WebhookSubscription) to create. + content-type: application/json + response: + docs: Success + type: root.CreateWebhookSubscriptionResponse + status-code: 200 + examples: + - headers: + Square-Version: '2025-10-16' + request: + idempotency_key: 63f84c6c-2200-4c99-846c-2670a1311fbf + subscription: + name: Example Webhook Subscription + event_types: + - payment.created + - payment.updated + notification_url: https://example-webhook-url.com + api_version: '2021-12-15' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: wbhk_b35f6b3145074cf9ad513610786c19d5 + name: Example Webhook Subscription + enabled: true + event_types: + - payment.created + - payment.updated + notification_url: https://example-webhook-url.com + api_version: '2021-12-15' + signature_key: 1k9bIJKCeTmSQwyagtNRLg + created_at: 2022-01-10 23:29:48 +0000 UTC + updated_at: 2022-01-10 23:29:48 +0000 UTC + get: + path: /v2/webhooks/subscriptions/{subscription_id} + method: GET + auth: + - oauth2: [] + docs: Retrieves a webhook subscription identified by its ID. + source: + openapi: ../default/openapi/openapi.json + display-name: RetrieveWebhookSubscription + request: + name: GetSubscriptionsRequest + path-parameters: + subscription_id: + type: string + docs: >- + [REQUIRED] The ID of the + [Subscription](entity:WebhookSubscription) to retrieve. + response: + docs: Success + type: root.GetWebhookSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: wbhk_b35f6b3145074cf9ad513610786c19d5 + name: Example Webhook Subscription + enabled: true + event_types: + - payment.created + - payment.updated + notification_url: https://example-webhook-url.com + api_version: '2021-12-15' + signature_key: 1k9bIJKCeTmSQwyagtNRLg + created_at: 2022-01-10 23:29:48 +0000 UTC + updated_at: 2022-01-10 23:29:48 +0000 UTC + update: + path: /v2/webhooks/subscriptions/{subscription_id} + method: PUT + auth: + - oauth2: [] + docs: Updates a webhook subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateWebhookSubscription + request: + name: UpdateWebhookSubscriptionRequest + path-parameters: + subscription_id: + type: string + docs: >- + [REQUIRED] The ID of the + [Subscription](entity:WebhookSubscription) to update. + body: + properties: + subscription: + type: optional + docs: The [Subscription](entity:WebhookSubscription) to update. + content-type: application/json + response: + docs: Success + type: root.UpdateWebhookSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: + subscription: + name: Updated Example Webhook Subscription + enabled: false + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription: + id: wbhk_b35f6b3145074cf9ad513610786c19d5 + name: Updated Example Webhook Subscription + enabled: false + event_types: + - payment.created + - payment.updated + notification_url: https://example-webhook-url.com + api_version: '2021-12-15' + signature_key: signature_key + created_at: 2022-01-10 23:29:48 +0000 UTC + updated_at: 2022-01-10 23:45:51 +0000 UTC + delete: + path: /v2/webhooks/subscriptions/{subscription_id} + method: DELETE + auth: + - oauth2: [] + docs: Deletes a webhook subscription. + source: + openapi: ../default/openapi/openapi.json + display-name: DeleteWebhookSubscription + request: + name: DeleteSubscriptionsRequest + path-parameters: + subscription_id: + type: string + docs: >- + [REQUIRED] The ID of the + [Subscription](entity:WebhookSubscription) to delete. + response: + docs: Success + type: root.DeleteWebhookSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + updateSignatureKey: + path: /v2/webhooks/subscriptions/{subscription_id}/signature-key + method: POST + auth: + - oauth2: [] + docs: >- + Updates a webhook subscription by replacing the existing signature key + with a new one. + source: + openapi: ../default/openapi/openapi.json + display-name: UpdateWebhookSubscriptionSignatureKey + request: + name: UpdateWebhookSubscriptionSignatureKeyRequest + path-parameters: + subscription_id: + type: string + docs: >- + [REQUIRED] The ID of the + [Subscription](entity:WebhookSubscription) to update. + body: + properties: + idempotency_key: + type: optional> + docs: >- + A unique string that identifies the + [UpdateWebhookSubscriptionSignatureKey](api-endpoint:WebhookSubscriptions-UpdateWebhookSubscriptionSignatureKey) + request. + validation: + maxLength: 45 + content-type: application/json + response: + docs: Success + type: root.UpdateWebhookSubscriptionSignatureKeyResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: + idempotency_key: ed80ae6b-0654-473b-bbab-a39aee89a60d + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + signature_key: 1k9bIJKCeTmSQwyagtNRLg + test: + path: /v2/webhooks/subscriptions/{subscription_id}/test + method: POST + auth: + - oauth2: [] + docs: >- + Tests a webhook subscription by sending a test event to the notification + URL. + source: + openapi: ../default/openapi/openapi.json + display-name: TestWebhookSubscription + request: + name: TestWebhookSubscriptionRequest + path-parameters: + subscription_id: + type: string + docs: >- + [REQUIRED] The ID of the + [Subscription](entity:WebhookSubscription) to test. + body: + properties: + event_type: + type: optional> + docs: >- + The event type that will be used to test the + [Subscription](entity:WebhookSubscription). The event type must + be + + contained in the list of event types in the + [Subscription](entity:WebhookSubscription). + content-type: application/json + response: + docs: Success + type: root.TestWebhookSubscriptionResponse + status-code: 200 + examples: + - path-parameters: + subscription_id: subscription_id + headers: + Square-Version: '2025-10-16' + request: + event_type: payment.created + response: + body: + errors: + - category: API_ERROR + code: INTERNAL_SERVER_ERROR + detail: detail + field: field + subscription_test_result: + id: 23eed5a9-2b12-403e-b212-7e2889aea0f6 + status_code: 404 + payload: >- + {"merchant_id":"1ZYMKZY1YFGBW","type":"payment.created","event_id":"23eed5a9-2b12-403e-b212-7e2889aea0f6","created_at":"2022-01-11T00:06:48.322945116Z","data":{"type":"payment","id":"KkAkhdMsgzn59SM8A89WgKwekxLZY","object":{"payment":{"amount_money":{"amount":100,"currency":"USD"},"approved_money":{"amount":100,"currency":"USD"},"capabilities":["EDIT_TIP_AMOUNT","EDIT_TIP_AMOUNT_UP","EDIT_TIP_AMOUNT_DOWN"],"card_details":{"avs_status":"AVS_ACCEPTED","card":{"bin":"540988","card_brand":"MASTERCARD","card_type":"CREDIT","exp_month":11,"exp_year":2022,"fingerprint":"sq-1-Tvruf3vPQxlvI6n0IcKYfBukrcv6IqWr8UyBdViWXU2yzGn5VMJvrsHMKpINMhPmVg","last_4":"9029","prepaid_type":"NOT_PREPAID"},"card_payment_timeline":{"authorized_at":"2020-11-22T21:16:51.198Z"},"cvv_status":"CVV_ACCEPTED","entry_method":"KEYED","statement_description":"SQ + *DEFAULT TEST + ACCOUNT","status":"AUTHORIZED"},"created_at":"2020-11-22T21:16:51.086Z","delay_action":"CANCEL","delay_duration":"PT168H","delayed_until":"2020-11-29T21:16:51.086Z","id":"hYy9pRFVxpDsO1FB05SunFWUe9JZY","location_id":"S8GWD5R9QB376","order_id":"03O3USaPaAaFnI6kkwB1JxGgBsUZY","receipt_number":"hYy9","risk_evaluation":{"created_at":"2020-11-22T21:16:51.198Z","risk_level":"NORMAL"},"source_type":"CARD","status":"APPROVED","total_money":{"amount":100,"currency":"USD"},"updated_at":"2020-11-22T21:16:51.198Z","version_token":"FfQhQJf9r3VSQIgyWBk1oqhIwiznLwVwJbVVA0bdyEv6o"}}}} + created_at: 2022-01-11 00:06:48.322945116 +0000 UTC m=+3863.054453746 + updated_at: 2022-01-11 00:06:48.322945116 +0000 UTC m=+3863.054453746 + source: + openapi: ../default/openapi/openapi.json diff --git a/.mock/fern.config.json b/.mock/fern.config.json new file mode 100644 index 00000000..6bf92d1d --- /dev/null +++ b/.mock/fern.config.json @@ -0,0 +1,4 @@ +{ + "organization" : "square", + "version" : "0.92.0" +} \ No newline at end of file diff --git a/reference.md b/reference.md index bd32d0a0..ddcc7f32 100644 --- a/reference.md +++ b/reference.md @@ -1,6 +1,6 @@ # Reference ## Mobile -
client.Mobile.AuthorizationCodeAsync(CreateMobileAuthorizationCodeRequest { ... }) -> CreateMobileAuthorizationCodeResponse +
client.Mobile.AuthorizationCodeAsync(Mobile.CreateMobileAuthorizationCodeRequest { ... }) -> CreateMobileAuthorizationCodeResponse
@@ -58,7 +58,7 @@ await client.Mobile.AuthorizationCodeAsync(
-**request:** `CreateMobileAuthorizationCodeRequest` +**request:** `Mobile.CreateMobileAuthorizationCodeRequest`
@@ -71,7 +71,7 @@ await client.Mobile.AuthorizationCodeAsync(
## OAuth -
client.OAuth.RevokeTokenAsync(RevokeTokenRequest { ... }) -> RevokeTokenResponse +
client.OAuth.RevokeTokenAsync(OAuth.RevokeTokenRequest { ... }) -> RevokeTokenResponse
@@ -128,7 +128,7 @@ await client.OAuth.RevokeTokenAsync(
-**request:** `RevokeTokenRequest` +**request:** `OAuth.RevokeTokenRequest`
@@ -140,7 +140,7 @@ await client.OAuth.RevokeTokenAsync(
-
client.OAuth.ObtainTokenAsync(ObtainTokenRequest { ... }) -> ObtainTokenResponse +
client.OAuth.ObtainTokenAsync(OAuth.ObtainTokenRequest { ... }) -> ObtainTokenResponse
@@ -210,7 +210,7 @@ await client.OAuth.ObtainTokenAsync(
-**request:** `ObtainTokenRequest` +**request:** `OAuth.ObtainTokenRequest`
@@ -300,7 +300,7 @@ await client.OAuth.AuthorizeAsync();
## V1Transactions -
client.V1Transactions.V1ListOrdersAsync(V1ListOrdersRequest { ... }) -> IEnumerable +
client.V1Transactions.V1ListOrdersAsync(V1Transactions.V1ListOrdersRequest { ... }) -> IEnumerable
@@ -350,7 +350,7 @@ await client.V1Transactions.V1ListOrdersAsync(
-**request:** `V1ListOrdersRequest` +**request:** `V1Transactions.V1ListOrdersRequest`
@@ -362,7 +362,7 @@ await client.V1Transactions.V1ListOrdersAsync(
-
client.V1Transactions.V1RetrieveOrderAsync(V1RetrieveOrderRequest { ... }) -> V1Order +
client.V1Transactions.V1RetrieveOrderAsync(V1Transactions.V1RetrieveOrderRequest { ... }) -> V1Order
@@ -406,7 +406,7 @@ await client.V1Transactions.V1RetrieveOrderAsync(
-**request:** `V1RetrieveOrderRequest` +**request:** `V1Transactions.V1RetrieveOrderRequest`
@@ -418,7 +418,7 @@ await client.V1Transactions.V1RetrieveOrderAsync(
-
client.V1Transactions.V1UpdateOrderAsync(V1UpdateOrderRequest { ... }) -> V1Order +
client.V1Transactions.V1UpdateOrderAsync(V1Transactions.V1UpdateOrderRequest { ... }) -> V1Order
@@ -467,7 +467,7 @@ await client.V1Transactions.V1UpdateOrderAsync(
-**request:** `V1UpdateOrderRequest` +**request:** `V1Transactions.V1UpdateOrderRequest`
@@ -480,7 +480,7 @@ await client.V1Transactions.V1UpdateOrderAsync(
## ApplePay -
client.ApplePay.RegisterDomainAsync(RegisterDomainRequest { ... }) -> RegisterDomainResponse +
client.ApplePay.RegisterDomainAsync(ApplePay.RegisterDomainRequest { ... }) -> RegisterDomainResponse
@@ -535,7 +535,7 @@ await client.ApplePay.RegisterDomainAsync(new RegisterDomainRequest { DomainName
-**request:** `RegisterDomainRequest` +**request:** `ApplePay.RegisterDomainRequest`
@@ -548,7 +548,7 @@ await client.ApplePay.RegisterDomainAsync(new RegisterDomainRequest { DomainName
## BankAccounts -
client.BankAccounts.ListAsync(ListBankAccountsRequest { ... }) -> Pager +
client.BankAccounts.ListAsync(BankAccounts.ListBankAccountsRequest { ... }) -> Core.Pager
@@ -597,7 +597,7 @@ await client.BankAccounts.ListAsync(
-**request:** `ListBankAccountsRequest` +**request:** `BankAccounts.ListBankAccountsRequest`
@@ -609,7 +609,7 @@ await client.BankAccounts.ListAsync(
-
client.BankAccounts.GetByV1IdAsync(GetByV1IdBankAccountsRequest { ... }) -> GetBankAccountByV1IdResponse +
client.BankAccounts.GetByV1IdAsync(BankAccounts.GetByV1IdBankAccountsRequest { ... }) -> GetBankAccountByV1IdResponse
@@ -653,7 +653,7 @@ await client.BankAccounts.GetByV1IdAsync(
-**request:** `GetByV1IdBankAccountsRequest` +**request:** `BankAccounts.GetByV1IdBankAccountsRequest`
@@ -665,7 +665,7 @@ await client.BankAccounts.GetByV1IdAsync(
-
client.BankAccounts.GetAsync(GetBankAccountsRequest { ... }) -> GetBankAccountResponse +
client.BankAccounts.GetAsync(BankAccounts.GetBankAccountsRequest { ... }) -> GetBankAccountResponse
@@ -710,7 +710,7 @@ await client.BankAccounts.GetAsync(
-**request:** `GetBankAccountsRequest` +**request:** `BankAccounts.GetBankAccountsRequest`
@@ -723,7 +723,7 @@ await client.BankAccounts.GetAsync(
## Bookings -
client.Bookings.ListAsync(ListBookingsRequest { ... }) -> Pager +
client.Bookings.ListAsync(Square.Bookings.ListBookingsRequest { ... }) -> Core.Pager
@@ -779,7 +779,7 @@ await client.Bookings.ListAsync(
-**request:** `ListBookingsRequest` +**request:** `Square.Bookings.ListBookingsRequest`
@@ -791,7 +791,7 @@ await client.Bookings.ListAsync(
-
client.Bookings.CreateAsync(CreateBookingRequest { ... }) -> CreateBookingResponse +
client.Bookings.CreateAsync(Square.Bookings.CreateBookingRequest { ... }) -> CreateBookingResponse
@@ -846,7 +846,7 @@ await client.Bookings.CreateAsync(new CreateBookingRequest { Booking = new Booki
-**request:** `CreateBookingRequest` +**request:** `Square.Bookings.CreateBookingRequest`
@@ -858,7 +858,7 @@ await client.Bookings.CreateAsync(new CreateBookingRequest { Booking = new Booki
-
client.Bookings.SearchAvailabilityAsync(SearchAvailabilityRequest { ... }) -> SearchAvailabilityResponse +
client.Bookings.SearchAvailabilityAsync(Square.Bookings.SearchAvailabilityRequest { ... }) -> SearchAvailabilityResponse
@@ -911,7 +911,7 @@ await client.Bookings.SearchAvailabilityAsync(
-**request:** `SearchAvailabilityRequest` +**request:** `Square.Bookings.SearchAvailabilityRequest`
@@ -923,7 +923,7 @@ await client.Bookings.SearchAvailabilityAsync(
-
client.Bookings.BulkRetrieveBookingsAsync(BulkRetrieveBookingsRequest { ... }) -> BulkRetrieveBookingsResponse +
client.Bookings.BulkRetrieveBookingsAsync(Square.Bookings.BulkRetrieveBookingsRequest { ... }) -> BulkRetrieveBookingsResponse
@@ -970,7 +970,7 @@ await client.Bookings.BulkRetrieveBookingsAsync(
-**request:** `BulkRetrieveBookingsRequest` +**request:** `Square.Bookings.BulkRetrieveBookingsRequest`
@@ -1021,7 +1021,7 @@ await client.Bookings.GetBusinessProfileAsync();
-
client.Bookings.RetrieveLocationBookingProfileAsync(RetrieveLocationBookingProfileRequest { ... }) -> RetrieveLocationBookingProfileResponse +
client.Bookings.RetrieveLocationBookingProfileAsync(Square.Bookings.RetrieveLocationBookingProfileRequest { ... }) -> RetrieveLocationBookingProfileResponse
@@ -1065,7 +1065,7 @@ await client.Bookings.RetrieveLocationBookingProfileAsync(
-**request:** `RetrieveLocationBookingProfileRequest` +**request:** `Square.Bookings.RetrieveLocationBookingProfileRequest`
@@ -1077,7 +1077,7 @@ await client.Bookings.RetrieveLocationBookingProfileAsync(
-
client.Bookings.BulkRetrieveTeamMemberBookingProfilesAsync(BulkRetrieveTeamMemberBookingProfilesRequest { ... }) -> BulkRetrieveTeamMemberBookingProfilesResponse +
client.Bookings.BulkRetrieveTeamMemberBookingProfilesAsync(Square.Bookings.BulkRetrieveTeamMemberBookingProfilesRequest { ... }) -> BulkRetrieveTeamMemberBookingProfilesResponse
@@ -1124,7 +1124,7 @@ await client.Bookings.BulkRetrieveTeamMemberBookingProfilesAsync(
-**request:** `BulkRetrieveTeamMemberBookingProfilesRequest` +**request:** `Square.Bookings.BulkRetrieveTeamMemberBookingProfilesRequest`
@@ -1136,7 +1136,7 @@ await client.Bookings.BulkRetrieveTeamMemberBookingProfilesAsync(
-
client.Bookings.GetAsync(GetBookingsRequest { ... }) -> GetBookingResponse +
client.Bookings.GetAsync(Square.Bookings.GetBookingsRequest { ... }) -> GetBookingResponse
@@ -1181,7 +1181,7 @@ await client.Bookings.GetAsync(new GetBookingsRequest { BookingId = "booking_id"
-**request:** `GetBookingsRequest` +**request:** `Square.Bookings.GetBookingsRequest`
@@ -1193,7 +1193,7 @@ await client.Bookings.GetAsync(new GetBookingsRequest { BookingId = "booking_id"
-
client.Bookings.UpdateAsync(UpdateBookingRequest { ... }) -> UpdateBookingResponse +
client.Bookings.UpdateAsync(Square.Bookings.UpdateBookingRequest { ... }) -> UpdateBookingResponse
@@ -1243,7 +1243,7 @@ await client.Bookings.UpdateAsync(
-**request:** `UpdateBookingRequest` +**request:** `Square.Bookings.UpdateBookingRequest`
@@ -1255,7 +1255,7 @@ await client.Bookings.UpdateAsync(
-
client.Bookings.CancelAsync(CancelBookingRequest { ... }) -> CancelBookingResponse +
client.Bookings.CancelAsync(Square.Bookings.CancelBookingRequest { ... }) -> CancelBookingResponse
@@ -1303,7 +1303,7 @@ await client.Bookings.CancelAsync(new CancelBookingRequest { BookingId = "bookin
-**request:** `CancelBookingRequest` +**request:** `Square.Bookings.CancelBookingRequest`
@@ -1316,7 +1316,7 @@ await client.Bookings.CancelAsync(new CancelBookingRequest { BookingId = "bookin
## Cards -
client.Cards.ListAsync(ListCardsRequest { ... }) -> Pager +
client.Cards.ListAsync(Cards.ListCardsRequest { ... }) -> Core.Pager
@@ -1368,7 +1368,7 @@ await client.Cards.ListAsync(
-**request:** `ListCardsRequest` +**request:** `Cards.ListCardsRequest`
@@ -1380,7 +1380,7 @@ await client.Cards.ListAsync(
-
client.Cards.CreateAsync(CreateCardRequest { ... }) -> CreateCardResponse +
client.Cards.CreateAsync(Cards.CreateCardRequest { ... }) -> CreateCardResponse
@@ -1443,7 +1443,7 @@ await client.Cards.CreateAsync(
-**request:** `CreateCardRequest` +**request:** `Cards.CreateCardRequest`
@@ -1455,7 +1455,7 @@ await client.Cards.CreateAsync(
-
client.Cards.GetAsync(GetCardsRequest { ... }) -> GetCardResponse +
client.Cards.GetAsync(Cards.GetCardsRequest { ... }) -> GetCardResponse
@@ -1497,7 +1497,7 @@ await client.Cards.GetAsync(new GetCardsRequest { CardId = "card_id" });
-**request:** `GetCardsRequest` +**request:** `Cards.GetCardsRequest`
@@ -1509,7 +1509,7 @@ await client.Cards.GetAsync(new GetCardsRequest { CardId = "card_id" });
-
client.Cards.DisableAsync(DisableCardsRequest { ... }) -> DisableCardResponse +
client.Cards.DisableAsync(Cards.DisableCardsRequest { ... }) -> DisableCardResponse
@@ -1552,7 +1552,7 @@ await client.Cards.DisableAsync(new DisableCardsRequest { CardId = "card_id" });
-**request:** `DisableCardsRequest` +**request:** `Cards.DisableCardsRequest`
@@ -1565,7 +1565,7 @@ await client.Cards.DisableAsync(new DisableCardsRequest { CardId = "card_id" });
## Catalog -
client.Catalog.BatchDeleteAsync(BatchDeleteCatalogObjectsRequest { ... }) -> BatchDeleteCatalogObjectsResponse +
client.Catalog.BatchDeleteAsync(Square.Catalog.BatchDeleteCatalogObjectsRequest { ... }) -> BatchDeleteCatalogObjectsResponse
@@ -1625,7 +1625,7 @@ await client.Catalog.BatchDeleteAsync(
-**request:** `BatchDeleteCatalogObjectsRequest` +**request:** `Square.Catalog.BatchDeleteCatalogObjectsRequest`
@@ -1637,7 +1637,7 @@ await client.Catalog.BatchDeleteAsync(
-
client.Catalog.BatchGetAsync(BatchGetCatalogObjectsRequest { ... }) -> BatchGetCatalogObjectsResponse +
client.Catalog.BatchGetAsync(Square.Catalog.BatchGetCatalogObjectsRequest { ... }) -> BatchGetCatalogObjectsResponse
@@ -1690,7 +1690,7 @@ await client.Catalog.BatchGetAsync(
-**request:** `BatchGetCatalogObjectsRequest` +**request:** `Square.Catalog.BatchGetCatalogObjectsRequest`
@@ -1702,7 +1702,7 @@ await client.Catalog.BatchGetAsync(
-
client.Catalog.BatchUpsertAsync(BatchUpsertCatalogObjectsRequest { ... }) -> BatchUpsertCatalogObjectsResponse +
client.Catalog.BatchUpsertAsync(Square.Catalog.BatchUpsertCatalogObjectsRequest { ... }) -> BatchUpsertCatalogObjectsResponse
@@ -1774,7 +1774,7 @@ await client.Catalog.BatchUpsertAsync(
-**request:** `BatchUpsertCatalogObjectsRequest` +**request:** `Square.Catalog.BatchUpsertCatalogObjectsRequest`
@@ -1826,7 +1826,7 @@ await client.Catalog.InfoAsync();
-
client.Catalog.ListAsync(ListCatalogRequest { ... }) -> Pager +
client.Catalog.ListAsync(Square.Catalog.ListCatalogRequest { ... }) -> Core.Pager
@@ -1882,7 +1882,7 @@ await client.Catalog.ListAsync(
-**request:** `ListCatalogRequest` +**request:** `Square.Catalog.ListCatalogRequest`
@@ -1894,7 +1894,7 @@ await client.Catalog.ListAsync(
-
client.Catalog.SearchAsync(SearchCatalogObjectsRequest { ... }) -> SearchCatalogObjectsResponse +
client.Catalog.SearchAsync(Square.Catalog.SearchCatalogObjectsRequest { ... }) -> SearchCatalogObjectsResponse
@@ -1959,7 +1959,7 @@ await client.Catalog.SearchAsync(
-**request:** `SearchCatalogObjectsRequest` +**request:** `Square.Catalog.SearchCatalogObjectsRequest`
@@ -1971,7 +1971,7 @@ await client.Catalog.SearchAsync(
-
client.Catalog.SearchItemsAsync(SearchCatalogItemsRequest { ... }) -> SearchCatalogItemsResponse +
client.Catalog.SearchItemsAsync(Square.Catalog.SearchCatalogItemsRequest { ... }) -> SearchCatalogItemsResponse
@@ -2036,7 +2036,7 @@ await client.Catalog.SearchItemsAsync( new CustomAttributeFilter { Key = "VINTAGE", - NumberFilter = new Range { Min = "min", Max = "max" }, + NumberFilter = new Square.Range { Min = "min", Max = "max" }, }, new CustomAttributeFilter { CustomAttributeDefinitionId = "VARIETAL_DEFINITION_ID" }, }, @@ -2056,7 +2056,7 @@ await client.Catalog.SearchItemsAsync(
-**request:** `SearchCatalogItemsRequest` +**request:** `Square.Catalog.SearchCatalogItemsRequest`
@@ -2068,7 +2068,7 @@ await client.Catalog.SearchItemsAsync(
-
client.Catalog.UpdateItemModifierListsAsync(UpdateItemModifierListsRequest { ... }) -> UpdateItemModifierListsResponse +
client.Catalog.UpdateItemModifierListsAsync(Square.Catalog.UpdateItemModifierListsRequest { ... }) -> UpdateItemModifierListsResponse
@@ -2123,7 +2123,7 @@ await client.Catalog.UpdateItemModifierListsAsync(
-**request:** `UpdateItemModifierListsRequest` +**request:** `Square.Catalog.UpdateItemModifierListsRequest`
@@ -2135,7 +2135,7 @@ await client.Catalog.UpdateItemModifierListsAsync(
-
client.Catalog.UpdateItemTaxesAsync(UpdateItemTaxesRequest { ... }) -> UpdateItemTaxesResponse +
client.Catalog.UpdateItemTaxesAsync(Square.Catalog.UpdateItemTaxesRequest { ... }) -> UpdateItemTaxesResponse
@@ -2186,7 +2186,7 @@ await client.Catalog.UpdateItemTaxesAsync(
-**request:** `UpdateItemTaxesRequest` +**request:** `Square.Catalog.UpdateItemTaxesRequest`
@@ -2199,7 +2199,7 @@ await client.Catalog.UpdateItemTaxesAsync(
## Channels -
client.Channels.ListAsync(ListChannelsRequest { ... }) -> Pager +
client.Channels.ListAsync(Channels.ListChannelsRequest { ... }) -> Core.Pager
@@ -2250,7 +2250,7 @@ await client.Channels.ListAsync(
-**request:** `ListChannelsRequest` +**request:** `Channels.ListChannelsRequest`
@@ -2262,7 +2262,7 @@ await client.Channels.ListAsync(
-
client.Channels.BulkRetrieveAsync(BulkRetrieveChannelsRequest { ... }) -> BulkRetrieveChannelsResponse +
client.Channels.BulkRetrieveAsync(Channels.BulkRetrieveChannelsRequest { ... }) -> BulkRetrieveChannelsResponse
@@ -2309,7 +2309,7 @@ await client.Channels.BulkRetrieveAsync(
-**request:** `BulkRetrieveChannelsRequest` +**request:** `Channels.BulkRetrieveChannelsRequest`
@@ -2321,7 +2321,7 @@ await client.Channels.BulkRetrieveAsync(
-
client.Channels.GetAsync(GetChannelsRequest { ... }) -> RetrieveChannelResponse +
client.Channels.GetAsync(Channels.GetChannelsRequest { ... }) -> RetrieveChannelResponse
@@ -2363,7 +2363,7 @@ await client.Channels.GetAsync(new GetChannelsRequest { ChannelId = "channel_id"
-**request:** `GetChannelsRequest` +**request:** `Channels.GetChannelsRequest`
@@ -2376,7 +2376,7 @@ await client.Channels.GetAsync(new GetChannelsRequest { ChannelId = "channel_id"
## Customers -
client.Customers.ListAsync(ListCustomersRequest { ... }) -> Pager +
client.Customers.ListAsync(Square.Customers.ListCustomersRequest { ... }) -> Core.Pager
@@ -2431,7 +2431,7 @@ await client.Customers.ListAsync(
-**request:** `ListCustomersRequest` +**request:** `Square.Customers.ListCustomersRequest`
@@ -2443,7 +2443,7 @@ await client.Customers.ListAsync(
-
client.Customers.CreateAsync(CreateCustomerRequest { ... }) -> CreateCustomerResponse +
client.Customers.CreateAsync(Square.Customers.CreateCustomerRequest { ... }) -> CreateCustomerResponse
@@ -2513,7 +2513,7 @@ await client.Customers.CreateAsync(
-**request:** `CreateCustomerRequest` +**request:** `Square.Customers.CreateCustomerRequest`
@@ -2525,7 +2525,7 @@ await client.Customers.CreateAsync(
-
client.Customers.BatchCreateAsync(BulkCreateCustomersRequest { ... }) -> BulkCreateCustomersResponse +
client.Customers.BatchCreateAsync(Square.Customers.BulkCreateCustomersRequest { ... }) -> BulkCreateCustomersResponse
@@ -2626,7 +2626,7 @@ await client.Customers.BatchCreateAsync(
-**request:** `BulkCreateCustomersRequest` +**request:** `Square.Customers.BulkCreateCustomersRequest`
@@ -2638,7 +2638,7 @@ await client.Customers.BatchCreateAsync(
-
client.Customers.BulkDeleteCustomersAsync(BulkDeleteCustomersRequest { ... }) -> BulkDeleteCustomersResponse +
client.Customers.BulkDeleteCustomersAsync(Square.Customers.BulkDeleteCustomersRequest { ... }) -> BulkDeleteCustomersResponse
@@ -2692,7 +2692,7 @@ await client.Customers.BulkDeleteCustomersAsync(
-**request:** `BulkDeleteCustomersRequest` +**request:** `Square.Customers.BulkDeleteCustomersRequest`
@@ -2704,7 +2704,7 @@ await client.Customers.BulkDeleteCustomersAsync(
-
client.Customers.BulkRetrieveCustomersAsync(BulkRetrieveCustomersRequest { ... }) -> BulkRetrieveCustomersResponse +
client.Customers.BulkRetrieveCustomersAsync(Square.Customers.BulkRetrieveCustomersRequest { ... }) -> BulkRetrieveCustomersResponse
@@ -2758,7 +2758,7 @@ await client.Customers.BulkRetrieveCustomersAsync(
-**request:** `BulkRetrieveCustomersRequest` +**request:** `Square.Customers.BulkRetrieveCustomersRequest`
@@ -2770,7 +2770,7 @@ await client.Customers.BulkRetrieveCustomersAsync(
-
client.Customers.BulkUpdateCustomersAsync(BulkUpdateCustomersRequest { ... }) -> BulkUpdateCustomersResponse +
client.Customers.BulkUpdateCustomersAsync(Square.Customers.BulkUpdateCustomersRequest { ... }) -> BulkUpdateCustomersResponse
@@ -2839,7 +2839,7 @@ await client.Customers.BulkUpdateCustomersAsync(
-**request:** `BulkUpdateCustomersRequest` +**request:** `Square.Customers.BulkUpdateCustomersRequest`
@@ -2851,7 +2851,7 @@ await client.Customers.BulkUpdateCustomersAsync(
-
client.Customers.SearchAsync(SearchCustomersRequest { ... }) -> SearchCustomersResponse +
client.Customers.SearchAsync(Square.Customers.SearchCustomersRequest { ... }) -> SearchCustomersResponse
@@ -2931,7 +2931,7 @@ await client.Customers.SearchAsync(
-**request:** `SearchCustomersRequest` +**request:** `Square.Customers.SearchCustomersRequest`
@@ -2943,7 +2943,7 @@ await client.Customers.SearchAsync(
-
client.Customers.GetAsync(GetCustomersRequest { ... }) -> GetCustomerResponse +
client.Customers.GetAsync(Square.Customers.GetCustomersRequest { ... }) -> GetCustomerResponse
@@ -2985,7 +2985,7 @@ await client.Customers.GetAsync(new GetCustomersRequest { CustomerId = "customer
-**request:** `GetCustomersRequest` +**request:** `Square.Customers.GetCustomersRequest`
@@ -2997,7 +2997,7 @@ await client.Customers.GetAsync(new GetCustomersRequest { CustomerId = "customer
-
client.Customers.UpdateAsync(UpdateCustomerRequest { ... }) -> UpdateCustomerResponse +
client.Customers.UpdateAsync(Square.Customers.UpdateCustomerRequest { ... }) -> UpdateCustomerResponse
@@ -3050,7 +3050,7 @@ await client.Customers.UpdateAsync(
-**request:** `UpdateCustomerRequest` +**request:** `Square.Customers.UpdateCustomerRequest`
@@ -3062,7 +3062,7 @@ await client.Customers.UpdateAsync(
-
client.Customers.DeleteAsync(DeleteCustomersRequest { ... }) -> DeleteCustomerResponse +
client.Customers.DeleteAsync(Square.Customers.DeleteCustomersRequest { ... }) -> DeleteCustomerResponse
@@ -3108,7 +3108,7 @@ await client.Customers.DeleteAsync(
-**request:** `DeleteCustomersRequest` +**request:** `Square.Customers.DeleteCustomersRequest`
@@ -3121,7 +3121,7 @@ await client.Customers.DeleteAsync(
## Devices -
client.Devices.ListAsync(ListDevicesRequest { ... }) -> Pager +
client.Devices.ListAsync(Square.Devices.ListDevicesRequest { ... }) -> Core.Pager
@@ -3172,7 +3172,7 @@ await client.Devices.ListAsync(
-**request:** `ListDevicesRequest` +**request:** `Square.Devices.ListDevicesRequest`
@@ -3184,7 +3184,7 @@ await client.Devices.ListAsync(
-
client.Devices.GetAsync(GetDevicesRequest { ... }) -> GetDeviceResponse +
client.Devices.GetAsync(Square.Devices.GetDevicesRequest { ... }) -> GetDeviceResponse
@@ -3226,7 +3226,7 @@ await client.Devices.GetAsync(new GetDevicesRequest { DeviceId = "device_id" });
-**request:** `GetDevicesRequest` +**request:** `Square.Devices.GetDevicesRequest`
@@ -3239,7 +3239,7 @@ await client.Devices.GetAsync(new GetDevicesRequest { DeviceId = "device_id" });
## Disputes -
client.Disputes.ListAsync(ListDisputesRequest { ... }) -> Pager +
client.Disputes.ListAsync(Square.Disputes.ListDisputesRequest { ... }) -> Core.Pager
@@ -3288,7 +3288,7 @@ await client.Disputes.ListAsync(
-**request:** `ListDisputesRequest` +**request:** `Square.Disputes.ListDisputesRequest`
@@ -3300,7 +3300,7 @@ await client.Disputes.ListAsync(
-
client.Disputes.GetAsync(GetDisputesRequest { ... }) -> GetDisputeResponse +
client.Disputes.GetAsync(Square.Disputes.GetDisputesRequest { ... }) -> GetDisputeResponse
@@ -3342,7 +3342,7 @@ await client.Disputes.GetAsync(new GetDisputesRequest { DisputeId = "dispute_id"
-**request:** `GetDisputesRequest` +**request:** `Square.Disputes.GetDisputesRequest`
@@ -3354,7 +3354,7 @@ await client.Disputes.GetAsync(new GetDisputesRequest { DisputeId = "dispute_id"
-
client.Disputes.AcceptAsync(AcceptDisputesRequest { ... }) -> AcceptDisputeResponse +
client.Disputes.AcceptAsync(Square.Disputes.AcceptDisputesRequest { ... }) -> AcceptDisputeResponse
@@ -3400,7 +3400,7 @@ await client.Disputes.AcceptAsync(new AcceptDisputesRequest { DisputeId = "dispu
-**request:** `AcceptDisputesRequest` +**request:** `Square.Disputes.AcceptDisputesRequest`
@@ -3412,7 +3412,7 @@ await client.Disputes.AcceptAsync(new AcceptDisputesRequest { DisputeId = "dispu
-
client.Disputes.CreateEvidenceTextAsync(CreateDisputeEvidenceTextRequest { ... }) -> CreateDisputeEvidenceTextResponse +
client.Disputes.CreateEvidenceTextAsync(Square.Disputes.CreateDisputeEvidenceTextRequest { ... }) -> CreateDisputeEvidenceTextResponse
@@ -3462,7 +3462,7 @@ await client.Disputes.CreateEvidenceTextAsync(
-**request:** `CreateDisputeEvidenceTextRequest` +**request:** `Square.Disputes.CreateDisputeEvidenceTextRequest`
@@ -3474,7 +3474,7 @@ await client.Disputes.CreateEvidenceTextAsync(
-
client.Disputes.SubmitEvidenceAsync(SubmitEvidenceDisputesRequest { ... }) -> SubmitEvidenceResponse +
client.Disputes.SubmitEvidenceAsync(Square.Disputes.SubmitEvidenceDisputesRequest { ... }) -> SubmitEvidenceResponse
@@ -3524,7 +3524,7 @@ await client.Disputes.SubmitEvidenceAsync(
-**request:** `SubmitEvidenceDisputesRequest` +**request:** `Square.Disputes.SubmitEvidenceDisputesRequest`
@@ -3537,7 +3537,7 @@ await client.Disputes.SubmitEvidenceAsync(
## Employees -
client.Employees.ListAsync(ListEmployeesRequest { ... }) -> Pager +
client.Employees.ListAsync(Employees.ListEmployeesRequest { ... }) -> Core.Pager
@@ -3587,7 +3587,7 @@ await client.Employees.ListAsync(
-**request:** `ListEmployeesRequest` +**request:** `Employees.ListEmployeesRequest`
@@ -3599,7 +3599,7 @@ await client.Employees.ListAsync(
-
client.Employees.GetAsync(GetEmployeesRequest { ... }) -> GetEmployeeResponse +
client.Employees.GetAsync(Employees.GetEmployeesRequest { ... }) -> GetEmployeeResponse
@@ -3641,7 +3641,7 @@ await client.Employees.GetAsync(new GetEmployeesRequest { Id = "id" });
-**request:** `GetEmployeesRequest` +**request:** `Employees.GetEmployeesRequest`
@@ -3654,7 +3654,7 @@ await client.Employees.GetAsync(new GetEmployeesRequest { Id = "id" });
## Events -
client.Events.SearchEventsAsync(SearchEventsRequest { ... }) -> SearchEventsResponse +
client.Events.SearchEventsAsync(Events.SearchEventsRequest { ... }) -> SearchEventsResponse
@@ -3696,7 +3696,7 @@ await client.Events.SearchEventsAsync(new SearchEventsRequest());
-**request:** `SearchEventsRequest` +**request:** `Events.SearchEventsRequest`
@@ -3788,7 +3788,7 @@ await client.Events.EnableEventsAsync();
-
client.Events.ListEventTypesAsync(ListEventTypesRequest { ... }) -> ListEventTypesResponse +
client.Events.ListEventTypesAsync(Events.ListEventTypesRequest { ... }) -> ListEventTypesResponse
@@ -3815,7 +3815,9 @@ Lists all event types that you can subscribe to as webhooks or query using the E
```csharp -await client.Events.ListEventTypesAsync(new ListEventTypesRequest { ApiVersion = "api_version" }); +await client.Events.ListEventTypesAsync( + new Square.Events.ListEventTypesRequest { ApiVersion = "api_version" } +); ```
@@ -3830,7 +3832,7 @@ await client.Events.ListEventTypesAsync(new ListEventTypesRequest { ApiVersion =
-**request:** `ListEventTypesRequest` +**request:** `Events.ListEventTypesRequest`
@@ -3843,7 +3845,7 @@ await client.Events.ListEventTypesAsync(new ListEventTypesRequest { ApiVersion =
## GiftCards -
client.GiftCards.ListAsync(ListGiftCardsRequest { ... }) -> Pager +
client.GiftCards.ListAsync(Square.GiftCards.ListGiftCardsRequest { ... }) -> Core.Pager
@@ -3895,7 +3897,7 @@ await client.GiftCards.ListAsync(
-**request:** `ListGiftCardsRequest` +**request:** `Square.GiftCards.ListGiftCardsRequest`
@@ -3907,7 +3909,7 @@ await client.GiftCards.ListAsync(
-
client.GiftCards.CreateAsync(CreateGiftCardRequest { ... }) -> CreateGiftCardResponse +
client.GiftCards.CreateAsync(Square.GiftCards.CreateGiftCardRequest { ... }) -> CreateGiftCardResponse
@@ -3960,7 +3962,7 @@ await client.GiftCards.CreateAsync(
-**request:** `CreateGiftCardRequest` +**request:** `Square.GiftCards.CreateGiftCardRequest`
@@ -3972,7 +3974,7 @@ await client.GiftCards.CreateAsync(
-
client.GiftCards.GetFromGanAsync(GetGiftCardFromGanRequest { ... }) -> GetGiftCardFromGanResponse +
client.GiftCards.GetFromGanAsync(Square.GiftCards.GetGiftCardFromGanRequest { ... }) -> GetGiftCardFromGanResponse
@@ -4014,7 +4016,7 @@ await client.GiftCards.GetFromGanAsync(new GetGiftCardFromGanRequest { Gan = "77
-**request:** `GetGiftCardFromGanRequest` +**request:** `Square.GiftCards.GetGiftCardFromGanRequest`
@@ -4026,7 +4028,7 @@ await client.GiftCards.GetFromGanAsync(new GetGiftCardFromGanRequest { Gan = "77
-
client.GiftCards.GetFromNonceAsync(GetGiftCardFromNonceRequest { ... }) -> GetGiftCardFromNonceResponse +
client.GiftCards.GetFromNonceAsync(Square.GiftCards.GetGiftCardFromNonceRequest { ... }) -> GetGiftCardFromNonceResponse
@@ -4070,7 +4072,7 @@ await client.GiftCards.GetFromNonceAsync(
-**request:** `GetGiftCardFromNonceRequest` +**request:** `Square.GiftCards.GetGiftCardFromNonceRequest`
@@ -4082,7 +4084,7 @@ await client.GiftCards.GetFromNonceAsync(
-
client.GiftCards.LinkCustomerAsync(LinkCustomerToGiftCardRequest { ... }) -> LinkCustomerToGiftCardResponse +
client.GiftCards.LinkCustomerAsync(Square.GiftCards.LinkCustomerToGiftCardRequest { ... }) -> LinkCustomerToGiftCardResponse
@@ -4130,7 +4132,7 @@ await client.GiftCards.LinkCustomerAsync(
-**request:** `LinkCustomerToGiftCardRequest` +**request:** `Square.GiftCards.LinkCustomerToGiftCardRequest`
@@ -4142,7 +4144,7 @@ await client.GiftCards.LinkCustomerAsync(
-
client.GiftCards.UnlinkCustomerAsync(UnlinkCustomerFromGiftCardRequest { ... }) -> UnlinkCustomerFromGiftCardResponse +
client.GiftCards.UnlinkCustomerAsync(Square.GiftCards.UnlinkCustomerFromGiftCardRequest { ... }) -> UnlinkCustomerFromGiftCardResponse
@@ -4190,7 +4192,7 @@ await client.GiftCards.UnlinkCustomerAsync(
-**request:** `UnlinkCustomerFromGiftCardRequest` +**request:** `Square.GiftCards.UnlinkCustomerFromGiftCardRequest`
@@ -4202,7 +4204,7 @@ await client.GiftCards.UnlinkCustomerAsync(
-
client.GiftCards.GetAsync(GetGiftCardsRequest { ... }) -> GetGiftCardResponse +
client.GiftCards.GetAsync(Square.GiftCards.GetGiftCardsRequest { ... }) -> GetGiftCardResponse
@@ -4244,7 +4246,7 @@ await client.GiftCards.GetAsync(new GetGiftCardsRequest { Id = "id" });
-**request:** `GetGiftCardsRequest` +**request:** `Square.GiftCards.GetGiftCardsRequest`
@@ -4257,7 +4259,7 @@ await client.GiftCards.GetAsync(new GetGiftCardsRequest { Id = "id" });
## Inventory -
client.Inventory.DeprecatedGetAdjustmentAsync(DeprecatedGetAdjustmentInventoryRequest { ... }) -> GetInventoryAdjustmentResponse +
client.Inventory.DeprecatedGetAdjustmentAsync(Inventory.DeprecatedGetAdjustmentInventoryRequest { ... }) -> GetInventoryAdjustmentResponse
@@ -4302,7 +4304,7 @@ await client.Inventory.DeprecatedGetAdjustmentAsync(
-**request:** `DeprecatedGetAdjustmentInventoryRequest` +**request:** `Inventory.DeprecatedGetAdjustmentInventoryRequest`
@@ -4314,7 +4316,7 @@ await client.Inventory.DeprecatedGetAdjustmentAsync(
-
client.Inventory.GetAdjustmentAsync(GetAdjustmentInventoryRequest { ... }) -> GetInventoryAdjustmentResponse +
client.Inventory.GetAdjustmentAsync(Inventory.GetAdjustmentInventoryRequest { ... }) -> GetInventoryAdjustmentResponse
@@ -4359,7 +4361,7 @@ await client.Inventory.GetAdjustmentAsync(
-**request:** `GetAdjustmentInventoryRequest` +**request:** `Inventory.GetAdjustmentInventoryRequest`
@@ -4657,7 +4659,7 @@ await client.Inventory.BatchCreateChangesAsync(
-
client.Inventory.BatchGetChangesAsync(BatchRetrieveInventoryChangesRequest { ... }) -> Pager +
client.Inventory.BatchGetChangesAsync(BatchRetrieveInventoryChangesRequest { ... }) -> Core.Pager
@@ -4728,7 +4730,7 @@ await client.Inventory.BatchGetChangesAsync(
-
client.Inventory.BatchGetCountsAsync(BatchGetInventoryCountsRequest { ... }) -> Pager +
client.Inventory.BatchGetCountsAsync(BatchGetInventoryCountsRequest { ... }) -> Core.Pager
@@ -4799,7 +4801,7 @@ await client.Inventory.BatchGetCountsAsync(
-
client.Inventory.DeprecatedGetPhysicalCountAsync(DeprecatedGetPhysicalCountInventoryRequest { ... }) -> GetInventoryPhysicalCountResponse +
client.Inventory.DeprecatedGetPhysicalCountAsync(Inventory.DeprecatedGetPhysicalCountInventoryRequest { ... }) -> GetInventoryPhysicalCountResponse
@@ -4844,7 +4846,7 @@ await client.Inventory.DeprecatedGetPhysicalCountAsync(
-**request:** `DeprecatedGetPhysicalCountInventoryRequest` +**request:** `Inventory.DeprecatedGetPhysicalCountInventoryRequest`
@@ -4856,7 +4858,7 @@ await client.Inventory.DeprecatedGetPhysicalCountAsync(
-
client.Inventory.GetPhysicalCountAsync(GetPhysicalCountInventoryRequest { ... }) -> GetInventoryPhysicalCountResponse +
client.Inventory.GetPhysicalCountAsync(Inventory.GetPhysicalCountInventoryRequest { ... }) -> GetInventoryPhysicalCountResponse
@@ -4901,7 +4903,7 @@ await client.Inventory.GetPhysicalCountAsync(
-**request:** `GetPhysicalCountInventoryRequest` +**request:** `Inventory.GetPhysicalCountInventoryRequest`
@@ -4913,7 +4915,7 @@ await client.Inventory.GetPhysicalCountAsync(
-
client.Inventory.GetTransferAsync(GetTransferInventoryRequest { ... }) -> GetInventoryTransferResponse +
client.Inventory.GetTransferAsync(Inventory.GetTransferInventoryRequest { ... }) -> GetInventoryTransferResponse
@@ -4958,7 +4960,7 @@ await client.Inventory.GetTransferAsync(
-**request:** `GetTransferInventoryRequest` +**request:** `Inventory.GetTransferInventoryRequest`
@@ -4970,7 +4972,7 @@ await client.Inventory.GetTransferAsync(
-
client.Inventory.GetAsync(GetInventoryRequest { ... }) -> Pager +
client.Inventory.GetAsync(Inventory.GetInventoryRequest { ... }) -> Core.Pager
@@ -5022,7 +5024,7 @@ await client.Inventory.GetAsync(
-**request:** `GetInventoryRequest` +**request:** `Inventory.GetInventoryRequest`
@@ -5034,7 +5036,7 @@ await client.Inventory.GetAsync(
-
client.Inventory.ChangesAsync(ChangesInventoryRequest { ... }) -> Pager +
client.Inventory.ChangesAsync(Inventory.ChangesInventoryRequest { ... }) -> Core.Pager
@@ -5095,7 +5097,7 @@ await client.Inventory.ChangesAsync(
-**request:** `ChangesInventoryRequest` +**request:** `Inventory.ChangesInventoryRequest`
@@ -5108,7 +5110,7 @@ await client.Inventory.ChangesAsync(
## Invoices -
client.Invoices.ListAsync(ListInvoicesRequest { ... }) -> Pager +
client.Invoices.ListAsync(Invoices.ListInvoicesRequest { ... }) -> Core.Pager
@@ -5159,7 +5161,7 @@ await client.Invoices.ListAsync(
-**request:** `ListInvoicesRequest` +**request:** `Invoices.ListInvoicesRequest`
@@ -5171,7 +5173,7 @@ await client.Invoices.ListAsync(
-
client.Invoices.CreateAsync(CreateInvoiceRequest { ... }) -> CreateInvoiceResponse +
client.Invoices.CreateAsync(Invoices.CreateInvoiceRequest { ... }) -> CreateInvoiceResponse
@@ -5276,7 +5278,7 @@ await client.Invoices.CreateAsync(
-**request:** `CreateInvoiceRequest` +**request:** `Invoices.CreateInvoiceRequest`
@@ -5288,7 +5290,7 @@ await client.Invoices.CreateAsync(
-
client.Invoices.SearchAsync(SearchInvoicesRequest { ... }) -> SearchInvoicesResponse +
client.Invoices.SearchAsync(Invoices.SearchInvoicesRequest { ... }) -> SearchInvoicesResponse
@@ -5350,7 +5352,7 @@ await client.Invoices.SearchAsync(
-**request:** `SearchInvoicesRequest` +**request:** `Invoices.SearchInvoicesRequest`
@@ -5362,7 +5364,7 @@ await client.Invoices.SearchAsync(
-
client.Invoices.GetAsync(GetInvoicesRequest { ... }) -> GetInvoiceResponse +
client.Invoices.GetAsync(Invoices.GetInvoicesRequest { ... }) -> GetInvoiceResponse
@@ -5404,7 +5406,7 @@ await client.Invoices.GetAsync(new GetInvoicesRequest { InvoiceId = "invoice_id"
-**request:** `GetInvoicesRequest` +**request:** `Invoices.GetInvoicesRequest`
@@ -5416,7 +5418,7 @@ await client.Invoices.GetAsync(new GetInvoicesRequest { InvoiceId = "invoice_id"
-
client.Invoices.UpdateAsync(UpdateInvoiceRequest { ... }) -> UpdateInvoiceResponse +
client.Invoices.UpdateAsync(Invoices.UpdateInvoiceRequest { ... }) -> UpdateInvoiceResponse
@@ -5479,7 +5481,7 @@ await client.Invoices.UpdateAsync(
-**request:** `UpdateInvoiceRequest` +**request:** `Invoices.UpdateInvoiceRequest`
@@ -5491,7 +5493,7 @@ await client.Invoices.UpdateAsync(
-
client.Invoices.DeleteAsync(DeleteInvoicesRequest { ... }) -> DeleteInvoiceResponse +
client.Invoices.DeleteAsync(Invoices.DeleteInvoicesRequest { ... }) -> DeleteInvoiceResponse
@@ -5537,7 +5539,7 @@ await client.Invoices.DeleteAsync(
-**request:** `DeleteInvoicesRequest` +**request:** `Invoices.DeleteInvoicesRequest`
@@ -5549,7 +5551,7 @@ await client.Invoices.DeleteAsync(
-
client.Invoices.DeleteInvoiceAttachmentAsync(DeleteInvoiceAttachmentRequest { ... }) -> DeleteInvoiceAttachmentResponse +
client.Invoices.DeleteInvoiceAttachmentAsync(Invoices.DeleteInvoiceAttachmentRequest { ... }) -> DeleteInvoiceAttachmentResponse
@@ -5594,7 +5596,7 @@ await client.Invoices.DeleteInvoiceAttachmentAsync(
-**request:** `DeleteInvoiceAttachmentRequest` +**request:** `Invoices.DeleteInvoiceAttachmentRequest`
@@ -5606,7 +5608,7 @@ await client.Invoices.DeleteInvoiceAttachmentAsync(
-
client.Invoices.CancelAsync(CancelInvoiceRequest { ... }) -> CancelInvoiceResponse +
client.Invoices.CancelAsync(Invoices.CancelInvoiceRequest { ... }) -> CancelInvoiceResponse
@@ -5653,7 +5655,7 @@ await client.Invoices.CancelAsync(
-**request:** `CancelInvoiceRequest` +**request:** `Invoices.CancelInvoiceRequest`
@@ -5665,7 +5667,7 @@ await client.Invoices.CancelAsync(
-
client.Invoices.PublishAsync(PublishInvoiceRequest { ... }) -> PublishInvoiceResponse +
client.Invoices.PublishAsync(Invoices.PublishInvoiceRequest { ... }) -> PublishInvoiceResponse
@@ -5727,7 +5729,7 @@ await client.Invoices.PublishAsync(
-**request:** `PublishInvoiceRequest` +**request:** `Invoices.PublishInvoiceRequest`
@@ -5740,7 +5742,7 @@ await client.Invoices.PublishAsync(
## Labor -
client.Labor.CreateScheduledShiftAsync(CreateScheduledShiftRequest { ... }) -> CreateScheduledShiftResponse +
client.Labor.CreateScheduledShiftAsync(Square.Labor.CreateScheduledShiftRequest { ... }) -> CreateScheduledShiftResponse
@@ -5807,7 +5809,7 @@ await client.Labor.CreateScheduledShiftAsync(
-**request:** `CreateScheduledShiftRequest` +**request:** `Square.Labor.CreateScheduledShiftRequest`
@@ -5819,7 +5821,7 @@ await client.Labor.CreateScheduledShiftAsync(
-
client.Labor.BulkPublishScheduledShiftsAsync(BulkPublishScheduledShiftsRequest { ... }) -> BulkPublishScheduledShiftsResponse +
client.Labor.BulkPublishScheduledShiftsAsync(Square.Labor.BulkPublishScheduledShiftsRequest { ... }) -> BulkPublishScheduledShiftsResponse
@@ -5875,7 +5877,7 @@ await client.Labor.BulkPublishScheduledShiftsAsync(
-**request:** `BulkPublishScheduledShiftsRequest` +**request:** `Square.Labor.BulkPublishScheduledShiftsRequest`
@@ -5887,7 +5889,7 @@ await client.Labor.BulkPublishScheduledShiftsAsync(
-
client.Labor.SearchScheduledShiftsAsync(SearchScheduledShiftsRequest { ... }) -> SearchScheduledShiftsResponse +
client.Labor.SearchScheduledShiftsAsync(Square.Labor.SearchScheduledShiftsRequest { ... }) -> SearchScheduledShiftsResponse
@@ -5948,7 +5950,7 @@ await client.Labor.SearchScheduledShiftsAsync(
-**request:** `SearchScheduledShiftsRequest` +**request:** `Square.Labor.SearchScheduledShiftsRequest`
@@ -5960,7 +5962,7 @@ await client.Labor.SearchScheduledShiftsAsync(
-
client.Labor.RetrieveScheduledShiftAsync(RetrieveScheduledShiftRequest { ... }) -> RetrieveScheduledShiftResponse +
client.Labor.RetrieveScheduledShiftAsync(Square.Labor.RetrieveScheduledShiftRequest { ... }) -> RetrieveScheduledShiftResponse
@@ -6002,7 +6004,7 @@ await client.Labor.RetrieveScheduledShiftAsync(new RetrieveScheduledShiftRequest
-**request:** `RetrieveScheduledShiftRequest` +**request:** `Square.Labor.RetrieveScheduledShiftRequest`
@@ -6014,7 +6016,7 @@ await client.Labor.RetrieveScheduledShiftAsync(new RetrieveScheduledShiftRequest
-
client.Labor.UpdateScheduledShiftAsync(UpdateScheduledShiftRequest { ... }) -> UpdateScheduledShiftResponse +
client.Labor.UpdateScheduledShiftAsync(Square.Labor.UpdateScheduledShiftRequest { ... }) -> UpdateScheduledShiftResponse
@@ -6084,7 +6086,7 @@ await client.Labor.UpdateScheduledShiftAsync(
-**request:** `UpdateScheduledShiftRequest` +**request:** `Square.Labor.UpdateScheduledShiftRequest`
@@ -6096,7 +6098,7 @@ await client.Labor.UpdateScheduledShiftAsync(
-
client.Labor.PublishScheduledShiftAsync(PublishScheduledShiftRequest { ... }) -> PublishScheduledShiftResponse +
client.Labor.PublishScheduledShiftAsync(Square.Labor.PublishScheduledShiftRequest { ... }) -> PublishScheduledShiftResponse
@@ -6147,7 +6149,7 @@ await client.Labor.PublishScheduledShiftAsync(
-**request:** `PublishScheduledShiftRequest` +**request:** `Square.Labor.PublishScheduledShiftRequest`
@@ -6159,7 +6161,7 @@ await client.Labor.PublishScheduledShiftAsync(
-
client.Labor.CreateTimecardAsync(CreateTimecardRequest { ... }) -> CreateTimecardResponse +
client.Labor.CreateTimecardAsync(Square.Labor.CreateTimecardRequest { ... }) -> CreateTimecardResponse
@@ -6249,7 +6251,7 @@ await client.Labor.CreateTimecardAsync(
-**request:** `CreateTimecardRequest` +**request:** `Square.Labor.CreateTimecardRequest`
@@ -6261,7 +6263,7 @@ await client.Labor.CreateTimecardAsync(
-
client.Labor.SearchTimecardsAsync(SearchTimecardsRequest { ... }) -> SearchTimecardsResponse +
client.Labor.SearchTimecardsAsync(Square.Labor.SearchTimecardsRequest { ... }) -> SearchTimecardsResponse
@@ -6333,7 +6335,7 @@ await client.Labor.SearchTimecardsAsync(
-**request:** `SearchTimecardsRequest` +**request:** `Square.Labor.SearchTimecardsRequest`
@@ -6345,7 +6347,7 @@ await client.Labor.SearchTimecardsAsync(
-
client.Labor.RetrieveTimecardAsync(RetrieveTimecardRequest { ... }) -> RetrieveTimecardResponse +
client.Labor.RetrieveTimecardAsync(Square.Labor.RetrieveTimecardRequest { ... }) -> RetrieveTimecardResponse
@@ -6387,7 +6389,7 @@ await client.Labor.RetrieveTimecardAsync(new RetrieveTimecardRequest { Id = "id"
-**request:** `RetrieveTimecardRequest` +**request:** `Square.Labor.RetrieveTimecardRequest`
@@ -6399,7 +6401,7 @@ await client.Labor.RetrieveTimecardAsync(new RetrieveTimecardRequest { Id = "id"
-
client.Labor.UpdateTimecardAsync(UpdateTimecardRequest { ... }) -> UpdateTimecardResponse +
client.Labor.UpdateTimecardAsync(Square.Labor.UpdateTimecardRequest { ... }) -> UpdateTimecardResponse
@@ -6481,7 +6483,7 @@ await client.Labor.UpdateTimecardAsync(
-**request:** `UpdateTimecardRequest` +**request:** `Square.Labor.UpdateTimecardRequest`
@@ -6493,7 +6495,7 @@ await client.Labor.UpdateTimecardAsync(
-
client.Labor.DeleteTimecardAsync(DeleteTimecardRequest { ... }) -> DeleteTimecardResponse +
client.Labor.DeleteTimecardAsync(Square.Labor.DeleteTimecardRequest { ... }) -> DeleteTimecardResponse
@@ -6535,7 +6537,7 @@ await client.Labor.DeleteTimecardAsync(new DeleteTimecardRequest { Id = "id" });
-**request:** `DeleteTimecardRequest` +**request:** `Square.Labor.DeleteTimecardRequest`
@@ -6588,7 +6590,7 @@ await client.Locations.ListAsync();
-
client.Locations.CreateAsync(CreateLocationRequest { ... }) -> CreateLocationResponse +
client.Locations.CreateAsync(Square.Locations.CreateLocationRequest { ... }) -> CreateLocationResponse
@@ -6652,7 +6654,7 @@ await client.Locations.CreateAsync(
-**request:** `CreateLocationRequest` +**request:** `Square.Locations.CreateLocationRequest`
@@ -6664,7 +6666,7 @@ await client.Locations.CreateAsync(
-
client.Locations.GetAsync(GetLocationsRequest { ... }) -> GetLocationResponse +
client.Locations.GetAsync(Square.Locations.GetLocationsRequest { ... }) -> GetLocationResponse
@@ -6707,7 +6709,7 @@ await client.Locations.GetAsync(new GetLocationsRequest { LocationId = "location
-**request:** `GetLocationsRequest` +**request:** `Square.Locations.GetLocationsRequest`
@@ -6719,7 +6721,7 @@ await client.Locations.GetAsync(new GetLocationsRequest { LocationId = "location
-
client.Locations.UpdateAsync(UpdateLocationRequest { ... }) -> UpdateLocationResponse +
client.Locations.UpdateAsync(Square.Locations.UpdateLocationRequest { ... }) -> UpdateLocationResponse
@@ -6758,19 +6760,19 @@ await client.Locations.UpdateAsync( { new BusinessHoursPeriod { - DayOfWeek = DayOfWeek.Fri, + DayOfWeek = Square.DayOfWeek.Fri, StartLocalTime = "07:00", EndLocalTime = "18:00", }, new BusinessHoursPeriod { - DayOfWeek = DayOfWeek.Sat, + DayOfWeek = Square.DayOfWeek.Sat, StartLocalTime = "07:00", EndLocalTime = "18:00", }, new BusinessHoursPeriod { - DayOfWeek = DayOfWeek.Sun, + DayOfWeek = Square.DayOfWeek.Sun, StartLocalTime = "09:00", EndLocalTime = "15:00", }, @@ -6794,7 +6796,7 @@ await client.Locations.UpdateAsync(
-**request:** `UpdateLocationRequest` +**request:** `Square.Locations.UpdateLocationRequest`
@@ -6806,7 +6808,7 @@ await client.Locations.UpdateAsync(
-
client.Locations.CheckoutsAsync(CreateCheckoutRequest { ... }) -> CreateCheckoutResponse +
client.Locations.CheckoutsAsync(Square.Locations.CreateCheckoutRequest { ... }) -> CreateCheckoutResponse
@@ -6949,7 +6951,7 @@ await client.Locations.CheckoutsAsync(
-**request:** `CreateCheckoutRequest` +**request:** `Square.Locations.CreateCheckoutRequest`
@@ -6962,7 +6964,7 @@ await client.Locations.CheckoutsAsync(
## Loyalty -
client.Loyalty.SearchEventsAsync(SearchLoyaltyEventsRequest { ... }) -> SearchLoyaltyEventsResponse +
client.Loyalty.SearchEventsAsync(Square.Loyalty.SearchLoyaltyEventsRequest { ... }) -> SearchLoyaltyEventsResponse
@@ -7026,7 +7028,7 @@ await client.Loyalty.SearchEventsAsync(
-**request:** `SearchLoyaltyEventsRequest` +**request:** `Square.Loyalty.SearchLoyaltyEventsRequest`
@@ -7039,7 +7041,7 @@ await client.Loyalty.SearchEventsAsync(
## Merchants -
client.Merchants.ListAsync(ListMerchantsRequest { ... }) -> Pager +
client.Merchants.ListAsync(Square.Merchants.ListMerchantsRequest { ... }) -> Core.Pager
@@ -7090,7 +7092,7 @@ await client.Merchants.ListAsync(new ListMerchantsRequest { Cursor = 1 });
-**request:** `ListMerchantsRequest` +**request:** `Square.Merchants.ListMerchantsRequest`
@@ -7102,7 +7104,7 @@ await client.Merchants.ListAsync(new ListMerchantsRequest { Cursor = 1 });
-
client.Merchants.GetAsync(GetMerchantsRequest { ... }) -> GetMerchantResponse +
client.Merchants.GetAsync(Square.Merchants.GetMerchantsRequest { ... }) -> GetMerchantResponse
@@ -7144,7 +7146,7 @@ await client.Merchants.GetAsync(new GetMerchantsRequest { MerchantId = "merchant
-**request:** `GetMerchantsRequest` +**request:** `Square.Merchants.GetMerchantsRequest`
@@ -7157,7 +7159,7 @@ await client.Merchants.GetAsync(new GetMerchantsRequest { MerchantId = "merchant
## Checkout -
client.Checkout.RetrieveLocationSettingsAsync(RetrieveLocationSettingsRequest { ... }) -> RetrieveLocationSettingsResponse +
client.Checkout.RetrieveLocationSettingsAsync(Square.Checkout.RetrieveLocationSettingsRequest { ... }) -> RetrieveLocationSettingsResponse
@@ -7201,7 +7203,7 @@ await client.Checkout.RetrieveLocationSettingsAsync(
-**request:** `RetrieveLocationSettingsRequest` +**request:** `Square.Checkout.RetrieveLocationSettingsRequest`
@@ -7213,7 +7215,7 @@ await client.Checkout.RetrieveLocationSettingsAsync(
-
client.Checkout.UpdateLocationSettingsAsync(UpdateLocationSettingsRequest { ... }) -> UpdateLocationSettingsResponse +
client.Checkout.UpdateLocationSettingsAsync(Square.Checkout.UpdateLocationSettingsRequest { ... }) -> UpdateLocationSettingsResponse
@@ -7261,7 +7263,7 @@ await client.Checkout.UpdateLocationSettingsAsync(
-**request:** `UpdateLocationSettingsRequest` +**request:** `Square.Checkout.UpdateLocationSettingsRequest`
@@ -7312,7 +7314,7 @@ await client.Checkout.RetrieveMerchantSettingsAsync();
-
client.Checkout.UpdateMerchantSettingsAsync(UpdateMerchantSettingsRequest { ... }) -> UpdateMerchantSettingsResponse +
client.Checkout.UpdateMerchantSettingsAsync(Square.Checkout.UpdateMerchantSettingsRequest { ... }) -> UpdateMerchantSettingsResponse
@@ -7356,7 +7358,7 @@ await client.Checkout.UpdateMerchantSettingsAsync(
-**request:** `UpdateMerchantSettingsRequest` +**request:** `Square.Checkout.UpdateMerchantSettingsRequest`
@@ -7494,7 +7496,7 @@ await client.Orders.CreateAsync(
-
client.Orders.BatchGetAsync(BatchGetOrdersRequest { ... }) -> BatchGetOrdersResponse +
client.Orders.BatchGetAsync(Square.Orders.BatchGetOrdersRequest { ... }) -> BatchGetOrdersResponse
@@ -7548,7 +7550,7 @@ await client.Orders.BatchGetAsync(
-**request:** `BatchGetOrdersRequest` +**request:** `Square.Orders.BatchGetOrdersRequest`
@@ -7560,7 +7562,7 @@ await client.Orders.BatchGetAsync(
-
client.Orders.CalculateAsync(CalculateOrderRequest { ... }) -> CalculateOrderResponse +
client.Orders.CalculateAsync(Square.Orders.CalculateOrderRequest { ... }) -> CalculateOrderResponse
@@ -7634,7 +7636,7 @@ await client.Orders.CalculateAsync(
-**request:** `CalculateOrderRequest` +**request:** `Square.Orders.CalculateOrderRequest`
@@ -7646,7 +7648,7 @@ await client.Orders.CalculateAsync(
-
client.Orders.CloneAsync(CloneOrderRequest { ... }) -> CloneOrderResponse +
client.Orders.CloneAsync(Square.Orders.CloneOrderRequest { ... }) -> CloneOrderResponse
@@ -7696,7 +7698,7 @@ await client.Orders.CloneAsync(
-**request:** `CloneOrderRequest` +**request:** `Square.Orders.CloneOrderRequest`
@@ -7708,7 +7710,7 @@ await client.Orders.CloneAsync(
-
client.Orders.SearchAsync(SearchOrdersRequest { ... }) -> SearchOrdersResponse +
client.Orders.SearchAsync(Square.Orders.SearchOrdersRequest { ... }) -> SearchOrdersResponse
@@ -7796,7 +7798,7 @@ await client.Orders.SearchAsync(
-**request:** `SearchOrdersRequest` +**request:** `Square.Orders.SearchOrdersRequest`
@@ -7808,7 +7810,7 @@ await client.Orders.SearchAsync(
-
client.Orders.GetAsync(GetOrdersRequest { ... }) -> GetOrderResponse +
client.Orders.GetAsync(Square.Orders.GetOrdersRequest { ... }) -> GetOrderResponse
@@ -7850,7 +7852,7 @@ await client.Orders.GetAsync(new GetOrdersRequest { OrderId = "order_id" });
-**request:** `GetOrdersRequest` +**request:** `Square.Orders.GetOrdersRequest`
@@ -7862,7 +7864,7 @@ await client.Orders.GetAsync(new GetOrdersRequest { OrderId = "order_id" });
-
client.Orders.UpdateAsync(UpdateOrderRequest { ... }) -> UpdateOrderResponse +
client.Orders.UpdateAsync(Square.Orders.UpdateOrderRequest { ... }) -> UpdateOrderResponse
@@ -7940,7 +7942,7 @@ await client.Orders.UpdateAsync(
-**request:** `UpdateOrderRequest` +**request:** `Square.Orders.UpdateOrderRequest`
@@ -7952,7 +7954,7 @@ await client.Orders.UpdateAsync(
-
client.Orders.PayAsync(PayOrderRequest { ... }) -> PayOrderResponse +
client.Orders.PayAsync(Square.Orders.PayOrderRequest { ... }) -> PayOrderResponse
@@ -8018,7 +8020,7 @@ await client.Orders.PayAsync(
-**request:** `PayOrderRequest` +**request:** `Square.Orders.PayOrderRequest`
@@ -8031,7 +8033,7 @@ await client.Orders.PayAsync(
## Payments -
client.Payments.ListAsync(ListPaymentsRequest { ... }) -> Pager +
client.Payments.ListAsync(Payments.ListPaymentsRequest { ... }) -> Core.Pager
@@ -8097,7 +8099,7 @@ await client.Payments.ListAsync(
-**request:** `ListPaymentsRequest` +**request:** `Payments.ListPaymentsRequest`
@@ -8109,7 +8111,7 @@ await client.Payments.ListAsync(
-
client.Payments.CreateAsync(CreatePaymentRequest { ... }) -> CreatePaymentResponse +
client.Payments.CreateAsync(Payments.CreatePaymentRequest { ... }) -> CreatePaymentResponse
@@ -8171,7 +8173,7 @@ await client.Payments.CreateAsync(
-**request:** `CreatePaymentRequest` +**request:** `Payments.CreatePaymentRequest`
@@ -8183,7 +8185,7 @@ await client.Payments.CreateAsync(
-
client.Payments.CancelByIdempotencyKeyAsync(CancelPaymentByIdempotencyKeyRequest { ... }) -> CancelPaymentByIdempotencyKeyResponse +
client.Payments.CancelByIdempotencyKeyAsync(Payments.CancelPaymentByIdempotencyKeyRequest { ... }) -> CancelPaymentByIdempotencyKeyResponse
@@ -8240,7 +8242,7 @@ await client.Payments.CancelByIdempotencyKeyAsync(
-**request:** `CancelPaymentByIdempotencyKeyRequest` +**request:** `Payments.CancelPaymentByIdempotencyKeyRequest`
@@ -8252,7 +8254,7 @@ await client.Payments.CancelByIdempotencyKeyAsync(
-
client.Payments.GetAsync(GetPaymentsRequest { ... }) -> GetPaymentResponse +
client.Payments.GetAsync(Payments.GetPaymentsRequest { ... }) -> GetPaymentResponse
@@ -8294,7 +8296,7 @@ await client.Payments.GetAsync(new GetPaymentsRequest { PaymentId = "payment_id"
-**request:** `GetPaymentsRequest` +**request:** `Payments.GetPaymentsRequest`
@@ -8306,7 +8308,7 @@ await client.Payments.GetAsync(new GetPaymentsRequest { PaymentId = "payment_id"
-
client.Payments.UpdateAsync(UpdatePaymentRequest { ... }) -> UpdatePaymentResponse +
client.Payments.UpdateAsync(Payments.UpdatePaymentRequest { ... }) -> UpdatePaymentResponse
@@ -8361,7 +8363,7 @@ await client.Payments.UpdateAsync(
-**request:** `UpdatePaymentRequest` +**request:** `Payments.UpdatePaymentRequest`
@@ -8373,7 +8375,7 @@ await client.Payments.UpdateAsync(
-
client.Payments.CancelAsync(CancelPaymentsRequest { ... }) -> CancelPaymentResponse +
client.Payments.CancelAsync(Payments.CancelPaymentsRequest { ... }) -> CancelPaymentResponse
@@ -8416,7 +8418,7 @@ await client.Payments.CancelAsync(new CancelPaymentsRequest { PaymentId = "payme
-**request:** `CancelPaymentsRequest` +**request:** `Payments.CancelPaymentsRequest`
@@ -8428,7 +8430,7 @@ await client.Payments.CancelAsync(new CancelPaymentsRequest { PaymentId = "payme
-
client.Payments.CompleteAsync(CompletePaymentRequest { ... }) -> CompletePaymentResponse +
client.Payments.CompleteAsync(Payments.CompletePaymentRequest { ... }) -> CompletePaymentResponse
@@ -8473,7 +8475,7 @@ await client.Payments.CompleteAsync(new CompletePaymentRequest { PaymentId = "pa
-**request:** `CompletePaymentRequest` +**request:** `Payments.CompletePaymentRequest`
@@ -8486,7 +8488,7 @@ await client.Payments.CompleteAsync(new CompletePaymentRequest { PaymentId = "pa
## Payouts -
client.Payouts.ListAsync(ListPayoutsRequest { ... }) -> Pager +
client.Payouts.ListAsync(Payouts.ListPayoutsRequest { ... }) -> Core.Pager
@@ -8541,7 +8543,7 @@ await client.Payouts.ListAsync(
-**request:** `ListPayoutsRequest` +**request:** `Payouts.ListPayoutsRequest`
@@ -8553,7 +8555,7 @@ await client.Payouts.ListAsync(
-
client.Payouts.GetAsync(GetPayoutsRequest { ... }) -> GetPayoutResponse +
client.Payouts.GetAsync(Payouts.GetPayoutsRequest { ... }) -> GetPayoutResponse
@@ -8596,7 +8598,7 @@ await client.Payouts.GetAsync(new GetPayoutsRequest { PayoutId = "payout_id" });
-**request:** `GetPayoutsRequest` +**request:** `Payouts.GetPayoutsRequest`
@@ -8608,7 +8610,7 @@ await client.Payouts.GetAsync(new GetPayoutsRequest { PayoutId = "payout_id" });
-
client.Payouts.ListEntriesAsync(ListEntriesPayoutsRequest { ... }) -> Pager +
client.Payouts.ListEntriesAsync(Payouts.ListEntriesPayoutsRequest { ... }) -> Core.Pager
@@ -8659,7 +8661,7 @@ await client.Payouts.ListEntriesAsync(
-**request:** `ListEntriesPayoutsRequest` +**request:** `Payouts.ListEntriesPayoutsRequest`
@@ -8672,7 +8674,7 @@ await client.Payouts.ListEntriesAsync(
## Refunds -
client.Refunds.ListAsync(ListRefundsRequest { ... }) -> Pager +
client.Refunds.ListAsync(Refunds.ListRefundsRequest { ... }) -> Core.Pager
@@ -8734,7 +8736,7 @@ await client.Refunds.ListAsync(
-**request:** `ListRefundsRequest` +**request:** `Refunds.ListRefundsRequest`
@@ -8746,7 +8748,7 @@ await client.Refunds.ListAsync(
-
client.Refunds.RefundPaymentAsync(RefundPaymentRequest { ... }) -> RefundPaymentResponse +
client.Refunds.RefundPaymentAsync(Refunds.RefundPaymentRequest { ... }) -> RefundPaymentResponse
@@ -8800,7 +8802,7 @@ await client.Refunds.RefundPaymentAsync(
-**request:** `RefundPaymentRequest` +**request:** `Refunds.RefundPaymentRequest`
@@ -8812,7 +8814,7 @@ await client.Refunds.RefundPaymentAsync(
-
client.Refunds.GetAsync(GetRefundsRequest { ... }) -> GetPaymentRefundResponse +
client.Refunds.GetAsync(Refunds.GetRefundsRequest { ... }) -> GetPaymentRefundResponse
@@ -8839,7 +8841,7 @@ Retrieves a specific refund using the `refund_id`.
```csharp -await client.Refunds.GetAsync(new GetRefundsRequest { RefundId = "refund_id" }); +await client.Refunds.GetAsync(new Square.Refunds.GetRefundsRequest { RefundId = "refund_id" }); ```
@@ -8854,7 +8856,7 @@ await client.Refunds.GetAsync(new GetRefundsRequest { RefundId = "refund_id" });
-**request:** `GetRefundsRequest` +**request:** `Refunds.GetRefundsRequest`
@@ -8910,7 +8912,7 @@ await client.Sites.ListAsync();
## Snippets -
client.Snippets.GetAsync(GetSnippetsRequest { ... }) -> GetSnippetResponse +
client.Snippets.GetAsync(Snippets.GetSnippetsRequest { ... }) -> GetSnippetResponse
@@ -8957,7 +8959,7 @@ await client.Snippets.GetAsync(new GetSnippetsRequest { SiteId = "site_id" });
-**request:** `GetSnippetsRequest` +**request:** `Snippets.GetSnippetsRequest`
@@ -8969,7 +8971,7 @@ await client.Snippets.GetAsync(new GetSnippetsRequest { SiteId = "site_id" });
-
client.Snippets.UpsertAsync(UpsertSnippetRequest { ... }) -> UpsertSnippetResponse +
client.Snippets.UpsertAsync(Snippets.UpsertSnippetRequest { ... }) -> UpsertSnippetResponse
@@ -9023,7 +9025,7 @@ await client.Snippets.UpsertAsync(
-**request:** `UpsertSnippetRequest` +**request:** `Snippets.UpsertSnippetRequest`
@@ -9035,7 +9037,7 @@ await client.Snippets.UpsertAsync(
-
client.Snippets.DeleteAsync(DeleteSnippetsRequest { ... }) -> DeleteSnippetResponse +
client.Snippets.DeleteAsync(Snippets.DeleteSnippetsRequest { ... }) -> DeleteSnippetResponse
@@ -9082,7 +9084,7 @@ await client.Snippets.DeleteAsync(new DeleteSnippetsRequest { SiteId = "site_id"
-**request:** `DeleteSnippetsRequest` +**request:** `Snippets.DeleteSnippetsRequest`
@@ -9095,7 +9097,7 @@ await client.Snippets.DeleteAsync(new DeleteSnippetsRequest { SiteId = "site_id"
## Subscriptions -
client.Subscriptions.CreateAsync(CreateSubscriptionRequest { ... }) -> CreateSubscriptionResponse +
client.Subscriptions.CreateAsync(Subscriptions.CreateSubscriptionRequest { ... }) -> CreateSubscriptionResponse
@@ -9160,7 +9162,7 @@ await client.Subscriptions.CreateAsync(
-**request:** `CreateSubscriptionRequest` +**request:** `Subscriptions.CreateSubscriptionRequest`
@@ -9172,7 +9174,7 @@ await client.Subscriptions.CreateAsync(
-
client.Subscriptions.BulkSwapPlanAsync(BulkSwapPlanRequest { ... }) -> BulkSwapPlanResponse +
client.Subscriptions.BulkSwapPlanAsync(Subscriptions.BulkSwapPlanRequest { ... }) -> BulkSwapPlanResponse
@@ -9222,7 +9224,7 @@ await client.Subscriptions.BulkSwapPlanAsync(
-**request:** `BulkSwapPlanRequest` +**request:** `Subscriptions.BulkSwapPlanRequest`
@@ -9234,7 +9236,7 @@ await client.Subscriptions.BulkSwapPlanAsync(
-
client.Subscriptions.SearchAsync(SearchSubscriptionsRequest { ... }) -> SearchSubscriptionsResponse +
client.Subscriptions.SearchAsync(Subscriptions.SearchSubscriptionsRequest { ... }) -> SearchSubscriptionsResponse
@@ -9302,7 +9304,7 @@ await client.Subscriptions.SearchAsync(
-**request:** `SearchSubscriptionsRequest` +**request:** `Subscriptions.SearchSubscriptionsRequest`
@@ -9314,7 +9316,7 @@ await client.Subscriptions.SearchAsync(
-
client.Subscriptions.GetAsync(GetSubscriptionsRequest { ... }) -> GetSubscriptionResponse +
client.Subscriptions.GetAsync(Subscriptions.GetSubscriptionsRequest { ... }) -> GetSubscriptionResponse
@@ -9342,7 +9344,11 @@ Retrieves a specific subscription. ```csharp await client.Subscriptions.GetAsync( - new GetSubscriptionsRequest { SubscriptionId = "subscription_id", Include = "include" } + new Square.Subscriptions.GetSubscriptionsRequest + { + SubscriptionId = "subscription_id", + Include = "include", + } ); ```
@@ -9358,7 +9364,7 @@ await client.Subscriptions.GetAsync(
-**request:** `GetSubscriptionsRequest` +**request:** `Subscriptions.GetSubscriptionsRequest`
@@ -9370,7 +9376,7 @@ await client.Subscriptions.GetAsync(
-
client.Subscriptions.UpdateAsync(UpdateSubscriptionRequest { ... }) -> UpdateSubscriptionResponse +
client.Subscriptions.UpdateAsync(Subscriptions.UpdateSubscriptionRequest { ... }) -> UpdateSubscriptionResponse
@@ -9419,7 +9425,7 @@ await client.Subscriptions.UpdateAsync(
-**request:** `UpdateSubscriptionRequest` +**request:** `Subscriptions.UpdateSubscriptionRequest`
@@ -9431,7 +9437,7 @@ await client.Subscriptions.UpdateAsync(
-
client.Subscriptions.DeleteActionAsync(DeleteActionSubscriptionsRequest { ... }) -> DeleteSubscriptionActionResponse +
client.Subscriptions.DeleteActionAsync(Subscriptions.DeleteActionSubscriptionsRequest { ... }) -> DeleteSubscriptionActionResponse
@@ -9479,7 +9485,7 @@ await client.Subscriptions.DeleteActionAsync(
-**request:** `DeleteActionSubscriptionsRequest` +**request:** `Subscriptions.DeleteActionSubscriptionsRequest`
@@ -9491,7 +9497,7 @@ await client.Subscriptions.DeleteActionAsync(
-
client.Subscriptions.ChangeBillingAnchorDateAsync(ChangeBillingAnchorDateRequest { ... }) -> ChangeBillingAnchorDateResponse +
client.Subscriptions.ChangeBillingAnchorDateAsync(Subscriptions.ChangeBillingAnchorDateRequest { ... }) -> ChangeBillingAnchorDateResponse
@@ -9540,7 +9546,7 @@ await client.Subscriptions.ChangeBillingAnchorDateAsync(
-**request:** `ChangeBillingAnchorDateRequest` +**request:** `Subscriptions.ChangeBillingAnchorDateRequest`
@@ -9552,7 +9558,7 @@ await client.Subscriptions.ChangeBillingAnchorDateAsync(
-
client.Subscriptions.CancelAsync(CancelSubscriptionsRequest { ... }) -> CancelSubscriptionResponse +
client.Subscriptions.CancelAsync(Subscriptions.CancelSubscriptionsRequest { ... }) -> CancelSubscriptionResponse
@@ -9598,7 +9604,7 @@ await client.Subscriptions.CancelAsync(
-**request:** `CancelSubscriptionsRequest` +**request:** `Subscriptions.CancelSubscriptionsRequest`
@@ -9610,7 +9616,7 @@ await client.Subscriptions.CancelAsync(
-
client.Subscriptions.ListEventsAsync(ListEventsSubscriptionsRequest { ... }) -> Pager +
client.Subscriptions.ListEventsAsync(Subscriptions.ListEventsSubscriptionsRequest { ... }) -> Core.Pager
@@ -9659,7 +9665,7 @@ await client.Subscriptions.ListEventsAsync(
-**request:** `ListEventsSubscriptionsRequest` +**request:** `Subscriptions.ListEventsSubscriptionsRequest`
@@ -9671,7 +9677,7 @@ await client.Subscriptions.ListEventsAsync(
-
client.Subscriptions.PauseAsync(PauseSubscriptionRequest { ... }) -> PauseSubscriptionResponse +
client.Subscriptions.PauseAsync(Subscriptions.PauseSubscriptionRequest { ... }) -> PauseSubscriptionResponse
@@ -9715,7 +9721,7 @@ await client.Subscriptions.PauseAsync(
-**request:** `PauseSubscriptionRequest` +**request:** `Subscriptions.PauseSubscriptionRequest`
@@ -9727,7 +9733,7 @@ await client.Subscriptions.PauseAsync(
-
client.Subscriptions.ResumeAsync(ResumeSubscriptionRequest { ... }) -> ResumeSubscriptionResponse +
client.Subscriptions.ResumeAsync(Subscriptions.ResumeSubscriptionRequest { ... }) -> ResumeSubscriptionResponse
@@ -9771,7 +9777,7 @@ await client.Subscriptions.ResumeAsync(
-**request:** `ResumeSubscriptionRequest` +**request:** `Subscriptions.ResumeSubscriptionRequest`
@@ -9783,7 +9789,7 @@ await client.Subscriptions.ResumeAsync(
-
client.Subscriptions.SwapPlanAsync(SwapPlanRequest { ... }) -> SwapPlanResponse +
client.Subscriptions.SwapPlanAsync(Subscriptions.SwapPlanRequest { ... }) -> SwapPlanResponse
@@ -9836,7 +9842,7 @@ await client.Subscriptions.SwapPlanAsync(
-**request:** `SwapPlanRequest` +**request:** `Subscriptions.SwapPlanRequest`
@@ -9947,7 +9953,7 @@ await client.TeamMembers.CreateAsync(
-
client.TeamMembers.BatchCreateAsync(BatchCreateTeamMembersRequest { ... }) -> BatchCreateTeamMembersResponse +
client.TeamMembers.BatchCreateAsync(Square.TeamMembers.BatchCreateTeamMembersRequest { ... }) -> BatchCreateTeamMembersResponse
@@ -10040,7 +10046,7 @@ await client.TeamMembers.BatchCreateAsync(
-**request:** `BatchCreateTeamMembersRequest` +**request:** `Square.TeamMembers.BatchCreateTeamMembersRequest`
@@ -10052,7 +10058,7 @@ await client.TeamMembers.BatchCreateAsync(
-
client.TeamMembers.BatchUpdateAsync(BatchUpdateTeamMembersRequest { ... }) -> BatchUpdateTeamMembersResponse +
client.TeamMembers.BatchUpdateAsync(Square.TeamMembers.BatchUpdateTeamMembersRequest { ... }) -> BatchUpdateTeamMembersResponse
@@ -10148,7 +10154,7 @@ await client.TeamMembers.BatchUpdateAsync(
-**request:** `BatchUpdateTeamMembersRequest` +**request:** `Square.TeamMembers.BatchUpdateTeamMembersRequest`
@@ -10160,7 +10166,7 @@ await client.TeamMembers.BatchUpdateAsync(
-
client.TeamMembers.SearchAsync(SearchTeamMembersRequest { ... }) -> SearchTeamMembersResponse +
client.TeamMembers.SearchAsync(Square.TeamMembers.SearchTeamMembersRequest { ... }) -> SearchTeamMembersResponse
@@ -10217,7 +10223,7 @@ await client.TeamMembers.SearchAsync(
-**request:** `SearchTeamMembersRequest` +**request:** `Square.TeamMembers.SearchTeamMembersRequest`
@@ -10229,7 +10235,7 @@ await client.TeamMembers.SearchAsync(
-
client.TeamMembers.GetAsync(GetTeamMembersRequest { ... }) -> GetTeamMemberResponse +
client.TeamMembers.GetAsync(Square.TeamMembers.GetTeamMembersRequest { ... }) -> GetTeamMemberResponse
@@ -10272,7 +10278,7 @@ await client.TeamMembers.GetAsync(new GetTeamMembersRequest { TeamMemberId = "te
-**request:** `GetTeamMembersRequest` +**request:** `Square.TeamMembers.GetTeamMembersRequest`
@@ -10284,7 +10290,7 @@ await client.TeamMembers.GetAsync(new GetTeamMembersRequest { TeamMemberId = "te
-
client.TeamMembers.UpdateAsync(UpdateTeamMembersRequest { ... }) -> UpdateTeamMemberResponse +
client.TeamMembers.UpdateAsync(Square.TeamMembers.UpdateTeamMembersRequest { ... }) -> UpdateTeamMemberResponse
@@ -10369,7 +10375,7 @@ await client.TeamMembers.UpdateAsync(
-**request:** `UpdateTeamMembersRequest` +**request:** `Square.TeamMembers.UpdateTeamMembersRequest`
@@ -10382,7 +10388,7 @@ await client.TeamMembers.UpdateAsync(
## Team -
client.Team.ListJobsAsync(ListJobsRequest { ... }) -> ListJobsResponse +
client.Team.ListJobsAsync(Team.ListJobsRequest { ... }) -> ListJobsResponse
@@ -10424,7 +10430,7 @@ await client.Team.ListJobsAsync(new ListJobsRequest { Cursor = "cursor" });
-**request:** `ListJobsRequest` +**request:** `Team.ListJobsRequest`
@@ -10436,7 +10442,7 @@ await client.Team.ListJobsAsync(new ListJobsRequest { Cursor = "cursor" });
-
client.Team.CreateJobAsync(CreateJobRequest { ... }) -> CreateJobResponse +
client.Team.CreateJobAsync(Team.CreateJobRequest { ... }) -> CreateJobResponse
@@ -10485,7 +10491,7 @@ await client.Team.CreateJobAsync(
-**request:** `CreateJobRequest` +**request:** `Team.CreateJobRequest`
@@ -10497,7 +10503,7 @@ await client.Team.CreateJobAsync(
-
client.Team.RetrieveJobAsync(RetrieveJobRequest { ... }) -> RetrieveJobResponse +
client.Team.RetrieveJobAsync(Team.RetrieveJobRequest { ... }) -> RetrieveJobResponse
@@ -10539,7 +10545,7 @@ await client.Team.RetrieveJobAsync(new RetrieveJobRequest { JobId = "job_id" });
-**request:** `RetrieveJobRequest` +**request:** `Team.RetrieveJobRequest`
@@ -10551,7 +10557,7 @@ await client.Team.RetrieveJobAsync(new RetrieveJobRequest { JobId = "job_id" });
-
client.Team.UpdateJobAsync(UpdateJobRequest { ... }) -> UpdateJobResponse +
client.Team.UpdateJobAsync(Team.UpdateJobRequest { ... }) -> UpdateJobResponse
@@ -10601,7 +10607,7 @@ await client.Team.UpdateJobAsync(
-**request:** `UpdateJobRequest` +**request:** `Team.UpdateJobRequest`
@@ -10614,7 +10620,7 @@ await client.Team.UpdateJobAsync(
## Terminal -
client.Terminal.DismissTerminalActionAsync(DismissTerminalActionRequest { ... }) -> DismissTerminalActionResponse +
client.Terminal.DismissTerminalActionAsync(Square.Terminal.DismissTerminalActionRequest { ... }) -> DismissTerminalActionResponse
@@ -10660,7 +10666,7 @@ await client.Terminal.DismissTerminalActionAsync(
-**request:** `DismissTerminalActionRequest` +**request:** `Square.Terminal.DismissTerminalActionRequest`
@@ -10672,7 +10678,7 @@ await client.Terminal.DismissTerminalActionAsync(
-
client.Terminal.DismissTerminalCheckoutAsync(DismissTerminalCheckoutRequest { ... }) -> DismissTerminalCheckoutResponse +
client.Terminal.DismissTerminalCheckoutAsync(Square.Terminal.DismissTerminalCheckoutRequest { ... }) -> DismissTerminalCheckoutResponse
@@ -10716,7 +10722,7 @@ await client.Terminal.DismissTerminalCheckoutAsync(
-**request:** `DismissTerminalCheckoutRequest` +**request:** `Square.Terminal.DismissTerminalCheckoutRequest`
@@ -10728,7 +10734,7 @@ await client.Terminal.DismissTerminalCheckoutAsync(
-
client.Terminal.DismissTerminalRefundAsync(DismissTerminalRefundRequest { ... }) -> DismissTerminalRefundResponse +
client.Terminal.DismissTerminalRefundAsync(Square.Terminal.DismissTerminalRefundRequest { ... }) -> DismissTerminalRefundResponse
@@ -10772,7 +10778,7 @@ await client.Terminal.DismissTerminalRefundAsync(
-**request:** `DismissTerminalRefundRequest` +**request:** `Square.Terminal.DismissTerminalRefundRequest`
@@ -10785,7 +10791,7 @@ await client.Terminal.DismissTerminalRefundAsync(
## TransferOrders -
client.TransferOrders.CreateAsync(CreateTransferOrderRequest { ... }) -> CreateTransferOrderResponse +
client.TransferOrders.CreateAsync(TransferOrders.CreateTransferOrderRequest { ... }) -> CreateTransferOrderResponse
@@ -10873,7 +10879,7 @@ await client.TransferOrders.CreateAsync(
-**request:** `CreateTransferOrderRequest` +**request:** `TransferOrders.CreateTransferOrderRequest`
@@ -10885,7 +10891,7 @@ await client.TransferOrders.CreateAsync(
-
client.TransferOrders.SearchAsync(SearchTransferOrdersRequest { ... }) -> Pager +
client.TransferOrders.SearchAsync(TransferOrders.SearchTransferOrdersRequest { ... }) -> Core.Pager
@@ -10957,7 +10963,7 @@ await client.TransferOrders.SearchAsync(
-**request:** `SearchTransferOrdersRequest` +**request:** `TransferOrders.SearchTransferOrdersRequest`
@@ -10969,7 +10975,7 @@ await client.TransferOrders.SearchAsync(
-
client.TransferOrders.GetAsync(GetTransferOrdersRequest { ... }) -> RetrieveTransferOrderResponse +
client.TransferOrders.GetAsync(TransferOrders.GetTransferOrdersRequest { ... }) -> RetrieveTransferOrderResponse
@@ -11019,7 +11025,7 @@ await client.TransferOrders.GetAsync(
-**request:** `GetTransferOrdersRequest` +**request:** `TransferOrders.GetTransferOrdersRequest`
@@ -11031,7 +11037,7 @@ await client.TransferOrders.GetAsync(
-
client.TransferOrders.UpdateAsync(UpdateTransferOrderRequest { ... }) -> UpdateTransferOrderResponse +
client.TransferOrders.UpdateAsync(TransferOrders.UpdateTransferOrderRequest { ... }) -> UpdateTransferOrderResponse
@@ -11101,7 +11107,7 @@ await client.TransferOrders.UpdateAsync(
-**request:** `UpdateTransferOrderRequest` +**request:** `TransferOrders.UpdateTransferOrderRequest`
@@ -11113,7 +11119,7 @@ await client.TransferOrders.UpdateAsync(
-
client.TransferOrders.DeleteAsync(DeleteTransferOrdersRequest { ... }) -> DeleteTransferOrderResponse +
client.TransferOrders.DeleteAsync(TransferOrders.DeleteTransferOrdersRequest { ... }) -> DeleteTransferOrderResponse
@@ -11161,7 +11167,7 @@ await client.TransferOrders.DeleteAsync(
-**request:** `DeleteTransferOrdersRequest` +**request:** `TransferOrders.DeleteTransferOrdersRequest`
@@ -11173,7 +11179,7 @@ await client.TransferOrders.DeleteAsync(
-
client.TransferOrders.CancelAsync(CancelTransferOrderRequest { ... }) -> CancelTransferOrderResponse +
client.TransferOrders.CancelAsync(TransferOrders.CancelTransferOrderRequest { ... }) -> CancelTransferOrderResponse
@@ -11231,7 +11237,7 @@ await client.TransferOrders.CancelAsync(
-**request:** `CancelTransferOrderRequest` +**request:** `TransferOrders.CancelTransferOrderRequest`
@@ -11243,7 +11249,7 @@ await client.TransferOrders.CancelAsync(
-
client.TransferOrders.ReceiveAsync(ReceiveTransferOrderRequest { ... }) -> ReceiveTransferOrderResponse +
client.TransferOrders.ReceiveAsync(TransferOrders.ReceiveTransferOrderRequest { ... }) -> ReceiveTransferOrderResponse
@@ -11326,7 +11332,7 @@ await client.TransferOrders.ReceiveAsync(
-**request:** `ReceiveTransferOrderRequest` +**request:** `TransferOrders.ReceiveTransferOrderRequest`
@@ -11338,7 +11344,7 @@ await client.TransferOrders.ReceiveAsync(
-
client.TransferOrders.StartAsync(StartTransferOrderRequest { ... }) -> StartTransferOrderResponse +
client.TransferOrders.StartAsync(TransferOrders.StartTransferOrderRequest { ... }) -> StartTransferOrderResponse
@@ -11394,7 +11400,7 @@ await client.TransferOrders.StartAsync(
-**request:** `StartTransferOrderRequest` +**request:** `TransferOrders.StartTransferOrderRequest`
@@ -11407,7 +11413,7 @@ await client.TransferOrders.StartAsync(
## Vendors -
client.Vendors.BatchCreateAsync(BatchCreateVendorsRequest { ... }) -> BatchCreateVendorsResponse +
client.Vendors.BatchCreateAsync(Vendors.BatchCreateVendorsRequest { ... }) -> BatchCreateVendorsResponse
@@ -11484,7 +11490,7 @@ await client.Vendors.BatchCreateAsync(
-**request:** `BatchCreateVendorsRequest` +**request:** `Vendors.BatchCreateVendorsRequest`
@@ -11496,7 +11502,7 @@ await client.Vendors.BatchCreateAsync(
-
client.Vendors.BatchGetAsync(BatchGetVendorsRequest { ... }) -> BatchGetVendorsResponse +
client.Vendors.BatchGetAsync(Vendors.BatchGetVendorsRequest { ... }) -> BatchGetVendorsResponse
@@ -11543,7 +11549,7 @@ await client.Vendors.BatchGetAsync(
-**request:** `BatchGetVendorsRequest` +**request:** `Vendors.BatchGetVendorsRequest`
@@ -11555,7 +11561,7 @@ await client.Vendors.BatchGetAsync(
-
client.Vendors.BatchUpdateAsync(BatchUpdateVendorsRequest { ... }) -> BatchUpdateVendorsResponse +
client.Vendors.BatchUpdateAsync(Vendors.BatchUpdateVendorsRequest { ... }) -> BatchUpdateVendorsResponse
@@ -11612,7 +11618,7 @@ await client.Vendors.BatchUpdateAsync(
-**request:** `BatchUpdateVendorsRequest` +**request:** `Vendors.BatchUpdateVendorsRequest`
@@ -11624,7 +11630,7 @@ await client.Vendors.BatchUpdateAsync(
-
client.Vendors.CreateAsync(CreateVendorRequest { ... }) -> CreateVendorResponse +
client.Vendors.CreateAsync(Vendors.CreateVendorRequest { ... }) -> CreateVendorResponse
@@ -11696,7 +11702,7 @@ await client.Vendors.CreateAsync(
-**request:** `CreateVendorRequest` +**request:** `Vendors.CreateVendorRequest`
@@ -11708,7 +11714,7 @@ await client.Vendors.CreateAsync(
-
client.Vendors.SearchAsync(SearchVendorsRequest { ... }) -> SearchVendorsResponse +
client.Vendors.SearchAsync(Vendors.SearchVendorsRequest { ... }) -> SearchVendorsResponse
@@ -11750,7 +11756,7 @@ await client.Vendors.SearchAsync(new SearchVendorsRequest());
-**request:** `SearchVendorsRequest` +**request:** `Vendors.SearchVendorsRequest`
@@ -11762,7 +11768,7 @@ await client.Vendors.SearchAsync(new SearchVendorsRequest());
-
client.Vendors.GetAsync(GetVendorsRequest { ... }) -> GetVendorResponse +
client.Vendors.GetAsync(Vendors.GetVendorsRequest { ... }) -> GetVendorResponse
@@ -11804,7 +11810,7 @@ await client.Vendors.GetAsync(new GetVendorsRequest { VendorId = "vendor_id" });
-**request:** `GetVendorsRequest` +**request:** `Vendors.GetVendorsRequest`
@@ -11816,7 +11822,7 @@ await client.Vendors.GetAsync(new GetVendorsRequest { VendorId = "vendor_id" });
-
client.Vendors.UpdateAsync(UpdateVendorsRequest { ... }) -> UpdateVendorResponse +
client.Vendors.UpdateAsync(Vendors.UpdateVendorsRequest { ... }) -> UpdateVendorResponse
@@ -11874,7 +11880,7 @@ await client.Vendors.UpdateAsync(
-**request:** `UpdateVendorsRequest` +**request:** `Vendors.UpdateVendorsRequest`
@@ -11887,7 +11893,7 @@ await client.Vendors.UpdateAsync(
## Bookings CustomAttributeDefinitions -
client.Bookings.CustomAttributeDefinitions.ListAsync(ListCustomAttributeDefinitionsRequest { ... }) -> Pager +
client.Bookings.CustomAttributeDefinitions.ListAsync(Square.Bookings.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { ... }) -> Core.Pager
@@ -11918,7 +11924,11 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` ```csharp await client.Bookings.CustomAttributeDefinitions.ListAsync( - new ListCustomAttributeDefinitionsRequest { Limit = 1, Cursor = "cursor" } + new Square.Bookings.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + Limit = 1, + Cursor = "cursor", + } ); ```
@@ -11934,7 +11944,7 @@ await client.Bookings.CustomAttributeDefinitions.ListAsync(
-**request:** `ListCustomAttributeDefinitionsRequest` +**request:** `Square.Bookings.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest`
@@ -11946,7 +11956,7 @@ await client.Bookings.CustomAttributeDefinitions.ListAsync(
-
client.Bookings.CustomAttributeDefinitions.CreateAsync(CreateBookingCustomAttributeDefinitionRequest { ... }) -> CreateBookingCustomAttributeDefinitionResponse +
client.Bookings.CustomAttributeDefinitions.CreateAsync(Square.Bookings.CustomAttributeDefinitions.CreateBookingCustomAttributeDefinitionRequest { ... }) -> CreateBookingCustomAttributeDefinitionResponse
@@ -11999,7 +12009,7 @@ await client.Bookings.CustomAttributeDefinitions.CreateAsync(
-**request:** `CreateBookingCustomAttributeDefinitionRequest` +**request:** `Square.Bookings.CustomAttributeDefinitions.CreateBookingCustomAttributeDefinitionRequest`
@@ -12011,7 +12021,7 @@ await client.Bookings.CustomAttributeDefinitions.CreateAsync(
-
client.Bookings.CustomAttributeDefinitions.GetAsync(GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveBookingCustomAttributeDefinitionResponse +
client.Bookings.CustomAttributeDefinitions.GetAsync(Square.Bookings.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveBookingCustomAttributeDefinitionResponse
@@ -12042,7 +12052,11 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` ```csharp await client.Bookings.CustomAttributeDefinitions.GetAsync( - new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + new Square.Bookings.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } ); ```
@@ -12058,7 +12072,7 @@ await client.Bookings.CustomAttributeDefinitions.GetAsync(
-**request:** `GetCustomAttributeDefinitionsRequest` +**request:** `Square.Bookings.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest`
@@ -12070,7 +12084,7 @@ await client.Bookings.CustomAttributeDefinitions.GetAsync(
-
client.Bookings.CustomAttributeDefinitions.UpdateAsync(UpdateBookingCustomAttributeDefinitionRequest { ... }) -> UpdateBookingCustomAttributeDefinitionResponse +
client.Bookings.CustomAttributeDefinitions.UpdateAsync(Square.Bookings.CustomAttributeDefinitions.UpdateBookingCustomAttributeDefinitionRequest { ... }) -> UpdateBookingCustomAttributeDefinitionResponse
@@ -12124,7 +12138,7 @@ await client.Bookings.CustomAttributeDefinitions.UpdateAsync(
-**request:** `UpdateBookingCustomAttributeDefinitionRequest` +**request:** `Square.Bookings.CustomAttributeDefinitions.UpdateBookingCustomAttributeDefinitionRequest`
@@ -12136,7 +12150,7 @@ await client.Bookings.CustomAttributeDefinitions.UpdateAsync(
-
client.Bookings.CustomAttributeDefinitions.DeleteAsync(DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteBookingCustomAttributeDefinitionResponse +
client.Bookings.CustomAttributeDefinitions.DeleteAsync(Square.Bookings.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteBookingCustomAttributeDefinitionResponse
@@ -12170,7 +12184,10 @@ or *Appointments Premium*. ```csharp await client.Bookings.CustomAttributeDefinitions.DeleteAsync( - new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + new Square.Bookings.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } ); ```
@@ -12186,7 +12203,7 @@ await client.Bookings.CustomAttributeDefinitions.DeleteAsync(
-**request:** `DeleteCustomAttributeDefinitionsRequest` +**request:** `Square.Bookings.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest`
@@ -12199,7 +12216,7 @@ await client.Bookings.CustomAttributeDefinitions.DeleteAsync(
## Bookings CustomAttributes -
client.Bookings.CustomAttributes.BatchDeleteAsync(BulkDeleteBookingCustomAttributesRequest { ... }) -> BulkDeleteBookingCustomAttributesResponse +
client.Bookings.CustomAttributes.BatchDeleteAsync(Square.Bookings.CustomAttributes.BulkDeleteBookingCustomAttributesRequest { ... }) -> BulkDeleteBookingCustomAttributesResponse
@@ -12258,7 +12275,7 @@ await client.Bookings.CustomAttributes.BatchDeleteAsync(
-**request:** `BulkDeleteBookingCustomAttributesRequest` +**request:** `Square.Bookings.CustomAttributes.BulkDeleteBookingCustomAttributesRequest`
@@ -12270,7 +12287,7 @@ await client.Bookings.CustomAttributes.BatchDeleteAsync(
-
client.Bookings.CustomAttributes.BatchUpsertAsync(BulkUpsertBookingCustomAttributesRequest { ... }) -> BulkUpsertBookingCustomAttributesResponse +
client.Bookings.CustomAttributes.BatchUpsertAsync(Square.Bookings.CustomAttributes.BulkUpsertBookingCustomAttributesRequest { ... }) -> BulkUpsertBookingCustomAttributesResponse
@@ -12333,7 +12350,7 @@ await client.Bookings.CustomAttributes.BatchUpsertAsync(
-**request:** `BulkUpsertBookingCustomAttributesRequest` +**request:** `Square.Bookings.CustomAttributes.BulkUpsertBookingCustomAttributesRequest`
@@ -12345,7 +12362,7 @@ await client.Bookings.CustomAttributes.BatchUpsertAsync(
-
client.Bookings.CustomAttributes.ListAsync(ListCustomAttributesRequest { ... }) -> Pager +
client.Bookings.CustomAttributes.ListAsync(Square.Bookings.CustomAttributes.ListCustomAttributesRequest { ... }) -> Core.Pager
@@ -12376,7 +12393,7 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` ```csharp await client.Bookings.CustomAttributes.ListAsync( - new ListCustomAttributesRequest + new Square.Bookings.CustomAttributes.ListCustomAttributesRequest { BookingId = "booking_id", Limit = 1, @@ -12398,7 +12415,7 @@ await client.Bookings.CustomAttributes.ListAsync(
-**request:** `ListCustomAttributesRequest` +**request:** `Square.Bookings.CustomAttributes.ListCustomAttributesRequest`
@@ -12410,7 +12427,7 @@ await client.Bookings.CustomAttributes.ListAsync(
-
client.Bookings.CustomAttributes.GetAsync(GetCustomAttributesRequest { ... }) -> RetrieveBookingCustomAttributeResponse +
client.Bookings.CustomAttributes.GetAsync(Square.Bookings.CustomAttributes.GetCustomAttributesRequest { ... }) -> RetrieveBookingCustomAttributeResponse
@@ -12441,7 +12458,7 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` ```csharp await client.Bookings.CustomAttributes.GetAsync( - new GetCustomAttributesRequest + new Square.Bookings.CustomAttributes.GetCustomAttributesRequest { BookingId = "booking_id", Key = "key", @@ -12463,7 +12480,7 @@ await client.Bookings.CustomAttributes.GetAsync(
-**request:** `GetCustomAttributesRequest` +**request:** `Square.Bookings.CustomAttributes.GetCustomAttributesRequest`
@@ -12475,7 +12492,7 @@ await client.Bookings.CustomAttributes.GetAsync(
-
client.Bookings.CustomAttributes.UpsertAsync(UpsertBookingCustomAttributeRequest { ... }) -> UpsertBookingCustomAttributeResponse +
client.Bookings.CustomAttributes.UpsertAsync(Square.Bookings.CustomAttributes.UpsertBookingCustomAttributeRequest { ... }) -> UpsertBookingCustomAttributeResponse
@@ -12530,7 +12547,7 @@ await client.Bookings.CustomAttributes.UpsertAsync(
-**request:** `UpsertBookingCustomAttributeRequest` +**request:** `Square.Bookings.CustomAttributes.UpsertBookingCustomAttributeRequest`
@@ -12542,7 +12559,7 @@ await client.Bookings.CustomAttributes.UpsertAsync(
-
client.Bookings.CustomAttributes.DeleteAsync(DeleteCustomAttributesRequest { ... }) -> DeleteBookingCustomAttributeResponse +
client.Bookings.CustomAttributes.DeleteAsync(Square.Bookings.CustomAttributes.DeleteCustomAttributesRequest { ... }) -> DeleteBookingCustomAttributeResponse
@@ -12576,7 +12593,11 @@ or *Appointments Premium*. ```csharp await client.Bookings.CustomAttributes.DeleteAsync( - new DeleteCustomAttributesRequest { BookingId = "booking_id", Key = "key" } + new Square.Bookings.CustomAttributes.DeleteCustomAttributesRequest + { + BookingId = "booking_id", + Key = "key", + } ); ```
@@ -12592,7 +12613,7 @@ await client.Bookings.CustomAttributes.DeleteAsync(
-**request:** `DeleteCustomAttributesRequest` +**request:** `Square.Bookings.CustomAttributes.DeleteCustomAttributesRequest`
@@ -12605,7 +12626,7 @@ await client.Bookings.CustomAttributes.DeleteAsync(
## Bookings LocationProfiles -
client.Bookings.LocationProfiles.ListAsync(ListLocationProfilesRequest { ... }) -> Pager +
client.Bookings.LocationProfiles.ListAsync(Square.Bookings.LocationProfiles.ListLocationProfilesRequest { ... }) -> Core.Pager
@@ -12649,7 +12670,7 @@ await client.Bookings.LocationProfiles.ListAsync(
-**request:** `ListLocationProfilesRequest` +**request:** `Square.Bookings.LocationProfiles.ListLocationProfilesRequest`
@@ -12662,7 +12683,7 @@ await client.Bookings.LocationProfiles.ListAsync(
## Bookings TeamMemberProfiles -
client.Bookings.TeamMemberProfiles.ListAsync(ListTeamMemberProfilesRequest { ... }) -> Pager +
client.Bookings.TeamMemberProfiles.ListAsync(Square.Bookings.TeamMemberProfiles.ListTeamMemberProfilesRequest { ... }) -> Core.Pager
@@ -12712,7 +12733,7 @@ await client.Bookings.TeamMemberProfiles.ListAsync(
-**request:** `ListTeamMemberProfilesRequest` +**request:** `Square.Bookings.TeamMemberProfiles.ListTeamMemberProfilesRequest`
@@ -12724,7 +12745,7 @@ await client.Bookings.TeamMemberProfiles.ListAsync(
-
client.Bookings.TeamMemberProfiles.GetAsync(GetTeamMemberProfilesRequest { ... }) -> GetTeamMemberBookingProfileResponse +
client.Bookings.TeamMemberProfiles.GetAsync(Square.Bookings.TeamMemberProfiles.GetTeamMemberProfilesRequest { ... }) -> GetTeamMemberBookingProfileResponse
@@ -12768,7 +12789,7 @@ await client.Bookings.TeamMemberProfiles.GetAsync(
-**request:** `GetTeamMemberProfilesRequest` +**request:** `Square.Bookings.TeamMemberProfiles.GetTeamMemberProfilesRequest`
@@ -12781,7 +12802,7 @@ await client.Bookings.TeamMemberProfiles.GetAsync(
## CashDrawers Shifts -
client.CashDrawers.Shifts.ListAsync(ListShiftsRequest { ... }) -> Pager +
client.CashDrawers.Shifts.ListAsync(Square.CashDrawers.Shifts.ListShiftsRequest { ... }) -> Core.Pager
@@ -12834,7 +12855,7 @@ await client.CashDrawers.Shifts.ListAsync(
-**request:** `ListShiftsRequest` +**request:** `Square.CashDrawers.Shifts.ListShiftsRequest`
@@ -12846,7 +12867,7 @@ await client.CashDrawers.Shifts.ListAsync(
-
client.CashDrawers.Shifts.GetAsync(GetShiftsRequest { ... }) -> GetCashDrawerShiftResponse +
client.CashDrawers.Shifts.GetAsync(Square.CashDrawers.Shifts.GetShiftsRequest { ... }) -> GetCashDrawerShiftResponse
@@ -12875,7 +12896,11 @@ Provides the summary details for a single cash drawer shift. See ```csharp await client.CashDrawers.Shifts.GetAsync( - new GetShiftsRequest { ShiftId = "shift_id", LocationId = "location_id" } + new Square.CashDrawers.Shifts.GetShiftsRequest + { + ShiftId = "shift_id", + LocationId = "location_id", + } ); ```
@@ -12891,7 +12916,7 @@ await client.CashDrawers.Shifts.GetAsync(
-**request:** `GetShiftsRequest` +**request:** `Square.CashDrawers.Shifts.GetShiftsRequest`
@@ -12903,7 +12928,7 @@ await client.CashDrawers.Shifts.GetAsync(
-
client.CashDrawers.Shifts.ListEventsAsync(ListEventsShiftsRequest { ... }) -> Pager +
client.CashDrawers.Shifts.ListEventsAsync(Square.CashDrawers.Shifts.ListEventsShiftsRequest { ... }) -> Core.Pager
@@ -12953,7 +12978,7 @@ await client.CashDrawers.Shifts.ListEventsAsync(
-**request:** `ListEventsShiftsRequest` +**request:** `Square.CashDrawers.Shifts.ListEventsShiftsRequest`
@@ -12967,7 +12992,7 @@ await client.CashDrawers.Shifts.ListEventsAsync( ## Catalog Images ## Catalog Object -
client.Catalog.Object.UpsertAsync(UpsertCatalogObjectRequest { ... }) -> UpsertCatalogObjectResponse +
client.Catalog.Object.UpsertAsync(Square.Catalog.Object.UpsertCatalogObjectRequest { ... }) -> UpsertCatalogObjectResponse
@@ -13019,7 +13044,7 @@ await client.Catalog.Object.UpsertAsync(
-**request:** `UpsertCatalogObjectRequest` +**request:** `Square.Catalog.Object.UpsertCatalogObjectRequest`
@@ -13031,7 +13056,7 @@ await client.Catalog.Object.UpsertAsync(
-
client.Catalog.Object.GetAsync(GetObjectRequest { ... }) -> GetCatalogObjectResponse +
client.Catalog.Object.GetAsync(Square.Catalog.Object.GetObjectRequest { ... }) -> GetCatalogObjectResponse
@@ -13087,7 +13112,7 @@ await client.Catalog.Object.GetAsync(
-**request:** `GetObjectRequest` +**request:** `Square.Catalog.Object.GetObjectRequest`
@@ -13099,7 +13124,7 @@ await client.Catalog.Object.GetAsync(
-
client.Catalog.Object.DeleteAsync(DeleteObjectRequest { ... }) -> DeleteCatalogObjectResponse +
client.Catalog.Object.DeleteAsync(Square.Catalog.Object.DeleteObjectRequest { ... }) -> DeleteCatalogObjectResponse
@@ -13150,7 +13175,7 @@ await client.Catalog.Object.DeleteAsync(new DeleteObjectRequest { ObjectId = "ob
-**request:** `DeleteObjectRequest` +**request:** `Square.Catalog.Object.DeleteObjectRequest`
@@ -13163,7 +13188,7 @@ await client.Catalog.Object.DeleteAsync(new DeleteObjectRequest { ObjectId = "ob
## Checkout PaymentLinks -
client.Checkout.PaymentLinks.ListAsync(ListPaymentLinksRequest { ... }) -> Pager +
client.Checkout.PaymentLinks.ListAsync(Square.Checkout.PaymentLinks.ListPaymentLinksRequest { ... }) -> Core.Pager
@@ -13207,7 +13232,7 @@ await client.Checkout.PaymentLinks.ListAsync(
-**request:** `ListPaymentLinksRequest` +**request:** `Square.Checkout.PaymentLinks.ListPaymentLinksRequest`
@@ -13219,7 +13244,7 @@ await client.Checkout.PaymentLinks.ListAsync(
-
client.Checkout.PaymentLinks.CreateAsync(CreatePaymentLinkRequest { ... }) -> CreatePaymentLinkResponse +
client.Checkout.PaymentLinks.CreateAsync(Square.Checkout.PaymentLinks.CreatePaymentLinkRequest { ... }) -> CreatePaymentLinkResponse
@@ -13272,7 +13297,7 @@ await client.Checkout.PaymentLinks.CreateAsync(
-**request:** `CreatePaymentLinkRequest` +**request:** `Square.Checkout.PaymentLinks.CreatePaymentLinkRequest`
@@ -13284,7 +13309,7 @@ await client.Checkout.PaymentLinks.CreateAsync(
-
client.Checkout.PaymentLinks.GetAsync(GetPaymentLinksRequest { ... }) -> GetPaymentLinkResponse +
client.Checkout.PaymentLinks.GetAsync(Square.Checkout.PaymentLinks.GetPaymentLinksRequest { ... }) -> GetPaymentLinkResponse
@@ -13326,7 +13351,7 @@ await client.Checkout.PaymentLinks.GetAsync(new GetPaymentLinksRequest { Id = "i
-**request:** `GetPaymentLinksRequest` +**request:** `Square.Checkout.PaymentLinks.GetPaymentLinksRequest`
@@ -13338,7 +13363,7 @@ await client.Checkout.PaymentLinks.GetAsync(new GetPaymentLinksRequest { Id = "i
-
client.Checkout.PaymentLinks.UpdateAsync(UpdatePaymentLinkRequest { ... }) -> UpdatePaymentLinkResponse +
client.Checkout.PaymentLinks.UpdateAsync(Square.Checkout.PaymentLinks.UpdatePaymentLinkRequest { ... }) -> UpdatePaymentLinkResponse
@@ -13392,7 +13417,7 @@ await client.Checkout.PaymentLinks.UpdateAsync(
-**request:** `UpdatePaymentLinkRequest` +**request:** `Square.Checkout.PaymentLinks.UpdatePaymentLinkRequest`
@@ -13404,7 +13429,7 @@ await client.Checkout.PaymentLinks.UpdateAsync(
-
client.Checkout.PaymentLinks.DeleteAsync(DeletePaymentLinksRequest { ... }) -> DeletePaymentLinkResponse +
client.Checkout.PaymentLinks.DeleteAsync(Square.Checkout.PaymentLinks.DeletePaymentLinksRequest { ... }) -> DeletePaymentLinkResponse
@@ -13446,7 +13471,7 @@ await client.Checkout.PaymentLinks.DeleteAsync(new DeletePaymentLinksRequest { I
-**request:** `DeletePaymentLinksRequest` +**request:** `Square.Checkout.PaymentLinks.DeletePaymentLinksRequest`
@@ -13459,7 +13484,7 @@ await client.Checkout.PaymentLinks.DeleteAsync(new DeletePaymentLinksRequest { I
## Customers CustomAttributeDefinitions -
client.Customers.CustomAttributeDefinitions.ListAsync(ListCustomAttributeDefinitionsRequest { ... }) -> Pager +
client.Customers.CustomAttributeDefinitions.ListAsync(Square.Customers.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { ... }) -> Core.Pager
@@ -13492,7 +13517,11 @@ seller-defined custom attributes (also known as custom fields) are always set to ```csharp await client.Customers.CustomAttributeDefinitions.ListAsync( - new ListCustomAttributeDefinitionsRequest { Limit = 1, Cursor = "cursor" } + new Square.Customers.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + Limit = 1, + Cursor = "cursor", + } ); ```
@@ -13508,7 +13537,7 @@ await client.Customers.CustomAttributeDefinitions.ListAsync(
-**request:** `ListCustomAttributeDefinitionsRequest` +**request:** `Square.Customers.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest`
@@ -13520,7 +13549,7 @@ await client.Customers.CustomAttributeDefinitions.ListAsync(
-
client.Customers.CustomAttributeDefinitions.CreateAsync(CreateCustomerCustomAttributeDefinitionRequest { ... }) -> CreateCustomerCustomAttributeDefinitionResponse +
client.Customers.CustomAttributeDefinitions.CreateAsync(Square.Customers.CustomAttributeDefinitions.CreateCustomerCustomAttributeDefinitionRequest { ... }) -> CreateCustomerCustomAttributeDefinitionResponse
@@ -13563,7 +13592,7 @@ await client.Customers.CustomAttributeDefinitions.CreateAsync( CustomAttributeDefinition = new CustomAttributeDefinition { Key = "favoritemovie", - Schema = new Dictionary() + Schema = new Dictionary() { { "$ref", @@ -13590,7 +13619,7 @@ await client.Customers.CustomAttributeDefinitions.CreateAsync(
-**request:** `CreateCustomerCustomAttributeDefinitionRequest` +**request:** `Square.Customers.CustomAttributeDefinitions.CreateCustomerCustomAttributeDefinitionRequest`
@@ -13602,7 +13631,7 @@ await client.Customers.CustomAttributeDefinitions.CreateAsync(
-
client.Customers.CustomAttributeDefinitions.GetAsync(GetCustomAttributeDefinitionsRequest { ... }) -> GetCustomerCustomAttributeDefinitionResponse +
client.Customers.CustomAttributeDefinitions.GetAsync(Square.Customers.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest { ... }) -> GetCustomerCustomAttributeDefinitionResponse
@@ -13634,7 +13663,11 @@ setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note t ```csharp await client.Customers.CustomAttributeDefinitions.GetAsync( - new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + new Square.Customers.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } ); ```
@@ -13650,7 +13683,7 @@ await client.Customers.CustomAttributeDefinitions.GetAsync(
-**request:** `GetCustomAttributeDefinitionsRequest` +**request:** `Square.Customers.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest`
@@ -13662,7 +13695,7 @@ await client.Customers.CustomAttributeDefinitions.GetAsync(
-
client.Customers.CustomAttributeDefinitions.UpdateAsync(UpdateCustomerCustomAttributeDefinitionRequest { ... }) -> UpdateCustomerCustomAttributeDefinitionResponse +
client.Customers.CustomAttributeDefinitions.UpdateAsync(Square.Customers.CustomAttributeDefinitions.UpdateCustomerCustomAttributeDefinitionRequest { ... }) -> UpdateCustomerCustomAttributeDefinitionResponse
@@ -13720,7 +13753,7 @@ await client.Customers.CustomAttributeDefinitions.UpdateAsync(
-**request:** `UpdateCustomerCustomAttributeDefinitionRequest` +**request:** `Square.Customers.CustomAttributeDefinitions.UpdateCustomerCustomAttributeDefinitionRequest`
@@ -13732,7 +13765,7 @@ await client.Customers.CustomAttributeDefinitions.UpdateAsync(
-
client.Customers.CustomAttributeDefinitions.DeleteAsync(DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteCustomerCustomAttributeDefinitionResponse +
client.Customers.CustomAttributeDefinitions.DeleteAsync(Square.Customers.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteCustomerCustomAttributeDefinitionResponse
@@ -13765,7 +13798,10 @@ Only the definition owner can delete a custom attribute definition. ```csharp await client.Customers.CustomAttributeDefinitions.DeleteAsync( - new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + new Square.Customers.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } ); ```
@@ -13781,7 +13817,7 @@ await client.Customers.CustomAttributeDefinitions.DeleteAsync(
-**request:** `DeleteCustomAttributeDefinitionsRequest` +**request:** `Square.Customers.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest`
@@ -13793,7 +13829,7 @@ await client.Customers.CustomAttributeDefinitions.DeleteAsync(
-
client.Customers.CustomAttributeDefinitions.BatchUpsertAsync(BatchUpsertCustomerCustomAttributesRequest { ... }) -> BatchUpsertCustomerCustomAttributesResponse +
client.Customers.CustomAttributeDefinitions.BatchUpsertAsync(Square.Customers.CustomAttributeDefinitions.BatchUpsertCustomerCustomAttributesRequest { ... }) -> BatchUpsertCustomerCustomAttributesResponse
@@ -13910,7 +13946,7 @@ await client.Customers.CustomAttributeDefinitions.BatchUpsertAsync(
-**request:** `BatchUpsertCustomerCustomAttributesRequest` +**request:** `Square.Customers.CustomAttributeDefinitions.BatchUpsertCustomerCustomAttributesRequest`
@@ -13923,7 +13959,7 @@ await client.Customers.CustomAttributeDefinitions.BatchUpsertAsync(
## Customers Groups -
client.Customers.Groups.ListAsync(ListGroupsRequest { ... }) -> Pager +
client.Customers.Groups.ListAsync(Square.Customers.Groups.ListGroupsRequest { ... }) -> Core.Pager
@@ -13965,7 +14001,7 @@ await client.Customers.Groups.ListAsync(new ListGroupsRequest { Cursor = "cursor
-**request:** `ListGroupsRequest` +**request:** `Square.Customers.Groups.ListGroupsRequest`
@@ -13977,7 +14013,7 @@ await client.Customers.Groups.ListAsync(new ListGroupsRequest { Cursor = "cursor
-
client.Customers.Groups.CreateAsync(CreateCustomerGroupRequest { ... }) -> CreateCustomerGroupResponse +
client.Customers.Groups.CreateAsync(Square.Customers.Groups.CreateCustomerGroupRequest { ... }) -> CreateCustomerGroupResponse
@@ -14023,7 +14059,7 @@ await client.Customers.Groups.CreateAsync(
-**request:** `CreateCustomerGroupRequest` +**request:** `Square.Customers.Groups.CreateCustomerGroupRequest`
@@ -14035,7 +14071,7 @@ await client.Customers.Groups.CreateAsync(
-
client.Customers.Groups.GetAsync(GetGroupsRequest { ... }) -> GetCustomerGroupResponse +
client.Customers.Groups.GetAsync(Square.Customers.Groups.GetGroupsRequest { ... }) -> GetCustomerGroupResponse
@@ -14077,7 +14113,7 @@ await client.Customers.Groups.GetAsync(new GetGroupsRequest { GroupId = "group_i
-**request:** `GetGroupsRequest` +**request:** `Square.Customers.Groups.GetGroupsRequest`
@@ -14089,7 +14125,7 @@ await client.Customers.Groups.GetAsync(new GetGroupsRequest { GroupId = "group_i
-
client.Customers.Groups.UpdateAsync(UpdateCustomerGroupRequest { ... }) -> UpdateCustomerGroupResponse +
client.Customers.Groups.UpdateAsync(Square.Customers.Groups.UpdateCustomerGroupRequest { ... }) -> UpdateCustomerGroupResponse
@@ -14137,7 +14173,7 @@ await client.Customers.Groups.UpdateAsync(
-**request:** `UpdateCustomerGroupRequest` +**request:** `Square.Customers.Groups.UpdateCustomerGroupRequest`
@@ -14149,7 +14185,7 @@ await client.Customers.Groups.UpdateAsync(
-
client.Customers.Groups.DeleteAsync(DeleteGroupsRequest { ... }) -> DeleteCustomerGroupResponse +
client.Customers.Groups.DeleteAsync(Square.Customers.Groups.DeleteGroupsRequest { ... }) -> DeleteCustomerGroupResponse
@@ -14191,7 +14227,7 @@ await client.Customers.Groups.DeleteAsync(new DeleteGroupsRequest { GroupId = "g
-**request:** `DeleteGroupsRequest` +**request:** `Square.Customers.Groups.DeleteGroupsRequest`
@@ -14203,7 +14239,7 @@ await client.Customers.Groups.DeleteAsync(new DeleteGroupsRequest { GroupId = "g
-
client.Customers.Groups.AddAsync(AddGroupsRequest { ... }) -> AddGroupToCustomerResponse +
client.Customers.Groups.AddAsync(Square.Customers.Groups.AddGroupsRequest { ... }) -> AddGroupToCustomerResponse
@@ -14250,7 +14286,7 @@ await client.Customers.Groups.AddAsync(
-**request:** `AddGroupsRequest` +**request:** `Square.Customers.Groups.AddGroupsRequest`
@@ -14262,7 +14298,7 @@ await client.Customers.Groups.AddAsync(
-
client.Customers.Groups.RemoveAsync(RemoveGroupsRequest { ... }) -> RemoveGroupFromCustomerResponse +
client.Customers.Groups.RemoveAsync(Square.Customers.Groups.RemoveGroupsRequest { ... }) -> RemoveGroupFromCustomerResponse
@@ -14309,7 +14345,7 @@ await client.Customers.Groups.RemoveAsync(
-**request:** `RemoveGroupsRequest` +**request:** `Square.Customers.Groups.RemoveGroupsRequest`
@@ -14322,7 +14358,7 @@ await client.Customers.Groups.RemoveAsync(
## Customers Segments -
client.Customers.Segments.ListAsync(ListSegmentsRequest { ... }) -> Pager +
client.Customers.Segments.ListAsync(Square.Customers.Segments.ListSegmentsRequest { ... }) -> Core.Pager
@@ -14364,7 +14400,7 @@ await client.Customers.Segments.ListAsync(new ListSegmentsRequest { Cursor = "cu
-**request:** `ListSegmentsRequest` +**request:** `Square.Customers.Segments.ListSegmentsRequest`
@@ -14376,7 +14412,7 @@ await client.Customers.Segments.ListAsync(new ListSegmentsRequest { Cursor = "cu
-
client.Customers.Segments.GetAsync(GetSegmentsRequest { ... }) -> GetCustomerSegmentResponse +
client.Customers.Segments.GetAsync(Square.Customers.Segments.GetSegmentsRequest { ... }) -> GetCustomerSegmentResponse
@@ -14418,7 +14454,7 @@ await client.Customers.Segments.GetAsync(new GetSegmentsRequest { SegmentId = "s
-**request:** `GetSegmentsRequest` +**request:** `Square.Customers.Segments.GetSegmentsRequest`
@@ -14431,7 +14467,7 @@ await client.Customers.Segments.GetAsync(new GetSegmentsRequest { SegmentId = "s
## Customers Cards -
client.Customers.Cards.CreateAsync(CreateCustomerCardRequest { ... }) -> CreateCustomerCardResponse +
client.Customers.Cards.CreateAsync(Square.Customers.Cards.CreateCustomerCardRequest { ... }) -> CreateCustomerCardResponse
@@ -14493,7 +14529,7 @@ await client.Customers.Cards.CreateAsync(
-**request:** `CreateCustomerCardRequest` +**request:** `Square.Customers.Cards.CreateCustomerCardRequest`
@@ -14505,7 +14541,7 @@ await client.Customers.Cards.CreateAsync(
-
client.Customers.Cards.DeleteAsync(DeleteCardsRequest { ... }) -> DeleteCustomerCardResponse +
client.Customers.Cards.DeleteAsync(Square.Customers.Cards.DeleteCardsRequest { ... }) -> DeleteCustomerCardResponse
@@ -14549,7 +14585,7 @@ await client.Customers.Cards.DeleteAsync(
-**request:** `DeleteCardsRequest` +**request:** `Square.Customers.Cards.DeleteCardsRequest`
@@ -14562,7 +14598,7 @@ await client.Customers.Cards.DeleteAsync(
## Customers CustomAttributes -
client.Customers.CustomAttributes.ListAsync(ListCustomAttributesRequest { ... }) -> Pager +
client.Customers.CustomAttributes.ListAsync(Square.Customers.CustomAttributes.ListCustomAttributesRequest { ... }) -> Core.Pager
@@ -14597,7 +14633,7 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Customers.CustomAttributes.ListAsync( - new ListCustomAttributesRequest + new Square.Customers.CustomAttributes.ListCustomAttributesRequest { CustomerId = "customer_id", Limit = 1, @@ -14619,7 +14655,7 @@ await client.Customers.CustomAttributes.ListAsync(
-**request:** `ListCustomAttributesRequest` +**request:** `Square.Customers.CustomAttributes.ListCustomAttributesRequest`
@@ -14631,7 +14667,7 @@ await client.Customers.CustomAttributes.ListAsync(
-
client.Customers.CustomAttributes.GetAsync(GetCustomAttributesRequest { ... }) -> GetCustomerCustomAttributeResponse +
client.Customers.CustomAttributes.GetAsync(Square.Customers.CustomAttributes.GetCustomAttributesRequest { ... }) -> GetCustomerCustomAttributeResponse
@@ -14666,7 +14702,7 @@ To retrieve a custom attribute owned by another application, the `visibility` se ```csharp await client.Customers.CustomAttributes.GetAsync( - new GetCustomAttributesRequest + new Square.Customers.CustomAttributes.GetCustomAttributesRequest { CustomerId = "customer_id", Key = "key", @@ -14688,7 +14724,7 @@ await client.Customers.CustomAttributes.GetAsync(
-**request:** `GetCustomAttributesRequest` +**request:** `Square.Customers.CustomAttributes.GetCustomAttributesRequest`
@@ -14700,7 +14736,7 @@ await client.Customers.CustomAttributes.GetAsync(
-
client.Customers.CustomAttributes.UpsertAsync(UpsertCustomerCustomAttributeRequest { ... }) -> UpsertCustomerCustomAttributeResponse +
client.Customers.CustomAttributes.UpsertAsync(Square.Customers.CustomAttributes.UpsertCustomerCustomAttributeRequest { ... }) -> UpsertCustomerCustomAttributeResponse
@@ -14757,7 +14793,7 @@ await client.Customers.CustomAttributes.UpsertAsync(
-**request:** `UpsertCustomerCustomAttributeRequest` +**request:** `Square.Customers.CustomAttributes.UpsertCustomerCustomAttributeRequest`
@@ -14769,7 +14805,7 @@ await client.Customers.CustomAttributes.UpsertAsync(
-
client.Customers.CustomAttributes.DeleteAsync(DeleteCustomAttributesRequest { ... }) -> DeleteCustomerCustomAttributeResponse +
client.Customers.CustomAttributes.DeleteAsync(Square.Customers.CustomAttributes.DeleteCustomAttributesRequest { ... }) -> DeleteCustomerCustomAttributeResponse
@@ -14801,7 +14837,11 @@ To delete a custom attribute owned by another application, the `visibility` sett ```csharp await client.Customers.CustomAttributes.DeleteAsync( - new DeleteCustomAttributesRequest { CustomerId = "customer_id", Key = "key" } + new Square.Customers.CustomAttributes.DeleteCustomAttributesRequest + { + CustomerId = "customer_id", + Key = "key", + } ); ```
@@ -14817,7 +14857,7 @@ await client.Customers.CustomAttributes.DeleteAsync(
-**request:** `DeleteCustomAttributesRequest` +**request:** `Square.Customers.CustomAttributes.DeleteCustomAttributesRequest`
@@ -14830,7 +14870,7 @@ await client.Customers.CustomAttributes.DeleteAsync(
## Devices Codes -
client.Devices.Codes.ListAsync(ListCodesRequest { ... }) -> Pager +
client.Devices.Codes.ListAsync(Square.Devices.Codes.ListCodesRequest { ... }) -> Core.Pager
@@ -14880,7 +14920,7 @@ await client.Devices.Codes.ListAsync(
-**request:** `ListCodesRequest` +**request:** `Square.Devices.Codes.ListCodesRequest`
@@ -14892,7 +14932,7 @@ await client.Devices.Codes.ListAsync(
-
client.Devices.Codes.CreateAsync(CreateDeviceCodeRequest { ... }) -> CreateDeviceCodeResponse +
client.Devices.Codes.CreateAsync(Square.Devices.Codes.CreateDeviceCodeRequest { ... }) -> CreateDeviceCodeResponse
@@ -14946,7 +14986,7 @@ await client.Devices.Codes.CreateAsync(
-**request:** `CreateDeviceCodeRequest` +**request:** `Square.Devices.Codes.CreateDeviceCodeRequest`
@@ -14958,7 +14998,7 @@ await client.Devices.Codes.CreateAsync(
-
client.Devices.Codes.GetAsync(GetCodesRequest { ... }) -> GetDeviceCodeResponse +
client.Devices.Codes.GetAsync(Square.Devices.Codes.GetCodesRequest { ... }) -> GetDeviceCodeResponse
@@ -15000,7 +15040,7 @@ await client.Devices.Codes.GetAsync(new GetCodesRequest { Id = "id" });
-**request:** `GetCodesRequest` +**request:** `Square.Devices.Codes.GetCodesRequest`
@@ -15013,7 +15053,7 @@ await client.Devices.Codes.GetAsync(new GetCodesRequest { Id = "id" });
## Disputes Evidence -
client.Disputes.Evidence.ListAsync(ListEvidenceRequest { ... }) -> Pager +
client.Disputes.Evidence.ListAsync(Square.Disputes.Evidence.ListEvidenceRequest { ... }) -> Core.Pager
@@ -15057,7 +15097,7 @@ await client.Disputes.Evidence.ListAsync(
-**request:** `ListEvidenceRequest` +**request:** `Square.Disputes.Evidence.ListEvidenceRequest`
@@ -15069,7 +15109,7 @@ await client.Disputes.Evidence.ListAsync(
-
client.Disputes.Evidence.GetAsync(GetEvidenceRequest { ... }) -> GetDisputeEvidenceResponse +
client.Disputes.Evidence.GetAsync(Square.Disputes.Evidence.GetEvidenceRequest { ... }) -> GetDisputeEvidenceResponse
@@ -15115,7 +15155,7 @@ await client.Disputes.Evidence.GetAsync(
-**request:** `GetEvidenceRequest` +**request:** `Square.Disputes.Evidence.GetEvidenceRequest`
@@ -15127,7 +15167,7 @@ await client.Disputes.Evidence.GetAsync(
-
client.Disputes.Evidence.DeleteAsync(DeleteEvidenceRequest { ... }) -> DeleteDisputeEvidenceResponse +
client.Disputes.Evidence.DeleteAsync(Square.Disputes.Evidence.DeleteEvidenceRequest { ... }) -> DeleteDisputeEvidenceResponse
@@ -15172,7 +15212,7 @@ await client.Disputes.Evidence.DeleteAsync(
-**request:** `DeleteEvidenceRequest` +**request:** `Square.Disputes.Evidence.DeleteEvidenceRequest`
@@ -15185,7 +15225,7 @@ await client.Disputes.Evidence.DeleteAsync(
## GiftCards Activities -
client.GiftCards.Activities.ListAsync(ListActivitiesRequest { ... }) -> Pager +
client.GiftCards.Activities.ListAsync(Square.GiftCards.Activities.ListActivitiesRequest { ... }) -> Core.Pager
@@ -15242,7 +15282,7 @@ await client.GiftCards.Activities.ListAsync(
-**request:** `ListActivitiesRequest` +**request:** `Square.GiftCards.Activities.ListActivitiesRequest`
@@ -15254,7 +15294,7 @@ await client.GiftCards.Activities.ListAsync(
-
client.GiftCards.Activities.CreateAsync(CreateGiftCardActivityRequest { ... }) -> CreateGiftCardActivityResponse +
client.GiftCards.Activities.CreateAsync(Square.GiftCards.Activities.CreateGiftCardActivityRequest { ... }) -> CreateGiftCardActivityResponse
@@ -15313,7 +15353,7 @@ await client.GiftCards.Activities.CreateAsync(
-**request:** `CreateGiftCardActivityRequest` +**request:** `Square.GiftCards.Activities.CreateGiftCardActivityRequest`
@@ -15326,7 +15366,7 @@ await client.GiftCards.Activities.CreateAsync(
## Labor BreakTypes -
client.Labor.BreakTypes.ListAsync(ListBreakTypesRequest { ... }) -> Pager +
client.Labor.BreakTypes.ListAsync(Square.Labor.BreakTypes.ListBreakTypesRequest { ... }) -> Core.Pager
@@ -15375,7 +15415,7 @@ await client.Labor.BreakTypes.ListAsync(
-**request:** `ListBreakTypesRequest` +**request:** `Square.Labor.BreakTypes.ListBreakTypesRequest`
@@ -15387,7 +15427,7 @@ await client.Labor.BreakTypes.ListAsync(
-
client.Labor.BreakTypes.CreateAsync(CreateBreakTypeRequest { ... }) -> CreateBreakTypeResponse +
client.Labor.BreakTypes.CreateAsync(Square.Labor.BreakTypes.CreateBreakTypeRequest { ... }) -> CreateBreakTypeResponse
@@ -15454,7 +15494,7 @@ await client.Labor.BreakTypes.CreateAsync(
-**request:** `CreateBreakTypeRequest` +**request:** `Square.Labor.BreakTypes.CreateBreakTypeRequest`
@@ -15466,7 +15506,7 @@ await client.Labor.BreakTypes.CreateAsync(
-
client.Labor.BreakTypes.GetAsync(GetBreakTypesRequest { ... }) -> GetBreakTypeResponse +
client.Labor.BreakTypes.GetAsync(Square.Labor.BreakTypes.GetBreakTypesRequest { ... }) -> GetBreakTypeResponse
@@ -15508,7 +15548,7 @@ await client.Labor.BreakTypes.GetAsync(new GetBreakTypesRequest { Id = "id" });
-**request:** `GetBreakTypesRequest` +**request:** `Square.Labor.BreakTypes.GetBreakTypesRequest`
@@ -15520,7 +15560,7 @@ await client.Labor.BreakTypes.GetAsync(new GetBreakTypesRequest { Id = "id" });
-
client.Labor.BreakTypes.UpdateAsync(UpdateBreakTypeRequest { ... }) -> UpdateBreakTypeResponse +
client.Labor.BreakTypes.UpdateAsync(Square.Labor.BreakTypes.UpdateBreakTypeRequest { ... }) -> UpdateBreakTypeResponse
@@ -15575,7 +15615,7 @@ await client.Labor.BreakTypes.UpdateAsync(
-**request:** `UpdateBreakTypeRequest` +**request:** `Square.Labor.BreakTypes.UpdateBreakTypeRequest`
@@ -15587,7 +15627,7 @@ await client.Labor.BreakTypes.UpdateAsync(
-
client.Labor.BreakTypes.DeleteAsync(DeleteBreakTypesRequest { ... }) -> DeleteBreakTypeResponse +
client.Labor.BreakTypes.DeleteAsync(Square.Labor.BreakTypes.DeleteBreakTypesRequest { ... }) -> DeleteBreakTypeResponse
@@ -15631,7 +15671,7 @@ await client.Labor.BreakTypes.DeleteAsync(new DeleteBreakTypesRequest { Id = "id
-**request:** `DeleteBreakTypesRequest` +**request:** `Square.Labor.BreakTypes.DeleteBreakTypesRequest`
@@ -15644,7 +15684,7 @@ await client.Labor.BreakTypes.DeleteAsync(new DeleteBreakTypesRequest { Id = "id
## Labor EmployeeWages -
client.Labor.EmployeeWages.ListAsync(ListEmployeeWagesRequest { ... }) -> Pager +
client.Labor.EmployeeWages.ListAsync(Square.Labor.EmployeeWages.ListEmployeeWagesRequest { ... }) -> Core.Pager
@@ -15693,7 +15733,7 @@ await client.Labor.EmployeeWages.ListAsync(
-**request:** `ListEmployeeWagesRequest` +**request:** `Square.Labor.EmployeeWages.ListEmployeeWagesRequest`
@@ -15705,7 +15745,7 @@ await client.Labor.EmployeeWages.ListAsync(
-
client.Labor.EmployeeWages.GetAsync(GetEmployeeWagesRequest { ... }) -> GetEmployeeWageResponse +
client.Labor.EmployeeWages.GetAsync(Square.Labor.EmployeeWages.GetEmployeeWagesRequest { ... }) -> GetEmployeeWageResponse
@@ -15747,7 +15787,7 @@ await client.Labor.EmployeeWages.GetAsync(new GetEmployeeWagesRequest { Id = "id
-**request:** `GetEmployeeWagesRequest` +**request:** `Square.Labor.EmployeeWages.GetEmployeeWagesRequest`
@@ -15760,7 +15800,7 @@ await client.Labor.EmployeeWages.GetAsync(new GetEmployeeWagesRequest { Id = "id
## Labor Shifts -
client.Labor.Shifts.CreateAsync(CreateShiftRequest { ... }) -> CreateShiftResponse +
client.Labor.Shifts.CreateAsync(Square.Labor.Shifts.CreateShiftRequest { ... }) -> CreateShiftResponse
@@ -15850,7 +15890,7 @@ await client.Labor.Shifts.CreateAsync(
-**request:** `CreateShiftRequest` +**request:** `Square.Labor.Shifts.CreateShiftRequest`
@@ -15862,7 +15902,7 @@ await client.Labor.Shifts.CreateAsync(
-
client.Labor.Shifts.SearchAsync(SearchShiftsRequest { ... }) -> SearchShiftsResponse +
client.Labor.Shifts.SearchAsync(Square.Labor.Shifts.SearchShiftsRequest { ... }) -> SearchShiftsResponse
@@ -15934,7 +15974,7 @@ await client.Labor.Shifts.SearchAsync(
-**request:** `SearchShiftsRequest` +**request:** `Square.Labor.Shifts.SearchShiftsRequest`
@@ -15946,7 +15986,7 @@ await client.Labor.Shifts.SearchAsync(
-
client.Labor.Shifts.GetAsync(GetShiftsRequest { ... }) -> GetShiftResponse +
client.Labor.Shifts.GetAsync(Square.Labor.Shifts.GetShiftsRequest { ... }) -> GetShiftResponse
@@ -15973,7 +16013,7 @@ Returns a single `Shift` specified by `id`.
```csharp -await client.Labor.Shifts.GetAsync(new GetShiftsRequest { Id = "id" }); +await client.Labor.Shifts.GetAsync(new Square.Labor.Shifts.GetShiftsRequest { Id = "id" }); ```
@@ -15988,7 +16028,7 @@ await client.Labor.Shifts.GetAsync(new GetShiftsRequest { Id = "id" });
-**request:** `GetShiftsRequest` +**request:** `Square.Labor.Shifts.GetShiftsRequest`
@@ -16000,7 +16040,7 @@ await client.Labor.Shifts.GetAsync(new GetShiftsRequest { Id = "id" });
-
client.Labor.Shifts.UpdateAsync(UpdateShiftRequest { ... }) -> UpdateShiftResponse +
client.Labor.Shifts.UpdateAsync(Square.Labor.Shifts.UpdateShiftRequest { ... }) -> UpdateShiftResponse
@@ -16081,7 +16121,7 @@ await client.Labor.Shifts.UpdateAsync(
-**request:** `UpdateShiftRequest` +**request:** `Square.Labor.Shifts.UpdateShiftRequest`
@@ -16093,7 +16133,7 @@ await client.Labor.Shifts.UpdateAsync(
-
client.Labor.Shifts.DeleteAsync(DeleteShiftsRequest { ... }) -> DeleteShiftResponse +
client.Labor.Shifts.DeleteAsync(Square.Labor.Shifts.DeleteShiftsRequest { ... }) -> DeleteShiftResponse
@@ -16135,7 +16175,7 @@ await client.Labor.Shifts.DeleteAsync(new DeleteShiftsRequest { Id = "id" });
-**request:** `DeleteShiftsRequest` +**request:** `Square.Labor.Shifts.DeleteShiftsRequest`
@@ -16148,7 +16188,7 @@ await client.Labor.Shifts.DeleteAsync(new DeleteShiftsRequest { Id = "id" });
## Labor TeamMemberWages -
client.Labor.TeamMemberWages.ListAsync(ListTeamMemberWagesRequest { ... }) -> Pager +
client.Labor.TeamMemberWages.ListAsync(Square.Labor.TeamMemberWages.ListTeamMemberWagesRequest { ... }) -> Core.Pager
@@ -16197,7 +16237,7 @@ await client.Labor.TeamMemberWages.ListAsync(
-**request:** `ListTeamMemberWagesRequest` +**request:** `Square.Labor.TeamMemberWages.ListTeamMemberWagesRequest`
@@ -16209,7 +16249,7 @@ await client.Labor.TeamMemberWages.ListAsync(
-
client.Labor.TeamMemberWages.GetAsync(GetTeamMemberWagesRequest { ... }) -> GetTeamMemberWageResponse +
client.Labor.TeamMemberWages.GetAsync(Square.Labor.TeamMemberWages.GetTeamMemberWagesRequest { ... }) -> GetTeamMemberWageResponse
@@ -16251,7 +16291,7 @@ await client.Labor.TeamMemberWages.GetAsync(new GetTeamMemberWagesRequest { Id =
-**request:** `GetTeamMemberWagesRequest` +**request:** `Square.Labor.TeamMemberWages.GetTeamMemberWagesRequest`
@@ -16264,7 +16304,7 @@ await client.Labor.TeamMemberWages.GetAsync(new GetTeamMemberWagesRequest { Id =
## Labor WorkweekConfigs -
client.Labor.WorkweekConfigs.ListAsync(ListWorkweekConfigsRequest { ... }) -> Pager +
client.Labor.WorkweekConfigs.ListAsync(Square.Labor.WorkweekConfigs.ListWorkweekConfigsRequest { ... }) -> Core.Pager
@@ -16308,7 +16348,7 @@ await client.Labor.WorkweekConfigs.ListAsync(
-**request:** `ListWorkweekConfigsRequest` +**request:** `Square.Labor.WorkweekConfigs.ListWorkweekConfigsRequest`
@@ -16320,7 +16360,7 @@ await client.Labor.WorkweekConfigs.ListAsync(
-
client.Labor.WorkweekConfigs.GetAsync(UpdateWorkweekConfigRequest { ... }) -> UpdateWorkweekConfigResponse +
client.Labor.WorkweekConfigs.GetAsync(Square.Labor.WorkweekConfigs.UpdateWorkweekConfigRequest { ... }) -> UpdateWorkweekConfigResponse
@@ -16373,7 +16413,7 @@ await client.Labor.WorkweekConfigs.GetAsync(
-**request:** `UpdateWorkweekConfigRequest` +**request:** `Square.Labor.WorkweekConfigs.UpdateWorkweekConfigRequest`
@@ -16386,7 +16426,7 @@ await client.Labor.WorkweekConfigs.GetAsync(
## Locations CustomAttributeDefinitions -
client.Locations.CustomAttributeDefinitions.ListAsync(ListCustomAttributeDefinitionsRequest { ... }) -> Pager +
client.Locations.CustomAttributeDefinitions.ListAsync(Square.Locations.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { ... }) -> Core.Pager
@@ -16417,7 +16457,7 @@ applications and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES` ```csharp await client.Locations.CustomAttributeDefinitions.ListAsync( - new ListCustomAttributeDefinitionsRequest + new Square.Locations.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { VisibilityFilter = VisibilityFilter.All, Limit = 1, @@ -16438,7 +16478,7 @@ await client.Locations.CustomAttributeDefinitions.ListAsync(
-**request:** `ListCustomAttributeDefinitionsRequest` +**request:** `Square.Locations.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest`
@@ -16450,7 +16490,7 @@ await client.Locations.CustomAttributeDefinitions.ListAsync(
-
client.Locations.CustomAttributeDefinitions.CreateAsync(CreateLocationCustomAttributeDefinitionRequest { ... }) -> CreateLocationCustomAttributeDefinitionResponse +
client.Locations.CustomAttributeDefinitions.CreateAsync(Square.Locations.CustomAttributeDefinitions.CreateLocationCustomAttributeDefinitionRequest { ... }) -> CreateLocationCustomAttributeDefinitionResponse
@@ -16489,7 +16529,7 @@ await client.Locations.CustomAttributeDefinitions.CreateAsync( CustomAttributeDefinition = new CustomAttributeDefinition { Key = "bestseller", - Schema = new Dictionary() + Schema = new Dictionary() { { "$ref", @@ -16516,7 +16556,7 @@ await client.Locations.CustomAttributeDefinitions.CreateAsync(
-**request:** `CreateLocationCustomAttributeDefinitionRequest` +**request:** `Square.Locations.CustomAttributeDefinitions.CreateLocationCustomAttributeDefinitionRequest`
@@ -16528,7 +16568,7 @@ await client.Locations.CustomAttributeDefinitions.CreateAsync(
-
client.Locations.CustomAttributeDefinitions.GetAsync(GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveLocationCustomAttributeDefinitionResponse +
client.Locations.CustomAttributeDefinitions.GetAsync(Square.Locations.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveLocationCustomAttributeDefinitionResponse
@@ -16558,7 +16598,11 @@ setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Locations.CustomAttributeDefinitions.GetAsync( - new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + new Square.Locations.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } ); ```
@@ -16574,7 +16618,7 @@ await client.Locations.CustomAttributeDefinitions.GetAsync(
-**request:** `GetCustomAttributeDefinitionsRequest` +**request:** `Square.Locations.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest`
@@ -16586,7 +16630,7 @@ await client.Locations.CustomAttributeDefinitions.GetAsync(
-
client.Locations.CustomAttributeDefinitions.UpdateAsync(UpdateLocationCustomAttributeDefinitionRequest { ... }) -> UpdateLocationCustomAttributeDefinitionResponse +
client.Locations.CustomAttributeDefinitions.UpdateAsync(Square.Locations.CustomAttributeDefinitions.UpdateLocationCustomAttributeDefinitionRequest { ... }) -> UpdateLocationCustomAttributeDefinitionResponse
@@ -16641,7 +16685,7 @@ await client.Locations.CustomAttributeDefinitions.UpdateAsync(
-**request:** `UpdateLocationCustomAttributeDefinitionRequest` +**request:** `Square.Locations.CustomAttributeDefinitions.UpdateLocationCustomAttributeDefinitionRequest`
@@ -16653,7 +16697,7 @@ await client.Locations.CustomAttributeDefinitions.UpdateAsync(
-
client.Locations.CustomAttributeDefinitions.DeleteAsync(DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteLocationCustomAttributeDefinitionResponse +
client.Locations.CustomAttributeDefinitions.DeleteAsync(Square.Locations.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteLocationCustomAttributeDefinitionResponse
@@ -16684,7 +16728,10 @@ Only the definition owner can delete a custom attribute definition. ```csharp await client.Locations.CustomAttributeDefinitions.DeleteAsync( - new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + new Square.Locations.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } ); ```
@@ -16700,7 +16747,7 @@ await client.Locations.CustomAttributeDefinitions.DeleteAsync(
-**request:** `DeleteCustomAttributeDefinitionsRequest` +**request:** `Square.Locations.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest`
@@ -16713,7 +16760,7 @@ await client.Locations.CustomAttributeDefinitions.DeleteAsync(
## Locations CustomAttributes -
client.Locations.CustomAttributes.BatchDeleteAsync(BulkDeleteLocationCustomAttributesRequest { ... }) -> BulkDeleteLocationCustomAttributesResponse +
client.Locations.CustomAttributes.BatchDeleteAsync(Square.Locations.CustomAttributes.BulkDeleteLocationCustomAttributesRequest { ... }) -> BulkDeleteLocationCustomAttributesResponse
@@ -16788,7 +16835,7 @@ await client.Locations.CustomAttributes.BatchDeleteAsync(
-**request:** `BulkDeleteLocationCustomAttributesRequest` +**request:** `Square.Locations.CustomAttributes.BulkDeleteLocationCustomAttributesRequest`
@@ -16800,7 +16847,7 @@ await client.Locations.CustomAttributes.BatchDeleteAsync(
-
client.Locations.CustomAttributes.BatchUpsertAsync(BulkUpsertLocationCustomAttributesRequest { ... }) -> BulkUpsertLocationCustomAttributesResponse +
client.Locations.CustomAttributes.BatchUpsertAsync(Square.Locations.CustomAttributes.BulkUpsertLocationCustomAttributesRequest { ... }) -> BulkUpsertLocationCustomAttributesResponse
@@ -16897,7 +16944,7 @@ await client.Locations.CustomAttributes.BatchUpsertAsync(
-**request:** `BulkUpsertLocationCustomAttributesRequest` +**request:** `Square.Locations.CustomAttributes.BulkUpsertLocationCustomAttributesRequest`
@@ -16909,7 +16956,7 @@ await client.Locations.CustomAttributes.BatchUpsertAsync(
-
client.Locations.CustomAttributes.ListAsync(ListCustomAttributesRequest { ... }) -> Pager +
client.Locations.CustomAttributes.ListAsync(Square.Locations.CustomAttributes.ListCustomAttributesRequest { ... }) -> Core.Pager
@@ -16942,7 +16989,7 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Locations.CustomAttributes.ListAsync( - new ListCustomAttributesRequest + new Square.Locations.CustomAttributes.ListCustomAttributesRequest { LocationId = "location_id", VisibilityFilter = VisibilityFilter.All, @@ -16965,7 +17012,7 @@ await client.Locations.CustomAttributes.ListAsync(
-**request:** `ListCustomAttributesRequest` +**request:** `Square.Locations.CustomAttributes.ListCustomAttributesRequest`
@@ -16977,7 +17024,7 @@ await client.Locations.CustomAttributes.ListAsync(
-
client.Locations.CustomAttributes.GetAsync(GetCustomAttributesRequest { ... }) -> RetrieveLocationCustomAttributeResponse +
client.Locations.CustomAttributes.GetAsync(Square.Locations.CustomAttributes.GetCustomAttributesRequest { ... }) -> RetrieveLocationCustomAttributeResponse
@@ -17009,7 +17056,7 @@ To retrieve a custom attribute owned by another application, the `visibility` se ```csharp await client.Locations.CustomAttributes.GetAsync( - new GetCustomAttributesRequest + new Square.Locations.CustomAttributes.GetCustomAttributesRequest { LocationId = "location_id", Key = "key", @@ -17031,7 +17078,7 @@ await client.Locations.CustomAttributes.GetAsync(
-**request:** `GetCustomAttributesRequest` +**request:** `Square.Locations.CustomAttributes.GetCustomAttributesRequest`
@@ -17043,7 +17090,7 @@ await client.Locations.CustomAttributes.GetAsync(
-
client.Locations.CustomAttributes.UpsertAsync(UpsertLocationCustomAttributeRequest { ... }) -> UpsertLocationCustomAttributeResponse +
client.Locations.CustomAttributes.UpsertAsync(Square.Locations.CustomAttributes.UpsertLocationCustomAttributeRequest { ... }) -> UpsertLocationCustomAttributeResponse
@@ -17097,7 +17144,7 @@ await client.Locations.CustomAttributes.UpsertAsync(
-**request:** `UpsertLocationCustomAttributeRequest` +**request:** `Square.Locations.CustomAttributes.UpsertLocationCustomAttributeRequest`
@@ -17109,7 +17156,7 @@ await client.Locations.CustomAttributes.UpsertAsync(
-
client.Locations.CustomAttributes.DeleteAsync(DeleteCustomAttributesRequest { ... }) -> DeleteLocationCustomAttributeResponse +
client.Locations.CustomAttributes.DeleteAsync(Square.Locations.CustomAttributes.DeleteCustomAttributesRequest { ... }) -> DeleteLocationCustomAttributeResponse
@@ -17139,7 +17186,11 @@ To delete a custom attribute owned by another application, the `visibility` sett ```csharp await client.Locations.CustomAttributes.DeleteAsync( - new DeleteCustomAttributesRequest { LocationId = "location_id", Key = "key" } + new Square.Locations.CustomAttributes.DeleteCustomAttributesRequest + { + LocationId = "location_id", + Key = "key", + } ); ```
@@ -17155,7 +17206,7 @@ await client.Locations.CustomAttributes.DeleteAsync(
-**request:** `DeleteCustomAttributesRequest` +**request:** `Square.Locations.CustomAttributes.DeleteCustomAttributesRequest`
@@ -17168,7 +17219,7 @@ await client.Locations.CustomAttributes.DeleteAsync(
## Locations Transactions -
client.Locations.Transactions.ListAsync(ListTransactionsRequest { ... }) -> ListTransactionsResponse +
client.Locations.Transactions.ListAsync(Square.Locations.Transactions.ListTransactionsRequest { ... }) -> ListTransactionsResponse
@@ -17224,7 +17275,7 @@ await client.Locations.Transactions.ListAsync(
-**request:** `ListTransactionsRequest` +**request:** `Square.Locations.Transactions.ListTransactionsRequest`
@@ -17236,7 +17287,7 @@ await client.Locations.Transactions.ListAsync(
-
client.Locations.Transactions.GetAsync(GetTransactionsRequest { ... }) -> GetTransactionResponse +
client.Locations.Transactions.GetAsync(Square.Locations.Transactions.GetTransactionsRequest { ... }) -> GetTransactionResponse
@@ -17280,7 +17331,7 @@ await client.Locations.Transactions.GetAsync(
-**request:** `GetTransactionsRequest` +**request:** `Square.Locations.Transactions.GetTransactionsRequest`
@@ -17292,7 +17343,7 @@ await client.Locations.Transactions.GetAsync(
-
client.Locations.Transactions.CaptureAsync(CaptureTransactionsRequest { ... }) -> CaptureTransactionResponse +
client.Locations.Transactions.CaptureAsync(Square.Locations.Transactions.CaptureTransactionsRequest { ... }) -> CaptureTransactionResponse
@@ -17341,7 +17392,7 @@ await client.Locations.Transactions.CaptureAsync(
-**request:** `CaptureTransactionsRequest` +**request:** `Square.Locations.Transactions.CaptureTransactionsRequest`
@@ -17353,7 +17404,7 @@ await client.Locations.Transactions.CaptureAsync(
-
client.Locations.Transactions.VoidAsync(VoidTransactionsRequest { ... }) -> VoidTransactionResponse +
client.Locations.Transactions.VoidAsync(Square.Locations.Transactions.VoidTransactionsRequest { ... }) -> VoidTransactionResponse
@@ -17402,7 +17453,7 @@ await client.Locations.Transactions.VoidAsync(
-**request:** `VoidTransactionsRequest` +**request:** `Square.Locations.Transactions.VoidTransactionsRequest`
@@ -17415,7 +17466,7 @@ await client.Locations.Transactions.VoidAsync(
## Loyalty Accounts -
client.Loyalty.Accounts.CreateAsync(CreateLoyaltyAccountRequest { ... }) -> CreateLoyaltyAccountResponse +
client.Loyalty.Accounts.CreateAsync(Square.Loyalty.Accounts.CreateLoyaltyAccountRequest { ... }) -> CreateLoyaltyAccountResponse
@@ -17467,7 +17518,7 @@ await client.Loyalty.Accounts.CreateAsync(
-**request:** `CreateLoyaltyAccountRequest` +**request:** `Square.Loyalty.Accounts.CreateLoyaltyAccountRequest`
@@ -17479,7 +17530,7 @@ await client.Loyalty.Accounts.CreateAsync(
-
client.Loyalty.Accounts.SearchAsync(SearchLoyaltyAccountsRequest { ... }) -> SearchLoyaltyAccountsResponse +
client.Loyalty.Accounts.SearchAsync(Square.Loyalty.Accounts.SearchLoyaltyAccountsRequest { ... }) -> SearchLoyaltyAccountsResponse
@@ -17537,7 +17588,7 @@ await client.Loyalty.Accounts.SearchAsync(
-**request:** `SearchLoyaltyAccountsRequest` +**request:** `Square.Loyalty.Accounts.SearchLoyaltyAccountsRequest`
@@ -17549,7 +17600,7 @@ await client.Loyalty.Accounts.SearchAsync(
-
client.Loyalty.Accounts.GetAsync(GetAccountsRequest { ... }) -> GetLoyaltyAccountResponse +
client.Loyalty.Accounts.GetAsync(Square.Loyalty.Accounts.GetAccountsRequest { ... }) -> GetLoyaltyAccountResponse
@@ -17591,7 +17642,7 @@ await client.Loyalty.Accounts.GetAsync(new GetAccountsRequest { AccountId = "acc
-**request:** `GetAccountsRequest` +**request:** `Square.Loyalty.Accounts.GetAccountsRequest`
@@ -17603,7 +17654,7 @@ await client.Loyalty.Accounts.GetAsync(new GetAccountsRequest { AccountId = "acc
-
client.Loyalty.Accounts.AccumulatePointsAsync(AccumulateLoyaltyPointsRequest { ... }) -> AccumulateLoyaltyPointsResponse +
client.Loyalty.Accounts.AccumulatePointsAsync(Square.Loyalty.Accounts.AccumulateLoyaltyPointsRequest { ... }) -> AccumulateLoyaltyPointsResponse
@@ -17669,7 +17720,7 @@ await client.Loyalty.Accounts.AccumulatePointsAsync(
-**request:** `AccumulateLoyaltyPointsRequest` +**request:** `Square.Loyalty.Accounts.AccumulateLoyaltyPointsRequest`
@@ -17681,7 +17732,7 @@ await client.Loyalty.Accounts.AccumulatePointsAsync(
-
client.Loyalty.Accounts.AdjustAsync(AdjustLoyaltyPointsRequest { ... }) -> AdjustLoyaltyPointsResponse +
client.Loyalty.Accounts.AdjustAsync(Square.Loyalty.Accounts.AdjustLoyaltyPointsRequest { ... }) -> AdjustLoyaltyPointsResponse
@@ -17738,7 +17789,7 @@ await client.Loyalty.Accounts.AdjustAsync(
-**request:** `AdjustLoyaltyPointsRequest` +**request:** `Square.Loyalty.Accounts.AdjustLoyaltyPointsRequest`
@@ -17794,7 +17845,7 @@ await client.Loyalty.Programs.ListAsync();
-
client.Loyalty.Programs.GetAsync(GetProgramsRequest { ... }) -> GetLoyaltyProgramResponse +
client.Loyalty.Programs.GetAsync(Square.Loyalty.Programs.GetProgramsRequest { ... }) -> GetLoyaltyProgramResponse
@@ -17838,7 +17889,7 @@ await client.Loyalty.Programs.GetAsync(new GetProgramsRequest { ProgramId = "pro
-**request:** `GetProgramsRequest` +**request:** `Square.Loyalty.Programs.GetProgramsRequest`
@@ -17850,7 +17901,7 @@ await client.Loyalty.Programs.GetAsync(new GetProgramsRequest { ProgramId = "pro
-
client.Loyalty.Programs.CalculateAsync(CalculateLoyaltyPointsRequest { ... }) -> CalculateLoyaltyPointsResponse +
client.Loyalty.Programs.CalculateAsync(Square.Loyalty.Programs.CalculateLoyaltyPointsRequest { ... }) -> CalculateLoyaltyPointsResponse
@@ -17913,7 +17964,7 @@ await client.Loyalty.Programs.CalculateAsync(
-**request:** `CalculateLoyaltyPointsRequest` +**request:** `Square.Loyalty.Programs.CalculateLoyaltyPointsRequest`
@@ -17926,7 +17977,7 @@ await client.Loyalty.Programs.CalculateAsync(
## Loyalty Rewards -
client.Loyalty.Rewards.CreateAsync(CreateLoyaltyRewardRequest { ... }) -> CreateLoyaltyRewardResponse +
client.Loyalty.Rewards.CreateAsync(Square.Loyalty.Rewards.CreateLoyaltyRewardRequest { ... }) -> CreateLoyaltyRewardResponse
@@ -17986,7 +18037,7 @@ await client.Loyalty.Rewards.CreateAsync(
-**request:** `CreateLoyaltyRewardRequest` +**request:** `Square.Loyalty.Rewards.CreateLoyaltyRewardRequest`
@@ -17998,7 +18049,7 @@ await client.Loyalty.Rewards.CreateAsync(
-
client.Loyalty.Rewards.SearchAsync(SearchLoyaltyRewardsRequest { ... }) -> SearchLoyaltyRewardsResponse +
client.Loyalty.Rewards.SearchAsync(Square.Loyalty.Rewards.SearchLoyaltyRewardsRequest { ... }) -> SearchLoyaltyRewardsResponse
@@ -18055,7 +18106,7 @@ await client.Loyalty.Rewards.SearchAsync(
-**request:** `SearchLoyaltyRewardsRequest` +**request:** `Square.Loyalty.Rewards.SearchLoyaltyRewardsRequest`
@@ -18067,7 +18118,7 @@ await client.Loyalty.Rewards.SearchAsync(
-
client.Loyalty.Rewards.GetAsync(GetRewardsRequest { ... }) -> GetLoyaltyRewardResponse +
client.Loyalty.Rewards.GetAsync(Square.Loyalty.Rewards.GetRewardsRequest { ... }) -> GetLoyaltyRewardResponse
@@ -18109,7 +18160,7 @@ await client.Loyalty.Rewards.GetAsync(new GetRewardsRequest { RewardId = "reward
-**request:** `GetRewardsRequest` +**request:** `Square.Loyalty.Rewards.GetRewardsRequest`
@@ -18121,7 +18172,7 @@ await client.Loyalty.Rewards.GetAsync(new GetRewardsRequest { RewardId = "reward
-
client.Loyalty.Rewards.DeleteAsync(DeleteRewardsRequest { ... }) -> DeleteLoyaltyRewardResponse +
client.Loyalty.Rewards.DeleteAsync(Square.Loyalty.Rewards.DeleteRewardsRequest { ... }) -> DeleteLoyaltyRewardResponse
@@ -18171,7 +18222,7 @@ await client.Loyalty.Rewards.DeleteAsync(new DeleteRewardsRequest { RewardId = "
-**request:** `DeleteRewardsRequest` +**request:** `Square.Loyalty.Rewards.DeleteRewardsRequest`
@@ -18183,7 +18234,7 @@ await client.Loyalty.Rewards.DeleteAsync(new DeleteRewardsRequest { RewardId = "
-
client.Loyalty.Rewards.RedeemAsync(RedeemLoyaltyRewardRequest { ... }) -> RedeemLoyaltyRewardResponse +
client.Loyalty.Rewards.RedeemAsync(Square.Loyalty.Rewards.RedeemLoyaltyRewardRequest { ... }) -> RedeemLoyaltyRewardResponse
@@ -18242,7 +18293,7 @@ await client.Loyalty.Rewards.RedeemAsync(
-**request:** `RedeemLoyaltyRewardRequest` +**request:** `Square.Loyalty.Rewards.RedeemLoyaltyRewardRequest`
@@ -18255,7 +18306,7 @@ await client.Loyalty.Rewards.RedeemAsync(
## Loyalty Programs Promotions -
client.Loyalty.Programs.Promotions.ListAsync(ListPromotionsRequest { ... }) -> Pager +
client.Loyalty.Programs.Promotions.ListAsync(Square.Loyalty.Programs.Promotions.ListPromotionsRequest { ... }) -> Core.Pager
@@ -18306,7 +18357,7 @@ await client.Loyalty.Programs.Promotions.ListAsync(
-**request:** `ListPromotionsRequest` +**request:** `Square.Loyalty.Programs.Promotions.ListPromotionsRequest`
@@ -18318,7 +18369,7 @@ await client.Loyalty.Programs.Promotions.ListAsync(
-
client.Loyalty.Programs.Promotions.CreateAsync(CreateLoyaltyPromotionRequest { ... }) -> CreateLoyaltyPromotionResponse +
client.Loyalty.Programs.Promotions.CreateAsync(Square.Loyalty.Programs.Promotions.CreateLoyaltyPromotionRequest { ... }) -> CreateLoyaltyPromotionResponse
@@ -18397,7 +18448,7 @@ await client.Loyalty.Programs.Promotions.CreateAsync(
-**request:** `CreateLoyaltyPromotionRequest` +**request:** `Square.Loyalty.Programs.Promotions.CreateLoyaltyPromotionRequest`
@@ -18409,7 +18460,7 @@ await client.Loyalty.Programs.Promotions.CreateAsync(
-
client.Loyalty.Programs.Promotions.GetAsync(GetPromotionsRequest { ... }) -> GetLoyaltyPromotionResponse +
client.Loyalty.Programs.Promotions.GetAsync(Square.Loyalty.Programs.Promotions.GetPromotionsRequest { ... }) -> GetLoyaltyPromotionResponse
@@ -18453,7 +18504,7 @@ await client.Loyalty.Programs.Promotions.GetAsync(
-**request:** `GetPromotionsRequest` +**request:** `Square.Loyalty.Programs.Promotions.GetPromotionsRequest`
@@ -18465,7 +18516,7 @@ await client.Loyalty.Programs.Promotions.GetAsync(
-
client.Loyalty.Programs.Promotions.CancelAsync(CancelPromotionsRequest { ... }) -> CancelLoyaltyPromotionResponse +
client.Loyalty.Programs.Promotions.CancelAsync(Square.Loyalty.Programs.Promotions.CancelPromotionsRequest { ... }) -> CancelLoyaltyPromotionResponse
@@ -18514,7 +18565,7 @@ await client.Loyalty.Programs.Promotions.CancelAsync(
-**request:** `CancelPromotionsRequest` +**request:** `Square.Loyalty.Programs.Promotions.CancelPromotionsRequest`
@@ -18527,7 +18578,7 @@ await client.Loyalty.Programs.Promotions.CancelAsync(
## Merchants CustomAttributeDefinitions -
client.Merchants.CustomAttributeDefinitions.ListAsync(ListCustomAttributeDefinitionsRequest { ... }) -> Pager +
client.Merchants.CustomAttributeDefinitions.ListAsync(Square.Merchants.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { ... }) -> Core.Pager
@@ -18558,7 +18609,7 @@ applications and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES` ```csharp await client.Merchants.CustomAttributeDefinitions.ListAsync( - new ListCustomAttributeDefinitionsRequest + new Square.Merchants.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { VisibilityFilter = VisibilityFilter.All, Limit = 1, @@ -18579,7 +18630,7 @@ await client.Merchants.CustomAttributeDefinitions.ListAsync(
-**request:** `ListCustomAttributeDefinitionsRequest` +**request:** `Square.Merchants.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest`
@@ -18591,7 +18642,7 @@ await client.Merchants.CustomAttributeDefinitions.ListAsync(
-
client.Merchants.CustomAttributeDefinitions.CreateAsync(CreateMerchantCustomAttributeDefinitionRequest { ... }) -> CreateMerchantCustomAttributeDefinitionResponse +
client.Merchants.CustomAttributeDefinitions.CreateAsync(Square.Merchants.CustomAttributeDefinitions.CreateMerchantCustomAttributeDefinitionRequest { ... }) -> CreateMerchantCustomAttributeDefinitionResponse
@@ -18630,7 +18681,7 @@ await client.Merchants.CustomAttributeDefinitions.CreateAsync( CustomAttributeDefinition = new CustomAttributeDefinition { Key = "alternative_seller_name", - Schema = new Dictionary() + Schema = new Dictionary() { { "$ref", @@ -18657,7 +18708,7 @@ await client.Merchants.CustomAttributeDefinitions.CreateAsync(
-**request:** `CreateMerchantCustomAttributeDefinitionRequest` +**request:** `Square.Merchants.CustomAttributeDefinitions.CreateMerchantCustomAttributeDefinitionRequest`
@@ -18669,7 +18720,7 @@ await client.Merchants.CustomAttributeDefinitions.CreateAsync(
-
client.Merchants.CustomAttributeDefinitions.GetAsync(GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveMerchantCustomAttributeDefinitionResponse +
client.Merchants.CustomAttributeDefinitions.GetAsync(Square.Merchants.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveMerchantCustomAttributeDefinitionResponse
@@ -18699,7 +18750,11 @@ setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Merchants.CustomAttributeDefinitions.GetAsync( - new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + new Square.Merchants.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } ); ```
@@ -18715,7 +18770,7 @@ await client.Merchants.CustomAttributeDefinitions.GetAsync(
-**request:** `GetCustomAttributeDefinitionsRequest` +**request:** `Square.Merchants.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest`
@@ -18727,7 +18782,7 @@ await client.Merchants.CustomAttributeDefinitions.GetAsync(
-
client.Merchants.CustomAttributeDefinitions.UpdateAsync(UpdateMerchantCustomAttributeDefinitionRequest { ... }) -> UpdateMerchantCustomAttributeDefinitionResponse +
client.Merchants.CustomAttributeDefinitions.UpdateAsync(Square.Merchants.CustomAttributeDefinitions.UpdateMerchantCustomAttributeDefinitionRequest { ... }) -> UpdateMerchantCustomAttributeDefinitionResponse
@@ -18782,7 +18837,7 @@ await client.Merchants.CustomAttributeDefinitions.UpdateAsync(
-**request:** `UpdateMerchantCustomAttributeDefinitionRequest` +**request:** `Square.Merchants.CustomAttributeDefinitions.UpdateMerchantCustomAttributeDefinitionRequest`
@@ -18794,7 +18849,7 @@ await client.Merchants.CustomAttributeDefinitions.UpdateAsync(
-
client.Merchants.CustomAttributeDefinitions.DeleteAsync(DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteMerchantCustomAttributeDefinitionResponse +
client.Merchants.CustomAttributeDefinitions.DeleteAsync(Square.Merchants.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteMerchantCustomAttributeDefinitionResponse
@@ -18825,7 +18880,10 @@ Only the definition owner can delete a custom attribute definition. ```csharp await client.Merchants.CustomAttributeDefinitions.DeleteAsync( - new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + new Square.Merchants.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } ); ```
@@ -18841,7 +18899,7 @@ await client.Merchants.CustomAttributeDefinitions.DeleteAsync(
-**request:** `DeleteCustomAttributeDefinitionsRequest` +**request:** `Square.Merchants.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest`
@@ -18854,7 +18912,7 @@ await client.Merchants.CustomAttributeDefinitions.DeleteAsync(
## Merchants CustomAttributes -
client.Merchants.CustomAttributes.BatchDeleteAsync(BulkDeleteMerchantCustomAttributesRequest { ... }) -> BulkDeleteMerchantCustomAttributesResponse +
client.Merchants.CustomAttributes.BatchDeleteAsync(Square.Merchants.CustomAttributes.BulkDeleteMerchantCustomAttributesRequest { ... }) -> BulkDeleteMerchantCustomAttributesResponse
@@ -18922,7 +18980,7 @@ await client.Merchants.CustomAttributes.BatchDeleteAsync(
-**request:** `BulkDeleteMerchantCustomAttributesRequest` +**request:** `Square.Merchants.CustomAttributes.BulkDeleteMerchantCustomAttributesRequest`
@@ -18934,7 +18992,7 @@ await client.Merchants.CustomAttributes.BatchDeleteAsync(
-
client.Merchants.CustomAttributes.BatchUpsertAsync(BulkUpsertMerchantCustomAttributesRequest { ... }) -> BulkUpsertMerchantCustomAttributesResponse +
client.Merchants.CustomAttributes.BatchUpsertAsync(Square.Merchants.CustomAttributes.BulkUpsertMerchantCustomAttributesRequest { ... }) -> BulkUpsertMerchantCustomAttributesResponse
@@ -19019,7 +19077,7 @@ await client.Merchants.CustomAttributes.BatchUpsertAsync(
-**request:** `BulkUpsertMerchantCustomAttributesRequest` +**request:** `Square.Merchants.CustomAttributes.BulkUpsertMerchantCustomAttributesRequest`
@@ -19031,7 +19089,7 @@ await client.Merchants.CustomAttributes.BatchUpsertAsync(
-
client.Merchants.CustomAttributes.ListAsync(ListCustomAttributesRequest { ... }) -> Pager +
client.Merchants.CustomAttributes.ListAsync(Square.Merchants.CustomAttributes.ListCustomAttributesRequest { ... }) -> Core.Pager
@@ -19064,7 +19122,7 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Merchants.CustomAttributes.ListAsync( - new ListCustomAttributesRequest + new Square.Merchants.CustomAttributes.ListCustomAttributesRequest { MerchantId = "merchant_id", VisibilityFilter = VisibilityFilter.All, @@ -19087,7 +19145,7 @@ await client.Merchants.CustomAttributes.ListAsync(
-**request:** `ListCustomAttributesRequest` +**request:** `Square.Merchants.CustomAttributes.ListCustomAttributesRequest`
@@ -19099,7 +19157,7 @@ await client.Merchants.CustomAttributes.ListAsync(
-
client.Merchants.CustomAttributes.GetAsync(GetCustomAttributesRequest { ... }) -> RetrieveMerchantCustomAttributeResponse +
client.Merchants.CustomAttributes.GetAsync(Square.Merchants.CustomAttributes.GetCustomAttributesRequest { ... }) -> RetrieveMerchantCustomAttributeResponse
@@ -19131,7 +19189,7 @@ To retrieve a custom attribute owned by another application, the `visibility` se ```csharp await client.Merchants.CustomAttributes.GetAsync( - new GetCustomAttributesRequest + new Square.Merchants.CustomAttributes.GetCustomAttributesRequest { MerchantId = "merchant_id", Key = "key", @@ -19153,7 +19211,7 @@ await client.Merchants.CustomAttributes.GetAsync(
-**request:** `GetCustomAttributesRequest` +**request:** `Square.Merchants.CustomAttributes.GetCustomAttributesRequest`
@@ -19165,7 +19223,7 @@ await client.Merchants.CustomAttributes.GetAsync(
-
client.Merchants.CustomAttributes.UpsertAsync(UpsertMerchantCustomAttributeRequest { ... }) -> UpsertMerchantCustomAttributeResponse +
client.Merchants.CustomAttributes.UpsertAsync(Square.Merchants.CustomAttributes.UpsertMerchantCustomAttributeRequest { ... }) -> UpsertMerchantCustomAttributeResponse
@@ -19219,7 +19277,7 @@ await client.Merchants.CustomAttributes.UpsertAsync(
-**request:** `UpsertMerchantCustomAttributeRequest` +**request:** `Square.Merchants.CustomAttributes.UpsertMerchantCustomAttributeRequest`
@@ -19231,7 +19289,7 @@ await client.Merchants.CustomAttributes.UpsertAsync(
-
client.Merchants.CustomAttributes.DeleteAsync(DeleteCustomAttributesRequest { ... }) -> DeleteMerchantCustomAttributeResponse +
client.Merchants.CustomAttributes.DeleteAsync(Square.Merchants.CustomAttributes.DeleteCustomAttributesRequest { ... }) -> DeleteMerchantCustomAttributeResponse
@@ -19261,7 +19319,11 @@ To delete a custom attribute owned by another application, the `visibility` sett ```csharp await client.Merchants.CustomAttributes.DeleteAsync( - new DeleteCustomAttributesRequest { MerchantId = "merchant_id", Key = "key" } + new Square.Merchants.CustomAttributes.DeleteCustomAttributesRequest + { + MerchantId = "merchant_id", + Key = "key", + } ); ```
@@ -19277,7 +19339,7 @@ await client.Merchants.CustomAttributes.DeleteAsync(
-**request:** `DeleteCustomAttributesRequest` +**request:** `Square.Merchants.CustomAttributes.DeleteCustomAttributesRequest`
@@ -19290,7 +19352,7 @@ await client.Merchants.CustomAttributes.DeleteAsync(
## Orders CustomAttributeDefinitions -
client.Orders.CustomAttributeDefinitions.ListAsync(ListCustomAttributeDefinitionsRequest { ... }) -> Pager +
client.Orders.CustomAttributeDefinitions.ListAsync(Square.Orders.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { ... }) -> Core.Pager
@@ -19323,7 +19385,7 @@ seller-defined custom attributes (also known as custom fields) are always set to ```csharp await client.Orders.CustomAttributeDefinitions.ListAsync( - new ListCustomAttributeDefinitionsRequest + new Square.Orders.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest { VisibilityFilter = VisibilityFilter.All, Cursor = "cursor", @@ -19344,7 +19406,7 @@ await client.Orders.CustomAttributeDefinitions.ListAsync(
-**request:** `ListCustomAttributeDefinitionsRequest` +**request:** `Square.Orders.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest`
@@ -19356,7 +19418,7 @@ await client.Orders.CustomAttributeDefinitions.ListAsync(
-
client.Orders.CustomAttributeDefinitions.CreateAsync(CreateOrderCustomAttributeDefinitionRequest { ... }) -> CreateOrderCustomAttributeDefinitionResponse +
client.Orders.CustomAttributeDefinitions.CreateAsync(Square.Orders.CustomAttributeDefinitions.CreateOrderCustomAttributeDefinitionRequest { ... }) -> CreateOrderCustomAttributeDefinitionResponse
@@ -19393,7 +19455,7 @@ await client.Orders.CustomAttributeDefinitions.CreateAsync( CustomAttributeDefinition = new CustomAttributeDefinition { Key = "cover-count", - Schema = new Dictionary() + Schema = new Dictionary() { { "$ref", @@ -19421,7 +19483,7 @@ await client.Orders.CustomAttributeDefinitions.CreateAsync(
-**request:** `CreateOrderCustomAttributeDefinitionRequest` +**request:** `Square.Orders.CustomAttributeDefinitions.CreateOrderCustomAttributeDefinitionRequest`
@@ -19433,7 +19495,7 @@ await client.Orders.CustomAttributeDefinitions.CreateAsync(
-
client.Orders.CustomAttributeDefinitions.GetAsync(GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveOrderCustomAttributeDefinitionResponse +
client.Orders.CustomAttributeDefinitions.GetAsync(Square.Orders.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest { ... }) -> RetrieveOrderCustomAttributeDefinitionResponse
@@ -19465,7 +19527,11 @@ setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note t ```csharp await client.Orders.CustomAttributeDefinitions.GetAsync( - new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + new Square.Orders.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } ); ```
@@ -19481,7 +19547,7 @@ await client.Orders.CustomAttributeDefinitions.GetAsync(
-**request:** `GetCustomAttributeDefinitionsRequest` +**request:** `Square.Orders.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest`
@@ -19493,7 +19559,7 @@ await client.Orders.CustomAttributeDefinitions.GetAsync(
-
client.Orders.CustomAttributeDefinitions.UpdateAsync(UpdateOrderCustomAttributeDefinitionRequest { ... }) -> UpdateOrderCustomAttributeDefinitionResponse +
client.Orders.CustomAttributeDefinitions.UpdateAsync(Square.Orders.CustomAttributeDefinitions.UpdateOrderCustomAttributeDefinitionRequest { ... }) -> UpdateOrderCustomAttributeDefinitionResponse
@@ -19549,7 +19615,7 @@ await client.Orders.CustomAttributeDefinitions.UpdateAsync(
-**request:** `UpdateOrderCustomAttributeDefinitionRequest` +**request:** `Square.Orders.CustomAttributeDefinitions.UpdateOrderCustomAttributeDefinitionRequest`
@@ -19561,7 +19627,7 @@ await client.Orders.CustomAttributeDefinitions.UpdateAsync(
-
client.Orders.CustomAttributeDefinitions.DeleteAsync(DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteOrderCustomAttributeDefinitionResponse +
client.Orders.CustomAttributeDefinitions.DeleteAsync(Square.Orders.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest { ... }) -> DeleteOrderCustomAttributeDefinitionResponse
@@ -19591,7 +19657,10 @@ Only the definition owner can delete a custom attribute definition. ```csharp await client.Orders.CustomAttributeDefinitions.DeleteAsync( - new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + new Square.Orders.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } ); ```
@@ -19607,7 +19676,7 @@ await client.Orders.CustomAttributeDefinitions.DeleteAsync(
-**request:** `DeleteCustomAttributeDefinitionsRequest` +**request:** `Square.Orders.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest`
@@ -19620,7 +19689,7 @@ await client.Orders.CustomAttributeDefinitions.DeleteAsync(
## Orders CustomAttributes -
client.Orders.CustomAttributes.BatchDeleteAsync(BulkDeleteOrderCustomAttributesRequest { ... }) -> BulkDeleteOrderCustomAttributesResponse +
client.Orders.CustomAttributes.BatchDeleteAsync(Square.Orders.CustomAttributes.BulkDeleteOrderCustomAttributesRequest { ... }) -> BulkDeleteOrderCustomAttributesResponse
@@ -19701,7 +19770,7 @@ await client.Orders.CustomAttributes.BatchDeleteAsync(
-**request:** `BulkDeleteOrderCustomAttributesRequest` +**request:** `Square.Orders.CustomAttributes.BulkDeleteOrderCustomAttributesRequest`
@@ -19713,7 +19782,7 @@ await client.Orders.CustomAttributes.BatchDeleteAsync(
-
client.Orders.CustomAttributes.BatchUpsertAsync(BulkUpsertOrderCustomAttributesRequest { ... }) -> BulkUpsertOrderCustomAttributesResponse +
client.Orders.CustomAttributes.BatchUpsertAsync(Square.Orders.CustomAttributes.BulkUpsertOrderCustomAttributesRequest { ... }) -> BulkUpsertOrderCustomAttributesResponse
@@ -19804,7 +19873,7 @@ await client.Orders.CustomAttributes.BatchUpsertAsync(
-**request:** `BulkUpsertOrderCustomAttributesRequest` +**request:** `Square.Orders.CustomAttributes.BulkUpsertOrderCustomAttributesRequest`
@@ -19816,7 +19885,7 @@ await client.Orders.CustomAttributes.BatchUpsertAsync(
-
client.Orders.CustomAttributes.ListAsync(ListCustomAttributesRequest { ... }) -> Pager +
client.Orders.CustomAttributes.ListAsync(Square.Orders.CustomAttributes.ListCustomAttributesRequest { ... }) -> Core.Pager
@@ -19851,7 +19920,7 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Orders.CustomAttributes.ListAsync( - new ListCustomAttributesRequest + new Square.Orders.CustomAttributes.ListCustomAttributesRequest { OrderId = "order_id", VisibilityFilter = VisibilityFilter.All, @@ -19874,7 +19943,7 @@ await client.Orders.CustomAttributes.ListAsync(
-**request:** `ListCustomAttributesRequest` +**request:** `Square.Orders.CustomAttributes.ListCustomAttributesRequest`
@@ -19886,7 +19955,7 @@ await client.Orders.CustomAttributes.ListAsync(
-
client.Orders.CustomAttributes.GetAsync(GetCustomAttributesRequest { ... }) -> RetrieveOrderCustomAttributeResponse +
client.Orders.CustomAttributes.GetAsync(Square.Orders.CustomAttributes.GetCustomAttributesRequest { ... }) -> RetrieveOrderCustomAttributeResponse
@@ -19921,7 +19990,7 @@ also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`. ```csharp await client.Orders.CustomAttributes.GetAsync( - new GetCustomAttributesRequest + new Square.Orders.CustomAttributes.GetCustomAttributesRequest { OrderId = "order_id", CustomAttributeKey = "custom_attribute_key", @@ -19943,7 +20012,7 @@ await client.Orders.CustomAttributes.GetAsync(
-**request:** `GetCustomAttributesRequest` +**request:** `Square.Orders.CustomAttributes.GetCustomAttributesRequest`
@@ -19955,7 +20024,7 @@ await client.Orders.CustomAttributes.GetAsync(
-
client.Orders.CustomAttributes.UpsertAsync(UpsertOrderCustomAttributeRequest { ... }) -> UpsertOrderCustomAttributeResponse +
client.Orders.CustomAttributes.UpsertAsync(Square.Orders.CustomAttributes.UpsertOrderCustomAttributeRequest { ... }) -> UpsertOrderCustomAttributeResponse
@@ -20017,7 +20086,7 @@ await client.Orders.CustomAttributes.UpsertAsync(
-**request:** `UpsertOrderCustomAttributeRequest` +**request:** `Square.Orders.CustomAttributes.UpsertOrderCustomAttributeRequest`
@@ -20029,7 +20098,7 @@ await client.Orders.CustomAttributes.UpsertAsync(
-
client.Orders.CustomAttributes.DeleteAsync(DeleteCustomAttributesRequest { ... }) -> DeleteOrderCustomAttributeResponse +
client.Orders.CustomAttributes.DeleteAsync(Square.Orders.CustomAttributes.DeleteCustomAttributesRequest { ... }) -> DeleteOrderCustomAttributeResponse
@@ -20061,7 +20130,7 @@ To delete a custom attribute owned by another application, the `visibility` sett ```csharp await client.Orders.CustomAttributes.DeleteAsync( - new DeleteCustomAttributesRequest + new Square.Orders.CustomAttributes.DeleteCustomAttributesRequest { OrderId = "order_id", CustomAttributeKey = "custom_attribute_key", @@ -20081,7 +20150,7 @@ await client.Orders.CustomAttributes.DeleteAsync(
-**request:** `DeleteCustomAttributesRequest` +**request:** `Square.Orders.CustomAttributes.DeleteCustomAttributesRequest`
@@ -20094,7 +20163,7 @@ await client.Orders.CustomAttributes.DeleteAsync(
## TeamMembers WageSetting -
client.TeamMembers.WageSetting.GetAsync(TeamMembers.WageSetting.GetWageSettingRequest { ... }) -> GetWageSettingResponse +
client.TeamMembers.WageSetting.GetAsync(Square.TeamMembers.WageSetting.GetWageSettingRequest { ... }) -> GetWageSettingResponse
@@ -20143,7 +20212,7 @@ await client.TeamMembers.WageSetting.GetAsync(
-**request:** `TeamMembers.WageSetting.GetWageSettingRequest` +**request:** `Square.TeamMembers.WageSetting.GetWageSettingRequest`
@@ -20155,7 +20224,7 @@ await client.TeamMembers.WageSetting.GetAsync(
-
client.TeamMembers.WageSetting.UpdateAsync(UpdateWageSettingRequest { ... }) -> UpdateWageSettingResponse +
client.TeamMembers.WageSetting.UpdateAsync(Square.TeamMembers.WageSetting.UpdateWageSettingRequest { ... }) -> UpdateWageSettingResponse
@@ -20229,7 +20298,7 @@ await client.TeamMembers.WageSetting.UpdateAsync(
-**request:** `UpdateWageSettingRequest` +**request:** `Square.TeamMembers.WageSetting.UpdateWageSettingRequest`
@@ -20242,7 +20311,7 @@ await client.TeamMembers.WageSetting.UpdateAsync(
## Terminal Actions -
client.Terminal.Actions.CreateAsync(CreateTerminalActionRequest { ... }) -> CreateTerminalActionResponse +
client.Terminal.Actions.CreateAsync(Square.Terminal.Actions.CreateTerminalActionRequest { ... }) -> CreateTerminalActionResponse
@@ -20300,7 +20369,7 @@ await client.Terminal.Actions.CreateAsync(
-**request:** `CreateTerminalActionRequest` +**request:** `Square.Terminal.Actions.CreateTerminalActionRequest`
@@ -20312,7 +20381,7 @@ await client.Terminal.Actions.CreateAsync(
-
client.Terminal.Actions.SearchAsync(SearchTerminalActionsRequest { ... }) -> SearchTerminalActionsResponse +
client.Terminal.Actions.SearchAsync(Square.Terminal.Actions.SearchTerminalActionsRequest { ... }) -> SearchTerminalActionsResponse
@@ -20367,7 +20436,7 @@ await client.Terminal.Actions.SearchAsync(
-**request:** `SearchTerminalActionsRequest` +**request:** `Square.Terminal.Actions.SearchTerminalActionsRequest`
@@ -20379,7 +20448,7 @@ await client.Terminal.Actions.SearchAsync(
-
client.Terminal.Actions.GetAsync(GetActionsRequest { ... }) -> GetTerminalActionResponse +
client.Terminal.Actions.GetAsync(Square.Terminal.Actions.GetActionsRequest { ... }) -> GetTerminalActionResponse
@@ -20421,7 +20490,7 @@ await client.Terminal.Actions.GetAsync(new GetActionsRequest { ActionId = "actio
-**request:** `GetActionsRequest` +**request:** `Square.Terminal.Actions.GetActionsRequest`
@@ -20433,7 +20502,7 @@ await client.Terminal.Actions.GetAsync(new GetActionsRequest { ActionId = "actio
-
client.Terminal.Actions.CancelAsync(CancelActionsRequest { ... }) -> CancelTerminalActionResponse +
client.Terminal.Actions.CancelAsync(Square.Terminal.Actions.CancelActionsRequest { ... }) -> CancelTerminalActionResponse
@@ -20475,7 +20544,7 @@ await client.Terminal.Actions.CancelAsync(new CancelActionsRequest { ActionId =
-**request:** `CancelActionsRequest` +**request:** `Square.Terminal.Actions.CancelActionsRequest`
@@ -20488,7 +20557,7 @@ await client.Terminal.Actions.CancelAsync(new CancelActionsRequest { ActionId =
## Terminal Checkouts -
client.Terminal.Checkouts.CreateAsync(CreateTerminalCheckoutRequest { ... }) -> CreateTerminalCheckoutResponse +
client.Terminal.Checkouts.CreateAsync(Square.Terminal.Checkouts.CreateTerminalCheckoutRequest { ... }) -> CreateTerminalCheckoutResponse
@@ -20546,7 +20615,7 @@ await client.Terminal.Checkouts.CreateAsync(
-**request:** `CreateTerminalCheckoutRequest` +**request:** `Square.Terminal.Checkouts.CreateTerminalCheckoutRequest`
@@ -20558,7 +20627,7 @@ await client.Terminal.Checkouts.CreateAsync(
-
client.Terminal.Checkouts.SearchAsync(SearchTerminalCheckoutsRequest { ... }) -> SearchTerminalCheckoutsResponse +
client.Terminal.Checkouts.SearchAsync(Square.Terminal.Checkouts.SearchTerminalCheckoutsRequest { ... }) -> SearchTerminalCheckoutsResponse
@@ -20609,7 +20678,7 @@ await client.Terminal.Checkouts.SearchAsync(
-**request:** `SearchTerminalCheckoutsRequest` +**request:** `Square.Terminal.Checkouts.SearchTerminalCheckoutsRequest`
@@ -20621,7 +20690,7 @@ await client.Terminal.Checkouts.SearchAsync(
-
client.Terminal.Checkouts.GetAsync(GetCheckoutsRequest { ... }) -> GetTerminalCheckoutResponse +
client.Terminal.Checkouts.GetAsync(Square.Terminal.Checkouts.GetCheckoutsRequest { ... }) -> GetTerminalCheckoutResponse
@@ -20663,7 +20732,7 @@ await client.Terminal.Checkouts.GetAsync(new GetCheckoutsRequest { CheckoutId =
-**request:** `GetCheckoutsRequest` +**request:** `Square.Terminal.Checkouts.GetCheckoutsRequest`
@@ -20675,7 +20744,7 @@ await client.Terminal.Checkouts.GetAsync(new GetCheckoutsRequest { CheckoutId =
-
client.Terminal.Checkouts.CancelAsync(CancelCheckoutsRequest { ... }) -> CancelTerminalCheckoutResponse +
client.Terminal.Checkouts.CancelAsync(Square.Terminal.Checkouts.CancelCheckoutsRequest { ... }) -> CancelTerminalCheckoutResponse
@@ -20719,7 +20788,7 @@ await client.Terminal.Checkouts.CancelAsync(
-**request:** `CancelCheckoutsRequest` +**request:** `Square.Terminal.Checkouts.CancelCheckoutsRequest`
@@ -20732,7 +20801,7 @@ await client.Terminal.Checkouts.CancelAsync(
## Terminal Refunds -
client.Terminal.Refunds.CreateAsync(CreateTerminalRefundRequest { ... }) -> CreateTerminalRefundResponse +
client.Terminal.Refunds.CreateAsync(Square.Terminal.Refunds.CreateTerminalRefundRequest { ... }) -> CreateTerminalRefundResponse
@@ -20786,7 +20855,7 @@ await client.Terminal.Refunds.CreateAsync(
-**request:** `CreateTerminalRefundRequest` +**request:** `Square.Terminal.Refunds.CreateTerminalRefundRequest`
@@ -20798,7 +20867,7 @@ await client.Terminal.Refunds.CreateAsync(
-
client.Terminal.Refunds.SearchAsync(SearchTerminalRefundsRequest { ... }) -> SearchTerminalRefundsResponse +
client.Terminal.Refunds.SearchAsync(Square.Terminal.Refunds.SearchTerminalRefundsRequest { ... }) -> SearchTerminalRefundsResponse
@@ -20849,7 +20918,7 @@ await client.Terminal.Refunds.SearchAsync(
-**request:** `SearchTerminalRefundsRequest` +**request:** `Square.Terminal.Refunds.SearchTerminalRefundsRequest`
@@ -20861,7 +20930,7 @@ await client.Terminal.Refunds.SearchAsync(
-
client.Terminal.Refunds.GetAsync(GetRefundsRequest { ... }) -> GetTerminalRefundResponse +
client.Terminal.Refunds.GetAsync(Square.Terminal.Refunds.GetRefundsRequest { ... }) -> GetTerminalRefundResponse
@@ -20889,7 +20958,7 @@ Retrieves an Interac Terminal refund object by ID. Terminal refund objects are a ```csharp await client.Terminal.Refunds.GetAsync( - new GetRefundsRequest { TerminalRefundId = "terminal_refund_id" } + new Square.Terminal.Refunds.GetRefundsRequest { TerminalRefundId = "terminal_refund_id" } ); ```
@@ -20905,7 +20974,7 @@ await client.Terminal.Refunds.GetAsync(
-**request:** `GetRefundsRequest` +**request:** `Square.Terminal.Refunds.GetRefundsRequest`
@@ -20917,7 +20986,7 @@ await client.Terminal.Refunds.GetAsync(
-
client.Terminal.Refunds.CancelAsync(CancelRefundsRequest { ... }) -> CancelTerminalRefundResponse +
client.Terminal.Refunds.CancelAsync(Square.Terminal.Refunds.CancelRefundsRequest { ... }) -> CancelTerminalRefundResponse
@@ -20961,7 +21030,7 @@ await client.Terminal.Refunds.CancelAsync(
-**request:** `CancelRefundsRequest` +**request:** `Square.Terminal.Refunds.CancelRefundsRequest`
@@ -20974,7 +21043,7 @@ await client.Terminal.Refunds.CancelAsync(
## Webhooks EventTypes -
client.Webhooks.EventTypes.ListAsync(ListEventTypesRequest { ... }) -> ListWebhookEventTypesResponse +
client.Webhooks.EventTypes.ListAsync(Square.Webhooks.EventTypes.ListEventTypesRequest { ... }) -> ListWebhookEventTypesResponse
@@ -21002,7 +21071,7 @@ Lists all webhook event types that can be subscribed to. ```csharp await client.Webhooks.EventTypes.ListAsync( - new ListEventTypesRequest { ApiVersion = "api_version" } + new Square.Webhooks.EventTypes.ListEventTypesRequest { ApiVersion = "api_version" } ); ```
@@ -21018,7 +21087,7 @@ await client.Webhooks.EventTypes.ListAsync(
-**request:** `ListEventTypesRequest` +**request:** `Square.Webhooks.EventTypes.ListEventTypesRequest`
@@ -21031,7 +21100,7 @@ await client.Webhooks.EventTypes.ListAsync(
## Webhooks Subscriptions -
client.Webhooks.Subscriptions.ListAsync(ListSubscriptionsRequest { ... }) -> Pager +
client.Webhooks.Subscriptions.ListAsync(Square.Webhooks.Subscriptions.ListSubscriptionsRequest { ... }) -> Core.Pager
@@ -21081,7 +21150,7 @@ await client.Webhooks.Subscriptions.ListAsync(
-**request:** `ListSubscriptionsRequest` +**request:** `Square.Webhooks.Subscriptions.ListSubscriptionsRequest`
@@ -21093,7 +21162,7 @@ await client.Webhooks.Subscriptions.ListAsync(
-
client.Webhooks.Subscriptions.CreateAsync(CreateWebhookSubscriptionRequest { ... }) -> CreateWebhookSubscriptionResponse +
client.Webhooks.Subscriptions.CreateAsync(Square.Webhooks.Subscriptions.CreateWebhookSubscriptionRequest { ... }) -> CreateWebhookSubscriptionResponse
@@ -21147,7 +21216,7 @@ await client.Webhooks.Subscriptions.CreateAsync(
-**request:** `CreateWebhookSubscriptionRequest` +**request:** `Square.Webhooks.Subscriptions.CreateWebhookSubscriptionRequest`
@@ -21159,7 +21228,7 @@ await client.Webhooks.Subscriptions.CreateAsync(
-
client.Webhooks.Subscriptions.GetAsync(GetSubscriptionsRequest { ... }) -> GetWebhookSubscriptionResponse +
client.Webhooks.Subscriptions.GetAsync(Square.Webhooks.Subscriptions.GetSubscriptionsRequest { ... }) -> GetWebhookSubscriptionResponse
@@ -21187,7 +21256,7 @@ Retrieves a webhook subscription identified by its ID. ```csharp await client.Webhooks.Subscriptions.GetAsync( - new GetSubscriptionsRequest { SubscriptionId = "subscription_id" } + new Square.Webhooks.Subscriptions.GetSubscriptionsRequest { SubscriptionId = "subscription_id" } ); ```
@@ -21203,7 +21272,7 @@ await client.Webhooks.Subscriptions.GetAsync(
-**request:** `GetSubscriptionsRequest` +**request:** `Square.Webhooks.Subscriptions.GetSubscriptionsRequest`
@@ -21215,7 +21284,7 @@ await client.Webhooks.Subscriptions.GetAsync(
-
client.Webhooks.Subscriptions.UpdateAsync(UpdateWebhookSubscriptionRequest { ... }) -> UpdateWebhookSubscriptionResponse +
client.Webhooks.Subscriptions.UpdateAsync(Square.Webhooks.Subscriptions.UpdateWebhookSubscriptionRequest { ... }) -> UpdateWebhookSubscriptionResponse
@@ -21267,7 +21336,7 @@ await client.Webhooks.Subscriptions.UpdateAsync(
-**request:** `UpdateWebhookSubscriptionRequest` +**request:** `Square.Webhooks.Subscriptions.UpdateWebhookSubscriptionRequest`
@@ -21279,7 +21348,7 @@ await client.Webhooks.Subscriptions.UpdateAsync(
-
client.Webhooks.Subscriptions.DeleteAsync(DeleteSubscriptionsRequest { ... }) -> DeleteWebhookSubscriptionResponse +
client.Webhooks.Subscriptions.DeleteAsync(Square.Webhooks.Subscriptions.DeleteSubscriptionsRequest { ... }) -> DeleteWebhookSubscriptionResponse
@@ -21323,7 +21392,7 @@ await client.Webhooks.Subscriptions.DeleteAsync(
-**request:** `DeleteSubscriptionsRequest` +**request:** `Square.Webhooks.Subscriptions.DeleteSubscriptionsRequest`
@@ -21335,7 +21404,7 @@ await client.Webhooks.Subscriptions.DeleteAsync(
-
client.Webhooks.Subscriptions.UpdateSignatureKeyAsync(UpdateWebhookSubscriptionSignatureKeyRequest { ... }) -> UpdateWebhookSubscriptionSignatureKeyResponse +
client.Webhooks.Subscriptions.UpdateSignatureKeyAsync(Square.Webhooks.Subscriptions.UpdateWebhookSubscriptionSignatureKeyRequest { ... }) -> UpdateWebhookSubscriptionSignatureKeyResponse
@@ -21383,7 +21452,7 @@ await client.Webhooks.Subscriptions.UpdateSignatureKeyAsync(
-**request:** `UpdateWebhookSubscriptionSignatureKeyRequest` +**request:** `Square.Webhooks.Subscriptions.UpdateWebhookSubscriptionSignatureKeyRequest`
@@ -21395,7 +21464,7 @@ await client.Webhooks.Subscriptions.UpdateSignatureKeyAsync(
-
client.Webhooks.Subscriptions.TestAsync(TestWebhookSubscriptionRequest { ... }) -> TestWebhookSubscriptionResponse +
client.Webhooks.Subscriptions.TestAsync(Square.Webhooks.Subscriptions.TestWebhookSubscriptionRequest { ... }) -> TestWebhookSubscriptionResponse
@@ -21443,7 +21512,7 @@ await client.Webhooks.Subscriptions.TestAsync(
-**request:** `TestWebhookSubscriptionRequest` +**request:** `Square.Webhooks.Subscriptions.TestWebhookSubscriptionRequest`
diff --git a/src/Square.Test/Core/Json/AdditionalPropertiesTests.cs b/src/Square.Test/Core/Json/AdditionalPropertiesTests.cs new file mode 100644 index 00000000..cd9156a1 --- /dev/null +++ b/src/Square.Test/Core/Json/AdditionalPropertiesTests.cs @@ -0,0 +1,365 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using NUnit.Framework; +using Square.Core; + +namespace Square.Test.Core.Json; + +[TestFixture] +public class AdditionalPropertiesTests +{ + [Test] + public void Record_OnDeserialized_ShouldPopulateAdditionalProperties() + { + // Arrange + const string json = """ + { + "id": "1", + "category": "fiction", + "title": "The Hobbit" + } + """; + + // Act + var record = JsonUtils.Deserialize(json); + + // Assert + Assert.That(record, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(record.Id, Is.EqualTo("1")); + Assert.That(record.AdditionalProperties["category"].GetString(), Is.EqualTo("fiction")); + Assert.That(record.AdditionalProperties["title"].GetString(), Is.EqualTo("The Hobbit")); + }); + } + + [Test] + public void RecordWithWriteableAdditionalProperties_OnSerialization_ShouldIncludeAdditionalProperties() + { + // Arrange + var record = new WriteableRecord + { + Id = "1", + AdditionalProperties = { ["category"] = "fiction", ["title"] = "The Hobbit" }, + }; + + // Act + var json = JsonUtils.Serialize(record); + var deserializedRecord = JsonUtils.Deserialize(json); + + // Assert + Assert.That(deserializedRecord, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(deserializedRecord.Id, Is.EqualTo("1")); + Assert.That( + deserializedRecord.AdditionalProperties["category"], + Is.InstanceOf() + ); + Assert.That( + ((JsonElement)deserializedRecord.AdditionalProperties["category"]!).GetString(), + Is.EqualTo("fiction") + ); + Assert.That( + deserializedRecord.AdditionalProperties["title"], + Is.InstanceOf() + ); + Assert.That( + ((JsonElement)deserializedRecord.AdditionalProperties["title"]!).GetString(), + Is.EqualTo("The Hobbit") + ); + }); + } + + [Test] + public void ReadOnlyAdditionalProperties_ShouldRetrieveValuesCorrectly() + { + // Arrange + var extensionData = new Dictionary + { + ["key1"] = JsonUtils.SerializeToElement("value1"), + ["key2"] = JsonUtils.SerializeToElement(123), + }; + var readOnlyProps = new ReadOnlyAdditionalProperties(); + readOnlyProps.CopyFromExtensionData(extensionData); + + // Act & Assert + Assert.That(readOnlyProps["key1"].GetString(), Is.EqualTo("value1")); + Assert.That(readOnlyProps["key2"].GetInt32(), Is.EqualTo(123)); + } + + [Test] + public void AdditionalProperties_ShouldBehaveAsDictionary() + { + // Arrange + var additionalProps = new AdditionalProperties { ["key1"] = "value1", ["key2"] = 123 }; + + // Act + additionalProps["key3"] = true; + + // Assert + Assert.Multiple(() => + { + Assert.That(additionalProps["key1"], Is.EqualTo("value1")); + Assert.That(additionalProps["key2"], Is.EqualTo(123)); + Assert.That((bool)additionalProps["key3"]!, Is.True); + Assert.That(additionalProps.Count, Is.EqualTo(3)); + }); + } + + [Test] + public void AdditionalProperties_ToJsonObject_ShouldSerializeCorrectly() + { + // Arrange + var additionalProps = new AdditionalProperties { ["key1"] = "value1", ["key2"] = 123 }; + + // Act + var jsonObject = additionalProps.ToJsonObject(); + + Assert.Multiple(() => + { + // Assert + Assert.That(jsonObject["key1"]!.GetValue(), Is.EqualTo("value1")); + Assert.That(jsonObject["key2"]!.GetValue(), Is.EqualTo(123)); + }); + } + + [Test] + public void AdditionalProperties_MixReadAndWrite_ShouldOverwriteDeserializedProperty() + { + // Arrange + const string json = """ + { + "id": "1", + "category": "fiction", + "title": "The Hobbit" + } + """; + var record = JsonUtils.Deserialize(json); + + // Act + record.AdditionalProperties["category"] = "non-fiction"; + + // Assert + Assert.Multiple(() => + { + Assert.That(record, Is.Not.Null); + Assert.That(record.Id, Is.EqualTo("1")); + Assert.That(record.AdditionalProperties["category"], Is.EqualTo("non-fiction")); + Assert.That(record.AdditionalProperties["title"], Is.InstanceOf()); + Assert.That( + ((JsonElement)record.AdditionalProperties["title"]!).GetString(), + Is.EqualTo("The Hobbit") + ); + }); + } + + [Test] + public void RecordWithReadonlyAdditionalPropertiesInts_OnDeserialized_ShouldPopulateAdditionalProperties() + { + // Arrange + const string json = """ + { + "extra1": 42, + "extra2": 99 + } + """; + + // Act + var record = JsonUtils.Deserialize(json); + + // Assert + Assert.That(record, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(record.AdditionalProperties["extra1"], Is.EqualTo(42)); + Assert.That(record.AdditionalProperties["extra2"], Is.EqualTo(99)); + }); + } + + [Test] + public void RecordWithAdditionalPropertiesInts_OnSerialization_ShouldIncludeAdditionalProperties() + { + // Arrange + var record = new WriteableRecordWithInts + { + AdditionalProperties = { ["extra1"] = 42, ["extra2"] = 99 }, + }; + + // Act + var json = JsonUtils.Serialize(record); + var deserializedRecord = JsonUtils.Deserialize(json); + + // Assert + Assert.That(deserializedRecord, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(deserializedRecord.AdditionalProperties["extra1"], Is.EqualTo(42)); + Assert.That(deserializedRecord.AdditionalProperties["extra2"], Is.EqualTo(99)); + }); + } + + [Test] + public void RecordWithReadonlyAdditionalPropertiesDictionaries_OnDeserialized_ShouldPopulateAdditionalProperties() + { + // Arrange + const string json = """ + { + "extra1": { "key1": true, "key2": false }, + "extra2": { "key3": true } + } + """; + + // Act + var record = JsonUtils.Deserialize(json); + + // Assert + Assert.That(record, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(record.AdditionalProperties["extra1"]["key1"], Is.True); + Assert.That(record.AdditionalProperties["extra1"]["key2"], Is.False); + Assert.That(record.AdditionalProperties["extra2"]["key3"], Is.True); + }); + } + + [Test] + public void RecordWithAdditionalPropertiesDictionaries_OnSerialization_ShouldIncludeAdditionalProperties() + { + // Arrange + var record = new WriteableRecordWithDictionaries + { + AdditionalProperties = + { + ["extra1"] = new Dictionary { { "key1", true }, { "key2", false } }, + ["extra2"] = new Dictionary { { "key3", true } }, + }, + }; + + // Act + var json = JsonUtils.Serialize(record); + var deserializedRecord = JsonUtils.Deserialize(json); + + // Assert + Assert.That(deserializedRecord, Is.Not.Null); + Assert.Multiple(() => + { + Assert.That(deserializedRecord.AdditionalProperties["extra1"]["key1"], Is.True); + Assert.That(deserializedRecord.AdditionalProperties["extra1"]["key2"], Is.False); + Assert.That(deserializedRecord.AdditionalProperties["extra2"]["key3"], Is.True); + }); + } + + private record Record : IJsonOnDeserialized + { + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; } = new(); + + void IJsonOnDeserialized.OnDeserialized() + { + AdditionalProperties.CopyFromExtensionData(_extensionData); + } + } + + private record WriteableRecord : IJsonOnDeserialized, IJsonOnSerializing + { + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() + { + AdditionalProperties.CopyFromExtensionData(_extensionData); + } + + void IJsonOnSerializing.OnSerializing() + { + AdditionalProperties.CopyToExtensionData(_extensionData); + } + } + + private record RecordWithInts : IJsonOnDeserialized + { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; } = new(); + + void IJsonOnDeserialized.OnDeserialized() + { + AdditionalProperties.CopyFromExtensionData(_extensionData); + } + } + + private record WriteableRecordWithInts : IJsonOnDeserialized, IJsonOnSerializing + { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public AdditionalProperties AdditionalProperties { get; } = new(); + + void IJsonOnDeserialized.OnDeserialized() + { + AdditionalProperties.CopyFromExtensionData(_extensionData); + } + + void IJsonOnSerializing.OnSerializing() + { + AdditionalProperties.CopyToExtensionData(_extensionData); + } + } + + private record RecordWithDictionaries : IJsonOnDeserialized + { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties< + Dictionary + > AdditionalProperties { get; } = new(); + + void IJsonOnDeserialized.OnDeserialized() + { + AdditionalProperties.CopyFromExtensionData(_extensionData); + } + } + + private record WriteableRecordWithDictionaries : IJsonOnDeserialized, IJsonOnSerializing + { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonIgnore] + public AdditionalProperties> AdditionalProperties { get; } = new(); + + void IJsonOnDeserialized.OnDeserialized() + { + AdditionalProperties.CopyFromExtensionData(_extensionData); + } + + void IJsonOnSerializing.OnSerializing() + { + AdditionalProperties.CopyToExtensionData(_extensionData); + } + } +} diff --git a/src/Square.Test/Core/Json/JsonAccessAttributeTests.cs b/src/Square.Test/Core/Json/JsonAccessAttributeTests.cs index 96f183f6..be0e2d54 100644 --- a/src/Square.Test/Core/Json/JsonAccessAttributeTests.cs +++ b/src/Square.Test/Core/Json/JsonAccessAttributeTests.cs @@ -72,8 +72,8 @@ public void JsonAccessAttribute_ShouldWorkAsExpected() var nullableReadOnlyList = obj.ReadOnlyNullableList?.ToArray(); Assert.That(nullableReadOnlyList, Is.Not.Null); Assert.That(nullableReadOnlyList, Has.Length.EqualTo(2)); - Assert.That(nullableReadOnlyList[0], Is.EqualTo("item1")); - Assert.That(nullableReadOnlyList[1], Is.EqualTo("item2")); + Assert.That(nullableReadOnlyList![0], Is.EqualTo("item1")); + Assert.That(nullableReadOnlyList![1], Is.EqualTo("item2")); var readOnlyList = obj.ReadOnlyList.ToArray(); Assert.That(readOnlyList, Is.Not.Null); diff --git a/src/Square.Test/Core/Pagination/IntOffsetTest.cs b/src/Square.Test/Core/Pagination/IntOffsetTest.cs index d5fe6869..7cabec4d 100644 --- a/src/Square.Test/Core/Pagination/IntOffsetTest.cs +++ b/src/Square.Test/Core/Pagination/IntOffsetTest.cs @@ -31,11 +31,14 @@ public async SystemTask OffsetPagerShouldWorkWithIntPage() responses.MoveNext(); return SystemTask.FromResult(responses.Current); }, - request => request.Pagination.Page, + request => request?.Pagination?.Page ?? 0, (request, offset) => { - request.Pagination ??= new(); - request.Pagination.Page = offset; + if (request is not null) + { + request.Pagination ??= new(); + request.Pagination.Page = offset; + } }, null, response => response?.Data?.Items?.ToList(), diff --git a/src/Square.Test/Core/Pagination/NoRequestCursorTest.cs b/src/Square.Test/Core/Pagination/NoRequestCursorTest.cs index 9450da39..0301eda6 100644 --- a/src/Square.Test/Core/Pagination/NoRequestCursorTest.cs +++ b/src/Square.Test/Core/Pagination/NoRequestCursorTest.cs @@ -49,8 +49,11 @@ public async SystemTask CursorPagerShouldWorkWithStringCursor() }, (request, cursor) => { - request.Cursor = cursor; - cursorCopy = cursor; + if (request is not null) + { + request.Cursor = cursor; + cursorCopy = cursor; + } }, response => response?.Cursor?.Next, response => response?.Data?.Items?.ToList() diff --git a/src/Square.Test/Core/Pagination/NoRequestOffsetTest.cs b/src/Square.Test/Core/Pagination/NoRequestOffsetTest.cs index 2e7b2917..1c563762 100644 --- a/src/Square.Test/Core/Pagination/NoRequestOffsetTest.cs +++ b/src/Square.Test/Core/Pagination/NoRequestOffsetTest.cs @@ -34,8 +34,11 @@ public async SystemTask OffsetPagerShouldWorkWithoutRequest() request => request?.Pagination?.Page ?? 0, (request, offset) => { - request.Pagination ??= new(); - request.Pagination.Page = offset; + if (request is not null) + { + request.Pagination ??= new(); + request.Pagination.Page = offset; + } }, null, response => response?.Data?.Items?.ToList(), diff --git a/src/Square.Test/Core/Pagination/StringCursorTest.cs b/src/Square.Test/Core/Pagination/StringCursorTest.cs index 56ea6b63..9374126b 100644 --- a/src/Square.Test/Core/Pagination/StringCursorTest.cs +++ b/src/Square.Test/Core/Pagination/StringCursorTest.cs @@ -10,6 +10,7 @@ public class StringCursorTest private const string? Cursor1 = null; private const string Cursor2 = "cursor2"; private const string Cursor3 = "cursor3"; + private const string Cursor4 = ""; [Test] public async SystemTask CursorPagerShouldWorkWithStringCursor() @@ -80,6 +81,69 @@ public async SystemTask CursorPagerShouldWorkWithStringCursor() Assert.That(await pageEnumerator.MoveNextAsync(), Is.False); } + [Test] + public async SystemTask CursorPagerShouldWorkWithStringCursor_EmptyStringCursor() + { + var responses = new List + { + new() + { + Data = new Data { Items = ["item1", "item2"] }, + Cursor = new Cursor { Next = Cursor2 }, + }, + new() + { + Data = new Data { Items = ["item1"] }, + Cursor = new Cursor { Next = Cursor4 }, + }, + new() + { + Data = new Data { Items = ["item2"] }, + Cursor = new Cursor { Next = Cursor3 }, + }, + }.GetEnumerator(); + var cursorCopy = Cursor1; + Pager pager = await CursorPager< + Request, + object?, + Response, + string, + object + >.CreateInstanceAsync( + new Request { Cursor = Cursor1 }, + null, + (_, _, _) => + { + responses.MoveNext(); + return SystemTask.FromResult(responses.Current); + }, + (request, cursor) => + { + request.Cursor = cursor; + cursorCopy = cursor; + }, + response => response?.Cursor?.Next, + response => response?.Data?.Items?.ToList() + ); + + var pageEnumerator = pager.AsPagesAsync().GetAsyncEnumerator(); + + // first page + Assert.That(await pageEnumerator.MoveNextAsync(), Is.True); + var page = pageEnumerator.Current; + Assert.That(page.Items, Has.Count.EqualTo(2)); + Assert.That(cursorCopy, Is.EqualTo(Cursor2)); + + // second page (cursor is empty string) + Assert.That(await pageEnumerator.MoveNextAsync(), Is.True); + page = pageEnumerator.Current; + Assert.That(page.Items, Has.Count.EqualTo(1)); + Assert.That(cursorCopy, Is.EqualTo(Cursor4)); + + // no more (should not reach third response) + Assert.That(await pageEnumerator.MoveNextAsync(), Is.False); + } + private class Request { public required string? Cursor { get; set; } diff --git a/src/Square.Test/Core/QueryStringConverterTests.cs b/src/Square.Test/Core/QueryStringConverterTests.cs index 5cc6683a..5ec9c8b8 100644 --- a/src/Square.Test/Core/QueryStringConverterTests.cs +++ b/src/Square.Test/Core/QueryStringConverterTests.cs @@ -97,7 +97,9 @@ public void ToQueryStringCollection_DeepObject() [Test] public void ToQueryStringCollection_OnString_ThrowsException() { - var exception = Assert.Throws(() => QueryStringConverter.ToForm("invalid")); + var exception = Assert.Throws(() => + QueryStringConverter.ToForm("invalid") + ); Assert.That( exception.Message, Is.EqualTo( @@ -109,8 +111,8 @@ public void ToQueryStringCollection_OnString_ThrowsException() [Test] public void ToQueryStringCollection_OnArray_ThrowsException() { - var exception = Assert.Throws( - () => QueryStringConverter.ToForm(Array.Empty()) + var exception = Assert.Throws(() => + QueryStringConverter.ToForm(Array.Empty()) ); Assert.That( exception.Message, diff --git a/src/Square.Test/Core/RawClientTests/AdditionalHeadersTests.cs b/src/Square.Test/Core/RawClientTests/AdditionalHeadersTests.cs index 52b06c88..1d1b5891 100644 --- a/src/Square.Test/Core/RawClientTests/AdditionalHeadersTests.cs +++ b/src/Square.Test/Core/RawClientTests/AdditionalHeadersTests.cs @@ -94,8 +94,9 @@ public async SystemTask SendRequestAsync_AdditionalHeaderParameters() Assert.That(content, Is.EqualTo("Success")); Assert.That(_server.LogEntries.Count, Is.EqualTo(1)); var headers = - _server.LogEntries[0].RequestMessage.Headers - ?? throw new Exception("Headers are null"); + _server.LogEntries[0].RequestMessage.Headers ?? throw new global::System.Exception( + "Headers are null" + ); Assert.That(headers, Contains.Key("client_multiple")); Assert.That(headers!["client_multiple"][0], Does.Contain("client_additional_headers1")); diff --git a/src/Square.Test/Core/RawClientTests/MultipartFormTests.cs b/src/Square.Test/Core/RawClientTests/MultipartFormTests.cs index 80de7dec..d73f0413 100644 --- a/src/Square.Test/Core/RawClientTests/MultipartFormTests.cs +++ b/src/Square.Test/Core/RawClientTests/MultipartFormTests.cs @@ -1052,7 +1052,7 @@ private static string GetBoundary(MultipartFormDataContent content) .Headers.ContentType?.Parameters.Single(p => p.Name.Equals("boundary", StringComparison.OrdinalIgnoreCase) ) - .Value?.Trim('"') ?? throw new Exception("Boundary not found"); + .Value?.Trim('"') ?? throw new global::System.Exception("Boundary not found"); } private static MultipartFormRequest CreateMultipartFormRequest() @@ -1084,16 +1084,16 @@ private class SimpleObject public int Count { get; set; } = 42; public char Initial { get; set; } = 'A'; public IEnumerable Values { get; set; } = - [ - "data", - DateOnly.Parse("2023-10-01"), - TimeOnly.Parse("12:00:00"), - TimeSpan.FromHours(1), - Guid.Parse("1a1bb98f-47c6-407b-9481-78476affe52a"), - true, - 42, - 'A', - ]; + [ + "data", + DateOnly.Parse("2023-10-01"), + TimeOnly.Parse("12:00:00"), + TimeSpan.FromHours(1), + Guid.Parse("1a1bb98f-47c6-407b-9481-78476affe52a"), + true, + 42, + 'A', + ]; } private class ComplexObject diff --git a/src/Square.Test/Core/RawClientTests/QueryParameterTests.cs b/src/Square.Test/Core/RawClientTests/QueryParameterTests.cs new file mode 100644 index 00000000..c137283c --- /dev/null +++ b/src/Square.Test/Core/RawClientTests/QueryParameterTests.cs @@ -0,0 +1,63 @@ +using NUnit.Framework; +using Square.Core; +using WireMock.Matchers; +using WireMock.Server; +using SystemTask = global::System.Threading.Tasks.Task; +using WireMockRequest = WireMock.RequestBuilders.Request; +using WireMockResponse = WireMock.ResponseBuilders.Response; + +namespace Square.Test.Core.RawClientTests; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class QueryParameterTests +{ + private WireMockServer _server; + private HttpClient _httpClient; + private RawClient _rawClient; + private string _baseUrl; + + [SetUp] + public void SetUp() + { + _server = WireMockServer.Start(); + _baseUrl = _server.Url ?? ""; + _httpClient = new HttpClient { BaseAddress = new Uri(_baseUrl) }; + _rawClient = new RawClient(new ClientOptions { HttpClient = _httpClient }); + } + + [Test] + public void CreateRequest_QueryParametersEscaping() + { + _server + .Given(WireMockRequest.Create().WithPath("/test").WithParam("foo", "bar").UsingGet()) + .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); + + var request = new JsonRequest() + { + BaseUrl = _baseUrl, + Method = HttpMethod.Get, + Path = "/test", + Query = new Dictionary + { + { "sample", "value" }, + { "email", "bob+test@example.com" }, + { "%Complete", "100" }, + }, + Options = new RequestOptions(), + }; + + var url = _rawClient.CreateHttpRequest(request).RequestUri!.AbsoluteUri; + + Assert.That(url, Does.Contain("sample=value")); + Assert.That(url, Does.Contain("email=bob%2Btest%40example.com")); + Assert.That(url, Does.Contain("%25Complete=100")); + } + + [TearDown] + public void TearDown() + { + _server.Dispose(); + _httpClient.Dispose(); + } +} diff --git a/src/Square.Test/Square.Test.csproj b/src/Square.Test/Square.Test.csproj index d2fd1278..383a3938 100644 --- a/src/Square.Test/Square.Test.csproj +++ b/src/Square.Test/Square.Test.csproj @@ -1,37 +1,33 @@ - - - net8.0 - 12 - enable - enable - false - true - true - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - \ No newline at end of file + + net8.0 + 12 + enable + enable + false + true + true + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/src/Square.Test/Unit/MockServer/ApplePay/RegisterDomainTest.cs b/src/Square.Test/Unit/MockServer/ApplePay/RegisterDomainTest.cs new file mode 100644 index 00000000..da9e7950 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/ApplePay/RegisterDomainTest.cs @@ -0,0 +1,60 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.ApplePay; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.ApplePay; + +[TestFixture] +public class RegisterDomainTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "domain_name": "example.com" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "status": "VERIFIED" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/apple-pay/domains") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.ApplePay.RegisterDomainAsync( + new RegisterDomainRequest { DomainName = "example.com" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/BankAccounts/GetByV1IdTest.cs b/src/Square.Test/Unit/MockServer/BankAccounts/GetByV1IdTest.cs new file mode 100644 index 00000000..a74f2174 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/BankAccounts/GetByV1IdTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.BankAccounts; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.BankAccounts; + +[TestFixture] +public class GetByV1IdTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "bank_account": { + "id": "w3yRgCGYQnwmdl0R3GB", + "account_number_suffix": "971", + "country": "US", + "currency": "USD", + "account_type": "CHECKING", + "holder_name": "Jane Doe", + "primary_bank_identification_number": "112200303", + "secondary_bank_identification_number": "secondary_bank_identification_number", + "debit_mandate_reference_id": "debit_mandate_reference_id", + "reference_id": "reference_id", + "location_id": "S8GWD5example", + "status": "VERIFICATION_IN_PROGRESS", + "creditable": false, + "debitable": false, + "fingerprint": "fingerprint", + "version": 5, + "bank_name": "Bank Name" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bank-accounts/by-v1-id/v1_bank_account_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.BankAccounts.GetByV1IdAsync( + new GetByV1IdBankAccountsRequest { V1BankAccountId = "v1_bank_account_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/BankAccounts/GetTest.cs b/src/Square.Test/Unit/MockServer/BankAccounts/GetTest.cs new file mode 100644 index 00000000..a7cc6f74 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/BankAccounts/GetTest.cs @@ -0,0 +1,70 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.BankAccounts; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.BankAccounts; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "bank_account": { + "id": "w3yRgCGYQnwmdl0R3GB", + "account_number_suffix": "971", + "country": "US", + "currency": "USD", + "account_type": "CHECKING", + "holder_name": "Jane Doe", + "primary_bank_identification_number": "112200303", + "secondary_bank_identification_number": "secondary_bank_identification_number", + "debit_mandate_reference_id": "debit_mandate_reference_id", + "reference_id": "reference_id", + "location_id": "S8GWD5example", + "status": "VERIFICATION_IN_PROGRESS", + "creditable": false, + "debitable": false, + "fingerprint": "fingerprint", + "version": 5, + "bank_name": "Bank Name" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bank-accounts/bank_account_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.BankAccounts.GetAsync( + new GetBankAccountsRequest { BankAccountId = "bank_account_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/BankAccounts/ListTest.cs b/src/Square.Test/Unit/MockServer/BankAccounts/ListTest.cs new file mode 100644 index 00000000..e5994174 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/BankAccounts/ListTest.cs @@ -0,0 +1,99 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.BankAccounts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.BankAccounts; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "bank_accounts": [ + { + "id": "ao6iaQ9vhDiaQD7n3GB", + "account_number_suffix": "971", + "country": "US", + "currency": "USD", + "account_type": "CHECKING", + "holder_name": "Jane Doe", + "primary_bank_identification_number": "112200303", + "secondary_bank_identification_number": "secondary_bank_identification_number", + "debit_mandate_reference_id": "debit_mandate_reference_id", + "reference_id": "reference_id", + "location_id": "S8GWD5example", + "status": "VERIFICATION_IN_PROGRESS", + "creditable": false, + "debitable": false, + "fingerprint": "fingerprint", + "version": 5, + "bank_name": "Bank Name" + }, + { + "id": "4x7WXuaxrkQkVlka3GB", + "account_number_suffix": "972", + "country": "US", + "currency": "USD", + "account_type": "CHECKING", + "holder_name": "Jane Doe", + "primary_bank_identification_number": "112200303", + "secondary_bank_identification_number": "secondary_bank_identification_number", + "debit_mandate_reference_id": "debit_mandate_reference_id", + "reference_id": "reference_id", + "location_id": "S8GWD5example", + "status": "VERIFICATION_IN_PROGRESS", + "creditable": false, + "debitable": false, + "fingerprint": "fingerprint", + "version": 5, + "bank_name": "Bank Name" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bank-accounts") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .WithParam("location_id", "location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.BankAccounts.ListAsync( + new ListBankAccountsRequest + { + Cursor = "cursor", + Limit = 1, + LocationId = "location_id", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/BaseMockServerTest.cs b/src/Square.Test/Unit/MockServer/BaseMockServerTest.cs new file mode 100644 index 00000000..9294c344 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/BaseMockServerTest.cs @@ -0,0 +1,39 @@ +using NUnit.Framework; +using Square; +using WireMock.Logging; +using WireMock.Server; +using WireMock.Settings; + +namespace Square.Test.Unit.MockServer; + +[SetUpFixture] +public class BaseMockServerTest +{ + protected static WireMockServer Server { get; set; } = null!; + + protected static SquareClient Client { get; set; } = null!; + + protected static RequestOptions RequestOptions { get; set; } = new(); + + [OneTimeSetUp] + public void GlobalSetup() + { + // Start the WireMock server + Server = WireMockServer.Start( + new WireMockServerSettings { Logger = new WireMockConsoleLogger() } + ); + + // Initialize the Client + Client = new SquareClient( + "TOKEN", + clientOptions: new ClientOptions { BaseUrl = Server.Urls[0], MaxRetries = 0 } + ); + } + + [OneTimeTearDown] + public void GlobalTeardown() + { + Server.Stop(); + Server.Dispose(); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveBookingsTest.cs b/src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveBookingsTest.cs new file mode 100644 index 00000000..33364d62 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveBookingsTest.cs @@ -0,0 +1,130 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class BulkRetrieveBookingsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "booking_ids": [ + "booking_ids" + ] + } + """; + + const string mockResponse = """ + { + "bookings": { + "sc3p3m7dvctfr1": { + "booking": { + "id": "sc3p3m7dvctfr1", + "version": 0, + "status": "ACCEPTED", + "created_at": "2023-04-26T18:19:21.000Z", + "updated_at": "2023-04-26T18:19:21.000Z", + "start_at": "2023-05-01T14:00:00.000Z", + "location_id": "LY6WNBPVM6VGV", + "customer_id": "4TDWKN9E8165X8Z77MRS0VFMJM", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "VG4FYBKK3UL6UITOEYQ6MFLS", + "team_member_id": "TMjiqI3PxyLMKr4k", + "service_variation_version": 1641341724039, + "any_team_member": false + } + ], + "all_day": false + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "tdegug1dvctdef": { + "errors": [ + { + "category": "INVALID_REQUEST_ERROR", + "code": "NOT_FOUND", + "detail": "Specified booking was not found.", + "field": "booking_id" + } + ] + }, + "tdegug1fqni3wh": { + "booking": { + "id": "tdegug1fqni3wh", + "version": 0, + "status": "ACCEPTED", + "created_at": "2023-04-26T18:19:30.000Z", + "updated_at": "2023-04-26T18:19:30.000Z", + "start_at": "2023-05-02T14:00:00.000Z", + "location_id": "LY6WNBPVM6VGV", + "customer_id": "4TDWKN9E8165X8Z77MRS0VFMJM", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "VG4FYBKK3UL6UITOEYQ6MFLS", + "team_member_id": "TMjiqI3PxyLMKr4k", + "service_variation_version": 1641341724039, + "any_team_member": false + } + ], + "all_day": false + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/bulk-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.BulkRetrieveBookingsAsync( + new BulkRetrieveBookingsRequest { BookingIds = new List() { "booking_ids" } } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveTeamMemberBookingProfilesTest.cs b/src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveTeamMemberBookingProfilesTest.cs new file mode 100644 index 00000000..7b32f6da --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/BulkRetrieveTeamMemberBookingProfilesTest.cs @@ -0,0 +1,106 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class BulkRetrieveTeamMemberBookingProfilesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "team_member_ids": [ + "team_member_ids" + ] + } + """; + + const string mockResponse = """ + { + "team_member_booking_profiles": { + "TMXUrsBWWcHTt79t": { + "errors": [ + { + "category": "INVALID_REQUEST_ERROR", + "code": "NOT_FOUND", + "detail": "Resource not found." + } + ] + }, + "TMaJcbiRqPIGZuS9": { + "team_member_booking_profile": { + "team_member_id": "TMaJcbiRqPIGZuS9", + "display_name": "Sandbox Staff 1", + "is_bookable": true + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "TMtdegug1fqni3wh": { + "team_member_booking_profile": { + "team_member_id": "TMtdegug1fqni3wh", + "display_name": "Sandbox Staff 2", + "is_bookable": true + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/team-member-booking-profiles/bulk-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.BulkRetrieveTeamMemberBookingProfilesAsync( + new BulkRetrieveTeamMemberBookingProfilesRequest + { + TeamMemberIds = new List() { "team_member_ids" }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CancelTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CancelTest.cs new file mode 100644 index 00000000..03616cd0 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CancelTest.cs @@ -0,0 +1,102 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "booking": { + "id": "zkras0xv0xwswx", + "version": 1, + "status": "CANCELLED_BY_CUSTOMER", + "created_at": "2020-10-28T15:47:41.000Z", + "updated_at": "2020-10-28T15:49:25.000Z", + "start_at": "2020-11-26T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "customer_id": "EX2QSVGTZN4K1E5QE1CBFNVQ8M", + "customer_note": "", + "seller_note": "", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ], + "transition_time_minutes": 1, + "all_day": true, + "location_type": "BUSINESS_LOCATION", + "creator_details": { + "creator_type": "TEAM_MEMBER", + "team_member_id": "team_member_id", + "customer_id": "customer_id" + }, + "source": "FIRST_PARTY_MERCHANT", + "address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id/cancel") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CancelAsync( + new CancelBookingRequest { BookingId = "booking_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CreateTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CreateTest.cs new file mode 100644 index 00000000..141160de --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CreateTest.cs @@ -0,0 +1,104 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "booking": {} + } + """; + + const string mockResponse = """ + { + "booking": { + "id": "zkras0xv0xwswx", + "version": 0, + "status": "ACCEPTED", + "created_at": "2020-10-28T15:47:41.000Z", + "updated_at": "2020-10-28T15:47:41.000Z", + "start_at": "2020-11-26T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "customer_id": "EX2QSVGTZN4K1E5QE1CBFNVQ8M", + "customer_note": "", + "seller_note": "", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ], + "transition_time_minutes": 1, + "all_day": true, + "location_type": "BUSINESS_LOCATION", + "creator_details": { + "creator_type": "TEAM_MEMBER", + "team_member_id": "team_member_id", + "customer_id": "customer_id" + }, + "source": "FIRST_PARTY_MERCHANT", + "address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CreateAsync( + new CreateBookingRequest { Booking = new Booking() } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/CreateTest.cs new file mode 100644 index 00000000..75aee425 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/CreateTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings.CustomAttributeDefinitions; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributeDefinitions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": {} + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "favoriteShampoo", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite Shampoo", + "description": "The favorite shampoo of the customer.", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "2022-11-16T15:27:30.000Z", + "created_at": "2022-11-16T15:27:30.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attribute-definitions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributeDefinitions.CreateAsync( + new CreateBookingCustomAttributeDefinitionRequest + { + CustomAttributeDefinition = new CustomAttributeDefinition(), + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/DeleteTest.cs new file mode 100644 index 00000000..7daa2596 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/DeleteTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributeDefinitions; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attribute-definitions/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributeDefinitions.DeleteAsync( + new Square.Bookings.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/GetTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/GetTest.cs new file mode 100644 index 00000000..deed5301 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/GetTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributeDefinitions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "favoriteShampoo", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite shampoo", + "description": "The favorite shampoo of the customer.", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-11-16T15:27:30.000Z", + "created_at": "2022-11-16T15:27:30.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attribute-definitions/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributeDefinitions.GetAsync( + new Square.Bookings.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/ListTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/ListTest.cs new file mode 100644 index 00000000..7b82086b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/ListTest.cs @@ -0,0 +1,82 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributeDefinitions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definitions": [ + { + "key": "favoriteShampoo", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite shampoo", + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 3, + "updated_at": "2022-11-16T15:39:38.000Z", + "created_at": "2022-11-16T15:27:30.000Z" + }, + { + "key": "partySize", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Party size", + "description": "Number of people in the party for dine-in", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "2022-11-16T15:49:05.000Z", + "created_at": "2022-11-16T15:49:05.000Z" + } + ], + "cursor": "YEk4UPbUEsu8MUV0xouO5hCiFcD9T5ztB6UWEJq5vZnqBFmoBEi0j1j6HWYTFGMRre4p7T5wAQBj3Th1NX3XgBFcQVEVsIxUQ2NsbwjRitfoEZDml9uxxQXepowyRvCuSThHPbJSn7M7wInl3x8XypQF9ahVVQXegJ0CxEKc0SBH", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attribute-definitions") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Bookings.CustomAttributeDefinitions.ListAsync( + new Square.Bookings.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/UpdateTest.cs new file mode 100644 index 00000000..cd4771d9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributeDefinitions/UpdateTest.cs @@ -0,0 +1,80 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings.CustomAttributeDefinitions; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributeDefinitions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": {} + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "favoriteShampoo", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite shampoo", + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 2, + "updated_at": "2022-11-16T15:39:38.000Z", + "created_at": "2022-11-16T15:27:30.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attribute-definitions/key") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributeDefinitions.UpdateAsync( + new UpdateBookingCustomAttributeDefinitionRequest + { + Key = "key", + CustomAttributeDefinition = new CustomAttributeDefinition(), + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchDeleteTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchDeleteTest.cs new file mode 100644 index 00000000..9b787066 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchDeleteTest.cs @@ -0,0 +1,109 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings.CustomAttributes; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributes; + +[TestFixture] +public class BatchDeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "key": { + "booking_id": "booking_id", + "key": "key" + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "booking_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "booking_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id3": { + "booking_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attributes/bulk-delete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributes.BatchDeleteAsync( + new BulkDeleteBookingCustomAttributesRequest + { + Values = new Dictionary() + { + { + "key", + new BookingCustomAttributeDeleteRequest + { + BookingId = "booking_id", + Key = "key", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchUpsertTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchUpsertTest.cs new file mode 100644 index 00000000..75e0fe31 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/BatchUpsertTest.cs @@ -0,0 +1,167 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings.CustomAttributes; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributes; + +[TestFixture] +public class BatchUpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "key": { + "booking_id": "booking_id", + "custom_attribute": {} + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "booking_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "custom_attribute": { + "key": "favoriteShampoo", + "value": "Spring Fresh", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-16T00:16:23.000Z", + "created_at": "2022-11-16T23:14:47.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "booking_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "custom_attribute": { + "key": "hasShoes", + "value": false, + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-16T00:16:23.000Z", + "created_at": "2022-11-16T00:16:20.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id3": { + "booking_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "custom_attribute": { + "key": "favoriteShampoo", + "value": "Hydro-Cool", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-16T00:16:23.000Z", + "created_at": "2022-11-16T00:16:20.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id4": { + "booking_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "custom_attribute": { + "key": "partySize", + "value": 4, + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-16T00:16:23.000Z", + "created_at": "2022-11-16T23:14:47.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id5": { + "booking_id": "70548QG1HN43B05G0KCZ4MMC1G", + "custom_attribute": { + "key": "celebrating", + "value": "birthday", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-16T00:16:23.000Z", + "created_at": "2022-11-16T00:16:20.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/custom-attributes/bulk-upsert") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributes.BatchUpsertAsync( + new BulkUpsertBookingCustomAttributesRequest + { + Values = new Dictionary() + { + { + "key", + new BookingCustomAttributeUpsertRequest + { + BookingId = "booking_id", + CustomAttribute = new CustomAttribute(), + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/DeleteTest.cs new file mode 100644 index 00000000..d45b711c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/DeleteTest.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributes; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id/custom-attributes/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributes.DeleteAsync( + new Square.Bookings.CustomAttributes.DeleteCustomAttributesRequest + { + BookingId = "booking_id", + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/GetTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/GetTest.cs new file mode 100644 index 00000000..86499e0f --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/GetTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute": { + "key": "favoriteShampoo", + "value": "Dune", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2022-11-16T15:50:27.000Z", + "created_at": "2022-11-16T15:50:27.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id/custom-attributes/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributes.GetAsync( + new Square.Bookings.CustomAttributes.GetCustomAttributesRequest + { + BookingId = "booking_id", + Key = "key", + WithDefinition = true, + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/ListTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/ListTest.cs new file mode 100644 index 00000000..705439e5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/ListTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attributes": [ + { + "key": "favoriteShampoo", + "value": "Hydro-Cool", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "updated_at": "2022-11-16T15:50:27.000Z", + "created_at": "2022-11-16T15:50:27.000Z" + }, + { + "key": "hasShoes", + "value": false, + "version": 1, + "visibility": "VISIBILITY_HIDDEN", + "updated_at": "2022-11-16T15:51:53.000Z", + "created_at": "2022-11-16T15:51:53.000Z" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id/custom-attributes") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Bookings.CustomAttributes.ListAsync( + new Square.Bookings.CustomAttributes.ListCustomAttributesRequest + { + BookingId = "booking_id", + Limit = 1, + Cursor = "cursor", + WithDefinitions = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/UpsertTest.cs new file mode 100644 index 00000000..85fb2f34 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/CustomAttributes/UpsertTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings.CustomAttributes; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.CustomAttributes; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute": {} + } + """; + + const string mockResponse = """ + { + "custom_attribute": { + "key": "favoriteShampoo", + "value": "Spring Fresh", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2022-11-16T15:50:27.000Z", + "created_at": "2022-11-16T15:50:27.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id/custom-attributes/key") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.CustomAttributes.UpsertAsync( + new UpsertBookingCustomAttributeRequest + { + BookingId = "booking_id", + Key = "key", + CustomAttribute = new CustomAttribute(), + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/GetBusinessProfileTest.cs b/src/Square.Test/Unit/MockServer/Bookings/GetBusinessProfileTest.cs new file mode 100644 index 00000000..b4eed094 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/GetBusinessProfileTest.cs @@ -0,0 +1,77 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class GetBusinessProfileTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "business_booking_profile": { + "seller_id": "MLJQYZZRM0D3Y", + "created_at": "2020-09-10T21:40:38.000Z", + "booking_enabled": true, + "customer_timezone_choice": "CUSTOMER_CHOICE", + "booking_policy": "ACCEPT_ALL", + "allow_user_cancel": true, + "business_appointment_settings": { + "location_types": [ + "BUSINESS_LOCATION" + ], + "alignment_time": "HALF_HOURLY", + "min_booking_lead_time_seconds": 0, + "max_booking_lead_time_seconds": 31536000, + "any_team_member_booking_enabled": true, + "multiple_service_booking_enabled": true, + "max_appointments_per_day_limit_type": "PER_TEAM_MEMBER", + "max_appointments_per_day_limit": 1, + "cancellation_window_seconds": 1, + "cancellation_fee_money": { + "currency": "USD" + }, + "cancellation_policy": "CUSTOM_POLICY", + "cancellation_policy_text": "cancellation_policy_text", + "skip_booking_flow_staff_selection": false + }, + "support_seller_level_writes": true + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/business-booking-profile") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.GetBusinessProfileAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/GetTest.cs b/src/Square.Test/Unit/MockServer/Bookings/GetTest.cs new file mode 100644 index 00000000..5923a119 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/GetTest.cs @@ -0,0 +1,96 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "booking": { + "id": "zkras0xv0xwswx", + "version": 1, + "status": "ACCEPTED", + "created_at": "2020-10-28T15:47:41.000Z", + "updated_at": "2020-10-28T15:49:25.000Z", + "start_at": "2020-11-26T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "customer_id": "EX2QSVGTZN4K1E5QE1CBFNVQ8M", + "customer_note": "", + "seller_note": "", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ], + "transition_time_minutes": 1, + "all_day": true, + "location_type": "BUSINESS_LOCATION", + "creator_details": { + "creator_type": "TEAM_MEMBER", + "team_member_id": "team_member_id", + "customer_id": "customer_id" + }, + "source": "FIRST_PARTY_MERCHANT", + "address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.GetAsync( + new GetBookingsRequest { BookingId = "booking_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/ListTest.cs b/src/Square.Test/Unit/MockServer/Bookings/ListTest.cs new file mode 100644 index 00000000..9d53f225 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/ListTest.cs @@ -0,0 +1,92 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Bookings; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "bookings": [ + { + "id": "zkras0xv0xwswx", + "version": 1, + "status": "ACCEPTED", + "created_at": "2020-10-28T15:47:41.000Z", + "updated_at": "2020-10-28T15:49:25.000Z", + "start_at": "2020-11-26T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "customer_id": "EX2QSVGTZN4K1E5QE1CBFNVQ8M", + "customer_note": "", + "seller_note": "", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ], + "transition_time_minutes": 1, + "all_day": true, + "location_type": "BUSINESS_LOCATION", + "source": "FIRST_PARTY_MERCHANT" + } + ], + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .WithParam("customer_id", "customer_id") + .WithParam("team_member_id", "team_member_id") + .WithParam("location_id", "location_id") + .WithParam("start_at_min", "start_at_min") + .WithParam("start_at_max", "start_at_max") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Bookings.ListAsync( + new ListBookingsRequest + { + Limit = 1, + Cursor = "cursor", + CustomerId = "customer_id", + TeamMemberId = "team_member_id", + LocationId = "location_id", + StartAtMin = "start_at_min", + StartAtMax = "start_at_max", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/LocationProfiles/ListTest.cs b/src/Square.Test/Unit/MockServer/Bookings/LocationProfiles/ListTest.cs new file mode 100644 index 00000000..6846ca65 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/LocationProfiles/ListTest.cs @@ -0,0 +1,65 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Bookings.LocationProfiles; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.LocationProfiles; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "location_booking_profiles": [ + { + "location_id": "LY6WNBPVM6VGV", + "booking_site_url": "https://squareup.com/book/LY6WNBPVM6VGV/testbusiness", + "online_booking_enabled": true + }, + { + "location_id": "PYTRNBPVMJUPV", + "booking_site_url": "booking_site_url", + "online_booking_enabled": false + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/location-booking-profiles") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Bookings.LocationProfiles.ListAsync( + new ListLocationProfilesRequest { Limit = 1, Cursor = "cursor" } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/RetrieveLocationBookingProfileTest.cs b/src/Square.Test/Unit/MockServer/Bookings/RetrieveLocationBookingProfileTest.cs new file mode 100644 index 00000000..872e2826 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/RetrieveLocationBookingProfileTest.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class RetrieveLocationBookingProfileTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "location_booking_profile": { + "location_id": "L3HETDGYQ4A2C", + "booking_site_url": "https://square.site/book/L3HETDGYQ4A2C/prod-business", + "online_booking_enabled": true + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/location-booking-profiles/location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.RetrieveLocationBookingProfileAsync( + new RetrieveLocationBookingProfileRequest { LocationId = "location_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/SearchAvailabilityTest.cs b/src/Square.Test/Unit/MockServer/Bookings/SearchAvailabilityTest.cs new file mode 100644 index 00000000..9e3a673a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/SearchAvailabilityTest.cs @@ -0,0 +1,288 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class SearchAvailabilityTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "start_at_range": {} + } + } + } + """; + + const string mockResponse = """ + { + "availabilities": [ + { + "start_at": "2020-11-26T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-26T13:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-26T14:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-26T14:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-26T15:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-26T15:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-26T16:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T09:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T09:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T10:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T10:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T11:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T11:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T12:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T12:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T13:30:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ] + }, + { + "start_at": "2020-11-27T14:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMaJcbiRqPIGZuS9", + "service_variation_version": 1599775456731 + } + ] + } + ], + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/availability/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.SearchAvailabilityAsync( + new SearchAvailabilityRequest + { + Query = new SearchAvailabilityQuery + { + Filter = new SearchAvailabilityFilter { StartAtRange = new TimeRange() }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/GetTest.cs b/src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/GetTest.cs new file mode 100644 index 00000000..c28e61ee --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/GetTest.cs @@ -0,0 +1,59 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings.TeamMemberProfiles; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.TeamMemberProfiles; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "team_member_booking_profile": { + "team_member_id": "TMaJcbiRqPIGZuS9", + "description": "description", + "display_name": "Sandbox Staff", + "is_bookable": true, + "profile_image_url": "profile_image_url" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/team-member-booking-profiles/team_member_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.TeamMemberProfiles.GetAsync( + new GetTeamMemberProfilesRequest { TeamMemberId = "team_member_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/ListTest.cs b/src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/ListTest.cs new file mode 100644 index 00000000..2cbb0d42 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/TeamMemberProfiles/ListTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Bookings.TeamMemberProfiles; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings.TeamMemberProfiles; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "team_member_booking_profiles": [ + { + "team_member_id": "TMXUrsBWWcHTt79t", + "description": "description", + "display_name": "Sandbox Seller", + "is_bookable": true, + "profile_image_url": "profile_image_url" + }, + { + "team_member_id": "TMaJcbiRqPIGZuS9", + "description": "description", + "display_name": "Sandbox Staff", + "is_bookable": true, + "profile_image_url": "profile_image_url" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/team-member-booking-profiles") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .WithParam("location_id", "location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Bookings.TeamMemberProfiles.ListAsync( + new ListTeamMemberProfilesRequest + { + BookableOnly = true, + Limit = 1, + Cursor = "cursor", + LocationId = "location_id", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Bookings/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Bookings/UpdateTest.cs new file mode 100644 index 00000000..104c0bb3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Bookings/UpdateTest.cs @@ -0,0 +1,104 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Bookings; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Bookings; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "booking": {} + } + """; + + const string mockResponse = """ + { + "booking": { + "id": "zkras0xv0xwswx", + "version": 2, + "status": "ACCEPTED", + "created_at": "2020-10-28T15:47:41.000Z", + "updated_at": "2020-10-28T15:49:25.000Z", + "start_at": "2020-11-26T13:00:00.000Z", + "location_id": "LEQHH0YY8B42M", + "customer_id": "EX2QSVGTZN4K1E5QE1CBFNVQ8M", + "customer_note": "I would like to sit near the window please", + "seller_note": "", + "appointment_segments": [ + { + "duration_minutes": 60, + "service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC", + "team_member_id": "TMXUrsBWWcHTt79t", + "service_variation_version": 1599775456731 + } + ], + "transition_time_minutes": 1, + "all_day": true, + "location_type": "CUSTOMER_LOCATION", + "creator_details": { + "creator_type": "TEAM_MEMBER", + "team_member_id": "team_member_id", + "customer_id": "customer_id" + }, + "source": "FIRST_PARTY_MERCHANT", + "address": { + "address_line_1": "1955 Broadway", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "Oakland", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "CA", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "94612", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/bookings/booking_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Bookings.UpdateAsync( + new UpdateBookingRequest { BookingId = "booking_id", Booking = new Booking() } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Cards/CreateTest.cs b/src/Square.Test/Unit/MockServer/Cards/CreateTest.cs new file mode 100644 index 00000000..3edc6eb8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Cards/CreateTest.cs @@ -0,0 +1,129 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Cards; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Cards; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "4935a656-a929-4792-b97c-8848be85c27c", + "source_id": "cnon:uIbfJXhXETSP197M3GB", + "card": { + "cardholder_name": "Amelia Earhart", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8", + "reference_id": "user-id-1" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "card": { + "id": "ccof:uIbfJXhXETSP197M3GB", + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "cardholder_name": "Amelia Earhart", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "fingerprint": "ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q", + "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8", + "merchant_id": "6SSW7HV8K2ST5", + "reference_id": "user-id-1", + "enabled": true, + "card_type": "CREDIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111", + "version": 1, + "card_co_brand": "UNKNOWN", + "issuer_alert": "ISSUER_ALERT_CARD_CLOSED", + "issuer_alert_at": "issuer_alert_at", + "hsa_fsa": false + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/cards") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Cards.CreateAsync( + new CreateCardRequest + { + IdempotencyKey = "4935a656-a929-4792-b97c-8848be85c27c", + SourceId = "cnon:uIbfJXhXETSP197M3GB", + Card = new Card + { + CardholderName = "Amelia Earhart", + BillingAddress = new Address + { + AddressLine1 = "500 Electric Ave", + AddressLine2 = "Suite 600", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + CustomerId = "VDKXEEKPJN48QDG3BGGFAK05P8", + ReferenceId = "user-id-1", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Cards/DisableTest.cs b/src/Square.Test/Unit/MockServer/Cards/DisableTest.cs new file mode 100644 index 00000000..a0d7f618 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Cards/DisableTest.cs @@ -0,0 +1,88 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Cards; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Cards; + +[TestFixture] +public class DisableTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "card": { + "id": "ccof:uIbfJXhXETSP197M3GB", + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "cardholder_name": "Amelia Earhart", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "fingerprint": "ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q", + "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8", + "merchant_id": "6SSW7HV8K2ST5", + "reference_id": "user-id-1", + "enabled": false, + "card_type": "CREDIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111", + "version": 2, + "card_co_brand": "UNKNOWN", + "issuer_alert": "ISSUER_ALERT_CARD_CLOSED", + "issuer_alert_at": "issuer_alert_at", + "hsa_fsa": false + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/cards/card_id/disable") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Cards.DisableAsync( + new DisableCardsRequest { CardId = "card_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Cards/GetTest.cs b/src/Square.Test/Unit/MockServer/Cards/GetTest.cs new file mode 100644 index 00000000..8118dfe3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Cards/GetTest.cs @@ -0,0 +1,83 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Cards; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Cards; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "card": { + "id": "ccof:uIbfJXhXETSP197M3GB", + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "cardholder_name": "Amelia Earhart", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "fingerprint": "ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q", + "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8", + "merchant_id": "6SSW7HV8K2ST5", + "reference_id": "user-id-1", + "enabled": true, + "card_type": "CREDIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111", + "version": 1, + "card_co_brand": "UNKNOWN", + "issuer_alert": "ISSUER_ALERT_CARD_CLOSED", + "issuer_alert_at": "issuer_alert_at", + "hsa_fsa": false + } + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/cards/card_id").UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Cards.GetAsync(new GetCardsRequest { CardId = "card_id" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Cards/ListTest.cs b/src/Square.Test/Unit/MockServer/Cards/ListTest.cs new file mode 100644 index 00000000..0d21658d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Cards/ListTest.cs @@ -0,0 +1,94 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Cards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Cards; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "cards": [ + { + "id": "ccof:uIbfJXhXETSP197M3GB", + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "cardholder_name": "Amelia Earhart", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "fingerprint": "ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q", + "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8", + "merchant_id": "6SSW7HV8K2ST5", + "reference_id": "user-id-1", + "enabled": true, + "card_type": "CREDIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111", + "version": 1, + "card_co_brand": "UNKNOWN", + "issuer_alert": "ISSUER_ALERT_CARD_CLOSED", + "issuer_alert_at": "issuer_alert_at", + "hsa_fsa": false + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/cards") + .WithParam("cursor", "cursor") + .WithParam("customer_id", "customer_id") + .WithParam("reference_id", "reference_id") + .WithParam("sort_order", "DESC") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Cards.ListAsync( + new ListCardsRequest + { + Cursor = "cursor", + CustomerId = "customer_id", + IncludeDisabled = true, + ReferenceId = "reference_id", + SortOrder = SortOrder.Desc, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/GetTest.cs b/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/GetTest.cs new file mode 100644 index 00000000..ed217d7a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/GetTest.cs @@ -0,0 +1,105 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.CashDrawers.Shifts; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "cash_drawer_shift": { + "id": "DCC99978-09A6-4926-849F-300BE9C5793A", + "state": "CLOSED", + "opened_at": "2019-11-22T00:42:54.000Z", + "ended_at": "2019-11-22T00:44:49.000Z", + "closed_at": "2019-11-22T00:44:49.000Z", + "description": "Misplaced some change", + "opened_cash_money": { + "amount": 10000, + "currency": "USD" + }, + "cash_payment_money": { + "amount": 100, + "currency": "USD" + }, + "cash_refunds_money": { + "amount": -100, + "currency": "USD" + }, + "cash_paid_in_money": { + "amount": 10000, + "currency": "USD" + }, + "cash_paid_out_money": { + "amount": -10000, + "currency": "USD" + }, + "expected_cash_money": { + "amount": 10000, + "currency": "USD" + }, + "closed_cash_money": { + "amount": 9970, + "currency": "USD" + }, + "device": { + "id": "id", + "name": "My iPad" + }, + "created_at": "created_at", + "updated_at": "updated_at", + "location_id": "location_id", + "team_member_ids": [ + "team_member_ids" + ], + "opening_team_member_id": "", + "ending_team_member_id": "", + "closing_team_member_id": "" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/cash-drawers/shifts/shift_id") + .WithParam("location_id", "location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.CashDrawers.Shifts.GetAsync( + new Square.CashDrawers.Shifts.GetShiftsRequest + { + ShiftId = "shift_id", + LocationId = "location_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListEventsTest.cs b/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListEventsTest.cs new file mode 100644 index 00000000..c39d8fca --- /dev/null +++ b/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListEventsTest.cs @@ -0,0 +1,128 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.CashDrawers.Shifts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.CashDrawers.Shifts; + +[TestFixture] +public class ListEventsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "cash_drawer_shift_events": [ + { + "id": "9F07DB01-D85A-4B77-88C3-D5C64CEB5155", + "event_type": "CASH_TENDER_PAYMENT", + "event_money": { + "amount": 100, + "currency": "USD" + }, + "created_at": "2019-11-22T00:43:02.000Z", + "description": "", + "team_member_id": "" + }, + { + "id": "B2854CEA-A781-49B3-8F31-C64558231F48", + "event_type": "CASH_TENDER_PAYMENT", + "event_money": { + "amount": 250, + "currency": "USD" + }, + "created_at": "2019-11-22T00:43:12.000Z", + "description": "", + "team_member_id": "" + }, + { + "id": "B5FB7F72-95CD-44A3-974D-26C41064D042", + "event_type": "CASH_TENDER_CANCELLED_PAYMENT", + "event_money": { + "amount": 250, + "currency": "USD" + }, + "created_at": "2019-11-22T00:43:23.000Z", + "description": "", + "team_member_id": "" + }, + { + "id": "0B425480-8504-40B4-A867-37B23543931B", + "event_type": "CASH_TENDER_REFUND", + "event_money": { + "amount": 100, + "currency": "USD" + }, + "created_at": "2019-11-22T00:43:46.000Z", + "description": "", + "team_member_id": "" + }, + { + "id": "8C66E60E-FDCF-4EEF-A98D-3B14B7ED5CBE", + "event_type": "PAID_IN", + "event_money": { + "amount": 10000, + "currency": "USD" + }, + "created_at": "2019-11-22T00:44:18.000Z", + "description": "Transfer from another drawer", + "team_member_id": "" + }, + { + "id": "D5ACA7FE-C64D-4ADA-8BC8-82118A2DAE4F", + "event_type": "PAID_OUT", + "event_money": { + "amount": 10000, + "currency": "USD" + }, + "created_at": "2019-11-22T00:44:29.000Z", + "description": "Transfer out to another drawer", + "team_member_id": "" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/cash-drawers/shifts/shift_id/events") + .WithParam("location_id", "location_id") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.CashDrawers.Shifts.ListEventsAsync( + new ListEventsShiftsRequest + { + ShiftId = "shift_id", + LocationId = "location_id", + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListTest.cs b/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListTest.cs new file mode 100644 index 00000000..a6fa96de --- /dev/null +++ b/src/Square.Test/Unit/MockServer/CashDrawers/Shifts/ListTest.cs @@ -0,0 +1,91 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.CashDrawers.Shifts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.CashDrawers.Shifts; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "cash_drawer_shifts": [ + { + "id": "DCC99978-09A6-4926-849F-300BE9C5793A", + "state": "CLOSED", + "opened_at": "2019-11-22T00:42:54.000Z", + "ended_at": "2019-11-22T00:44:49.000Z", + "closed_at": "2019-11-22T00:44:49.000Z", + "description": "Misplaced some change", + "opened_cash_money": { + "amount": 10000, + "currency": "USD" + }, + "expected_cash_money": { + "amount": 10000, + "currency": "USD" + }, + "closed_cash_money": { + "amount": 9970, + "currency": "USD" + }, + "created_at": "created_at", + "updated_at": "updated_at", + "location_id": "location_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/cash-drawers/shifts") + .WithParam("location_id", "location_id") + .WithParam("sort_order", "DESC") + .WithParam("begin_time", "begin_time") + .WithParam("end_time", "end_time") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.CashDrawers.Shifts.ListAsync( + new ListShiftsRequest + { + LocationId = "location_id", + SortOrder = SortOrder.Desc, + BeginTime = "begin_time", + EndTime = "end_time", + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/BatchDeleteTest.cs b/src/Square.Test/Unit/MockServer/Catalog/BatchDeleteTest.cs new file mode 100644 index 00000000..a368f548 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/BatchDeleteTest.cs @@ -0,0 +1,75 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class BatchDeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI", + "AA27W3M2GGTF3H6AVPNB77CK" + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "deleted_object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI", + "AA27W3M2GGTF3H6AVPNB77CK" + ], + "deleted_at": "2016-11-16T22:25:24.878Z" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/batch-delete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.BatchDeleteAsync( + new BatchDeleteCatalogObjectsRequest + { + ObjectIds = new List() + { + "W62UWFY35CWMYGVWK6TWJDNI", + "AA27W3M2GGTF3H6AVPNB77CK", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/BatchGetTest.cs b/src/Square.Test/Unit/MockServer/Catalog/BatchGetTest.cs new file mode 100644 index 00000000..dc4a3d0a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/BatchGetTest.cs @@ -0,0 +1,161 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class BatchGetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI", + "AA27W3M2GGTF3H6AVPNB77CK" + ], + "include_related_objects": true + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + } + ], + "related_objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "ordinal": 1000000, + "type": "CATEGORY" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "TAX" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/batch-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.BatchGetAsync( + new BatchGetCatalogObjectsRequest + { + ObjectIds = new List() + { + "W62UWFY35CWMYGVWK6TWJDNI", + "AA27W3M2GGTF3H6AVPNB77CK", + }, + IncludeRelatedObjects = true, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/BatchUpsertTest.cs b/src/Square.Test/Unit/MockServer/Catalog/BatchUpsertTest.cs new file mode 100644 index 00000000..ab79f0e3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/BatchUpsertTest.cs @@ -0,0 +1,224 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class BatchUpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "789ff020-f723-43a9-b4b5-43b5dc1fa3dc", + "batches": [ + { + "objects": [ + { + "id": "id", + "type": "ITEM" + }, + { + "id": "id", + "type": "ITEM" + }, + { + "id": "id", + "type": "ITEM" + }, + { + "id": "id", + "type": "TAX" + } + ] + } + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "ordinal": 1000000, + "type": "CATEGORY" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "TAX" + } + ], + "updated_at": "updated_at", + "id_mappings": [ + { + "client_object_id": "#Tea", + "object_id": "67GA7XA2FWMRYY2VCONTYZJR" + }, + { + "client_object_id": "#Coffee", + "object_id": "MQ4TZKOG3SR2EQI3TWEK4AH7" + }, + { + "client_object_id": "#Beverages", + "object_id": "XCS4SCGN4WQYE2VU4U3TKXEH" + }, + { + "client_object_id": "#SalesTax", + "object_id": "HP5VNYPKZKTNCKZ2Z5NPUH6A" + }, + { + "client_object_id": "#Tea_Mug", + "object_id": "CAJBHUIQH7ONTSZI2KTVOUP6" + }, + { + "client_object_id": "#Coffee_Regular", + "object_id": "GY2GXJTVVPQAPW43GFRR3NG6" + }, + { + "client_object_id": "#Coffee_Large", + "object_id": "JE6VHPSRQL6IWSN26C36CJ7W" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/batch-upsert") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.BatchUpsertAsync( + new BatchUpsertCatalogObjectsRequest + { + IdempotencyKey = "789ff020-f723-43a9-b4b5-43b5dc1fa3dc", + Batches = new List() + { + new CatalogObjectBatch + { + Objects = new List() + { + new CatalogObject( + new CatalogObject.Item(new CatalogObjectItem { Id = "id" }) + ), + new CatalogObject( + new CatalogObject.Item(new CatalogObjectItem { Id = "id" }) + ), + new CatalogObject( + new CatalogObject.Item(new CatalogObjectItem { Id = "id" }) + ), + new CatalogObject( + new CatalogObject.Tax(new CatalogObjectTax { Id = "id" }) + ), + }, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/InfoTest.cs b/src/Square.Test/Unit/MockServer/Catalog/InfoTest.cs new file mode 100644 index 00000000..ac24e6c4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/InfoTest.cs @@ -0,0 +1,64 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class InfoTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "limits": { + "batch_upsert_max_objects_per_batch": 1000, + "batch_upsert_max_total_objects": 10000, + "batch_retrieve_max_object_ids": 1000, + "search_max_page_limit": 1000, + "batch_delete_max_object_ids": 200, + "update_item_taxes_max_item_ids": 1000, + "update_item_taxes_max_taxes_to_enable": 1000, + "update_item_taxes_max_taxes_to_disable": 1000, + "update_item_modifier_lists_max_item_ids": 1000, + "update_item_modifier_lists_max_modifier_lists_to_enable": 1000, + "update_item_modifier_lists_max_modifier_lists_to_disable": 1000 + }, + "standard_unit_description_group": { + "standard_unit_descriptions": [ + {} + ], + "language_code": "language_code" + } + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/catalog/info").UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.InfoAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/ListTest.cs b/src/Square.Test/Unit/MockServer/Catalog/ListTest.cs new file mode 100644 index 00000000..93d23ebd --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/ListTest.cs @@ -0,0 +1,104 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Catalog; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "cursor": "cursor", + "objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "ordinal": 1000000, + "type": "CATEGORY" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "TAX" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/list") + .WithParam("cursor", "cursor") + .WithParam("types", "types") + .WithParam("catalog_version", "1000000") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Catalog.ListAsync( + new ListCatalogRequest + { + Cursor = "cursor", + Types = "types", + CatalogVersion = 1000000, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/Object/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Catalog/Object/DeleteTest.cs new file mode 100644 index 00000000..0a2bedc7 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/Object/DeleteTest.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog.Object; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog.Object; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "deleted_object_ids": [ + "7SB3ZQYJ5GDMVFL7JK46JCHT", + "KQLFFHA6K6J3YQAQAWDQAL57" + ], + "deleted_at": "2016-11-16T22:25:24.878Z" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/object/object_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.Object.DeleteAsync( + new DeleteObjectRequest { ObjectId = "object_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/Object/GetTest.cs b/src/Square.Test/Unit/MockServer/Catalog/Object/GetTest.cs new file mode 100644 index 00000000..20718b49 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/Object/GetTest.cs @@ -0,0 +1,161 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog.Object; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog.Object; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "object": { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "item_data": { + "name": "name", + "description": "description", + "abbreviation": "abbreviation", + "label_color": "label_color", + "is_taxable": true, + "category_id": "category_id", + "tax_ids": [ + "tax_ids" + ], + "modifier_list_info": [ + { + "modifier_list_id": "modifier_list_id" + } + ], + "product_type": "REGULAR", + "skip_modifier_screen": true, + "item_options": [ + {} + ], + "ecom_uri": "ecom_uri", + "ecom_image_uris": [ + "ecom_image_uris" + ], + "image_ids": [ + "image_ids" + ], + "sort_name": "sort_name", + "description_html": "description_html", + "description_plaintext": "description_plaintext", + "channels": [ + "channels" + ], + "is_archived": true, + "is_alcoholic": true + }, + "type": "ITEM" + }, + "related_objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "ordinal": 1000000, + "type": "CATEGORY" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "TAX" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/object/object_id") + .WithParam("catalog_version", "1000000") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.Object.GetAsync( + new GetObjectRequest + { + ObjectId = "object_id", + IncludeRelatedObjects = true, + CatalogVersion = 1000000, + IncludeCategoryPathToRoot = true, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/Object/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Catalog/Object/UpsertTest.cs new file mode 100644 index 00000000..e5255aaf --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/Object/UpsertTest.cs @@ -0,0 +1,141 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog.Object; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog.Object; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "af3d1afc-7212-4300-b463-0bfc5314a5ae", + "object": { + "id": "id", + "type": "ITEM" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "catalog_object": { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "item_data": { + "name": "name", + "description": "description", + "abbreviation": "abbreviation", + "label_color": "label_color", + "is_taxable": true, + "category_id": "category_id", + "tax_ids": [ + "tax_ids" + ], + "modifier_list_info": [ + { + "modifier_list_id": "modifier_list_id" + } + ], + "product_type": "REGULAR", + "skip_modifier_screen": true, + "item_options": [ + {} + ], + "ecom_uri": "ecom_uri", + "ecom_image_uris": [ + "ecom_image_uris" + ], + "image_ids": [ + "image_ids" + ], + "sort_name": "sort_name", + "description_html": "description_html", + "description_plaintext": "description_plaintext", + "channels": [ + "channels" + ], + "is_archived": true, + "is_alcoholic": true + }, + "type": "ITEM" + }, + "id_mappings": [ + { + "client_object_id": "#Cocoa", + "object_id": "R2TA2FOBUGCJZNIWJSOSNAI4" + }, + { + "client_object_id": "#Small", + "object_id": "QRT53UP4LITLWGOGBZCUWP63" + }, + { + "client_object_id": "#Large", + "object_id": "NS77DKEIQ3AEQTCP727DSA7U" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/object") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.Object.UpsertAsync( + new UpsertCatalogObjectRequest + { + IdempotencyKey = "af3d1afc-7212-4300-b463-0bfc5314a5ae", + Object = new CatalogObject( + new CatalogObject.Item(new CatalogObjectItem { Id = "id" }) + ), + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/SearchItemsTest.cs b/src/Square.Test/Unit/MockServer/Catalog/SearchItemsTest.cs new file mode 100644 index 00000000..12cad91b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/SearchItemsTest.cs @@ -0,0 +1,160 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class SearchItemsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "text_filter": "red", + "category_ids": [ + "WINE_CATEGORY_ID" + ], + "stock_levels": [ + "OUT", + "LOW" + ], + "enabled_location_ids": [ + "ATL_LOCATION_ID" + ], + "limit": 100, + "sort_order": "ASC", + "product_types": [ + "REGULAR" + ], + "custom_attribute_filters": [ + { + "custom_attribute_definition_id": "VEGAN_DEFINITION_ID", + "bool_filter": true + }, + { + "custom_attribute_definition_id": "BRAND_DEFINITION_ID", + "string_filter": "Dark Horse" + }, + { + "key": "VINTAGE", + "number_filter": { + "min": "min", + "max": "max" + } + }, + { + "custom_attribute_definition_id": "VARIETAL_DEFINITION_ID" + } + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "items": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + } + ], + "cursor": "cursor", + "matched_variation_ids": [ + "VBJNPHCOKDFECR6VU25WRJUD" + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/search-catalog-items") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.SearchItemsAsync( + new SearchCatalogItemsRequest + { + TextFilter = "red", + CategoryIds = new List() { "WINE_CATEGORY_ID" }, + StockLevels = new List() + { + SearchCatalogItemsRequestStockLevel.Out, + SearchCatalogItemsRequestStockLevel.Low, + }, + EnabledLocationIds = new List() { "ATL_LOCATION_ID" }, + Limit = 100, + SortOrder = SortOrder.Asc, + ProductTypes = new List() + { + CatalogItemProductType.Regular, + }, + CustomAttributeFilters = new List() + { + new CustomAttributeFilter + { + CustomAttributeDefinitionId = "VEGAN_DEFINITION_ID", + BoolFilter = true, + }, + new CustomAttributeFilter + { + CustomAttributeDefinitionId = "BRAND_DEFINITION_ID", + StringFilter = "Dark Horse", + }, + new CustomAttributeFilter + { + Key = "VINTAGE", + NumberFilter = new Square.Range { Min = "min", Max = "max" }, + }, + new CustomAttributeFilter + { + CustomAttributeDefinitionId = "VARIETAL_DEFINITION_ID", + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/SearchTest.cs b/src/Square.Test/Unit/MockServer/Catalog/SearchTest.cs new file mode 100644 index 00000000..c299d452 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/SearchTest.cs @@ -0,0 +1,150 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "object_types": [ + "ITEM" + ], + "query": { + "prefix_query": { + "attribute_name": "name", + "attribute_prefix": "tea" + } + }, + "limit": 100 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "cursor": "cursor", + "objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + }, + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + } + ], + "related_objects": [ + { + "id": "id", + "updated_at": "updated_at", + "version": 1000000, + "is_deleted": true, + "custom_attribute_values": { + "key": {} + }, + "catalog_v1_ids": [ + {} + ], + "present_at_all_locations": true, + "present_at_location_ids": [ + "present_at_location_ids" + ], + "absent_at_location_ids": [ + "absent_at_location_ids" + ], + "image_id": "image_id", + "type": "ITEM" + } + ], + "latest_time": "latest_time" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.SearchAsync( + new SearchCatalogObjectsRequest + { + ObjectTypes = new List() { CatalogObjectType.Item }, + Query = new CatalogQuery + { + PrefixQuery = new CatalogQueryPrefix + { + AttributeName = "name", + AttributePrefix = "tea", + }, + }, + Limit = 100, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/UpdateItemModifierListsTest.cs b/src/Square.Test/Unit/MockServer/Catalog/UpdateItemModifierListsTest.cs new file mode 100644 index 00000000..f196be92 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/UpdateItemModifierListsTest.cs @@ -0,0 +1,84 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class UpdateItemModifierListsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "item_ids": [ + "H42BRLUJ5KTZTTMPVSLFAACQ", + "2JXOBJIHCWBQ4NZ3RIXQGJA6" + ], + "modifier_lists_to_enable": [ + "H42BRLUJ5KTZTTMPVSLFAACQ", + "2JXOBJIHCWBQ4NZ3RIXQGJA6" + ], + "modifier_lists_to_disable": [ + "7WRC16CJZDVLSNDQ35PP6YAD" + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "updated_at": "2016-11-16T22:25:24.878Z" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/update-item-modifier-lists") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.UpdateItemModifierListsAsync( + new UpdateItemModifierListsRequest + { + ItemIds = new List() + { + "H42BRLUJ5KTZTTMPVSLFAACQ", + "2JXOBJIHCWBQ4NZ3RIXQGJA6", + }, + ModifierListsToEnable = new List() + { + "H42BRLUJ5KTZTTMPVSLFAACQ", + "2JXOBJIHCWBQ4NZ3RIXQGJA6", + }, + ModifierListsToDisable = new List() { "7WRC16CJZDVLSNDQ35PP6YAD" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Catalog/UpdateItemTaxesTest.cs b/src/Square.Test/Unit/MockServer/Catalog/UpdateItemTaxesTest.cs new file mode 100644 index 00000000..34becedd --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Catalog/UpdateItemTaxesTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Catalog; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Catalog; + +[TestFixture] +public class UpdateItemTaxesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "item_ids": [ + "H42BRLUJ5KTZTTMPVSLFAACQ", + "2JXOBJIHCWBQ4NZ3RIXQGJA6" + ], + "taxes_to_enable": [ + "4WRCNHCJZDVLSNDQ35PP6YAD" + ], + "taxes_to_disable": [ + "AQCEGCEBBQONINDOHRGZISEX" + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "updated_at": "2016-11-16T22:25:24.878Z" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/catalog/update-item-taxes") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Catalog.UpdateItemTaxesAsync( + new UpdateItemTaxesRequest + { + ItemIds = new List() + { + "H42BRLUJ5KTZTTMPVSLFAACQ", + "2JXOBJIHCWBQ4NZ3RIXQGJA6", + }, + TaxesToEnable = new List() { "4WRCNHCJZDVLSNDQ35PP6YAD" }, + TaxesToDisable = new List() { "AQCEGCEBBQONINDOHRGZISEX" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Channels/BulkRetrieveTest.cs b/src/Square.Test/Unit/MockServer/Channels/BulkRetrieveTest.cs new file mode 100644 index 00000000..5945c535 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Channels/BulkRetrieveTest.cs @@ -0,0 +1,119 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Channels; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Channels; + +[TestFixture] +public class BulkRetrieveTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "channel_ids": [ + "CH_9C03D0B59", + "CH_6X139B5MN", + "NOT_EXISTING" + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "responses": { + "CH_6X139B5MN": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "channel": { + "id": "CH_6X139B5MN", + "merchant_id": "ML64FACEA", + "name": "Contoso Fulfillment Application", + "version": 1, + "reference": { + "type": "OAUTH_APPLICATION", + "id": "OA_9C03D0444" + }, + "status": "ACTIVE", + "created_at": "2022-10-25T16:27:00.000Z", + "updated_at": "2022-10-25T16:48:00.000Z" + } + }, + "CH_9C03D0B59": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "channel": { + "id": "CH_9C03D0B59", + "merchant_id": "ML64FACEA", + "name": "State Street Store", + "version": 1, + "reference": { + "type": "LOCATION", + "id": "OA_9C03D0B59" + }, + "status": "ACTIVE", + "created_at": "2022-10-25T16:27:00.000Z", + "updated_at": "2022-10-25T16:48:00.000Z" + } + }, + "NOT_EXISTING": { + "errors": [ + { + "category": "API_ERROR", + "code": "NOT_FOUND" + } + ] + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/channels/bulk-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Channels.BulkRetrieveAsync( + new BulkRetrieveChannelsRequest + { + ChannelIds = new List() { "CH_9C03D0B59", "CH_6X139B5MN", "NOT_EXISTING" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Channels/GetTest.cs b/src/Square.Test/Unit/MockServer/Channels/GetTest.cs new file mode 100644 index 00000000..06c3cbd3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Channels/GetTest.cs @@ -0,0 +1,64 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Channels; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Channels; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "channel": { + "id": "CH_9C03D0B59", + "merchant_id": "ML64FACEA", + "name": "Contoso Fulfillment Application", + "version": 1, + "reference": { + "type": "OAUTH_APPLICATION", + "id": "OA_9C03D0444" + }, + "status": "ACTIVE", + "created_at": "2022-10-25T16:27:00.000Z", + "updated_at": "2022-10-25T16:48:00.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/channels/channel_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Channels.GetAsync( + new GetChannelsRequest { ChannelId = "channel_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Channels/ListTest.cs b/src/Square.Test/Unit/MockServer/Channels/ListTest.cs new file mode 100644 index 00000000..11a29025 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Channels/ListTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Channels; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Channels; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "channels": [ + { + "id": "CH_9C03D0B59", + "merchant_id": "ML64FACEA", + "name": "Contoso Fulfillment Application", + "version": 1, + "reference": { + "type": "OAUTH_APPLICATION", + "id": "OA_9C03D0444" + }, + "status": "ACTIVE", + "created_at": "2022-10-25T16:27:00.000Z", + "updated_at": "2022-10-25T16:48:00.000Z" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/channels") + .WithParam("reference_type", "UNKNOWN_TYPE") + .WithParam("reference_id", "reference_id") + .WithParam("status", "ACTIVE") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Channels.ListAsync( + new ListChannelsRequest + { + ReferenceType = ReferenceType.UnknownType, + ReferenceId = "reference_id", + Status = ChannelStatus.Active, + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/CreateTest.cs b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/CreateTest.cs new file mode 100644 index 00000000..64d86f04 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/CreateTest.cs @@ -0,0 +1,211 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout.PaymentLinks; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout.PaymentLinks; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "cd9e25dc-d9f2-4430-aedb-61605070e95f", + "quick_pay": { + "name": "Auto Detailing", + "price_money": { + "amount": 10000, + "currency": "USD" + }, + "location_id": "A9Y43N9ABXZBP" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment_link": { + "id": "PKVT6XGJZXYUP3NZ", + "version": 1, + "description": "description", + "order_id": "o4b7saqp4HzhNttf5AJxC0Srjd4F", + "checkout_options": { + "allow_tipping": true, + "custom_fields": [ + { + "title": "title" + } + ], + "subscription_plan_id": "subscription_plan_id", + "redirect_url": "redirect_url", + "merchant_support_email": "merchant_support_email", + "ask_for_shipping_address": true, + "shipping_fee": { + "charge": {} + }, + "enable_coupon": true, + "enable_loyalty": true + }, + "pre_populated_data": { + "buyer_email": "buyer_email", + "buyer_phone_number": "buyer_phone_number" + }, + "url": "https://square.link/u/EXAMPLE", + "long_url": "https://checkout.square.site/EXAMPLE", + "created_at": "2022-04-25T23:58:01.000Z", + "updated_at": "updated_at", + "payment_note": "payment_note" + }, + "related_resources": { + "orders": [ + { + "id": "o4b7saqp4HzhNttf5AJxC0Srjd4F", + "location_id": "{LOCATION_ID}", + "source": { + "name": "Test Online Checkout Application" + }, + "line_items": [ + { + "uid": "8YX13D1U3jO7czP8JVrAR", + "name": "Auto Detailing", + "quantity": "1", + "item_type": "ITEM", + "base_price_money": { + "amount": 12500, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 12500, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 12500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_money": { + "amount": 12500, + "currency": "USD" + } + } + ], + "fulfillments": [ + { + "uid": "bBpNrxjdQxGQP16sTmdzi", + "type": "PICKUP", + "state": "PROPOSED" + } + ], + "net_amounts": { + "total_money": { + "amount": 12500, + "currency": "USD" + }, + "tax_money": { + "amount": 0, + "currency": "USD" + }, + "discount_money": { + "amount": 0, + "currency": "USD" + }, + "tip_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "created_at": "2022-03-03T00:53:15.829Z", + "updated_at": "2022-03-03T00:53:15.829Z", + "state": "DRAFT", + "version": 1, + "total_money": { + "amount": 12500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_tip_money": { + "amount": 0, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "subscription_plans": [ + { + "id": "id", + "type": "ITEM" + } + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/payment-links") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.PaymentLinks.CreateAsync( + new CreatePaymentLinkRequest + { + IdempotencyKey = "cd9e25dc-d9f2-4430-aedb-61605070e95f", + QuickPay = new QuickPay + { + Name = "Auto Detailing", + PriceMoney = new Money { Amount = 10000, Currency = Currency.Usd }, + LocationId = "A9Y43N9ABXZBP", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/DeleteTest.cs new file mode 100644 index 00000000..85615cca --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/DeleteTest.cs @@ -0,0 +1,54 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout.PaymentLinks; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout.PaymentLinks; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "id": "MQASNYL6QB6DFCJ3", + "cancelled_order_id": "asx8LgZ6MRzD0fObfkJ6obBmSh4F" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/payment-links/id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.PaymentLinks.DeleteAsync( + new DeletePaymentLinksRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/GetTest.cs b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/GetTest.cs new file mode 100644 index 00000000..30596f04 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/GetTest.cs @@ -0,0 +1,83 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout.PaymentLinks; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout.PaymentLinks; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment_link": { + "id": "LLO5Q3FRCFICDB4B", + "version": 1, + "description": "description", + "order_id": "4uKASDATqSd1QQ9jV86sPhMdVEbSJc4F", + "checkout_options": { + "allow_tipping": true, + "custom_fields": [ + { + "title": "title" + } + ], + "subscription_plan_id": "subscription_plan_id", + "redirect_url": "redirect_url", + "merchant_support_email": "merchant_support_email", + "ask_for_shipping_address": true, + "shipping_fee": { + "charge": {} + }, + "enable_coupon": true, + "enable_loyalty": true + }, + "pre_populated_data": { + "buyer_email": "buyer_email", + "buyer_phone_number": "buyer_phone_number" + }, + "url": "https://square.link/u/EXAMPLE", + "long_url": "https://checkout.square.site/EXAMPLE", + "created_at": "2022-04-26T00:10:29.000Z", + "updated_at": "updated_at", + "payment_note": "payment_note" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/payment-links/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.PaymentLinks.GetAsync( + new GetPaymentLinksRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/ListTest.cs b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/ListTest.cs new file mode 100644 index 00000000..90424b40 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/ListTest.cs @@ -0,0 +1,80 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Checkout.PaymentLinks; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout.PaymentLinks; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment_links": [ + { + "id": "TN4BWEDJ9AI5MBIV", + "version": 2, + "description": "description", + "order_id": "Qqc6yppGvxVwc46Cch4zHTaJqc4F", + "checkout_options": { + "ask_for_shipping_address": true + }, + "url": "https://square.link/u/EXAMPLE", + "long_url": "long_url", + "created_at": "2022-04-26T00:15:15.000Z", + "updated_at": "2022-04-26T00:18:24.000Z", + "payment_note": "test" + }, + { + "id": "RY5UNCUMPJN5XKCT", + "version": 1, + "description": "", + "order_id": "EmBmGt3zJD15QeO1dxzBTxMxtwfZY", + "url": "https://square.link/u/EXAMPLE", + "long_url": "long_url", + "created_at": "2022-04-11T23:14:59.000Z", + "updated_at": "updated_at", + "payment_note": "payment_note" + } + ], + "cursor": "MTY1NQ==" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/payment-links") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Checkout.PaymentLinks.ListAsync( + new ListPaymentLinksRequest { Cursor = "cursor", Limit = 1 } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/UpdateTest.cs new file mode 100644 index 00000000..7f390027 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/PaymentLinks/UpdateTest.cs @@ -0,0 +1,105 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout.PaymentLinks; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout.PaymentLinks; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "payment_link": { + "version": 1, + "checkout_options": { + "ask_for_shipping_address": true + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment_link": { + "id": "TY4BWEDJ6AI5MBIV", + "version": 2, + "description": "description", + "order_id": "Qqc8ypQGvxVwc46Cch4zHTaJqc4F", + "checkout_options": { + "allow_tipping": true, + "custom_fields": [ + { + "title": "title" + } + ], + "subscription_plan_id": "subscription_plan_id", + "redirect_url": "redirect_url", + "merchant_support_email": "merchant_support_email", + "ask_for_shipping_address": true, + "shipping_fee": { + "charge": {} + }, + "enable_coupon": true, + "enable_loyalty": true + }, + "pre_populated_data": { + "buyer_email": "buyer_email", + "buyer_phone_number": "buyer_phone_number" + }, + "url": "https://square.link/u/EXAMPLE", + "long_url": "https://checkout.square.site/EXAMPLE", + "created_at": "2022-04-26T00:15:15.000Z", + "updated_at": "2022-04-26T00:18:24.000Z", + "payment_note": "test" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/payment-links/id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.PaymentLinks.UpdateAsync( + new UpdatePaymentLinkRequest + { + Id = "id", + PaymentLink = new PaymentLink + { + Version = 1, + CheckoutOptions = new CheckoutOptions { AskForShippingAddress = true }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/RetrieveLocationSettingsTest.cs b/src/Square.Test/Unit/MockServer/Checkout/RetrieveLocationSettingsTest.cs new file mode 100644 index 00000000..82f180b2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/RetrieveLocationSettingsTest.cs @@ -0,0 +1,84 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout; + +[TestFixture] +public class RetrieveLocationSettingsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "location_settings": { + "location_id": "LOCATION_ID_1", + "customer_notes_enabled": true, + "policies": [ + { + "uid": "POLICY_ID_1", + "title": "Return Policy", + "description": "This is my Return Policy" + } + ], + "branding": { + "header_type": "FRAMED_LOGO", + "button_color": "#ffffff", + "button_shape": "ROUNDED" + }, + "tipping": { + "percentages": [ + 10, + 15, + 20 + ], + "smart_tipping_enabled": true, + "default_percent": 15, + "smart_tips": [ + {} + ] + }, + "coupons": { + "enabled": true + }, + "updated_at": "2022-06-16T22:25:35.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/location-settings/location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.RetrieveLocationSettingsAsync( + new RetrieveLocationSettingsRequest { LocationId = "location_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/RetrieveMerchantSettingsTest.cs b/src/Square.Test/Unit/MockServer/Checkout/RetrieveMerchantSettingsTest.cs new file mode 100644 index 00000000..8a3f8ca1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/RetrieveMerchantSettingsTest.cs @@ -0,0 +1,83 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout; + +[TestFixture] +public class RetrieveMerchantSettingsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "merchant_settings": { + "payment_methods": { + "apple_pay": { + "enabled": true + }, + "google_pay": { + "enabled": true + }, + "afterpay_clearpay": { + "order_eligibility_range": { + "min": { + "amount": 100, + "currency": "USD" + }, + "max": { + "amount": 10000, + "currency": "USD" + } + }, + "item_eligibility_range": { + "min": { + "amount": 100, + "currency": "USD" + }, + "max": { + "amount": 10000, + "currency": "USD" + } + }, + "enabled": true + } + }, + "updated_at": "2022-06-16T22:25:35.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/merchant-settings") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.RetrieveMerchantSettingsAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/UpdateLocationSettingsTest.cs b/src/Square.Test/Unit/MockServer/Checkout/UpdateLocationSettingsTest.cs new file mode 100644 index 00000000..3b7d9be8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/UpdateLocationSettingsTest.cs @@ -0,0 +1,101 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout; + +[TestFixture] +public class UpdateLocationSettingsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "location_settings": {} + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "location_settings": { + "location_id": "LOCATION_ID_1", + "customer_notes_enabled": false, + "policies": [ + { + "uid": "POLICY_ID_1", + "title": "Return Policy", + "description": "This is my Return Policy" + }, + { + "uid": "POLICY_ID_2", + "title": "Return Policy", + "description": "Items may be returned within 30 days of purchase." + } + ], + "branding": { + "header_type": "FRAMED_LOGO", + "button_color": "#00b23b", + "button_shape": "ROUNDED" + }, + "tipping": { + "percentages": [ + 15, + 20, + 25 + ], + "smart_tipping_enabled": true, + "default_percent": 20, + "smart_tips": [ + {} + ] + }, + "coupons": { + "enabled": true + }, + "updated_at": "2022-06-16T22:25:35.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/location-settings/location_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.UpdateLocationSettingsAsync( + new UpdateLocationSettingsRequest + { + LocationId = "location_id", + LocationSettings = new CheckoutLocationSettings(), + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Checkout/UpdateMerchantSettingsTest.cs b/src/Square.Test/Unit/MockServer/Checkout/UpdateMerchantSettingsTest.cs new file mode 100644 index 00000000..b02e0b1b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Checkout/UpdateMerchantSettingsTest.cs @@ -0,0 +1,94 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Checkout; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Checkout; + +[TestFixture] +public class UpdateMerchantSettingsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "merchant_settings": {} + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "merchant_settings": { + "payment_methods": { + "apple_pay": { + "enabled": false + }, + "google_pay": { + "enabled": true + }, + "afterpay_clearpay": { + "order_eligibility_range": { + "min": { + "amount": 100, + "currency": "USD" + }, + "max": { + "amount": 10000, + "currency": "USD" + } + }, + "item_eligibility_range": { + "min": { + "amount": 100, + "currency": "USD" + }, + "max": { + "amount": 10000, + "currency": "USD" + } + }, + "enabled": true + } + }, + "updated_at": "2022-06-16T22:25:35.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/online-checkout/merchant-settings") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Checkout.UpdateMerchantSettingsAsync( + new UpdateMerchantSettingsRequest { MerchantSettings = new CheckoutMerchantSettings() } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/BatchCreateTest.cs b/src/Square.Test/Unit/MockServer/Customers/BatchCreateTest.cs new file mode 100644 index 00000000..1f9ed093 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/BatchCreateTest.cs @@ -0,0 +1,206 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class BatchCreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "customers": { + "8bb76c4f-e35d-4c5b-90de-1194cd9179f0": { + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-555-4240", + "reference_id": "YOUR_REFERENCE_ID", + "note": "a customer" + }, + "d1689f23-b25d-4932-b2f0-aed00f5e2029": { + "given_name": "Marie", + "family_name": "Curie", + "email_address": "Marie.Curie@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 601", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-444-4240", + "reference_id": "YOUR_REFERENCE_ID", + "note": "another customer" + } + } + } + """; + + const string mockResponse = """ + { + "responses": { + "8bb76c4f-e35d-4c5b-90de-1194cd9179f4": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "customer": { + "id": "8DDA5NZVBZFGAX0V3HPF81HHE0", + "created_at": "2024-03-23T20:21:54.859Z", + "updated_at": "2024-03-23T20:21:54.859Z", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-555-4240", + "reference_id": "YOUR_REFERENCE_ID", + "note": "a customer", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "version": 0 + } + }, + "d1689f23-b25d-4932-b2f0-aed00f5e2029": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "customer": { + "id": "N18CPRVXR5214XPBBA6BZQWF3C", + "created_at": "2024-03-23T20:21:54.859Z", + "updated_at": "2024-03-23T20:21:54.859Z", + "given_name": "Marie", + "family_name": "Curie", + "email_address": "Marie.Curie@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 601", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-444-4240", + "reference_id": "YOUR_REFERENCE_ID", + "note": "another customer", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "version": 0 + } + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/bulk-create") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.BatchCreateAsync( + new BulkCreateCustomersRequest + { + Customers = new Dictionary() + { + { + "8bb76c4f-e35d-4c5b-90de-1194cd9179f0", + new BulkCreateCustomerData + { + GivenName = "Amelia", + FamilyName = "Earhart", + EmailAddress = "Amelia.Earhart@example.com", + Address = new Address + { + AddressLine1 = "500 Electric Ave", + AddressLine2 = "Suite 600", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + PhoneNumber = "+1-212-555-4240", + ReferenceId = "YOUR_REFERENCE_ID", + Note = "a customer", + } + }, + { + "d1689f23-b25d-4932-b2f0-aed00f5e2029", + new BulkCreateCustomerData + { + GivenName = "Marie", + FamilyName = "Curie", + EmailAddress = "Marie.Curie@example.com", + Address = new Address + { + AddressLine1 = "500 Electric Ave", + AddressLine2 = "Suite 601", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + PhoneNumber = "+1-212-444-4240", + ReferenceId = "YOUR_REFERENCE_ID", + Note = "another customer", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/BulkDeleteCustomersTest.cs b/src/Square.Test/Unit/MockServer/Customers/BulkDeleteCustomersTest.cs new file mode 100644 index 00000000..0fcf421c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/BulkDeleteCustomersTest.cs @@ -0,0 +1,99 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class BulkDeleteCustomersTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "customer_ids": [ + "8DDA5NZVBZFGAX0V3HPF81HHE0", + "N18CPRVXR5214XPBBA6BZQWF3C", + "2GYD7WNXF7BJZW1PMGNXZ3Y8M8" + ] + } + """; + + const string mockResponse = """ + { + "responses": { + "2GYD7WNXF7BJZW1PMGNXZ3Y8M8": { + "errors": [ + { + "category": "INVALID_REQUEST_ERROR", + "code": "NOT_FOUND", + "detail": "Customer with ID `2GYD7WNXF7BJZW1PMGNXZ3Y8M8` not found." + } + ] + }, + "8DDA5NZVBZFGAX0V3HPF81HHE0": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "N18CPRVXR5214XPBBA6BZQWF3C": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/bulk-delete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.BulkDeleteCustomersAsync( + new BulkDeleteCustomersRequest + { + CustomerIds = new List() + { + "8DDA5NZVBZFGAX0V3HPF81HHE0", + "N18CPRVXR5214XPBBA6BZQWF3C", + "2GYD7WNXF7BJZW1PMGNXZ3Y8M8", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/BulkRetrieveCustomersTest.cs b/src/Square.Test/Unit/MockServer/Customers/BulkRetrieveCustomersTest.cs new file mode 100644 index 00000000..0c1a305c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/BulkRetrieveCustomersTest.cs @@ -0,0 +1,126 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class BulkRetrieveCustomersTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "customer_ids": [ + "8DDA5NZVBZFGAX0V3HPF81HHE0", + "N18CPRVXR5214XPBBA6BZQWF3C", + "2GYD7WNXF7BJZW1PMGNXZ3Y8M8" + ] + } + """; + + const string mockResponse = """ + { + "responses": { + "2GYD7WNXF7BJZW1PMGNXZ3Y8M8": { + "errors": [ + { + "category": "INVALID_REQUEST_ERROR", + "code": "NOT_FOUND", + "detail": "Customer with ID `2GYD7WNXF7BJZW1PMGNXZ3Y8M8` not found." + } + ] + }, + "8DDA5NZVBZFGAX0V3HPF81HHE0": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "customer": { + "id": "8DDA5NZVBZFGAX0V3HPF81HHE0", + "created_at": "2024-01-19T00:27:54.590Z", + "updated_at": "2024-01-19T00:38:06.000Z", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "New.Amelia.Earhart@example.com", + "birthday": "1897-07-24", + "note": "updated customer note", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "version": 3 + } + }, + "N18CPRVXR5214XPBBA6BZQWF3C": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "customer": { + "id": "N18CPRVXR5214XPBBA6BZQWF3C", + "created_at": "2024-01-19T00:27:54.590Z", + "updated_at": "2024-01-19T00:38:06.000Z", + "given_name": "Marie", + "family_name": "Curie", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "version": 1 + } + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/bulk-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.BulkRetrieveCustomersAsync( + new BulkRetrieveCustomersRequest + { + CustomerIds = new List() + { + "8DDA5NZVBZFGAX0V3HPF81HHE0", + "N18CPRVXR5214XPBBA6BZQWF3C", + "2GYD7WNXF7BJZW1PMGNXZ3Y8M8", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/BulkUpdateCustomersTest.cs b/src/Square.Test/Unit/MockServer/Customers/BulkUpdateCustomersTest.cs new file mode 100644 index 00000000..6fdca7a9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/BulkUpdateCustomersTest.cs @@ -0,0 +1,139 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class BulkUpdateCustomersTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "customers": { + "8DDA5NZVBZFGAX0V3HPF81HHE0": { + "email_address": "New.Amelia.Earhart@example.com", + "note": "updated customer note", + "version": 2 + }, + "N18CPRVXR5214XPBBA6BZQWF3C": { + "given_name": "Marie", + "family_name": "Curie", + "version": 0 + } + } + } + """; + + const string mockResponse = """ + { + "responses": { + "8DDA5NZVBZFGAX0V3HPF81HHE0": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "customer": { + "id": "8DDA5NZVBZFGAX0V3HPF81HHE0", + "created_at": "2024-01-19T00:27:54.590Z", + "updated_at": "2024-01-19T00:38:06.000Z", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "New.Amelia.Earhart@example.com", + "birthday": "1897-07-24", + "note": "updated customer note", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "version": 3 + } + }, + "N18CPRVXR5214XPBBA6BZQWF3C": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "customer": { + "id": "N18CPRVXR5214XPBBA6BZQWF3C", + "created_at": "2024-01-19T00:27:54.590Z", + "updated_at": "2024-01-19T00:38:06.000Z", + "given_name": "Marie", + "family_name": "Curie", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "version": 1 + } + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/bulk-update") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.BulkUpdateCustomersAsync( + new BulkUpdateCustomersRequest + { + Customers = new Dictionary() + { + { + "8DDA5NZVBZFGAX0V3HPF81HHE0", + new BulkUpdateCustomerData + { + EmailAddress = "New.Amelia.Earhart@example.com", + Note = "updated customer note", + Version = 2, + } + }, + { + "N18CPRVXR5214XPBBA6BZQWF3C", + new BulkUpdateCustomerData + { + GivenName = "Marie", + FamilyName = "Curie", + Version = 0, + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Cards/CreateTest.cs b/src/Square.Test/Unit/MockServer/Customers/Cards/CreateTest.cs new file mode 100644 index 00000000..7205b636 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Cards/CreateTest.cs @@ -0,0 +1,120 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Cards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Cards; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "card_nonce": "YOUR_CARD_NONCE", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "cardholder_name": "Amelia Earhart" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "card": { + "id": "icard-card_id", + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2018, + "cardholder_name": "Amelia Earhart", + "billing_address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "fingerprint": "fingerprint", + "customer_id": "customer_id", + "merchant_id": "merchant_id", + "reference_id": "reference_id", + "enabled": true, + "card_type": "UNKNOWN_CARD_TYPE", + "prepaid_type": "UNKNOWN_PREPAID_TYPE", + "bin": "bin", + "version": 1000000, + "card_co_brand": "UNKNOWN", + "issuer_alert": "ISSUER_ALERT_CARD_CLOSED", + "issuer_alert_at": "issuer_alert_at", + "hsa_fsa": true + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/cards") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Cards.CreateAsync( + new CreateCustomerCardRequest + { + CustomerId = "customer_id", + CardNonce = "YOUR_CARD_NONCE", + BillingAddress = new Address + { + AddressLine1 = "500 Electric Ave", + AddressLine2 = "Suite 600", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + CardholderName = "Amelia Earhart", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Cards/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Customers/Cards/DeleteTest.cs new file mode 100644 index 00000000..fb67688d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Cards/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Cards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Cards; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/cards/card_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Cards.DeleteAsync( + new DeleteCardsRequest { CustomerId = "customer_id", CardId = "card_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CreateTest.cs b/src/Square.Test/Unit/MockServer/Customers/CreateTest.cs new file mode 100644 index 00000000..a51bc68b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CreateTest.cs @@ -0,0 +1,133 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-555-4240", + "reference_id": "YOUR_REFERENCE_ID", + "note": "a customer" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "customer": { + "id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2016-03-23T20:21:54.859Z", + "updated_at": "2016-03-23T20:21:54.859Z", + "given_name": "Amelia", + "family_name": "Earhart", + "nickname": "nickname", + "company_name": "company_name", + "email_address": "Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "phone_number": "+1-212-555-4240", + "birthday": "birthday", + "reference_id": "YOUR_REFERENCE_ID", + "note": "a customer", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "group_ids": [ + "group_ids" + ], + "segment_ids": [ + "segment_ids" + ], + "version": 0, + "tax_ids": { + "eu_vat": "eu_vat" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CreateAsync( + new CreateCustomerRequest + { + GivenName = "Amelia", + FamilyName = "Earhart", + EmailAddress = "Amelia.Earhart@example.com", + Address = new Address + { + AddressLine1 = "500 Electric Ave", + AddressLine2 = "Suite 600", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + PhoneNumber = "+1-212-555-4240", + ReferenceId = "YOUR_REFERENCE_ID", + Note = "a customer", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/BatchUpsertTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/BatchUpsertTest.cs new file mode 100644 index 00000000..c1a46704 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/BatchUpsertTest.cs @@ -0,0 +1,253 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributeDefinitions; + +[TestFixture] +public class BatchUpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "id1": { + "customer_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "custom_attribute": { + "key": "favoritemovie", + "value": "Dune" + } + }, + "id2": { + "customer_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "custom_attribute": { + "key": "ownsmovie", + "value": false + } + }, + "id3": { + "customer_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "custom_attribute": { + "key": "favoritemovie", + "value": "Star Wars" + } + }, + "id4": { + "customer_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "custom_attribute": { + "key": "square:a0f1505a-2aa1-490d-91a8-8d31ff181808", + "value": "10.5" + } + }, + "id5": { + "customer_id": "70548QG1HN43B05G0KCZ4MMC1G", + "custom_attribute": { + "key": "sq0ids-0evKIskIGaY45fCyNL66aw:backupemail", + "value": "fake-email@squareup.com" + } + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "customer_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "custom_attribute": { + "key": "favoritemovie", + "value": "Dune", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2021-12-09T00:16:23.000Z", + "created_at": "2021-12-08T23:14:47.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "customer_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "custom_attribute": { + "key": "ownsmovie", + "value": false, + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2021-12-09T00:16:23.000Z", + "created_at": "2021-12-09T00:16:20.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id3": { + "customer_id": "SY8EMWRNDN3TQDP2H4KS1QWMMM", + "custom_attribute": { + "key": "favoritemovie", + "value": "Star Wars", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2021-12-09T00:16:23.000Z", + "created_at": "2021-12-09T00:16:20.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id4": { + "customer_id": "N3NCVYY3WS27HF0HKANA3R9FP8", + "custom_attribute": { + "key": "square:a0f1505a-2aa1-490d-91a8-8d31ff181808", + "value": "10.5", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2021-12-09T00:16:23.000Z", + "created_at": "2021-12-08T23:14:47.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id5": { + "customer_id": "70548QG1HN43B05G0KCZ4MMC1G", + "custom_attribute": { + "key": "sq0ids-0evKIskIGaY45fCyNL66aw:backupemail", + "value": "fake-email@squareup.com", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2021-12-09T00:16:23.000Z", + "created_at": "2021-12-09T00:16:20.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/custom-attributes/bulk-upsert") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributeDefinitions.BatchUpsertAsync( + new BatchUpsertCustomerCustomAttributesRequest + { + Values = new Dictionary< + string, + BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + >() + { + { + "id1", + new BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + { + CustomerId = "N3NCVYY3WS27HF0HKANA3R9FP8", + CustomAttribute = new CustomAttribute + { + Key = "favoritemovie", + Value = "Dune", + }, + } + }, + { + "id2", + new BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + { + CustomerId = "SY8EMWRNDN3TQDP2H4KS1QWMMM", + CustomAttribute = new CustomAttribute + { + Key = "ownsmovie", + Value = false, + }, + } + }, + { + "id3", + new BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + { + CustomerId = "SY8EMWRNDN3TQDP2H4KS1QWMMM", + CustomAttribute = new CustomAttribute + { + Key = "favoritemovie", + Value = "Star Wars", + }, + } + }, + { + "id4", + new BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + { + CustomerId = "N3NCVYY3WS27HF0HKANA3R9FP8", + CustomAttribute = new CustomAttribute + { + Key = "square:a0f1505a-2aa1-490d-91a8-8d31ff181808", + Value = "10.5", + }, + } + }, + { + "id5", + new BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + { + CustomerId = "70548QG1HN43B05G0KCZ4MMC1G", + CustomAttribute = new CustomAttribute + { + Key = "sq0ids-0evKIskIGaY45fCyNL66aw:backupemail", + Value = "fake-email@squareup.com", + }, + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/CreateTest.cs new file mode 100644 index 00000000..bf0fa62b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/CreateTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributeDefinitions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "key": "favoritemovie", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite Movie", + "description": "The favorite movie of the customer.", + "visibility": "VISIBILITY_HIDDEN" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "favoritemovie", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite Movie", + "description": "The favorite movie of the customer.", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "2022-04-26T15:27:30.000Z", + "created_at": "2022-04-26T15:27:30.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/custom-attribute-definitions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributeDefinitions.CreateAsync( + new CreateCustomerCustomAttributeDefinitionRequest + { + CustomAttributeDefinition = new CustomAttributeDefinition + { + Key = "favoritemovie", + Schema = new Dictionary() + { + { + "$ref", + "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + }, + Name = "Favorite Movie", + Description = "The favorite movie of the customer.", + Visibility = CustomAttributeDefinitionVisibility.VisibilityHidden, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/DeleteTest.cs new file mode 100644 index 00000000..6e3303a4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/DeleteTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributeDefinitions; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/custom-attribute-definitions/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributeDefinitions.DeleteAsync( + new Square.Customers.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/GetTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/GetTest.cs new file mode 100644 index 00000000..ad42e417 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/GetTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributeDefinitions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "favoritemovie", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite Movie", + "description": "The favorite movie of the customer.", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-04-26T15:27:30.000Z", + "created_at": "2022-04-26T15:27:30.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/custom-attribute-definitions/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributeDefinitions.GetAsync( + new Square.Customers.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/ListTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/ListTest.cs new file mode 100644 index 00000000..bfa76c3e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/ListTest.cs @@ -0,0 +1,82 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributeDefinitions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definitions": [ + { + "key": "favoritemovie", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite Movie", + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 3, + "updated_at": "2022-04-26T15:39:38.000Z", + "created_at": "2022-04-26T15:27:30.000Z" + }, + { + "key": "ownsmovie", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Boolean" + }, + "name": "Owns Movie", + "description": "Customer owns movie.", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "2022-04-26T15:49:05.000Z", + "created_at": "2022-04-26T15:49:05.000Z" + } + ], + "cursor": "YEk4UPbUEsu8MUV0xouO5hCiFcD9T5ztB6UWEJq5vZnqBFmoBEi0j1j6HWYTFGMRre4p7T5wAQBj3Th1NX3XgBFcQVEVsIxUQ2NsbwjRitfoEZDml9uxxQXepowyRvCuSThHPbJSn7M7wInl3x8XypQF9ahVVQXegJ0CxEKc0SBH", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/custom-attribute-definitions") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Customers.CustomAttributeDefinitions.ListAsync( + new Square.Customers.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/UpdateTest.cs new file mode 100644 index 00000000..f3bb2358 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributeDefinitions/UpdateTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributeDefinitions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "favoritemovie", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Favorite Movie", + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 2, + "updated_at": "2022-04-26T15:39:38.000Z", + "created_at": "2022-04-26T15:27:30.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/custom-attribute-definitions/key") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributeDefinitions.UpdateAsync( + new UpdateCustomerCustomAttributeDefinitionRequest + { + Key = "key", + CustomAttributeDefinition = new CustomAttributeDefinition + { + Description = "Update the description as desired.", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadOnly, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/DeleteTest.cs new file mode 100644 index 00000000..e6bec06b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/DeleteTest.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributes; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/custom-attributes/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributes.DeleteAsync( + new Square.Customers.CustomAttributes.DeleteCustomAttributesRequest + { + CustomerId = "customer_id", + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/GetTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/GetTest.cs new file mode 100644 index 00000000..6e95af06 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/GetTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute": { + "key": "favoritemovie", + "value": "Dune", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2022-04-26T15:50:27.000Z", + "created_at": "2022-04-26T15:50:27.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/custom-attributes/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributes.GetAsync( + new Square.Customers.CustomAttributes.GetCustomAttributesRequest + { + CustomerId = "customer_id", + Key = "key", + WithDefinition = true, + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/ListTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/ListTest.cs new file mode 100644 index 00000000..ade2741c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/ListTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attributes": [ + { + "key": "favoritemovie", + "value": "Dune", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "updated_at": "2022-04-26T15:50:27.000Z", + "created_at": "2022-04-26T15:50:27.000Z" + }, + { + "key": "ownsmovie", + "value": false, + "version": 1, + "visibility": "VISIBILITY_HIDDEN", + "updated_at": "2022-04-26T15:51:53.000Z", + "created_at": "2022-04-26T15:51:53.000Z" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/custom-attributes") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Customers.CustomAttributes.ListAsync( + new Square.Customers.CustomAttributes.ListCustomAttributesRequest + { + CustomerId = "customer_id", + Limit = 1, + Cursor = "cursor", + WithDefinitions = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/UpsertTest.cs new file mode 100644 index 00000000..458ebcc8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/CustomAttributes/UpsertTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.CustomAttributes; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute": { + "value": "Dune" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute": { + "key": "favoritemovie", + "value": "Dune", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2022-04-26T15:50:27.000Z", + "created_at": "2022-04-26T15:50:27.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/custom-attributes/key") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.CustomAttributes.UpsertAsync( + new UpsertCustomerCustomAttributeRequest + { + CustomerId = "customer_id", + Key = "key", + CustomAttribute = new CustomAttribute { Value = "Dune" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Customers/DeleteTest.cs new file mode 100644 index 00000000..69e51d87 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id") + .WithParam("version", "1000000") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.DeleteAsync( + new DeleteCustomersRequest { CustomerId = "customer_id", Version = 1000000 } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/GetTest.cs b/src/Square.Test/Unit/MockServer/Customers/GetTest.cs new file mode 100644 index 00000000..aaf5993d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/GetTest.cs @@ -0,0 +1,95 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "customer": { + "id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2016-03-23T20:21:54.859Z", + "updated_at": "2016-03-23T20:21:54.859Z", + "given_name": "Amelia", + "family_name": "Earhart", + "nickname": "nickname", + "company_name": "company_name", + "email_address": "Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "phone_number": "+1-212-555-4240", + "birthday": "birthday", + "reference_id": "YOUR_REFERENCE_ID", + "note": "a customer", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "group_ids": [ + "545AXB44B4XXWMVQ4W8SBT3HHF" + ], + "segment_ids": [ + "1KB9JE5EGJXCW.REACHABLE" + ], + "version": 1, + "tax_ids": { + "eu_vat": "eu_vat" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.GetAsync( + new GetCustomersRequest { CustomerId = "customer_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/AddTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/AddTest.cs new file mode 100644 index 00000000..b4911590 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/AddTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class AddTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/groups/group_id") + .UsingPut() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Groups.AddAsync( + new AddGroupsRequest { CustomerId = "customer_id", GroupId = "group_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/CreateTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/CreateTest.cs new file mode 100644 index 00000000..1e91ea54 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/CreateTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "group": { + "name": "Loyal Customers" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "group": { + "id": "2TAT3CMH4Q0A9M87XJZED0WMR3", + "name": "Loyal Customers", + "created_at": "2020-04-13T21:54:57.863Z", + "updated_at": "2020-04-13T21:54:58.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/groups") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Groups.CreateAsync( + new CreateCustomerGroupRequest + { + Group = new CustomerGroup { Name = "Loyal Customers" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/DeleteTest.cs new file mode 100644 index 00000000..9bc7bdc8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/groups/group_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Groups.DeleteAsync( + new DeleteGroupsRequest { GroupId = "group_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/GetTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/GetTest.cs new file mode 100644 index 00000000..21fb6e0c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/GetTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "group": { + "id": "2TAT3CMH4Q0A9M87XJZED0WMR3", + "name": "Loyal Customers", + "created_at": "2020-04-13T21:54:57.863Z", + "updated_at": "2020-04-13T21:54:58.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/groups/group_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Groups.GetAsync( + new GetGroupsRequest { GroupId = "group_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/ListTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/ListTest.cs new file mode 100644 index 00000000..a60790df --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/ListTest.cs @@ -0,0 +1,67 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "groups": [ + { + "id": "2TAT3CMH4Q0A9M87XJZED0WMR3", + "name": "Loyal Customers", + "created_at": "2020-04-13T21:54:57.863Z", + "updated_at": "2020-04-13T21:54:58.000Z" + }, + { + "id": "4XMEHESXJBNE9S9JAKZD2FGB14", + "name": "Super Loyal Customers", + "created_at": "2020-04-13T21:55:18.795Z", + "updated_at": "2020-04-13T21:55:19.000Z" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/groups") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Customers.Groups.ListAsync( + new ListGroupsRequest { Cursor = "cursor", Limit = 1 } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/RemoveTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/RemoveTest.cs new file mode 100644 index 00000000..27b81363 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/RemoveTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class RemoveTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id/groups/group_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Groups.RemoveAsync( + new RemoveGroupsRequest { CustomerId = "customer_id", GroupId = "group_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Groups/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Customers/Groups/UpdateTest.cs new file mode 100644 index 00000000..7d27c71a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Groups/UpdateTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Groups; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Groups; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "group": { + "name": "Loyal Customers" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "group": { + "id": "2TAT3CMH4Q0A9M87XJZED0WMR3", + "name": "Loyal Customers", + "created_at": "2020-04-13T21:54:57.863Z", + "updated_at": "2020-04-13T21:54:58.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/groups/group_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Groups.UpdateAsync( + new UpdateCustomerGroupRequest + { + GroupId = "group_id", + Group = new CustomerGroup { Name = "Loyal Customers" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/ListTest.cs b/src/Square.Test/Unit/MockServer/Customers/ListTest.cs new file mode 100644 index 00000000..b712fb08 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/ListTest.cs @@ -0,0 +1,99 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "customers": [ + { + "id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2016-03-23T20:21:54.859Z", + "updated_at": "2016-03-23T20:21:55.000Z", + "given_name": "Amelia", + "family_name": "Earhart", + "nickname": "nickname", + "company_name": "company_name", + "email_address": "Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-555-4240", + "birthday": "birthday", + "reference_id": "YOUR_REFERENCE_ID", + "note": "a customer", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "group_ids": [ + "545AXB44B4XXWMVQ4W8SBT3HHF" + ], + "segment_ids": [ + "1KB9JE5EGJXCW.REACHABLE" + ], + "version": 1 + } + ], + "cursor": "cursor", + "count": 1000000 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .WithParam("sort_field", "DEFAULT") + .WithParam("sort_order", "DESC") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Customers.ListAsync( + new ListCustomersRequest + { + Cursor = "cursor", + Limit = 1, + SortField = CustomerSortField.Default, + SortOrder = SortOrder.Desc, + Count = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/SearchTest.cs b/src/Square.Test/Unit/MockServer/Customers/SearchTest.cs new file mode 100644 index 00000000..8d118058 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/SearchTest.cs @@ -0,0 +1,187 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "limit": 2, + "query": { + "filter": { + "creation_source": { + "values": [ + "THIRD_PARTY" + ], + "rule": "INCLUDE" + }, + "created_at": { + "start_at": "2018-01-01T00:00:00.000Z", + "end_at": "2018-02-01T00:00:00.000Z" + }, + "email_address": { + "fuzzy": "example.com" + }, + "group_ids": { + "all": [ + "545AXB44B4XXWMVQ4W8SBT3HHF" + ] + } + }, + "sort": { + "field": "CREATED_AT", + "order": "ASC" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "customers": [ + { + "id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2018-01-23T20:21:54.859Z", + "updated_at": "2020-04-20T10:02:43.083Z", + "given_name": "James", + "family_name": "Bond", + "nickname": "nickname", + "company_name": "company_name", + "email_address": "james.bond@example.com", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-555-4250", + "birthday": "birthday", + "reference_id": "YOUR_REFERENCE_ID_2", + "note": "note", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "DIRECTORY", + "group_ids": [ + "545AXB44B4XXWMVQ4W8SBT3HHF" + ], + "segment_ids": [ + "1KB9JE5EGJXCW.REACHABLE" + ], + "version": 7 + }, + { + "id": "A9641GZW2H7Z56YYSD41Q12HDW", + "created_at": "2018-01-30T14:10:54.859Z", + "updated_at": "2018-03-08T18:25:21.342Z", + "given_name": "Amelia", + "family_name": "Earhart", + "nickname": "nickname", + "company_name": "company_name", + "email_address": "amelia.earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "phone_number": "+1-212-555-9238", + "birthday": "birthday", + "reference_id": "YOUR_REFERENCE_ID_1", + "note": "a customer", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "group_ids": [ + "545AXB44B4XXWMVQ4W8SBT3HHF" + ], + "segment_ids": [ + "1KB9JE5EGJXCW.REACHABLE" + ], + "version": 1 + } + ], + "cursor": "9dpS093Uy12AzeE", + "count": 1000000 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.SearchAsync( + new SearchCustomersRequest + { + Limit = 2, + Query = new CustomerQuery + { + Filter = new CustomerFilter + { + CreationSource = new CustomerCreationSourceFilter + { + Values = new List() + { + CustomerCreationSource.ThirdParty, + }, + Rule = CustomerInclusionExclusion.Include, + }, + CreatedAt = new TimeRange + { + StartAt = "2018-01-01T00:00:00-00:00", + EndAt = "2018-02-01T00:00:00-00:00", + }, + EmailAddress = new CustomerTextFilter { Fuzzy = "example.com" }, + GroupIds = new FilterValue + { + All = new List() { "545AXB44B4XXWMVQ4W8SBT3HHF" }, + }, + }, + Sort = new CustomerSort + { + Field = CustomerSortField.CreatedAt, + Order = SortOrder.Asc, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Segments/GetTest.cs b/src/Square.Test/Unit/MockServer/Customers/Segments/GetTest.cs new file mode 100644 index 00000000..839adf38 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Segments/GetTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers.Segments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Segments; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "segment": { + "id": "GMNXRZVEXNQDF.CHURN_RISK", + "name": "Lapsed", + "created_at": "2020-01-09T19:33:24.469Z", + "updated_at": "2020-04-13T23:01:13.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/segments/segment_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.Segments.GetAsync( + new GetSegmentsRequest { SegmentId = "segment_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/Segments/ListTest.cs b/src/Square.Test/Unit/MockServer/Customers/Segments/ListTest.cs new file mode 100644 index 00000000..f59037a9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/Segments/ListTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Customers.Segments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers.Segments; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "segments": [ + { + "id": "GMNXRZVEXNQDF.CHURN_RISK", + "name": "Lapsed", + "created_at": "2020-01-09T19:33:24.469Z", + "updated_at": "2020-04-13T21:47:04.000Z" + }, + { + "id": "GMNXRZVEXNQDF.LOYAL", + "name": "Regulars", + "created_at": "2020-01-09T19:33:24.486Z", + "updated_at": "2020-04-13T21:47:04.000Z" + }, + { + "id": "GMNXRZVEXNQDF.REACHABLE", + "name": "Reachable", + "created_at": "2020-01-09T19:33:21.813Z", + "updated_at": "2020-04-13T21:47:04.000Z" + }, + { + "id": "gv2:KF92J19VXN5FK30GX2E8HSGQ20", + "name": "Instant Profile", + "created_at": "2020-01-09T19:33:25.000Z", + "updated_at": "2020-04-13T23:01:03.000Z" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/segments") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Customers.Segments.ListAsync( + new ListSegmentsRequest { Cursor = "cursor", Limit = 1 } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Customers/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Customers/UpdateTest.cs new file mode 100644 index 00000000..c7a85f1a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Customers/UpdateTest.cs @@ -0,0 +1,111 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Customers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Customers; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "email_address": "New.Amelia.Earhart@example.com", + "note": "updated customer note", + "version": 2 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "customer": { + "id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2016-03-23T20:21:54.859Z", + "updated_at": "2016-05-15T20:21:55.000Z", + "given_name": "Amelia", + "family_name": "Earhart", + "nickname": "nickname", + "company_name": "company_name", + "email_address": "New.Amelia.Earhart@example.com", + "address": { + "address_line_1": "500 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "phone_number": "phone_number", + "birthday": "birthday", + "reference_id": "YOUR_REFERENCE_ID", + "note": "updated customer note", + "preferences": { + "email_unsubscribed": false + }, + "creation_source": "THIRD_PARTY", + "group_ids": [ + "group_ids" + ], + "segment_ids": [ + "segment_ids" + ], + "version": 3, + "tax_ids": { + "eu_vat": "eu_vat" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/customers/customer_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Customers.UpdateAsync( + new UpdateCustomerRequest + { + CustomerId = "customer_id", + EmailAddress = "New.Amelia.Earhart@example.com", + Note = "updated customer note", + Version = 2, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Devices/Codes/CreateTest.cs b/src/Square.Test/Unit/MockServer/Devices/Codes/CreateTest.cs new file mode 100644 index 00000000..7ffd6750 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Devices/Codes/CreateTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Devices.Codes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Devices.Codes; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "01bb00a6-0c86-4770-94ed-f5fca973cd56", + "device_code": { + "name": "Counter 1", + "product_type": "TERMINAL_API", + "location_id": "B5E4484SHHNYH" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "device_code": { + "id": "B3Z6NAMYQSMTM", + "name": "Counter 1", + "code": "EBCARJ", + "device_id": "device_id", + "product_type": "TERMINAL_API", + "location_id": "B5E4484SHHNYH", + "status": "UNPAIRED", + "pair_by": "2020-02-06T18:49:33.000Z", + "created_at": "2020-02-06T18:44:33.000Z", + "status_changed_at": "2020-02-06T18:44:33.000Z", + "paired_at": "paired_at" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/devices/codes") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Devices.Codes.CreateAsync( + new CreateDeviceCodeRequest + { + IdempotencyKey = "01bb00a6-0c86-4770-94ed-f5fca973cd56", + DeviceCode = new DeviceCode + { + Name = "Counter 1", + ProductType = "TERMINAL_API", + LocationId = "B5E4484SHHNYH", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Devices/Codes/GetTest.cs b/src/Square.Test/Unit/MockServer/Devices/Codes/GetTest.cs new file mode 100644 index 00000000..911fe85e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Devices/Codes/GetTest.cs @@ -0,0 +1,62 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Devices.Codes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Devices.Codes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "device_code": { + "id": "B3Z6NAMYQSMTM", + "name": "Counter 1", + "code": "EBCARJ", + "device_id": "907CS13101300122", + "product_type": "TERMINAL_API", + "location_id": "B5E4484SHHNYH", + "status": "PAIRED", + "pair_by": "2020-02-06T18:49:33.000Z", + "created_at": "2020-02-06T18:44:33.000Z", + "status_changed_at": "2020-02-06T18:47:28.000Z", + "paired_at": "paired_at" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/devices/codes/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Devices.Codes.GetAsync(new GetCodesRequest { Id = "id" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Devices/Codes/ListTest.cs b/src/Square.Test/Unit/MockServer/Devices/Codes/ListTest.cs new file mode 100644 index 00000000..a167d58f --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Devices/Codes/ListTest.cs @@ -0,0 +1,90 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Devices.Codes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Devices.Codes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "device_codes": [ + { + "id": "B3Z6NAMYQSMTM", + "name": "Counter 1", + "code": "EBCARJ", + "device_id": "907CS13101300122", + "product_type": "TERMINAL_API", + "location_id": "B5E4484SHHNYH", + "status": "PAIRED", + "pair_by": "2020-02-06T18:49:33.000Z", + "created_at": "2020-02-06T18:44:33.000Z", + "status_changed_at": "2020-02-06T18:47:28.000Z", + "paired_at": "paired_at" + }, + { + "id": "YKGMJMYK8H4PQ", + "name": "Unused device code", + "code": "GVXNYN", + "device_id": "device_id", + "product_type": "TERMINAL_API", + "location_id": "A6SYFRSV4WAFW", + "status": "UNPAIRED", + "pair_by": "2020-02-07T20:00:04.000Z", + "created_at": "2020-02-07T19:55:04.000Z", + "status_changed_at": "2020-02-07T19:55:04.000Z", + "paired_at": "paired_at" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/devices/codes") + .WithParam("cursor", "cursor") + .WithParam("location_id", "location_id") + .WithParam("product_type", "TERMINAL_API") + .WithParam("status", "UNKNOWN") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Devices.Codes.ListAsync( + new ListCodesRequest + { + Cursor = "cursor", + LocationId = "location_id", + ProductType = "TERMINAL_API", + Status = DeviceCodeStatus.Unknown, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Devices/GetTest.cs b/src/Square.Test/Unit/MockServer/Devices/GetTest.cs new file mode 100644 index 00000000..de5a1c6a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Devices/GetTest.cs @@ -0,0 +1,108 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Devices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Devices; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "device": { + "id": "device:995CS397A6475287", + "attributes": { + "type": "TERMINAL", + "manufacturer": "Square", + "model": "T2", + "name": "0995-01-01T00:00:00.000Z", + "manufacturers_id": "995CS397A6475287", + "updated_at": "2023-09-29T13:12:22.365Z", + "version": "5.41.0085", + "merchant_token": "MLCHXZCBWFGDW" + }, + "components": [ + { + "type": "APPLICATION", + "application_details": { + "application_type": "TERMINAL_API", + "version": "6.25", + "session_location": "LMN2K7S3RTOU3" + } + }, + { + "type": "CARD_READER", + "card_reader_details": { + "version": "3.53.70" + } + }, + { + "type": "BATTERY", + "battery_details": { + "visible_percent": 5, + "external_power": "AVAILABLE_CHARGING" + } + }, + { + "type": "WIFI", + "wifi_details": { + "active": true, + "ssid": "Staff Network", + "ip_address_v4": "10.0.0.7", + "secure_connection": "WPA/WPA2 PSK", + "signal_strength": { + "value": 2 + } + } + }, + { + "type": "ETHERNET", + "ethernet_details": { + "active": false + } + } + ], + "status": { + "category": "AVAILABLE" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/devices/device_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Devices.GetAsync( + new GetDevicesRequest { DeviceId = "device_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Devices/ListTest.cs b/src/Square.Test/Unit/MockServer/Devices/ListTest.cs new file mode 100644 index 00000000..fa8cc09d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Devices/ListTest.cs @@ -0,0 +1,178 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Devices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Devices; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "devices": [ + { + "id": "device:995CS397A6475287", + "attributes": { + "type": "TERMINAL", + "manufacturer": "Square", + "model": "Square Terminal (1st Gen, v2)", + "name": "5287-01-01T00:00:00.000Z", + "manufacturers_id": "995CS397A6475287", + "updated_at": "2025-08-19T13:04:56.335Z", + "version": "5.57.0067", + "merchant_token": "MLCHNZCBWFDZB" + }, + "components": [ + { + "type": "APPLICATION", + "application_details": { + "application_type": "TERMINAL_API", + "version": "6.77", + "session_location": "LMN2K7S3RTOU3" + } + }, + { + "type": "CARD_READER", + "card_reader_details": { + "version": "4.1.51" + } + }, + { + "type": "BATTERY", + "battery_details": { + "visible_percent": 77, + "external_power": "AVAILABLE_CHARGING" + } + }, + { + "type": "WIFI", + "wifi_details": { + "active": true, + "ssid": "Staff Network", + "ip_address_v4": "10.0.0.7", + "secure_connection": "WPA/WPA2 PSK", + "signal_strength": { + "value": 2 + } + } + }, + { + "type": "ETHERNET", + "ethernet_details": { + "active": false + } + } + ], + "status": { + "category": "AVAILABLE" + } + }, + { + "id": "device:998WS21803L03559", + "attributes": { + "type": "HANDHELD", + "manufacturer": "Square", + "model": "Square Handheld (1st Gen, v1)", + "name": "3559-01-01T00:00:00.000Z", + "manufacturers_id": "998WS21803L03559", + "updated_at": "2025-08-19T12:39:56.335Z", + "version": "7.21.0017", + "merchant_token": "MLCHXZCBWFGDW" + }, + "components": [ + { + "type": "APPLICATION", + "application_details": { + "application_type": "TERMINAL_API", + "version": "6.77", + "session_location": "LMN2K7S3RTOU3" + } + }, + { + "type": "CARD_READER", + "card_reader_details": { + "version": "4.5.58" + } + }, + { + "type": "BATTERY", + "battery_details": { + "visible_percent": 22, + "external_power": "AVAILABLE_CHARGING" + } + }, + { + "type": "WIFI", + "wifi_details": { + "active": true, + "ssid": "Staff Network", + "ip_address_v4": "10.0.0.7", + "secure_connection": "WPA/WPA2 PSK", + "signal_strength": { + "value": 2 + } + } + }, + { + "type": "ETHERNET", + "ethernet_details": { + "active": false + } + } + ], + "status": { + "category": "NEEDS_ATTENTION" + } + } + ], + "cursor": "GcXjlV2iaizH7R0fMT6wUDbw6l4otigjzx8XOOspUKHo9EPLRByM" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/devices") + .WithParam("cursor", "cursor") + .WithParam("sort_order", "DESC") + .WithParam("limit", "1") + .WithParam("location_id", "location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Devices.ListAsync( + new ListDevicesRequest + { + Cursor = "cursor", + SortOrder = SortOrder.Desc, + Limit = 1, + LocationId = "location_id", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/AcceptTest.cs b/src/Square.Test/Unit/MockServer/Disputes/AcceptTest.cs new file mode 100644 index 00000000..a5c35be5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/AcceptTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Disputes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes; + +[TestFixture] +public class AcceptTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "dispute": { + "dispute_id": "dispute_id", + "id": "XDgyFu7yo1E2S5lQGGpYn", + "amount_money": { + "amount": 2500, + "currency": "USD" + }, + "reason": "NO_KNOWLEDGE", + "state": "ACCEPTED", + "due_at": "2022-07-13T00:00:00.000Z", + "disputed_payment": { + "payment_id": "zhyh1ch64kRBrrlfVhwjCEjZWzNZY" + }, + "evidence_ids": [ + "evidence_ids" + ], + "card_brand": "VISA", + "created_at": "2022-06-29T18:45:22.265Z", + "updated_at": "2022-07-07T19:14:42.650Z", + "brand_dispute_id": "100000809947", + "reported_date": "reported_date", + "reported_at": "2022-06-29T00:00:00.000Z", + "version": 2, + "location_id": "L1HN3ZMQK64X9" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id/accept") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Disputes.AcceptAsync( + new AcceptDisputesRequest { DisputeId = "dispute_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/CreateEvidenceTextTest.cs b/src/Square.Test/Unit/MockServer/Disputes/CreateEvidenceTextTest.cs new file mode 100644 index 00000000..7fb73648 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/CreateEvidenceTextTest.cs @@ -0,0 +1,80 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Disputes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes; + +[TestFixture] +public class CreateEvidenceTextTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "ed3ee3933d946f1514d505d173c82648", + "evidence_type": "TRACKING_NUMBER", + "evidence_text": "1Z8888888888888888" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "evidence": { + "evidence_id": "evidence_id", + "id": "TOomLInj6iWmP3N8qfCXrB", + "dispute_id": "bVTprrwk0gygTLZ96VX1oB", + "evidence_file": { + "filename": "filename", + "filetype": "filetype" + }, + "evidence_text": "The customer purchased the item twice, on April 11 and April 28.", + "uploaded_at": "2022-05-18T16:01:10.000Z", + "evidence_type": "REBUTTAL_EXPLANATION" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id/evidence-text") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Disputes.CreateEvidenceTextAsync( + new CreateDisputeEvidenceTextRequest + { + DisputeId = "dispute_id", + IdempotencyKey = "ed3ee3933d946f1514d505d173c82648", + EvidenceType = DisputeEvidenceType.TrackingNumber, + EvidenceText = "1Z8888888888888888", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/Evidence/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Disputes/Evidence/DeleteTest.cs new file mode 100644 index 00000000..edd6739a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/Evidence/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Disputes.Evidence; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes.Evidence; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id/evidence/evidence_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Disputes.Evidence.DeleteAsync( + new DeleteEvidenceRequest { DisputeId = "dispute_id", EvidenceId = "evidence_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/Evidence/GetTest.cs b/src/Square.Test/Unit/MockServer/Disputes/Evidence/GetTest.cs new file mode 100644 index 00000000..c9c64de0 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/Evidence/GetTest.cs @@ -0,0 +1,64 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Disputes.Evidence; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes.Evidence; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "evidence": { + "evidence_id": "evidence_id", + "id": "TOomLInj6iWmP3N8qfCXrB", + "dispute_id": "bVTprrwk0gygTLZ96VX1oB", + "evidence_file": { + "filename": "customer-interaction.jpg", + "filetype": "image/jpeg" + }, + "evidence_text": "evidence_text", + "uploaded_at": "2022-05-18T16:01:10.000Z", + "evidence_type": "CARDHOLDER_COMMUNICATION" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id/evidence/evidence_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Disputes.Evidence.GetAsync( + new GetEvidenceRequest { DisputeId = "dispute_id", EvidenceId = "evidence_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/Evidence/ListTest.cs b/src/Square.Test/Unit/MockServer/Disputes/Evidence/ListTest.cs new file mode 100644 index 00000000..149aefa9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/Evidence/ListTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Disputes.Evidence; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes.Evidence; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "evidence": [ + { + "evidence_id": "evidence_id", + "id": "CpfnkwGselCwS8QFvxN6", + "dispute_id": "bVTprrwk0gygTLZ96VX1oB", + "evidence_file": { + "filename": "customer-interaction", + "filetype": "JPG" + }, + "evidence_text": "evidence_text", + "uploaded_at": "2022-05-10T15:57:13.802Z", + "evidence_type": "CARDHOLDER_COMMUNICATION" + }, + { + "evidence_id": "evidence_id", + "id": "TOomLInj6iWmP3N8qfCXrB", + "dispute_id": "bVTprrwk0gygTLZ96VX1oB", + "evidence_file": { + "filename": "", + "filetype": "" + }, + "evidence_text": "evidence_text", + "uploaded_at": "2022-05-18T16:01:10.000Z", + "evidence_type": "REBUTTAL_EXPLANATION" + } + ], + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id/evidence") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Disputes.Evidence.ListAsync( + new ListEvidenceRequest { DisputeId = "dispute_id", Cursor = "cursor" } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/GetTest.cs b/src/Square.Test/Unit/MockServer/Disputes/GetTest.cs new file mode 100644 index 00000000..c2aa359b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/GetTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Disputes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "dispute": { + "dispute_id": "dispute_id", + "id": "XDgyFu7yo1E2S5lQGGpYn", + "amount_money": { + "amount": 2500, + "currency": "USD" + }, + "reason": "NO_KNOWLEDGE", + "state": "ACCEPTED", + "due_at": "2022-07-13T00:00:00.000Z", + "disputed_payment": { + "payment_id": "zhyh1ch64kRBrrlfVhwjCEjZWzNZY" + }, + "evidence_ids": [ + "evidence_ids" + ], + "card_brand": "VISA", + "created_at": "2022-06-29T18:45:22.265Z", + "updated_at": "2022-07-07T19:14:42.650Z", + "brand_dispute_id": "100000809947", + "reported_date": "reported_date", + "reported_at": "2022-06-29T00:00:00.000Z", + "version": 2, + "location_id": "L1HN3ZMQK64X9" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Disputes.GetAsync( + new GetDisputesRequest { DisputeId = "dispute_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/ListTest.cs b/src/Square.Test/Unit/MockServer/Disputes/ListTest.cs new file mode 100644 index 00000000..f000972c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/ListTest.cs @@ -0,0 +1,112 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Disputes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "disputes": [ + { + "dispute_id": "dispute_id", + "id": "XDgyFu7yo1E2S5lQGGpYn", + "amount_money": { + "amount": 2500, + "currency": "USD" + }, + "reason": "NO_KNOWLEDGE", + "state": "ACCEPTED", + "due_at": "2022-07-13T00:00:00.000Z", + "disputed_payment": { + "payment_id": "zhyh1ch64kRBrrlfVhwjCEjZWzNZY" + }, + "evidence_ids": [ + "evidence_ids" + ], + "card_brand": "VISA", + "created_at": "2022-06-29T18:45:22.265Z", + "updated_at": "2022-07-07T19:14:42.650Z", + "brand_dispute_id": "100000809947", + "reported_date": "reported_date", + "reported_at": "2022-06-29T00:00:00.000Z", + "version": 2, + "location_id": "L1HN3ZMQK64X9" + }, + { + "dispute_id": "dispute_id", + "id": "jLGg7aXC7lvKPr9PISt0T", + "amount_money": { + "amount": 2209, + "currency": "USD" + }, + "reason": "NOT_AS_DESCRIBED", + "state": "EVIDENCE_REQUIRED", + "due_at": "2022-05-13T00:00:00.000Z", + "disputed_payment": { + "payment_id": "zhyh1ch64kRBrrlfVhwjCEjZWzNZY" + }, + "evidence_ids": [ + "evidence_ids" + ], + "card_brand": "VISA", + "created_at": "2022-04-29T18:45:22.265Z", + "updated_at": "2022-04-29T18:45:22.265Z", + "brand_dispute_id": "r5Of6YaGT7AdeRaVoAGCJw", + "reported_date": "reported_date", + "reported_at": "2022-04-29T00:00:00.000Z", + "version": 1, + "location_id": "18YC4JDH91E1H" + } + ], + "cursor": "G1aSTRm48CLjJsg6Sg3hQN1b1OMaoVuG" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes") + .WithParam("cursor", "cursor") + .WithParam("states", "INQUIRY_EVIDENCE_REQUIRED") + .WithParam("location_id", "location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Disputes.ListAsync( + new ListDisputesRequest + { + Cursor = "cursor", + States = DisputeState.InquiryEvidenceRequired, + LocationId = "location_id", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Disputes/SubmitEvidenceTest.cs b/src/Square.Test/Unit/MockServer/Disputes/SubmitEvidenceTest.cs new file mode 100644 index 00000000..2217c026 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Disputes/SubmitEvidenceTest.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Disputes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Disputes; + +[TestFixture] +public class SubmitEvidenceTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "dispute": { + "dispute_id": "dispute_id", + "id": "EAZoK70gX3fyvibecLwIGB", + "amount_money": { + "amount": 4350, + "currency": "USD" + }, + "reason": "CUSTOMER_REQUESTS_CREDIT", + "state": "PROCESSING", + "due_at": "2022-06-01T00:00:00.000Z", + "disputed_payment": { + "payment_id": "2yeBUWJzllJTpmnSqtMRAL19taB" + }, + "evidence_ids": [ + "evidence_ids" + ], + "card_brand": "VISA", + "created_at": "2022-05-18T16:02:15.313Z", + "updated_at": "2022-05-18T16:02:15.313Z", + "brand_dispute_id": "100000399240", + "reported_date": "reported_date", + "reported_at": "2022-05-18T00:00:00.000Z", + "version": 4, + "location_id": "LSY8XKGSMMX94" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/disputes/dispute_id/submit-evidence") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Disputes.SubmitEvidenceAsync( + new SubmitEvidenceDisputesRequest { DisputeId = "dispute_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Employees/GetTest.cs b/src/Square.Test/Unit/MockServer/Employees/GetTest.cs new file mode 100644 index 00000000..01a5d6f1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Employees/GetTest.cs @@ -0,0 +1,60 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Employees; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Employees; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "employee": { + "id": "id", + "first_name": "first_name", + "last_name": "last_name", + "email": "email", + "phone_number": "phone_number", + "location_ids": [ + "location_ids" + ], + "status": "ACTIVE", + "is_owner": true, + "created_at": "created_at", + "updated_at": "updated_at" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/employees/id").UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Employees.GetAsync(new GetEmployeesRequest { Id = "id" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Employees/ListTest.cs b/src/Square.Test/Unit/MockServer/Employees/ListTest.cs new file mode 100644 index 00000000..381430b1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Employees/ListTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Employees; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Employees; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "employees": [ + { + "id": "id", + "first_name": "first_name", + "last_name": "last_name", + "email": "email", + "phone_number": "phone_number", + "location_ids": [ + "location_ids" + ], + "status": "ACTIVE", + "is_owner": true, + "created_at": "created_at", + "updated_at": "updated_at" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/employees") + .WithParam("location_id", "location_id") + .WithParam("status", "ACTIVE") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Employees.ListAsync( + new ListEmployeesRequest + { + LocationId = "location_id", + Status = EmployeeStatus.Active, + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Events/DisableEventsTest.cs b/src/Square.Test/Unit/MockServer/Events/DisableEventsTest.cs new file mode 100644 index 00000000..294e02e2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Events/DisableEventsTest.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Events; + +[TestFixture] +public class DisableEventsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/events/disable").UsingPut() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Events.DisableEventsAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Events/EnableEventsTest.cs b/src/Square.Test/Unit/MockServer/Events/EnableEventsTest.cs new file mode 100644 index 00000000..ab215498 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Events/EnableEventsTest.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Events; + +[TestFixture] +public class EnableEventsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/events/enable").UsingPut() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Events.EnableEventsAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Events/ListEventTypesTest.cs b/src/Square.Test/Unit/MockServer/Events/ListEventTypesTest.cs new file mode 100644 index 00000000..f957d22c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Events/ListEventTypesTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Events; + +[TestFixture] +public class ListEventTypesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "event_types": [ + "inventory.count.updated" + ], + "metadata": [ + { + "event_type": "inventory.count.updated", + "api_version_introduced": "2018-07-12", + "release_status": "PUBLIC" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/events/types") + .WithParam("api_version", "api_version") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Events.ListEventTypesAsync( + new Square.Events.ListEventTypesRequest { ApiVersion = "api_version" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Events/SearchEventsTest.cs b/src/Square.Test/Unit/MockServer/Events/SearchEventsTest.cs new file mode 100644 index 00000000..ca04d39a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Events/SearchEventsTest.cs @@ -0,0 +1,97 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Events; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Events; + +[TestFixture] +public class SearchEventsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "events": [ + { + "merchant_id": "0HPGX5JYE6EE1", + "location_id": "VJDQQP3CG14EY", + "type": "dispute.state.updated", + "event_id": "73ecd468-0aba-424f-b862-583d44efe7c8", + "created_at": "2022-04-26T10:08:40.454Z", + "data": { + "type": "dispute", + "id": "ORSEVtZAJxb37RA1EiGw", + "object": { + "dispute": { + "amount_money": { + "amount": 8801, + "currency": "USD" + }, + "brand_dispute_id": "r9rKGSBBQbywBNnWWIiGFg", + "card_brand": "VISA", + "created_at": "2020-02-19T21:24:53.258Z", + "disputed_payment": { + "payment_id": "fbmsaEOpoARDKxiSGH1fqPuqoqFZY" + }, + "due_at": "2020-03-04T00:00:00.000Z", + "id": "ORSEVtZAJxb37RA1EiGw", + "location_id": "VJDQQP3CG14EY", + "reason": "AMOUNT_DIFFERS", + "reported_at": "2020-02-19T00:00:00.000Z", + "state": "WON", + "updated_at": "2020-02-19T21:34:41.851Z", + "version": 6 + } + } + } + } + ], + "metadata": [ + { + "event_id": "73ecd468-0aba-424f-b862-583d44efe7c8", + "api_version": "2022-12-13" + } + ], + "cursor": "6b571fc9773647f=" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/events") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Events.SearchEventsAsync(new SearchEventsRequest()); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/Activities/CreateTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/Activities/CreateTest.cs new file mode 100644 index 00000000..e828efc9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/Activities/CreateTest.cs @@ -0,0 +1,165 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards.Activities; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards.Activities; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "U16kfr-kA70er-q4Rsym-7U7NnY", + "gift_card_activity": { + "type": "ACTIVATE", + "location_id": "81FN9BNFZTKS4", + "gift_card_id": "gftc:6d55a72470d940c6ba09c0ab8ad08d20", + "activate_activity_details": { + "order_id": "jJNGHm4gLI6XkFbwtiSLqK72KkAZY", + "line_item_uid": "eIWl7X0nMuO9Ewbh0ChIx" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card_activity": { + "id": "gcact_c8f8cbf1f24b448d8ecf39ed03f97864", + "type": "ACTIVATE", + "location_id": "81FN9BNFZTKS4", + "created_at": "2021-05-20T22:26:54.000Z", + "gift_card_id": "gftc:6d55a72470d940c6ba09c0ab8ad08d20", + "gift_card_gan": "7783320002929081", + "gift_card_balance_money": { + "amount": 1000, + "currency": "USD" + }, + "load_activity_details": { + "order_id": "order_id", + "line_item_uid": "line_item_uid", + "reference_id": "reference_id", + "buyer_payment_instrument_ids": [ + "buyer_payment_instrument_ids" + ] + }, + "activate_activity_details": { + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "order_id": "jJNGHm4gLI6XkFbwtiSLqK72KkAZY", + "line_item_uid": "eIWl7X0nMuO9Ewbh0ChIx", + "reference_id": "reference_id", + "buyer_payment_instrument_ids": [ + "buyer_payment_instrument_ids" + ] + }, + "redeem_activity_details": { + "amount_money": {}, + "payment_id": "payment_id", + "reference_id": "reference_id", + "status": "PENDING" + }, + "clear_balance_activity_details": { + "reason": "SUSPICIOUS_ACTIVITY" + }, + "deactivate_activity_details": { + "reason": "SUSPICIOUS_ACTIVITY" + }, + "adjust_increment_activity_details": { + "amount_money": {}, + "reason": "COMPLIMENTARY" + }, + "adjust_decrement_activity_details": { + "amount_money": {}, + "reason": "SUSPICIOUS_ACTIVITY" + }, + "refund_activity_details": { + "redeem_activity_id": "redeem_activity_id", + "reference_id": "reference_id", + "payment_id": "payment_id" + }, + "unlinked_activity_refund_activity_details": { + "amount_money": {}, + "reference_id": "reference_id", + "payment_id": "payment_id" + }, + "import_activity_details": { + "amount_money": {} + }, + "block_activity_details": { + "reason": "CHARGEBACK_BLOCK" + }, + "unblock_activity_details": { + "reason": "CHARGEBACK_UNBLOCK" + }, + "import_reversal_activity_details": { + "amount_money": {} + }, + "transfer_balance_to_activity_details": { + "transfer_from_gift_card_id": "transfer_from_gift_card_id", + "amount_money": {} + }, + "transfer_balance_from_activity_details": { + "transfer_to_gift_card_id": "transfer_to_gift_card_id", + "amount_money": {} + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards/activities") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.Activities.CreateAsync( + new CreateGiftCardActivityRequest + { + IdempotencyKey = "U16kfr-kA70er-q4Rsym-7U7NnY", + GiftCardActivity = new GiftCardActivity + { + Type = GiftCardActivityType.Activate, + LocationId = "81FN9BNFZTKS4", + GiftCardId = "gftc:6d55a72470d940c6ba09c0ab8ad08d20", + ActivateActivityDetails = new GiftCardActivityActivate + { + OrderId = "jJNGHm4gLI6XkFbwtiSLqK72KkAZY", + LineItemUid = "eIWl7X0nMuO9Ewbh0ChIx", + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/Activities/ListTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/Activities/ListTest.cs new file mode 100644 index 00000000..e0ecdfe2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/Activities/ListTest.cs @@ -0,0 +1,186 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.GiftCards.Activities; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards.Activities; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card_activities": [ + { + "id": "gcact_897698f894b44b3db46c6147e26a0e19", + "type": "REDEEM", + "location_id": "81FN9BNFZTKS4", + "created_at": "2021-06-02T22:26:38.000Z", + "gift_card_id": "gftc:6d55a72470d940c6ba09c0ab8ad08d20", + "gift_card_gan": "7783320002929081", + "gift_card_balance_money": { + "amount": 700, + "currency": "USD" + }, + "redeem_activity_details": { + "amount_money": { + "amount": 300, + "currency": "USD" + } + }, + "clear_balance_activity_details": { + "reason": "SUSPICIOUS_ACTIVITY" + }, + "deactivate_activity_details": { + "reason": "SUSPICIOUS_ACTIVITY" + }, + "adjust_increment_activity_details": { + "amount_money": {}, + "reason": "COMPLIMENTARY" + }, + "adjust_decrement_activity_details": { + "amount_money": {}, + "reason": "SUSPICIOUS_ACTIVITY" + }, + "unlinked_activity_refund_activity_details": { + "amount_money": {} + }, + "import_activity_details": { + "amount_money": {} + }, + "block_activity_details": { + "reason": "CHARGEBACK_BLOCK" + }, + "unblock_activity_details": { + "reason": "CHARGEBACK_UNBLOCK" + }, + "import_reversal_activity_details": { + "amount_money": {} + }, + "transfer_balance_to_activity_details": { + "transfer_from_gift_card_id": "transfer_from_gift_card_id", + "amount_money": {} + }, + "transfer_balance_from_activity_details": { + "transfer_to_gift_card_id": "transfer_to_gift_card_id", + "amount_money": {} + } + }, + { + "id": "gcact_b968ebfc7d46437b945be7b9e09123b4", + "type": "ACTIVATE", + "location_id": "81FN9BNFZTKS4", + "created_at": "2021-05-20T22:26:54.000Z", + "gift_card_id": "gftc:6d55a72470d940c6ba09c0ab8ad08d20", + "gift_card_gan": "7783320002929081", + "gift_card_balance_money": { + "amount": 1000, + "currency": "USD" + }, + "activate_activity_details": { + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "order_id": "jJNGHm4gLI6XkFbwtiSLqK72KkAZY", + "line_item_uid": "eIWl7X0nMuO9Ewbh0ChIx" + }, + "redeem_activity_details": { + "amount_money": {} + }, + "clear_balance_activity_details": { + "reason": "SUSPICIOUS_ACTIVITY" + }, + "deactivate_activity_details": { + "reason": "SUSPICIOUS_ACTIVITY" + }, + "adjust_increment_activity_details": { + "amount_money": {}, + "reason": "COMPLIMENTARY" + }, + "adjust_decrement_activity_details": { + "amount_money": {}, + "reason": "SUSPICIOUS_ACTIVITY" + }, + "unlinked_activity_refund_activity_details": { + "amount_money": {} + }, + "import_activity_details": { + "amount_money": {} + }, + "block_activity_details": { + "reason": "CHARGEBACK_BLOCK" + }, + "unblock_activity_details": { + "reason": "CHARGEBACK_UNBLOCK" + }, + "import_reversal_activity_details": { + "amount_money": {} + }, + "transfer_balance_to_activity_details": { + "transfer_from_gift_card_id": "transfer_from_gift_card_id", + "amount_money": {} + }, + "transfer_balance_from_activity_details": { + "transfer_to_gift_card_id": "transfer_to_gift_card_id", + "amount_money": {} + } + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards/activities") + .WithParam("gift_card_id", "gift_card_id") + .WithParam("type", "type") + .WithParam("location_id", "location_id") + .WithParam("begin_time", "begin_time") + .WithParam("end_time", "end_time") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .WithParam("sort_order", "sort_order") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.GiftCards.Activities.ListAsync( + new ListActivitiesRequest + { + GiftCardId = "gift_card_id", + Type = "type", + LocationId = "location_id", + BeginTime = "begin_time", + EndTime = "end_time", + Limit = 1, + Cursor = "cursor", + SortOrder = "sort_order", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/CreateTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/CreateTest.cs new file mode 100644 index 00000000..13f14965 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/CreateTest.cs @@ -0,0 +1,83 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "NC9Tm69EjbjtConu", + "location_id": "81FN9BNFZTKS4", + "gift_card": { + "type": "DIGITAL" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card": { + "id": "gftc:6cbacbb64cf54e2ca9f573d619038059", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "PENDING", + "balance_money": { + "amount": 0, + "currency": "USD" + }, + "gan": "7783320006753271", + "created_at": "2021-05-20T22:26:54.000Z", + "customer_ids": [ + "customer_ids" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.CreateAsync( + new CreateGiftCardRequest + { + IdempotencyKey = "NC9Tm69EjbjtConu", + LocationId = "81FN9BNFZTKS4", + GiftCard = new GiftCard { Type = GiftCardType.Digital }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/GetFromGanTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/GetFromGanTest.cs new file mode 100644 index 00000000..cbade65f --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/GetFromGanTest.cs @@ -0,0 +1,75 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class GetFromGanTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "gan": "7783320001001635" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card": { + "id": "gftc:6944163553804e439d89adb47caf806a", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 5000, + "currency": "USD" + }, + "gan": "7783320001001635", + "created_at": "2021-05-20T22:26:54.000Z", + "customer_ids": [ + "customer_ids" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards/from-gan") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.GetFromGanAsync( + new GetGiftCardFromGanRequest { Gan = "7783320001001635" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/GetFromNonceTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/GetFromNonceTest.cs new file mode 100644 index 00000000..73729635 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/GetFromNonceTest.cs @@ -0,0 +1,75 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class GetFromNonceTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "nonce": "cnon:7783322135245171" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card": { + "id": "gftc:6944163553804e439d89adb47caf806a", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 5000, + "currency": "USD" + }, + "gan": "7783320001001635", + "created_at": "2021-05-20T22:26:54.000Z", + "customer_ids": [ + "customer_ids" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards/from-nonce") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.GetFromNonceAsync( + new GetGiftCardFromNonceRequest { Nonce = "cnon:7783322135245171" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/GetTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/GetTest.cs new file mode 100644 index 00000000..ac688ea4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/GetTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card": { + "id": "gftc:00113070ba5745f0b2377c1b9570cb03", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 1000, + "currency": "USD" + }, + "gan": "7783320001001635", + "created_at": "2021-05-20T22:26:54.000Z", + "customer_ids": [ + "customer_ids" + ] + } + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/gift-cards/id").UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.GetAsync(new GetGiftCardsRequest { Id = "id" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/LinkCustomerTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/LinkCustomerTest.cs new file mode 100644 index 00000000..b428ed6b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/LinkCustomerTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class LinkCustomerTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "customer_id": "GKY0FZ3V717AH8Q2D821PNT2ZW" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card": { + "id": "gftc:71ea002277a34f8a945e284b04822edb", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 2500, + "currency": "USD" + }, + "gan": "7783320005440920", + "created_at": "2021-03-25T05:13:01.000Z", + "customer_ids": [ + "GKY0FZ3V717AH8Q2D821PNT2ZW" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards/gift_card_id/link-customer") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.LinkCustomerAsync( + new LinkCustomerToGiftCardRequest + { + GiftCardId = "gift_card_id", + CustomerId = "GKY0FZ3V717AH8Q2D821PNT2ZW", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/ListTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/ListTest.cs new file mode 100644 index 00000000..b36547f9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/ListTest.cs @@ -0,0 +1,95 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_cards": [ + { + "id": "gftc:00113070ba5745f0b2377c1b9570cb03", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 3900, + "currency": "USD" + }, + "gan": "7783320008524605", + "created_at": "2021-06-09T22:26:54.000Z", + "customer_ids": [ + "customer_ids" + ] + }, + { + "id": "gftc:00128a12725b41e58e0de1d20497a9dd", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 2000, + "currency": "USD" + }, + "gan": "7783320002692465", + "created_at": "2021-05-20T22:26:54.000Z", + "customer_ids": [ + "customer_ids" + ] + } + ], + "cursor": "JbFmyvUpaNKsfC1hoLSA4WlqkgkZXTWeKuStajR5BkP7OE0ETAbeWSi6U6u7sH" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards") + .WithParam("type", "type") + .WithParam("state", "state") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .WithParam("customer_id", "customer_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.GiftCards.ListAsync( + new ListGiftCardsRequest + { + Type = "type", + State = "state", + Limit = 1, + Cursor = "cursor", + CustomerId = "customer_id", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/GiftCards/UnlinkCustomerTest.cs b/src/Square.Test/Unit/MockServer/GiftCards/UnlinkCustomerTest.cs new file mode 100644 index 00000000..4a5c7ce9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/GiftCards/UnlinkCustomerTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.GiftCards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.GiftCards; + +[TestFixture] +public class UnlinkCustomerTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "customer_id": "GKY0FZ3V717AH8Q2D821PNT2ZW" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "gift_card": { + "id": "gftc:71ea002277a34f8a945e284b04822edb", + "type": "DIGITAL", + "gan_source": "SQUARE", + "state": "ACTIVE", + "balance_money": { + "amount": 2500, + "currency": "USD" + }, + "gan": "7783320005440920", + "created_at": "2021-03-25T05:13:01.000Z", + "customer_ids": [ + "customer_ids" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/gift-cards/gift_card_id/unlink-customer") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.GiftCards.UnlinkCustomerAsync( + new UnlinkCustomerFromGiftCardRequest + { + GiftCardId = "gift_card_id", + CustomerId = "GKY0FZ3V717AH8Q2D821PNT2ZW", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/BatchCreateChangesTest.cs b/src/Square.Test/Unit/MockServer/Inventory/BatchCreateChangesTest.cs new file mode 100644 index 00000000..45b9f10d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/BatchCreateChangesTest.cs @@ -0,0 +1,112 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class BatchCreateChangesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + "changes": [ + { + "type": "PHYSICAL_COUNT", + "physical_count": { + "reference_id": "1536bfbf-efed-48bf-b17d-a197141b2a92", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "53", + "team_member_id": "LRK57NSQ5X7PUD05", + "occurred_at": "2016-11-16T22:25:24.878Z" + } + } + ], + "ignore_unchanged_counts": true + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "counts": [ + { + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "53", + "calculated_at": "2016-11-16T22:28:01.223Z", + "is_estimated": true + } + ], + "changes": [ + { + "type": "PHYSICAL_COUNT", + "measurement_unit_id": "measurement_unit_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/changes/batch-create") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.BatchCreateChangesAsync( + new BatchChangeInventoryRequest + { + IdempotencyKey = "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + Changes = new List() + { + new InventoryChange + { + Type = InventoryChangeType.PhysicalCount, + PhysicalCount = new InventoryPhysicalCount + { + ReferenceId = "1536bfbf-efed-48bf-b17d-a197141b2a92", + CatalogObjectId = "W62UWFY35CWMYGVWK6TWJDNI", + State = InventoryState.InStock, + LocationId = "C6W5YS5QM06F5", + Quantity = "53", + TeamMemberId = "LRK57NSQ5X7PUD05", + OccurredAt = "2016-11-16T22:25:24.878Z", + }, + }, + }, + IgnoreUnchangedCounts = true, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/BatchGetChangesTest.cs b/src/Square.Test/Unit/MockServer/Inventory/BatchGetChangesTest.cs new file mode 100644 index 00000000..233eecfb --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/BatchGetChangesTest.cs @@ -0,0 +1,103 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class BatchGetChangesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "catalog_object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI" + ], + "location_ids": [ + "C6W5YS5QM06F5" + ], + "types": [ + "PHYSICAL_COUNT" + ], + "states": [ + "IN_STOCK" + ], + "updated_after": "2016-11-01T00:00:00.000Z", + "updated_before": "2016-12-01T00:00:00.000Z" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "changes": [ + { + "type": "PHYSICAL_COUNT", + "physical_count": { + "id": "46YDTW253DWGGK9HMAE6XCAO", + "reference_id": "22c07cf4-5626-4224-89f9-691112019399", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "86", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "team_member_id": "LRK57NSQ5X7PUD05", + "occurred_at": "2016-11-16T22:24:49.028Z", + "created_at": "2016-11-16T22:25:24.878Z" + }, + "measurement_unit_id": "measurement_unit_id" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/changes/batch-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Inventory.BatchGetChangesAsync( + new BatchRetrieveInventoryChangesRequest + { + CatalogObjectIds = new List() { "W62UWFY35CWMYGVWK6TWJDNI" }, + LocationIds = new List() { "C6W5YS5QM06F5" }, + Types = new List() { InventoryChangeType.PhysicalCount }, + States = new List() { InventoryState.InStock }, + UpdatedAfter = "2016-11-01T00:00:00.000Z", + UpdatedBefore = "2016-12-01T00:00:00.000Z", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/BatchGetCountsTest.cs b/src/Square.Test/Unit/MockServer/Inventory/BatchGetCountsTest.cs new file mode 100644 index 00000000..cc3ed21b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/BatchGetCountsTest.cs @@ -0,0 +1,81 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class BatchGetCountsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "catalog_object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI" + ], + "location_ids": [ + "59TNP9SA8VGDA" + ], + "updated_after": "2016-11-16T00:00:00.000Z" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "counts": [ + { + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "59TNP9SA8VGDA", + "quantity": "79", + "calculated_at": "2016-11-16T22:28:01.223Z", + "is_estimated": true + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/counts/batch-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Inventory.BatchGetCountsAsync( + new BatchGetInventoryCountsRequest + { + CatalogObjectIds = new List() { "W62UWFY35CWMYGVWK6TWJDNI" }, + LocationIds = new List() { "59TNP9SA8VGDA" }, + UpdatedAfter = "2016-11-16T00:00:00.000Z", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/ChangesTest.cs b/src/Square.Test/Unit/MockServer/Inventory/ChangesTest.cs new file mode 100644 index 00000000..227d04d7 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/ChangesTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class ChangesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "changes": [ + { + "type": "ADJUSTMENT", + "adjustment": { + "id": "OJKJIUANKLMLQANZADNPLKAD", + "reference_id": "d8207693-168f-4b44-a2fd-a7ff533ddd26", + "from_state": "IN_STOCK", + "to_state": "SOLD", + "location_id": "C6W5YS5QM06F5", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "quantity": "3", + "total_price_money": { + "amount": 5000, + "currency": "USD" + }, + "occurred_at": "2016-11-16T22:25:24.878Z", + "created_at": "2016-11-16T22:25:24.878Z", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "team_member_id": "AV7YRCGI2H1J5NQ8E1XIZCNA", + "transaction_id": "5APV6JYK1SNCZD11AND2RX1Z" + }, + "measurement_unit_id": "measurement_unit_id" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/catalog_object_id/changes") + .WithParam("location_ids", "location_ids") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Inventory.ChangesAsync( + new ChangesInventoryRequest + { + CatalogObjectId = "catalog_object_id", + LocationIds = "location_ids", + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchChangeTest.cs b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchChangeTest.cs new file mode 100644 index 00000000..4993b041 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchChangeTest.cs @@ -0,0 +1,112 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class DeprecatedBatchChangeTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + "changes": [ + { + "type": "PHYSICAL_COUNT", + "physical_count": { + "reference_id": "1536bfbf-efed-48bf-b17d-a197141b2a92", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "53", + "team_member_id": "LRK57NSQ5X7PUD05", + "occurred_at": "2016-11-16T22:25:24.878Z" + } + } + ], + "ignore_unchanged_counts": true + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "counts": [ + { + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "53", + "calculated_at": "2016-11-16T22:28:01.223Z", + "is_estimated": true + } + ], + "changes": [ + { + "type": "PHYSICAL_COUNT", + "measurement_unit_id": "measurement_unit_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/batch-change") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.DeprecatedBatchChangeAsync( + new BatchChangeInventoryRequest + { + IdempotencyKey = "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + Changes = new List() + { + new InventoryChange + { + Type = InventoryChangeType.PhysicalCount, + PhysicalCount = new InventoryPhysicalCount + { + ReferenceId = "1536bfbf-efed-48bf-b17d-a197141b2a92", + CatalogObjectId = "W62UWFY35CWMYGVWK6TWJDNI", + State = InventoryState.InStock, + LocationId = "C6W5YS5QM06F5", + Quantity = "53", + TeamMemberId = "LRK57NSQ5X7PUD05", + OccurredAt = "2016-11-16T22:25:24.878Z", + }, + }, + }, + IgnoreUnchangedCounts = true, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetChangesTest.cs b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetChangesTest.cs new file mode 100644 index 00000000..210c497e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetChangesTest.cs @@ -0,0 +1,104 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class DeprecatedBatchGetChangesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "catalog_object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI" + ], + "location_ids": [ + "C6W5YS5QM06F5" + ], + "types": [ + "PHYSICAL_COUNT" + ], + "states": [ + "IN_STOCK" + ], + "updated_after": "2016-11-01T00:00:00.000Z", + "updated_before": "2016-12-01T00:00:00.000Z" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "changes": [ + { + "type": "PHYSICAL_COUNT", + "physical_count": { + "id": "46YDTW253DWGGK9HMAE6XCAO", + "reference_id": "22c07cf4-5626-4224-89f9-691112019399", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "86", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "team_member_id": "LRK57NSQ5X7PUD05", + "occurred_at": "2016-11-16T22:24:49.028Z", + "created_at": "2016-11-16T22:25:24.878Z" + }, + "measurement_unit_id": "measurement_unit_id" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/batch-retrieve-changes") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.DeprecatedBatchGetChangesAsync( + new BatchRetrieveInventoryChangesRequest + { + CatalogObjectIds = new List() { "W62UWFY35CWMYGVWK6TWJDNI" }, + LocationIds = new List() { "C6W5YS5QM06F5" }, + Types = new List() { InventoryChangeType.PhysicalCount }, + States = new List() { InventoryState.InStock }, + UpdatedAfter = "2016-11-01T00:00:00.000Z", + UpdatedBefore = "2016-12-01T00:00:00.000Z", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetCountsTest.cs b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetCountsTest.cs new file mode 100644 index 00000000..12fc000e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedBatchGetCountsTest.cs @@ -0,0 +1,82 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class DeprecatedBatchGetCountsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "catalog_object_ids": [ + "W62UWFY35CWMYGVWK6TWJDNI" + ], + "location_ids": [ + "59TNP9SA8VGDA" + ], + "updated_after": "2016-11-16T00:00:00.000Z" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "counts": [ + { + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "59TNP9SA8VGDA", + "quantity": "79", + "calculated_at": "2016-11-16T22:28:01.223Z", + "is_estimated": true + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/batch-retrieve-counts") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.DeprecatedBatchGetCountsAsync( + new BatchGetInventoryCountsRequest + { + CatalogObjectIds = new List() { "W62UWFY35CWMYGVWK6TWJDNI" }, + LocationIds = new List() { "59TNP9SA8VGDA" }, + UpdatedAfter = "2016-11-16T00:00:00.000Z", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetAdjustmentTest.cs b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetAdjustmentTest.cs new file mode 100644 index 00000000..29e871b4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetAdjustmentTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class DeprecatedGetAdjustmentTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "adjustment": { + "id": "UDMOEO78BG6GYWA2XDRYX3KB", + "reference_id": "4a366069-4096-47a2-99a5-0084ac879509", + "from_state": "IN_STOCK", + "to_state": "SOLD", + "location_id": "C6W5YS5QM06F5", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "quantity": "7", + "total_price_money": { + "amount": 4550, + "currency": "USD" + }, + "occurred_at": "2016-11-16T25:44:22.837Z", + "created_at": "2016-11-17T13:02:15.142Z", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "employee_id": "employee_id", + "team_member_id": "LRK57NSQ5X7PUD05", + "transaction_id": "transaction_id", + "refund_id": "refund_id", + "purchase_order_id": "purchase_order_id", + "goods_receipt_id": "goods_receipt_id", + "adjustment_group": { + "id": "id", + "root_adjustment_id": "root_adjustment_id", + "from_state": "CUSTOM", + "to_state": "CUSTOM" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/adjustment/adjustment_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.DeprecatedGetAdjustmentAsync( + new DeprecatedGetAdjustmentInventoryRequest { AdjustmentId = "adjustment_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetPhysicalCountTest.cs b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetPhysicalCountTest.cs new file mode 100644 index 00000000..4b19cf78 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/DeprecatedGetPhysicalCountTest.cs @@ -0,0 +1,70 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class DeprecatedGetPhysicalCountTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "count": { + "id": "ANZADNPLKADOJKJIUANKLMLQ", + "reference_id": "f857ec37-f9a0-4458-8e23-5b5e0bea4e53", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "15", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "employee_id": "employee_id", + "team_member_id": "LRK57NSQ5X7PUD05", + "occurred_at": "2016-11-16T22:25:24.878Z", + "created_at": "2016-11-16T22:25:24.878Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/physical-count/physical_count_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.DeprecatedGetPhysicalCountAsync( + new DeprecatedGetPhysicalCountInventoryRequest { PhysicalCountId = "physical_count_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/GetAdjustmentTest.cs b/src/Square.Test/Unit/MockServer/Inventory/GetAdjustmentTest.cs new file mode 100644 index 00000000..7a3aa225 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/GetAdjustmentTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class GetAdjustmentTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "adjustment": { + "id": "UDMOEO78BG6GYWA2XDRYX3KB", + "reference_id": "4a366069-4096-47a2-99a5-0084ac879509", + "from_state": "IN_STOCK", + "to_state": "SOLD", + "location_id": "C6W5YS5QM06F5", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "quantity": "7", + "total_price_money": { + "amount": 4550, + "currency": "USD" + }, + "occurred_at": "2016-11-16T25:44:22.837Z", + "created_at": "2016-11-17T13:02:15.142Z", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "employee_id": "employee_id", + "team_member_id": "LRK57NSQ5X7PUD05", + "transaction_id": "transaction_id", + "refund_id": "refund_id", + "purchase_order_id": "purchase_order_id", + "goods_receipt_id": "goods_receipt_id", + "adjustment_group": { + "id": "id", + "root_adjustment_id": "root_adjustment_id", + "from_state": "CUSTOM", + "to_state": "CUSTOM" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/adjustments/adjustment_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.GetAdjustmentAsync( + new GetAdjustmentInventoryRequest { AdjustmentId = "adjustment_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/GetPhysicalCountTest.cs b/src/Square.Test/Unit/MockServer/Inventory/GetPhysicalCountTest.cs new file mode 100644 index 00000000..c8172005 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/GetPhysicalCountTest.cs @@ -0,0 +1,70 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class GetPhysicalCountTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "count": { + "id": "ANZADNPLKADOJKJIUANKLMLQ", + "reference_id": "f857ec37-f9a0-4458-8e23-5b5e0bea4e53", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "15", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "employee_id": "employee_id", + "team_member_id": "LRK57NSQ5X7PUD05", + "occurred_at": "2016-11-16T22:25:24.878Z", + "created_at": "2016-11-16T22:25:24.878Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/physical-counts/physical_count_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.GetPhysicalCountAsync( + new GetPhysicalCountInventoryRequest { PhysicalCountId = "physical_count_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/GetTest.cs b/src/Square.Test/Unit/MockServer/Inventory/GetTest.cs new file mode 100644 index 00000000..5153d080 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/GetTest.cs @@ -0,0 +1,69 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "counts": [ + { + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "state": "IN_STOCK", + "location_id": "C6W5YS5QM06F5", + "quantity": "22", + "calculated_at": "2016-11-16T22:28:01.223Z", + "is_estimated": true + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/catalog_object_id") + .WithParam("location_ids", "location_ids") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Inventory.GetAsync( + new GetInventoryRequest + { + CatalogObjectId = "catalog_object_id", + LocationIds = "location_ids", + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Inventory/GetTransferTest.cs b/src/Square.Test/Unit/MockServer/Inventory/GetTransferTest.cs new file mode 100644 index 00000000..46881138 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Inventory/GetTransferTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Inventory; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Inventory; + +[TestFixture] +public class GetTransferTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "transfer": { + "id": "UDMOEO78BG6GYWA2XDRYX3KB", + "reference_id": "4a366069-4096-47a2-99a5-0084ac879509", + "state": "IN_STOCK", + "from_location_id": "C6W5YS5QM06F5", + "to_location_id": "59TNP9SA8VGDA", + "catalog_object_id": "W62UWFY35CWMYGVWK6TWJDNI", + "catalog_object_type": "ITEM_VARIATION", + "quantity": "7", + "occurred_at": "2016-11-16T25:44:22.837Z", + "created_at": "2016-11-17T13:02:15.142Z", + "source": { + "product": "SQUARE_POS", + "application_id": "416ff29c-86c4-4feb-b58c-9705f21f3ea0", + "name": "Square Point of Sale 4.37" + }, + "employee_id": "employee_id", + "team_member_id": "LRK57NSQ5X7PUD05" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/inventory/transfers/transfer_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Inventory.GetTransferAsync( + new GetTransferInventoryRequest { TransferId = "transfer_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/CancelTest.cs b/src/Square.Test/Unit/MockServer/Invoices/CancelTest.cs new file mode 100644 index 00000000..346d6637 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/CancelTest.cs @@ -0,0 +1,139 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "version": 0 + } + """; + + const string mockResponse = """ + { + "invoice": { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 1, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240", + "company_name": "company_name" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "uid": "beebd363-e47f-4075-8785-c235aaa7df11", + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow", + "status": "PENDING" + } + ], + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "public_url", + "next_payment_amount_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "CANCELED", + "timezone": "America/Los_Angeles", + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-06-18T18:23:11.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/invoice_id/cancel") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.CancelAsync( + new CancelInvoiceRequest { InvoiceId = "invoice_id", Version = 0 } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/CreateTest.cs b/src/Square.Test/Unit/MockServer/Invoices/CreateTest.cs new file mode 100644 index 00000000..b150e2f0 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/CreateTest.cs @@ -0,0 +1,246 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "invoice": { + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4" + }, + "payment_requests": [ + { + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow" + } + ] + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "sale_or_service_date": "2030-01-24", + "store_payment_method_enabled": false + }, + "idempotency_key": "ce3748f9-5fc1-4762-aa12-aae5e843f1f4" + } + """; + + const string mockResponse = """ + { + "invoice": { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 0, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240", + "company_name": "company_name" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "uid": "beebd363-e47f-4075-8785-c235aaa7df11", + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow", + "status": "PENDING" + } + ], + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "public_url", + "next_payment_amount_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "DRAFT", + "timezone": "America/Los_Angeles", + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-06-18T17:45:13.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.CreateAsync( + new CreateInvoiceRequest + { + Invoice = new Invoice + { + LocationId = "ES0RJRZYEC39A", + OrderId = "CAISENgvlJ6jLWAzERDzjyHVybY", + PrimaryRecipient = new InvoiceRecipient + { + CustomerId = "JDKYHBWT1D4F8MFH63DBMEN8Y4", + }, + PaymentRequests = new List() + { + new InvoicePaymentRequest + { + RequestType = InvoiceRequestType.Balance, + DueDate = "2030-01-24", + TippingEnabled = true, + AutomaticPaymentSource = InvoiceAutomaticPaymentSource.None, + Reminders = new List() + { + new InvoicePaymentReminder + { + RelativeScheduledDays = -1, + Message = "Your invoice is due tomorrow", + }, + }, + }, + }, + DeliveryMethod = InvoiceDeliveryMethod.Email, + InvoiceNumber = "inv-100", + Title = "Event Planning Services", + Description = "We appreciate your business!", + ScheduledAt = "2030-01-13T10:00:00Z", + AcceptedPaymentMethods = new InvoiceAcceptedPaymentMethods + { + Card = true, + SquareGiftCard = false, + BankAccount = false, + BuyNowPayLater = false, + CashAppPay = false, + }, + CustomFields = new List() + { + new InvoiceCustomField + { + Label = "Event Reference Number", + Value = "Ref. #1234", + Placement = InvoiceCustomFieldPlacement.AboveLineItems, + }, + new InvoiceCustomField + { + Label = "Terms of Service", + Value = "The terms of service are...", + Placement = InvoiceCustomFieldPlacement.BelowLineItems, + }, + }, + SaleOrServiceDate = "2030-01-24", + StorePaymentMethodEnabled = false, + }, + IdempotencyKey = "ce3748f9-5fc1-4762-aa12-aae5e843f1f4", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/DeleteInvoiceAttachmentTest.cs b/src/Square.Test/Unit/MockServer/Invoices/DeleteInvoiceAttachmentTest.cs new file mode 100644 index 00000000..b5d9c002 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/DeleteInvoiceAttachmentTest.cs @@ -0,0 +1,56 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class DeleteInvoiceAttachmentTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/invoice_id/attachments/attachment_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.DeleteInvoiceAttachmentAsync( + new DeleteInvoiceAttachmentRequest + { + InvoiceId = "invoice_id", + AttachmentId = "attachment_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Invoices/DeleteTest.cs new file mode 100644 index 00000000..5ff36a7d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/invoice_id") + .WithParam("version", "1") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.DeleteAsync( + new DeleteInvoicesRequest { InvoiceId = "invoice_id", Version = 1 } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/GetTest.cs b/src/Square.Test/Unit/MockServer/Invoices/GetTest.cs new file mode 100644 index 00000000..9cdb5641 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/GetTest.cs @@ -0,0 +1,131 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "invoice": { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 0, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240", + "company_name": "company_name" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "uid": "beebd363-e47f-4075-8785-c235aaa7df11", + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow", + "status": "PENDING" + } + ], + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "public_url", + "next_payment_amount_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "DRAFT", + "timezone": "America/Los_Angeles", + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-06-18T17:45:13.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/invoice_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.GetAsync( + new GetInvoicesRequest { InvoiceId = "invoice_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/ListTest.cs b/src/Square.Test/Unit/MockServer/Invoices/ListTest.cs new file mode 100644 index 00000000..3757ce26 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/ListTest.cs @@ -0,0 +1,224 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "invoices": [ + { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 1, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "uid": "beebd363-e47f-4075-8785-c235aaa7df11", + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow", + "status": "PENDING" + } + ], + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "public_url", + "status": "DRAFT", + "timezone": "America/Los_Angeles", + "created_at": "2030-01-13T17:45:13.000Z", + "updated_at": "2030-01-13T21:24:10.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + { + "id": "inva:0-3bB9ZuDHiziThQhuC4fwWt", + "filename": "file.jpg", + "description": "Service contract", + "filesize": 102705, + "hash": "273ee02cb6f5f8a3a8ca23604930dd53", + "mime_type": "image/jpeg", + "uploaded_at": "2030-01-13T21:24:10.000Z" + } + ], + "creator_team_member_id": "creator_team_member_id" + }, + { + "id": "inv:0-ChC366qAfskpGrBI_1bozs9mEA3", + "version": 3, + "location_id": "ES0RJRZYEC39A", + "order_id": "a65jnS8NXbfprvGJzY9F4fQTuaB", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240" + }, + "payment_requests": [ + { + "uid": "66c3bdfd-5090-4ff9-a8a0-c1e1a2ffa176", + "request_type": "DEPOSIT", + "due_date": "2021-01-23", + "percentage_requested": "25", + "tipping_enabled": false, + "automatic_payment_source": "CARD_ON_FILE", + "card_id": "ccof:IkWfpLj4tNHMyFii3GB", + "computed_amount_money": { + "amount": 1000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 1000, + "currency": "USD" + } + }, + { + "uid": "120c5e18-4f80-4f6b-b159-774cb9bf8f99", + "request_type": "BALANCE", + "due_date": "2021-06-15", + "tipping_enabled": false, + "automatic_payment_source": "CARD_ON_FILE", + "card_id": "ccof:IkWfpLj4tNHMyFii3GB", + "computed_amount_money": { + "amount": 3000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-455", + "title": "title", + "description": "description", + "scheduled_at": "scheduled_at", + "public_url": "https://squareup.com/pay-invoice/invtmp:5e22a2c2-47c1-46d6-b061-808764dfe2b9", + "next_payment_amount_money": { + "amount": 3000, + "currency": "USD" + }, + "status": "PARTIALLY_PAID", + "timezone": "America/Los_Angeles", + "created_at": "2021-01-23T15:29:12.000Z", + "updated_at": "2021-01-23T15:29:56.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": true, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + {} + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + } + ], + "cursor": "ChoIDhIWVm54ZVRhLXhySFBOejBBM2xJb2daUQoFCI4IGAE", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices") + .WithParam("location_id", "location_id") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Invoices.ListAsync( + new ListInvoicesRequest + { + LocationId = "location_id", + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/PublishTest.cs b/src/Square.Test/Unit/MockServer/Invoices/PublishTest.cs new file mode 100644 index 00000000..895cb4c4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/PublishTest.cs @@ -0,0 +1,145 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class PublishTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "version": 1, + "idempotency_key": "32da42d0-1997-41b0-826b-f09464fc2c2e" + } + """; + + const string mockResponse = """ + { + "invoice": { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 1, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240", + "company_name": "company_name" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "uid": "beebd363-e47f-4075-8785-c235aaa7df11", + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow", + "status": "PENDING" + } + ], + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "https://squareup.com/pay-invoice/invtmp:5e22a2c2-47c1-46d6-b061-808764dfe2b9", + "next_payment_amount_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "SCHEDULED", + "timezone": "America/Los_Angeles", + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-06-18T18:23:11.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/invoice_id/publish") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.PublishAsync( + new PublishInvoiceRequest + { + InvoiceId = "invoice_id", + Version = 1, + IdempotencyKey = "32da42d0-1997-41b0-826b-f09464fc2c2e", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/SearchTest.cs b/src/Square.Test/Unit/MockServer/Invoices/SearchTest.cs new file mode 100644 index 00000000..120a0f42 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/SearchTest.cs @@ -0,0 +1,243 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "location_ids": [ + "ES0RJRZYEC39A" + ], + "customer_ids": [ + "JDKYHBWT1D4F8MFH63DBMEN8Y4" + ] + }, + "sort": { + "field": "INVOICE_SORT_DATE", + "order": "DESC" + } + }, + "limit": 100 + } + """; + + const string mockResponse = """ + { + "invoices": [ + { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 0, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": true, + "automatic_payment_source": "NONE", + "reminders": [ + { + "uid": "beebd363-e47f-4075-8785-c235aaa7df11", + "relative_scheduled_days": -1, + "message": "Your invoice is due tomorrow", + "status": "PENDING" + } + ], + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "public_url", + "status": "DRAFT", + "timezone": "America/Los_Angeles", + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-06-18T17:45:13.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + }, + { + "id": "inv:0-ChC366qAfskpGrBI_1bozs9mEA3", + "version": 3, + "location_id": "ES0RJRZYEC39A", + "order_id": "a65jnS8NXbfprvGJzY9F4fQTuaB", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240" + }, + "payment_requests": [ + { + "uid": "66c3bdfd-5090-4ff9-a8a0-c1e1a2ffa176", + "request_type": "DEPOSIT", + "due_date": "2021-01-23", + "percentage_requested": "25", + "tipping_enabled": false, + "automatic_payment_source": "CARD_ON_FILE", + "card_id": "ccof:IkWfpLj4tNHMyFii3GB", + "computed_amount_money": { + "amount": 1000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 1000, + "currency": "USD" + } + }, + { + "uid": "120c5e18-4f80-4f6b-b159-774cb9bf8f99", + "request_type": "BALANCE", + "due_date": "2021-06-15", + "tipping_enabled": false, + "automatic_payment_source": "CARD_ON_FILE", + "card_id": "ccof:IkWfpLj4tNHMyFii3GB", + "computed_amount_money": { + "amount": 3000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-455", + "title": "title", + "description": "description", + "scheduled_at": "scheduled_at", + "public_url": "https://squareup.com/pay-invoice/invtmp:5e22a2c2-47c1-46d6-b061-808764dfe2b9", + "next_payment_amount_money": { + "amount": 3000, + "currency": "USD" + }, + "status": "PARTIALLY_PAID", + "timezone": "America/Los_Angeles", + "created_at": "2021-01-23T15:29:12.000Z", + "updated_at": "2021-01-23T15:29:56.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": true, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + {} + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + } + ], + "cursor": "ChoIDhIWVm54ZVRhLXhySFBOejBBM2xJb2daUQoFCI4IGAE", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.SearchAsync( + new SearchInvoicesRequest + { + Query = new InvoiceQuery + { + Filter = new InvoiceFilter + { + LocationIds = new List() { "ES0RJRZYEC39A" }, + CustomerIds = new List() { "JDKYHBWT1D4F8MFH63DBMEN8Y4" }, + }, + Sort = new InvoiceSort { Field = "INVOICE_SORT_DATE", Order = SortOrder.Desc }, + }, + Limit = 100, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Invoices/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Invoices/UpdateTest.cs new file mode 100644 index 00000000..62d169b5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Invoices/UpdateTest.cs @@ -0,0 +1,156 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Invoices; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Invoices; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "invoice": { + "version": 1, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "tipping_enabled": false + } + ] + }, + "idempotency_key": "4ee82288-0910-499e-ab4c-5d0071dad1be" + } + """; + + const string mockResponse = """ + { + "invoice": { + "id": "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "version": 2, + "location_id": "ES0RJRZYEC39A", + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "primary_recipient": { + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "given_name": "Amelia", + "family_name": "Earhart", + "email_address": "Amelia.Earhart@example.com", + "phone_number": "1-212-555-4240", + "company_name": "company_name" + }, + "payment_requests": [ + { + "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + "request_type": "BALANCE", + "due_date": "2030-01-24", + "tipping_enabled": false, + "automatic_payment_source": "NONE", + "computed_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "total_completed_amount_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "delivery_method": "EMAIL", + "invoice_number": "inv-100", + "title": "Event Planning Services", + "description": "We appreciate your business!", + "scheduled_at": "2030-01-13T10:00:00.000Z", + "public_url": "public_url", + "next_payment_amount_money": { + "amount": 10000, + "currency": "USD" + }, + "status": "UNPAID", + "timezone": "America/Los_Angeles", + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-06-18T18:23:11.000Z", + "accepted_payment_methods": { + "card": true, + "square_gift_card": false, + "bank_account": false, + "buy_now_pay_later": false, + "cash_app_pay": false + }, + "custom_fields": [ + { + "label": "Event Reference Number", + "value": "Ref. #1234", + "placement": "ABOVE_LINE_ITEMS" + }, + { + "label": "Terms of Service", + "value": "The terms of service are...", + "placement": "BELOW_LINE_ITEMS" + } + ], + "subscription_id": "subscription_id", + "sale_or_service_date": "2030-01-24", + "payment_conditions": "payment_conditions", + "store_payment_method_enabled": false, + "attachments": [ + {} + ], + "creator_team_member_id": "creator_team_member_id" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/invoices/invoice_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Invoices.UpdateAsync( + new UpdateInvoiceRequest + { + InvoiceId = "invoice_id", + Invoice = new Invoice + { + Version = 1, + PaymentRequests = new List() + { + new InvoicePaymentRequest + { + Uid = "2da7964f-f3d2-4f43-81e8-5aa220bf3355", + TippingEnabled = false, + }, + }, + }, + IdempotencyKey = "4ee82288-0910-499e-ab4c-5d0071dad1be", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/BreakTypes/CreateTest.cs b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/CreateTest.cs new file mode 100644 index 00000000..9b7757a2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/CreateTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.BreakTypes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.BreakTypes; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "PAD3NG5KSN2GL", + "break_type": { + "location_id": "CGJN03P1D08GF", + "break_name": "Lunch Break", + "expected_duration": "PT30M", + "is_paid": true + } + } + """; + + const string mockResponse = """ + { + "break_type": { + "id": "49SSVDJG76WF3", + "location_id": "CGJN03P1D08GF", + "break_name": "Lunch Break", + "expected_duration": "PT30M", + "is_paid": true, + "version": 1, + "created_at": "2019-02-26T22:42:54.000Z", + "updated_at": "2019-02-26T22:42:54.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/break-types") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.BreakTypes.CreateAsync( + new CreateBreakTypeRequest + { + IdempotencyKey = "PAD3NG5KSN2GL", + BreakType = new BreakType + { + LocationId = "CGJN03P1D08GF", + BreakName = "Lunch Break", + ExpectedDuration = "PT30M", + IsPaid = true, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/BreakTypes/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/DeleteTest.cs new file mode 100644 index 00000000..b3157e9c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/DeleteTest.cs @@ -0,0 +1,51 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.BreakTypes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.BreakTypes; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/break-types/id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.BreakTypes.DeleteAsync( + new DeleteBreakTypesRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/BreakTypes/GetTest.cs b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/GetTest.cs new file mode 100644 index 00000000..92b0d95f --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/GetTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.BreakTypes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.BreakTypes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "break_type": { + "id": "lA0mj_RSOprNPwMUXdYp", + "location_id": "059SB0E0WCNWS", + "break_name": "Lunch Break", + "expected_duration": "PT30M", + "is_paid": true, + "version": 1, + "created_at": "2019-02-21T17:50:00.000Z", + "updated_at": "2019-02-21T17:50:00.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/break-types/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.BreakTypes.GetAsync( + new GetBreakTypesRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/BreakTypes/ListTest.cs b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/ListTest.cs new file mode 100644 index 00000000..eb6443da --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/ListTest.cs @@ -0,0 +1,81 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Labor.BreakTypes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.BreakTypes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "break_types": [ + { + "id": "REGS1EQR1TPZ5", + "location_id": "PAA1RJZZKXBFG", + "break_name": "Coffee Break", + "expected_duration": "PT5M", + "is_paid": false, + "version": 1, + "created_at": "2019-01-22T20:47:37.000Z", + "updated_at": "2019-01-22T20:47:37.000Z" + }, + { + "id": "92EPDRQKJ5088", + "location_id": "PAA1RJZZKXBFG", + "break_name": "Lunch Break", + "expected_duration": "PT1H", + "is_paid": true, + "version": 3, + "created_at": "2019-01-25T19:26:30.000Z", + "updated_at": "2019-01-25T19:26:30.000Z" + } + ], + "cursor": "2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/break-types") + .WithParam("location_id", "location_id") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Labor.BreakTypes.ListAsync( + new ListBreakTypesRequest + { + LocationId = "location_id", + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/BreakTypes/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/UpdateTest.cs new file mode 100644 index 00000000..f5c3b0ec --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/BreakTypes/UpdateTest.cs @@ -0,0 +1,86 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.BreakTypes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.BreakTypes; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "break_type": { + "location_id": "26M7H24AZ9N6R", + "break_name": "Lunch", + "expected_duration": "PT50M", + "is_paid": true, + "version": 1 + } + } + """; + + const string mockResponse = """ + { + "break_type": { + "id": "Q6JSJS6D4DBCH", + "location_id": "26M7H24AZ9N6R", + "break_name": "Lunch", + "expected_duration": "PT50M", + "is_paid": true, + "version": 2, + "created_at": "2018-06-12T20:19:12.000Z", + "updated_at": "2019-02-26T23:12:59.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/break-types/id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.BreakTypes.UpdateAsync( + new UpdateBreakTypeRequest + { + Id = "id", + BreakType = new BreakType + { + LocationId = "26M7H24AZ9N6R", + BreakName = "Lunch", + ExpectedDuration = "PT50M", + IsPaid = true, + Version = 1, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/BulkPublishScheduledShiftsTest.cs b/src/Square.Test/Unit/MockServer/Labor/BulkPublishScheduledShiftsTest.cs new file mode 100644 index 00000000..c8c199ba --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/BulkPublishScheduledShiftsTest.cs @@ -0,0 +1,116 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class BulkPublishScheduledShiftsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "scheduled_shifts": { + "key": {} + }, + "scheduled_shift_notification_audience": "AFFECTED" + } + """; + + const string mockResponse = """ + { + "responses": { + "idp_key_1": { + "scheduled_shift": { + "id": "K0YH4CV5462JB", + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-03-25T08:11:00.000Z", + "end_at": "2019-03-25T18:18:00.000Z", + "notes": "Don't forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "published_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-03-25T08:11:00.000Z", + "end_at": "2019-03-25T18:18:00.000Z", + "notes": "Don't forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "version": 3, + "created_at": "2019-02-25T08:11:00.000Z", + "updated_at": "2019-02-25T08:11:15.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "idp_key_2": { + "errors": [ + { + "category": "INVALID_REQUEST_ERROR", + "code": "INVALID_VALUE", + "detail": "Scheduled shift with id 'scheduled-shift-2' not found", + "field": "scheduled-shifts.scheduled-shift-2" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/scheduled-shifts/bulk-publish") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.BulkPublishScheduledShiftsAsync( + new BulkPublishScheduledShiftsRequest + { + ScheduledShifts = new Dictionary() + { + { "key", new BulkPublishScheduledShiftsData() }, + }, + ScheduledShiftNotificationAudience = ScheduledShiftNotificationAudience.Affected, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/CreateScheduledShiftTest.cs b/src/Square.Test/Unit/MockServer/Labor/CreateScheduledShiftTest.cs new file mode 100644 index 00000000..cb74677b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/CreateScheduledShiftTest.cs @@ -0,0 +1,113 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class CreateScheduledShiftTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "HIDSNG5KS478L", + "scheduled_shift": { + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false + } + } + } + """; + + const string mockResponse = """ + { + "scheduled_shift": { + "id": "K0YH4CV5462JB", + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "published_shift_details": { + "team_member_id": "team_member_id", + "location_id": "location_id", + "job_id": "job_id", + "start_at": "start_at", + "end_at": "end_at", + "notes": "notes", + "is_deleted": true, + "timezone": "timezone" + }, + "version": 1, + "created_at": "2019-02-25T08:11:00.000Z", + "updated_at": "2019-02-25T08:11:00.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/scheduled-shifts") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.CreateScheduledShiftAsync( + new CreateScheduledShiftRequest + { + IdempotencyKey = "HIDSNG5KS478L", + ScheduledShift = new ScheduledShift + { + DraftShiftDetails = new ScheduledShiftDetails + { + TeamMemberId = "ormj0jJJZ5OZIzxrZYJI", + LocationId = "PAA1RJZZKXBFG", + JobId = "FzbJAtt9qEWncK1BWgVCxQ6M", + StartAt = "2019-01-25T03:11:00-05:00", + EndAt = "2019-01-25T13:11:00-05:00", + Notes = "Dont forget to prep the vegetables", + IsDeleted = false, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/CreateTimecardTest.cs b/src/Square.Test/Unit/MockServer/Labor/CreateTimecardTest.cs new file mode 100644 index 00000000..0fbc9ea8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/CreateTimecardTest.cs @@ -0,0 +1,152 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class CreateTimecardTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "HIDSNG5KS478L", + "timecard": { + "location_id": "PAA1RJZZKXBFG", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Barista", + "hourly_rate": { + "amount": 1100, + "currency": "USD" + }, + "tip_eligible": true + }, + "breaks": [ + { + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + } + } + """; + + const string mockResponse = """ + { + "timecard": { + "id": "K0YH4CV5462JB", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Barista", + "hourly_rate": { + "amount": 1100, + "currency": "USD" + }, + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "tip_eligible": true + }, + "breaks": [ + { + "id": "X7GAQYVVRRG6P", + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 1, + "created_at": "2019-02-28T00:39:02.000Z", + "updated_at": "2019-02-28T00:39:02.000Z", + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/timecards") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.CreateTimecardAsync( + new CreateTimecardRequest + { + IdempotencyKey = "HIDSNG5KS478L", + Timecard = new Timecard + { + LocationId = "PAA1RJZZKXBFG", + StartAt = "2019-01-25T03:11:00-05:00", + EndAt = "2019-01-25T13:11:00-05:00", + Wage = new TimecardWage + { + Title = "Barista", + HourlyRate = new Money { Amount = 1100, Currency = Currency.Usd }, + TipEligible = true, + }, + Breaks = new List() + { + new Break + { + StartAt = "2019-01-25T06:11:00-05:00", + EndAt = "2019-01-25T06:16:00-05:00", + BreakTypeId = "REGS1EQR1TPZ5", + Name = "Tea Break", + ExpectedDuration = "PT5M", + IsPaid = true, + }, + }, + TeamMemberId = "ormj0jJJZ5OZIzxrZYJI", + DeclaredCashTipMoney = new Money { Amount = 500, Currency = Currency.Usd }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/DeleteTimecardTest.cs b/src/Square.Test/Unit/MockServer/Labor/DeleteTimecardTest.cs new file mode 100644 index 00000000..52439dff --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/DeleteTimecardTest.cs @@ -0,0 +1,51 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class DeleteTimecardTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/timecards/id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.DeleteTimecardAsync( + new DeleteTimecardRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/EmployeeWages/GetTest.cs b/src/Square.Test/Unit/MockServer/Labor/EmployeeWages/GetTest.cs new file mode 100644 index 00000000..7a876831 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/EmployeeWages/GetTest.cs @@ -0,0 +1,60 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.EmployeeWages; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.EmployeeWages; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "employee_wage": { + "id": "pXS3qCv7BERPnEGedM4S8mhm", + "employee_id": "33fJchumvVdJwxV0H6L9", + "title": "Manager", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/employee-wages/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.EmployeeWages.GetAsync( + new GetEmployeeWagesRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/EmployeeWages/ListTest.cs b/src/Square.Test/Unit/MockServer/Labor/EmployeeWages/ListTest.cs new file mode 100644 index 00000000..44a61954 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/EmployeeWages/ListTest.cs @@ -0,0 +1,97 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Labor.EmployeeWages; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.EmployeeWages; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "employee_wages": [ + { + "id": "pXS3qCv7BERPnEGedM4S8mhm", + "employee_id": "33fJchumvVdJwxV0H6L9", + "title": "Manager", + "hourly_rate": { + "amount": 3250, + "currency": "USD" + } + }, + { + "id": "rZduCkzYDUVL3ovh1sQgbue6", + "employee_id": "33fJchumvVdJwxV0H6L9", + "title": "Cook", + "hourly_rate": { + "amount": 2600, + "currency": "USD" + } + }, + { + "id": "FxLbs5KpPUHa8wyt5ctjubDX", + "employee_id": "33fJchumvVdJwxV0H6L9", + "title": "Barista", + "hourly_rate": { + "amount": 1600, + "currency": "USD" + } + }, + { + "id": "vD1wCgijMDR3cX5TPnu7VXto", + "employee_id": "33fJchumvVdJwxV0H6L9", + "title": "Cashier", + "hourly_rate": { + "amount": 1700, + "currency": "USD" + } + } + ], + "cursor": "2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/employee-wages") + .WithParam("employee_id", "employee_id") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Labor.EmployeeWages.ListAsync( + new ListEmployeeWagesRequest + { + EmployeeId = "employee_id", + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/PublishScheduledShiftTest.cs b/src/Square.Test/Unit/MockServer/Labor/PublishScheduledShiftTest.cs new file mode 100644 index 00000000..b32752a9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/PublishScheduledShiftTest.cs @@ -0,0 +1,94 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class PublishScheduledShiftTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "HIDSNG5KS478L", + "version": 2, + "scheduled_shift_notification_audience": "ALL" + } + """; + + const string mockResponse = """ + { + "scheduled_shift": { + "id": "K0YH4CV5462JB", + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "published_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "version": 2, + "created_at": "2019-02-25T08:11:00.000Z", + "updated_at": "2019-02-25T08:11:00.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/scheduled-shifts/id/publish") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.PublishScheduledShiftAsync( + new PublishScheduledShiftRequest + { + Id = "id", + IdempotencyKey = "HIDSNG5KS478L", + Version = 2, + ScheduledShiftNotificationAudience = ScheduledShiftNotificationAudience.All, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/RetrieveScheduledShiftTest.cs b/src/Square.Test/Unit/MockServer/Labor/RetrieveScheduledShiftTest.cs new file mode 100644 index 00000000..442ada99 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/RetrieveScheduledShiftTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class RetrieveScheduledShiftTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "scheduled_shift": { + "id": "K0YH4CV5462JB", + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-03-25T08:11:00.000Z", + "end_at": "2019-03-25T18:18:00.000Z", + "notes": "Don't forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "published_shift_details": { + "team_member_id": "team_member_id", + "location_id": "location_id", + "job_id": "job_id", + "start_at": "start_at", + "end_at": "end_at", + "notes": "notes", + "is_deleted": true, + "timezone": "timezone" + }, + "version": 2, + "created_at": "2019-02-25T08:11:00.000Z", + "updated_at": "2019-02-25T08:11:15.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/scheduled-shifts/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.RetrieveScheduledShiftAsync( + new RetrieveScheduledShiftRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/RetrieveTimecardTest.cs b/src/Square.Test/Unit/MockServer/Labor/RetrieveTimecardTest.cs new file mode 100644 index 00000000..6f80fc80 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/RetrieveTimecardTest.cs @@ -0,0 +1,88 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class RetrieveTimecardTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "timecard": { + "id": "T35HMQSN89SV4", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-02-23T23:00:00.000Z", + "end_at": "2019-02-24T02:00:00.000Z", + "wage": { + "title": "Cashier", + "hourly_rate": { + "amount": 1457, + "currency": "USD" + }, + "job_id": "N4YKVLzFj3oGtNocqoYHYpW3", + "tip_eligible": true + }, + "breaks": [ + { + "id": "M9BBKEPQAQD2T", + "start_at": "2019-02-24T00:00:00.000Z", + "end_at": "2019-02-24T01:00:00.000Z", + "break_type_id": "92EPDRQKJ5088", + "name": "Lunch Break", + "expected_duration": "PT1H", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 1, + "created_at": "2019-02-27T00:12:12.000Z", + "updated_at": "2019-02-27T00:12:12.000Z", + "team_member_id": "D71KRMQof6cXGUW0aAv7", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/timecards/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.RetrieveTimecardAsync( + new RetrieveTimecardRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/SearchScheduledShiftsTest.cs b/src/Square.Test/Unit/MockServer/Labor/SearchScheduledShiftsTest.cs new file mode 100644 index 00000000..842950b8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/SearchScheduledShiftsTest.cs @@ -0,0 +1,105 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class SearchScheduledShiftsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "assignment_status": "ASSIGNED" + }, + "sort": { + "field": "CREATED_AT", + "order": "ASC" + } + }, + "limit": 2, + "cursor": "xoxp-1234-5678-90123" + } + """; + + const string mockResponse = """ + { + "scheduled_shifts": [ + { + "id": "K0YH4CV5462JB", + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "version": 1, + "created_at": "2019-02-25T08:11:00.000Z", + "updated_at": "2019-02-25T08:11:00.000Z" + } + ], + "cursor": "xoxp-123-2123-123232", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/scheduled-shifts/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.SearchScheduledShiftsAsync( + new SearchScheduledShiftsRequest + { + Query = new ScheduledShiftQuery + { + Filter = new ScheduledShiftFilter + { + AssignmentStatus = ScheduledShiftFilterAssignmentStatus.Assigned, + }, + Sort = new ScheduledShiftSort + { + Field = ScheduledShiftSortField.CreatedAt, + Order = SortOrder.Asc, + }, + }, + Limit = 2, + Cursor = "xoxp-1234-5678-90123", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/SearchTimecardsTest.cs b/src/Square.Test/Unit/MockServer/Labor/SearchTimecardsTest.cs new file mode 100644 index 00000000..1cee36f9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/SearchTimecardsTest.cs @@ -0,0 +1,174 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class SearchTimecardsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "workday": { + "date_range": { + "start_date": "2019-01-20", + "end_date": "2019-02-03" + }, + "match_timecards_by": "START_AT", + "default_timezone": "America/Los_Angeles" + } + } + }, + "limit": 100 + } + """; + + const string mockResponse = """ + { + "timecards": [ + { + "id": "X714F3HA6D1PT", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-21T08:11:00.000Z", + "end_at": "2019-01-21T18:11:00.000Z", + "wage": { + "title": "Barista", + "hourly_rate": { + "amount": 1100, + "currency": "USD" + }, + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "tip_eligible": true + }, + "breaks": [ + { + "id": "SJW7X6AKEJQ65", + "start_at": "2019-01-21T11:11:00.000Z", + "end_at": "2019-01-21T11:11:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT10M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 6, + "created_at": "2019-01-24T01:12:03.000Z", + "updated_at": "2019-02-07T22:21:08.000Z", + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + { + "id": "GDHYBZYWK0P2V", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-22T17:02:00.000Z", + "end_at": "2019-01-22T18:02:00.000Z", + "wage": { + "title": "Cook", + "hourly_rate": { + "amount": 1600, + "currency": "USD" + }, + "job_id": "gcbz15vKGnMKmaWJJ152kjim", + "tip_eligible": true + }, + "breaks": [ + { + "id": "BKS6VR7WR748A", + "start_at": "2019-01-22T19:30:00.000Z", + "end_at": "2019-01-22T19:40:00.000Z", + "break_type_id": "WQX00VR99F53J", + "name": "Tea Break", + "expected_duration": "PT10M", + "is_paid": true + }, + { + "id": "BQFEZSHFZSC51", + "start_at": "2019-01-22T17:30:00.000Z", + "end_at": "2019-01-22T17:44:00.000Z", + "break_type_id": "P6Q468ZFRN1AC", + "name": "Coffee Break", + "expected_duration": "PT15M", + "is_paid": false + } + ], + "status": "CLOSED", + "version": 16, + "created_at": "2019-01-23T23:32:45.000Z", + "updated_at": "2019-01-24T00:56:25.000Z", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "declared_cash_tip_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/timecards/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.SearchTimecardsAsync( + new SearchTimecardsRequest + { + Query = new TimecardQuery + { + Filter = new TimecardFilter + { + Workday = new TimecardWorkday + { + DateRange = new DateRange + { + StartDate = "2019-01-20", + EndDate = "2019-02-03", + }, + MatchTimecardsBy = TimecardWorkdayMatcher.StartAt, + DefaultTimezone = "America/Los_Angeles", + }, + }, + }, + Limit = 100, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/Shifts/CreateTest.cs b/src/Square.Test/Unit/MockServer/Labor/Shifts/CreateTest.cs new file mode 100644 index 00000000..7bb46cde --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/Shifts/CreateTest.cs @@ -0,0 +1,153 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.Shifts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.Shifts; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "HIDSNG5KS478L", + "shift": { + "location_id": "PAA1RJZZKXBFG", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Barista", + "hourly_rate": { + "amount": 1100, + "currency": "USD" + }, + "tip_eligible": true + }, + "breaks": [ + { + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + } + } + """; + + const string mockResponse = """ + { + "shift": { + "id": "K0YH4CV5462JB", + "employee_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Barista", + "hourly_rate": { + "amount": 1100, + "currency": "USD" + }, + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "tip_eligible": true + }, + "breaks": [ + { + "id": "X7GAQYVVRRG6P", + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 1, + "created_at": "2019-02-28T00:39:02.000Z", + "updated_at": "2019-02-28T00:39:02.000Z", + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/shifts") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.Shifts.CreateAsync( + new CreateShiftRequest + { + IdempotencyKey = "HIDSNG5KS478L", + Shift = new Shift + { + LocationId = "PAA1RJZZKXBFG", + StartAt = "2019-01-25T03:11:00-05:00", + EndAt = "2019-01-25T13:11:00-05:00", + Wage = new ShiftWage + { + Title = "Barista", + HourlyRate = new Money { Amount = 1100, Currency = Currency.Usd }, + TipEligible = true, + }, + Breaks = new List() + { + new Break + { + StartAt = "2019-01-25T06:11:00-05:00", + EndAt = "2019-01-25T06:16:00-05:00", + BreakTypeId = "REGS1EQR1TPZ5", + Name = "Tea Break", + ExpectedDuration = "PT5M", + IsPaid = true, + }, + }, + TeamMemberId = "ormj0jJJZ5OZIzxrZYJI", + DeclaredCashTipMoney = new Money { Amount = 500, Currency = Currency.Usd }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/Shifts/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Labor/Shifts/DeleteTest.cs new file mode 100644 index 00000000..ae808997 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/Shifts/DeleteTest.cs @@ -0,0 +1,49 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.Shifts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.Shifts; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/shifts/id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.Shifts.DeleteAsync(new DeleteShiftsRequest { Id = "id" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/Shifts/GetTest.cs b/src/Square.Test/Unit/MockServer/Labor/Shifts/GetTest.cs new file mode 100644 index 00000000..105b43eb --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/Shifts/GetTest.cs @@ -0,0 +1,84 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.Shifts; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "shift": { + "id": "T35HMQSN89SV4", + "employee_id": "D71KRMQof6cXGUW0aAv7", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-02-23T23:00:00.000Z", + "end_at": "2019-02-24T02:00:00.000Z", + "wage": { + "title": "Cashier", + "hourly_rate": { + "amount": 1457, + "currency": "USD" + }, + "job_id": "N4YKVLzFj3oGtNocqoYHYpW3", + "tip_eligible": true + }, + "breaks": [ + { + "id": "M9BBKEPQAQD2T", + "start_at": "2019-02-24T00:00:00.000Z", + "end_at": "2019-02-24T01:00:00.000Z", + "break_type_id": "92EPDRQKJ5088", + "name": "Lunch Break", + "expected_duration": "PT1H", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 1, + "created_at": "2019-02-27T00:12:12.000Z", + "updated_at": "2019-02-27T00:12:12.000Z", + "team_member_id": "D71KRMQof6cXGUW0aAv7", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/labor/shifts/id").UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.Shifts.GetAsync( + new Square.Labor.Shifts.GetShiftsRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/Shifts/SearchTest.cs b/src/Square.Test/Unit/MockServer/Labor/Shifts/SearchTest.cs new file mode 100644 index 00000000..40f79fa3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/Shifts/SearchTest.cs @@ -0,0 +1,176 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.Shifts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.Shifts; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "workday": { + "date_range": { + "start_date": "2019-01-20", + "end_date": "2019-02-03" + }, + "match_shifts_by": "START_AT", + "default_timezone": "America/Los_Angeles" + } + } + }, + "limit": 100 + } + """; + + const string mockResponse = """ + { + "shifts": [ + { + "id": "X714F3HA6D1PT", + "employee_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-21T08:11:00.000Z", + "end_at": "2019-01-21T18:11:00.000Z", + "wage": { + "title": "Barista", + "hourly_rate": { + "amount": 1100, + "currency": "USD" + }, + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "tip_eligible": true + }, + "breaks": [ + { + "id": "SJW7X6AKEJQ65", + "start_at": "2019-01-21T11:11:00.000Z", + "end_at": "2019-01-21T11:11:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT10M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 6, + "created_at": "2019-01-24T01:12:03.000Z", + "updated_at": "2019-02-07T22:21:08.000Z", + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + { + "id": "GDHYBZYWK0P2V", + "employee_id": "33fJchumvVdJwxV0H6L9", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-22T17:02:00.000Z", + "end_at": "2019-01-22T18:02:00.000Z", + "wage": { + "title": "Cook", + "hourly_rate": { + "amount": 1600, + "currency": "USD" + }, + "job_id": "gcbz15vKGnMKmaWJJ152kjim", + "tip_eligible": true + }, + "breaks": [ + { + "id": "BKS6VR7WR748A", + "start_at": "2019-01-23T19:30:00.000Z", + "end_at": "2019-01-23T19:40:00.000Z", + "break_type_id": "WQX00VR99F53J", + "name": "Tea Break", + "expected_duration": "PT10M", + "is_paid": true + }, + { + "id": "BQFEZSHFZSC51", + "start_at": "2019-01-22T17:30:00.000Z", + "end_at": "2019-01-22T17:44:00.000Z", + "break_type_id": "P6Q468ZFRN1AC", + "name": "Coffee Break", + "expected_duration": "PT15M", + "is_paid": false + } + ], + "status": "CLOSED", + "version": 16, + "created_at": "2019-01-23T23:32:45.000Z", + "updated_at": "2019-01-24T00:56:25.000Z", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "declared_cash_tip_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/shifts/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.Shifts.SearchAsync( + new SearchShiftsRequest + { + Query = new ShiftQuery + { + Filter = new ShiftFilter + { + Workday = new ShiftWorkday + { + DateRange = new DateRange + { + StartDate = "2019-01-20", + EndDate = "2019-02-03", + }, + MatchShiftsBy = ShiftWorkdayMatcher.StartAt, + DefaultTimezone = "America/Los_Angeles", + }, + }, + }, + Limit = 100, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/Shifts/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Labor/Shifts/UpdateTest.cs new file mode 100644 index 00000000..df16394e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/Shifts/UpdateTest.cs @@ -0,0 +1,156 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.Shifts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.Shifts; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "shift": { + "location_id": "PAA1RJZZKXBFG", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Bartender", + "hourly_rate": { + "amount": 1500, + "currency": "USD" + }, + "tip_eligible": true + }, + "breaks": [ + { + "id": "X7GAQYVVRRG6P", + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "version": 1, + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + } + } + """; + + const string mockResponse = """ + { + "shift": { + "id": "K0YH4CV5462JB", + "employee_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Bartender", + "hourly_rate": { + "amount": 1500, + "currency": "USD" + }, + "job_id": "dZtrPh5GSDGugyXGByesVp51", + "tip_eligible": true + }, + "breaks": [ + { + "id": "X7GAQYVVRRG6P", + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 2, + "created_at": "2019-02-28T00:39:02.000Z", + "updated_at": "2019-02-28T00:42:41.000Z", + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/shifts/id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.Shifts.UpdateAsync( + new UpdateShiftRequest + { + Id = "id", + Shift = new Shift + { + LocationId = "PAA1RJZZKXBFG", + StartAt = "2019-01-25T03:11:00-05:00", + EndAt = "2019-01-25T13:11:00-05:00", + Wage = new ShiftWage + { + Title = "Bartender", + HourlyRate = new Money { Amount = 1500, Currency = Currency.Usd }, + TipEligible = true, + }, + Breaks = new List() + { + new Break + { + Id = "X7GAQYVVRRG6P", + StartAt = "2019-01-25T06:11:00-05:00", + EndAt = "2019-01-25T06:16:00-05:00", + BreakTypeId = "REGS1EQR1TPZ5", + Name = "Tea Break", + ExpectedDuration = "PT5M", + IsPaid = true, + }, + }, + Version = 1, + TeamMemberId = "ormj0jJJZ5OZIzxrZYJI", + DeclaredCashTipMoney = new Money { Amount = 500, Currency = Currency.Usd }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/GetTest.cs b/src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/GetTest.cs new file mode 100644 index 00000000..fa0db127 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/GetTest.cs @@ -0,0 +1,63 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.TeamMemberWages; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.TeamMemberWages; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "team_member_wage": { + "id": "pXS3qCv7BERPnEGedM4S8mhm", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "title": "Manager", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "jxJNN6eCJsLrhg5UFJrDWDGE", + "tip_eligible": false + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/team-member-wages/id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.TeamMemberWages.GetAsync( + new GetTeamMemberWagesRequest { Id = "id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/ListTest.cs b/src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/ListTest.cs new file mode 100644 index 00000000..84025d08 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/TeamMemberWages/ListTest.cs @@ -0,0 +1,105 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Labor.TeamMemberWages; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.TeamMemberWages; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "team_member_wages": [ + { + "id": "pXS3qCv7BERPnEGedM4S8mhm", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "title": "Manager", + "hourly_rate": { + "amount": 3250, + "currency": "USD" + }, + "job_id": "jxJNN6eCJsLrhg5UFJrDWDGE", + "tip_eligible": false + }, + { + "id": "rZduCkzYDUVL3ovh1sQgbue6", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "title": "Cook", + "hourly_rate": { + "amount": 2600, + "currency": "USD" + }, + "job_id": "gcbz15vKGnMKmaWJJ152kjim", + "tip_eligible": true + }, + { + "id": "FxLbs5KpPUHa8wyt5ctjubDX", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "title": "Barista", + "hourly_rate": { + "amount": 1600, + "currency": "USD" + }, + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "tip_eligible": true + }, + { + "id": "vD1wCgijMDR3cX5TPnu7VXto", + "team_member_id": "33fJchumvVdJwxV0H6L9", + "title": "Cashier", + "hourly_rate": { + "amount": 1700, + "currency": "USD" + }, + "job_id": "N4YKVLzFj3oGtNocqoYHYpW3", + "tip_eligible": true + } + ], + "cursor": "2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/team-member-wages") + .WithParam("team_member_id", "team_member_id") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Labor.TeamMemberWages.ListAsync( + new ListTeamMemberWagesRequest + { + TeamMemberId = "team_member_id", + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/UpdateScheduledShiftTest.cs b/src/Square.Test/Unit/MockServer/Labor/UpdateScheduledShiftTest.cs new file mode 100644 index 00000000..3aff0684 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/UpdateScheduledShiftTest.cs @@ -0,0 +1,114 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class UpdateScheduledShiftTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "scheduled_shift": { + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-03-25T08:11:00.000Z", + "end_at": "2019-03-25T18:18:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false + }, + "version": 1 + } + } + """; + + const string mockResponse = """ + { + "scheduled_shift": { + "id": "K0YH4CV5462JB", + "draft_shift_details": { + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "location_id": "PAA1RJZZKXBFG", + "job_id": "FzbJAtt9qEWncK1BWgVCxQ6M", + "start_at": "2019-03-25T08:11:00.000Z", + "end_at": "2019-03-25T18:18:00.000Z", + "notes": "Dont forget to prep the vegetables", + "is_deleted": false, + "timezone": "America/New_York" + }, + "published_shift_details": { + "team_member_id": "team_member_id", + "location_id": "location_id", + "job_id": "job_id", + "start_at": "start_at", + "end_at": "end_at", + "notes": "notes", + "is_deleted": true, + "timezone": "timezone" + }, + "version": 2, + "created_at": "2019-02-25T08:11:00.000Z", + "updated_at": "2019-02-25T08:11:15.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/scheduled-shifts/id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.UpdateScheduledShiftAsync( + new UpdateScheduledShiftRequest + { + Id = "id", + ScheduledShift = new ScheduledShift + { + DraftShiftDetails = new ScheduledShiftDetails + { + TeamMemberId = "ormj0jJJZ5OZIzxrZYJI", + LocationId = "PAA1RJZZKXBFG", + JobId = "FzbJAtt9qEWncK1BWgVCxQ6M", + StartAt = "2019-03-25T03:11:00-05:00", + EndAt = "2019-03-25T13:18:00-05:00", + Notes = "Dont forget to prep the vegetables", + IsDeleted = false, + }, + Version = 1, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/UpdateTimecardTest.cs b/src/Square.Test/Unit/MockServer/Labor/UpdateTimecardTest.cs new file mode 100644 index 00000000..c9321e3d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/UpdateTimecardTest.cs @@ -0,0 +1,157 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor; + +[TestFixture] +public class UpdateTimecardTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "timecard": { + "location_id": "PAA1RJZZKXBFG", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Bartender", + "hourly_rate": { + "amount": 1500, + "currency": "USD" + }, + "tip_eligible": true + }, + "breaks": [ + { + "id": "X7GAQYVVRRG6P", + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 1, + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + } + } + """; + + const string mockResponse = """ + { + "timecard": { + "id": "K0YH4CV5462JB", + "location_id": "PAA1RJZZKXBFG", + "timezone": "America/New_York", + "start_at": "2019-01-25T08:11:00.000Z", + "end_at": "2019-01-25T18:11:00.000Z", + "wage": { + "title": "Bartender", + "hourly_rate": { + "amount": 1500, + "currency": "USD" + }, + "job_id": "dZtrPh5GSDGugyXGByesVp51", + "tip_eligible": true + }, + "breaks": [ + { + "id": "X7GAQYVVRRG6P", + "start_at": "2019-01-25T11:11:00.000Z", + "end_at": "2019-01-25T11:16:00.000Z", + "break_type_id": "REGS1EQR1TPZ5", + "name": "Tea Break", + "expected_duration": "PT5M", + "is_paid": true + } + ], + "status": "CLOSED", + "version": 2, + "created_at": "2019-02-28T00:39:02.000Z", + "updated_at": "2019-02-28T00:42:41.000Z", + "team_member_id": "ormj0jJJZ5OZIzxrZYJI", + "declared_cash_tip_money": { + "amount": 500, + "currency": "USD" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/timecards/id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.UpdateTimecardAsync( + new UpdateTimecardRequest + { + Id = "id", + Timecard = new Timecard + { + LocationId = "PAA1RJZZKXBFG", + StartAt = "2019-01-25T03:11:00-05:00", + EndAt = "2019-01-25T13:11:00-05:00", + Wage = new TimecardWage + { + Title = "Bartender", + HourlyRate = new Money { Amount = 1500, Currency = Currency.Usd }, + TipEligible = true, + }, + Breaks = new List() + { + new Break + { + Id = "X7GAQYVVRRG6P", + StartAt = "2019-01-25T06:11:00-05:00", + EndAt = "2019-01-25T06:16:00-05:00", + BreakTypeId = "REGS1EQR1TPZ5", + Name = "Tea Break", + ExpectedDuration = "PT5M", + IsPaid = true, + }, + }, + Status = TimecardStatus.Closed, + Version = 1, + TeamMemberId = "ormj0jJJZ5OZIzxrZYJI", + DeclaredCashTipMoney = new Money { Amount = 500, Currency = Currency.Usd }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/GetTest.cs b/src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/GetTest.cs new file mode 100644 index 00000000..b32cb039 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/GetTest.cs @@ -0,0 +1,81 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Labor.WorkweekConfigs; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.WorkweekConfigs; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "workweek_config": { + "start_of_week": "MON", + "start_of_day_local_time": "10:00", + "version": 10 + } + } + """; + + const string mockResponse = """ + { + "workweek_config": { + "id": "FY4VCAQN700GM", + "start_of_week": "MON", + "start_of_day_local_time": "10:00", + "version": 11, + "created_at": "2016-02-04T00:58:24.000Z", + "updated_at": "2019-02-28T01:04:35.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/workweek-configs/id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Labor.WorkweekConfigs.GetAsync( + new UpdateWorkweekConfigRequest + { + Id = "id", + WorkweekConfig = new WorkweekConfig + { + StartOfWeek = Weekday.Mon, + StartOfDayLocalTime = "10:00", + Version = 10, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/ListTest.cs b/src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/ListTest.cs new file mode 100644 index 00000000..d3b38c5e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Labor/WorkweekConfigs/ListTest.cs @@ -0,0 +1,63 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Labor.WorkweekConfigs; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Labor.WorkweekConfigs; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "workweek_configs": [ + { + "id": "FY4VCAQN700GM", + "start_of_week": "MON", + "start_of_day_local_time": "10:00", + "version": 11, + "created_at": "2016-02-04T00:58:24.000Z", + "updated_at": "2019-02-28T01:04:35.000Z" + } + ], + "cursor": "2fofTniCgT0yIPAq26kmk0YyFQJZfbWkh73OOnlTHmTAx13NgED", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/labor/workweek-configs") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Labor.WorkweekConfigs.ListAsync( + new ListWorkweekConfigsRequest { Limit = 1, Cursor = "cursor" } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CheckoutsTest.cs b/src/Square.Test/Unit/MockServer/Locations/CheckoutsTest.cs new file mode 100644 index 00000000..39a5be95 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CheckoutsTest.cs @@ -0,0 +1,426 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations; + +[TestFixture] +public class CheckoutsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "86ae1696-b1e3-4328-af6d-f1e04d947ad6", + "order": { + "order": { + "location_id": "location_id", + "reference_id": "reference_id", + "customer_id": "customer_id", + "line_items": [ + { + "name": "Printed T Shirt", + "quantity": "2", + "applied_taxes": [ + { + "tax_uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3" + } + ], + "applied_discounts": [ + { + "discount_uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4" + } + ], + "base_price_money": { + "amount": 1500, + "currency": "USD" + } + }, + { + "name": "Slim Jeans", + "quantity": "1", + "base_price_money": { + "amount": 2500, + "currency": "USD" + } + }, + { + "name": "Woven Sweater", + "quantity": "3", + "base_price_money": { + "amount": 3500, + "currency": "USD" + } + } + ], + "taxes": [ + { + "uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3", + "type": "INCLUSIVE", + "percentage": "7.75", + "scope": "LINE_ITEM" + } + ], + "discounts": [ + { + "uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4", + "type": "FIXED_AMOUNT", + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "scope": "LINE_ITEM" + } + ] + }, + "idempotency_key": "12ae1696-z1e3-4328-af6d-f1e04d947gd4" + }, + "ask_for_shipping_address": true, + "merchant_support_email": "merchant+support@website.com", + "pre_populate_buyer_email": "example@email.com", + "pre_populate_shipping_address": { + "address_line_1": "1455 Market St.", + "address_line_2": "Suite 600", + "locality": "San Francisco", + "administrative_district_level_1": "CA", + "postal_code": "94103", + "country": "US", + "first_name": "Jane", + "last_name": "Doe" + }, + "redirect_url": "https://merchant.website.com/order-confirm", + "additional_recipients": [ + { + "location_id": "057P5VYJ4A5X1", + "description": "Application fees", + "amount_money": { + "amount": 60, + "currency": "USD" + } + } + ] + } + """; + + const string mockResponse = """ + { + "checkout": { + "id": "CAISEHGimXh-C3RIT4og1a6u1qw", + "checkout_page_url": "https://connect.squareup.com/v2/checkout?c=CAISEHGimXh-C3RIT4og1a6u1qw&l=CYTKRM7R7JMV8", + "ask_for_shipping_address": true, + "merchant_support_email": "merchant+support@website.com", + "pre_populate_buyer_email": "example@email.com", + "pre_populate_shipping_address": { + "address_line_1": "1455 Market St.", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "San Francisco", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "CA", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "94103", + "country": "US", + "first_name": "Jane", + "last_name": "Doe" + }, + "redirect_url": "https://merchant.website.com/order-confirm", + "order": { + "id": "id", + "location_id": "location_id", + "reference_id": "reference_id", + "customer_id": "customer_id", + "line_items": [ + { + "name": "Printed T Shirt", + "quantity": "2", + "applied_taxes": [ + { + "tax_uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3", + "applied_money": { + "amount": 103, + "currency": "USD" + } + } + ], + "applied_discounts": [ + { + "discount_uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4", + "applied_money": { + "amount": 100, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 1500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 103, + "currency": "USD" + }, + "total_discount_money": { + "amount": 100, + "currency": "USD" + }, + "total_money": { + "amount": 1503, + "currency": "USD" + } + }, + { + "name": "Slim Jeans", + "quantity": "1", + "base_price_money": { + "amount": 2500, + "currency": "USD" + }, + "total_money": { + "amount": 2500, + "currency": "USD" + } + }, + { + "name": "Woven Sweater", + "quantity": "3", + "base_price_money": { + "amount": 3500, + "currency": "USD" + }, + "total_money": { + "amount": 10500, + "currency": "USD" + } + } + ], + "taxes": [ + { + "uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3", + "type": "INCLUSIVE", + "percentage": "7.75", + "scope": "LINE_ITEM" + } + ], + "discounts": [ + { + "uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4", + "type": "FIXED_AMOUNT", + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "applied_money": { + "amount": 100, + "currency": "USD" + }, + "scope": "LINE_ITEM" + } + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "created_at": "created_at", + "updated_at": "updated_at", + "closed_at": "closed_at", + "state": "OPEN", + "version": 1, + "total_money": { + "amount": 14503, + "currency": "USD" + }, + "total_tax_money": { + "amount": 103, + "currency": "USD" + }, + "total_discount_money": { + "amount": 100, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ] + }, + "created_at": "2017-06-16T22:25:35.000Z", + "additional_recipients": [ + { + "location_id": "057P5VYJ4A5X1", + "description": "Application fees", + "amount_money": { + "amount": 60, + "currency": "USD" + } + } + ] + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/checkouts") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CheckoutsAsync( + new CreateCheckoutRequest + { + LocationId = "location_id", + IdempotencyKey = "86ae1696-b1e3-4328-af6d-f1e04d947ad6", + Order = new CreateOrderRequest + { + Order = new Order + { + LocationId = "location_id", + ReferenceId = "reference_id", + CustomerId = "customer_id", + LineItems = new List() + { + new OrderLineItem + { + Name = "Printed T Shirt", + Quantity = "2", + AppliedTaxes = new List() + { + new OrderLineItemAppliedTax + { + TaxUid = "38ze1696-z1e3-5628-af6d-f1e04d947fg3", + }, + }, + AppliedDiscounts = new List() + { + new OrderLineItemAppliedDiscount + { + DiscountUid = "56ae1696-z1e3-9328-af6d-f1e04d947gd4", + }, + }, + BasePriceMoney = new Money + { + Amount = 1500, + Currency = Currency.Usd, + }, + }, + new OrderLineItem + { + Name = "Slim Jeans", + Quantity = "1", + BasePriceMoney = new Money + { + Amount = 2500, + Currency = Currency.Usd, + }, + }, + new OrderLineItem + { + Name = "Woven Sweater", + Quantity = "3", + BasePriceMoney = new Money + { + Amount = 3500, + Currency = Currency.Usd, + }, + }, + }, + Taxes = new List() + { + new OrderLineItemTax + { + Uid = "38ze1696-z1e3-5628-af6d-f1e04d947fg3", + Type = OrderLineItemTaxType.Inclusive, + Percentage = "7.75", + Scope = OrderLineItemTaxScope.LineItem, + }, + }, + Discounts = new List() + { + new OrderLineItemDiscount + { + Uid = "56ae1696-z1e3-9328-af6d-f1e04d947gd4", + Type = OrderLineItemDiscountType.FixedAmount, + AmountMoney = new Money { Amount = 100, Currency = Currency.Usd }, + Scope = OrderLineItemDiscountScope.LineItem, + }, + }, + }, + IdempotencyKey = "12ae1696-z1e3-4328-af6d-f1e04d947gd4", + }, + AskForShippingAddress = true, + MerchantSupportEmail = "merchant+support@website.com", + PrePopulateBuyerEmail = "example@email.com", + PrePopulateShippingAddress = new Address + { + AddressLine1 = "1455 Market St.", + AddressLine2 = "Suite 600", + Locality = "San Francisco", + AdministrativeDistrictLevel1 = "CA", + PostalCode = "94103", + Country = Country.Us, + FirstName = "Jane", + LastName = "Doe", + }, + RedirectUrl = "https://merchant.website.com/order-confirm", + AdditionalRecipients = new List() + { + new ChargeRequestAdditionalRecipient + { + LocationId = "057P5VYJ4A5X1", + Description = "Application fees", + AmountMoney = new Money { Amount = 60, Currency = Currency.Usd }, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CreateTest.cs b/src/Square.Test/Unit/MockServer/Locations/CreateTest.cs new file mode 100644 index 00000000..84684b9d --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CreateTest.cs @@ -0,0 +1,141 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "location": { + "name": "Midtown", + "address": { + "address_line_1": "1234 Peachtree St. NE", + "locality": "Atlanta", + "administrative_district_level_1": "GA", + "postal_code": "30309" + }, + "description": "Midtown Atlanta store" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "location": { + "id": "3Z4V4WHQK64X9", + "name": "Midtown", + "address": { + "address_line_1": "1234 Peachtree St. NE", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "Atlanta", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "GA", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "30309", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "timezone": "America/New_York", + "capabilities": [ + "CREDIT_CARD_PROCESSING" + ], + "status": "ACTIVE", + "created_at": "2022-02-19T17:58:25.000Z", + "merchant_id": "3MYCJG5GVYQ8Q", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "phone_number": "phone_number", + "business_name": "Jet Fuel Coffee", + "type": "PHYSICAL", + "website_url": "website_url", + "business_hours": { + "periods": [ + {} + ] + }, + "business_email": "business_email", + "description": "Midtown Atlanta store", + "twitter_username": "twitter_username", + "instagram_username": "instagram_username", + "facebook_url": "facebook_url", + "coordinates": { + "latitude": 33.7889, + "longitude": -84.3841 + }, + "logo_url": "logo_url", + "pos_background_url": "pos_background_url", + "mcc": "7299", + "full_format_logo_url": "full_format_logo_url", + "tax_ids": { + "eu_vat": "eu_vat", + "fr_siret": "fr_siret", + "fr_naf": "fr_naf", + "es_nif": "es_nif", + "jp_qii": "jp_qii" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CreateAsync( + new CreateLocationRequest + { + Location = new Location + { + Name = "Midtown", + Address = new Address + { + AddressLine1 = "1234 Peachtree St. NE", + Locality = "Atlanta", + AdministrativeDistrictLevel1 = "GA", + PostalCode = "30309", + }, + Description = "Midtown Atlanta store", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/CreateTest.cs new file mode 100644 index 00000000..be476a16 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/CreateTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributeDefinitions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "key": "bestseller", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Bestseller", + "description": "Bestselling item at location", + "visibility": "VISIBILITY_READ_WRITE_VALUES" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "bestseller", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Bestseller", + "description": "Bestselling item at location", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-12-02T19:06:36.559Z", + "created_at": "2022-12-02T19:06:36.559Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attribute-definitions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributeDefinitions.CreateAsync( + new CreateLocationCustomAttributeDefinitionRequest + { + CustomAttributeDefinition = new CustomAttributeDefinition + { + Key = "bestseller", + Schema = new Dictionary() + { + { + "$ref", + "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + }, + Name = "Bestseller", + Description = "Bestselling item at location", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadWriteValues, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/DeleteTest.cs new file mode 100644 index 00000000..b2d8223e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/DeleteTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributeDefinitions; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attribute-definitions/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributeDefinitions.DeleteAsync( + new Square.Locations.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/GetTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/GetTest.cs new file mode 100644 index 00000000..8a1423a1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/GetTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributeDefinitions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "bestseller", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Bestseller", + "description": "Bestselling item at location", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-12-02T19:06:36.559Z", + "created_at": "2022-12-02T19:06:36.559Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attribute-definitions/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributeDefinitions.GetAsync( + new Square.Locations.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/ListTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/ListTest.cs new file mode 100644 index 00000000..0680a3b3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/ListTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributeDefinitions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definitions": [ + { + "key": "phone-number", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.PhoneNumber" + }, + "name": "phone number", + "description": "Location's phone number", + "visibility": "VISIBILITY_READ_ONLY", + "version": 1, + "updated_at": "2022-12-02T19:50:21.832Z", + "created_at": "2022-12-02T19:50:21.832Z" + }, + { + "key": "bestseller", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Bestseller", + "description": "Bestselling item at location", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 4, + "updated_at": "2022-12-03T10:17:52.341Z", + "created_at": "2022-12-02T19:06:36.559Z" + } + ], + "cursor": "ImfNzWVSiAYyiAR4gEcxDJ75KZAOSjX8H2BVHUTR0ofCtp4SdYvrUKbwYY2aCH2WqZ2FsfAuylEVUlTfaINg3ecIlFpP9Y5Ie66w9NSg9nqdI5fCJ6qdH2s0za5m2plFonsjIuFaoN89j78ROUwuSOzD6mFZPcJHhJ0CxEKc0SBH", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attribute-definitions") + .WithParam("visibility_filter", "ALL") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Locations.CustomAttributeDefinitions.ListAsync( + new Square.Locations.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + VisibilityFilter = VisibilityFilter.All, + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/UpdateTest.cs new file mode 100644 index 00000000..849c4cbe --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributeDefinitions/UpdateTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributeDefinitions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "bestseller", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Bestseller", + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 2, + "updated_at": "2022-12-02T19:34:10.181Z", + "created_at": "2022-12-02T19:06:36.559Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attribute-definitions/key") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributeDefinitions.UpdateAsync( + new UpdateLocationCustomAttributeDefinitionRequest + { + Key = "key", + CustomAttributeDefinition = new CustomAttributeDefinition + { + Description = "Update the description as desired.", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadOnly, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchDeleteTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchDeleteTest.cs new file mode 100644 index 00000000..bc2f95e0 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchDeleteTest.cs @@ -0,0 +1,130 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributes; + +[TestFixture] +public class BatchDeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "id1": { + "key": "bestseller" + }, + "id2": { + "key": "bestseller" + }, + "id3": { + "key": "phone-number" + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "location_id": "L0TBCBTB7P8RQ", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "location_id": "L9XMD04V3STJX", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id3": { + "location_id": "L0TBCBTB7P8RQ", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attributes/bulk-delete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributes.BatchDeleteAsync( + new BulkDeleteLocationCustomAttributesRequest + { + Values = new Dictionary< + string, + BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest + >() + { + { + "id1", + new BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest + { + Key = "bestseller", + } + }, + { + "id2", + new BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest + { + Key = "bestseller", + } + }, + { + "id3", + new BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest + { + Key = "phone-number", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchUpsertTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchUpsertTest.cs new file mode 100644 index 00000000..f2f25636 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/BatchUpsertTest.cs @@ -0,0 +1,181 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributes; + +[TestFixture] +public class BatchUpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "id1": { + "location_id": "L0TBCBTB7P8RQ", + "custom_attribute": { + "key": "bestseller", + "value": "hot cocoa" + } + }, + "id2": { + "location_id": "L9XMD04V3STJX", + "custom_attribute": { + "key": "bestseller", + "value": "berry smoothie" + } + }, + "id3": { + "location_id": "L0TBCBTB7P8RQ", + "custom_attribute": { + "key": "phone-number", + "value": "+12223334444" + } + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "location_id": "L0TBCBTB7P8RQ", + "custom_attribute": { + "key": "bestseller", + "value": "hot cocoa", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2023-01-09T19:21:04.551Z", + "created_at": "2023-01-09T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "location_id": "L9XMD04V3STJX", + "custom_attribute": { + "key": "bestseller", + "value": "berry smoothie", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2023-01-09T19:21:04.551Z", + "created_at": "2023-01-09T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id3": { + "location_id": "L0TBCBTB7P8RQ", + "custom_attribute": { + "key": "phone-number", + "value": "+12239903892", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2023-01-09T19:21:04.563Z", + "created_at": "2023-01-09T19:04:57.985Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/custom-attributes/bulk-upsert") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributes.BatchUpsertAsync( + new BulkUpsertLocationCustomAttributesRequest + { + Values = new Dictionary< + string, + BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest + >() + { + { + "id1", + new BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest + { + LocationId = "L0TBCBTB7P8RQ", + CustomAttribute = new CustomAttribute + { + Key = "bestseller", + Value = "hot cocoa", + }, + } + }, + { + "id2", + new BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest + { + LocationId = "L9XMD04V3STJX", + CustomAttribute = new CustomAttribute + { + Key = "bestseller", + Value = "berry smoothie", + }, + } + }, + { + "id3", + new BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest + { + LocationId = "L0TBCBTB7P8RQ", + CustomAttribute = new CustomAttribute + { + Key = "phone-number", + Value = "+12223334444", + }, + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/DeleteTest.cs new file mode 100644 index 00000000..73e28af8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/DeleteTest.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributes; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/custom-attributes/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributes.DeleteAsync( + new Square.Locations.CustomAttributes.DeleteCustomAttributesRequest + { + LocationId = "location_id", + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/GetTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/GetTest.cs new file mode 100644 index 00000000..ebcd1f3a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/GetTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute": { + "key": "bestseller", + "value": "hot cocoa", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2023-01-09T19:21:04.551Z", + "created_at": "2023-01-09T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/custom-attributes/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributes.GetAsync( + new Square.Locations.CustomAttributes.GetCustomAttributesRequest + { + LocationId = "location_id", + Key = "key", + WithDefinition = true, + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/ListTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/ListTest.cs new file mode 100644 index 00000000..8329c50e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/ListTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attributes": [ + { + "key": "phone-number", + "value": "+12223334444", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-12-12T18:13:03.745Z", + "created_at": "2022-12-12T18:13:03.745Z" + }, + { + "key": "bestseller", + "value": "hot cocoa", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-12-12T19:27:57.975Z", + "created_at": "2022-12-12T19:27:57.975Z" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/custom-attributes") + .WithParam("visibility_filter", "ALL") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Locations.CustomAttributes.ListAsync( + new Square.Locations.CustomAttributes.ListCustomAttributesRequest + { + LocationId = "location_id", + VisibilityFilter = VisibilityFilter.All, + Limit = 1, + Cursor = "cursor", + WithDefinitions = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/UpsertTest.cs new file mode 100644 index 00000000..665be7cb --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/CustomAttributes/UpsertTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.CustomAttributes; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute": { + "value": "hot cocoa" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute": { + "key": "bestseller", + "value": "hot cocoa", + "version": 2, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2023-01-09T19:21:04.551Z", + "created_at": "2023-01-09T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/custom-attributes/key") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.CustomAttributes.UpsertAsync( + new UpsertLocationCustomAttributeRequest + { + LocationId = "location_id", + Key = "key", + CustomAttribute = new CustomAttribute { Value = "hot cocoa" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/GetTest.cs b/src/Square.Test/Unit/MockServer/Locations/GetTest.cs new file mode 100644 index 00000000..9d480732 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/GetTest.cs @@ -0,0 +1,110 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "location": { + "id": "18YC4JDH91E1H", + "name": "Grant Park", + "address": { + "address_line_1": "123 Main St", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "San Francisco", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "CA", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "94114", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "timezone": "America/Los_Angeles", + "capabilities": [ + "CREDIT_CARD_PROCESSING" + ], + "status": "ACTIVE", + "created_at": "2016-09-19T17:33:12.000Z", + "merchant_id": "3MYCJG5GVYQ8Q", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "phone_number": "+1 650-354-7217", + "business_name": "Jet Fuel Coffee", + "type": "PHYSICAL", + "website_url": "website_url", + "business_hours": { + "periods": [ + {} + ] + }, + "business_email": "business_email", + "description": "description", + "twitter_username": "twitter_username", + "instagram_username": "instagram_username", + "facebook_url": "facebook_url", + "coordinates": { + "latitude": 1.1, + "longitude": 1.1 + }, + "logo_url": "logo_url", + "pos_background_url": "pos_background_url", + "mcc": "mcc", + "full_format_logo_url": "full_format_logo_url", + "tax_ids": { + "eu_vat": "eu_vat", + "fr_siret": "fr_siret", + "fr_naf": "fr_naf", + "es_nif": "es_nif", + "jp_qii": "jp_qii" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.GetAsync( + new GetLocationsRequest { LocationId = "location_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/ListTest.cs b/src/Square.Test/Unit/MockServer/Locations/ListTest.cs new file mode 100644 index 00000000..70f0a839 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/ListTest.cs @@ -0,0 +1,116 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "locations": [ + { + "id": "18YC4JDH91E1H", + "name": "Grant Park", + "address": { + "address_line_1": "123 Main St", + "locality": "San Francisco", + "administrative_district_level_1": "CA", + "postal_code": "94114", + "country": "US" + }, + "timezone": "America/Los_Angeles", + "capabilities": [ + "CREDIT_CARD_PROCESSING" + ], + "status": "ACTIVE", + "created_at": "2016-09-19T17:33:12.000Z", + "merchant_id": "3MYCJG5GVYQ8Q", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "phone_number": "+1 650-354-7217", + "business_name": "Jet Fuel Coffee", + "type": "PHYSICAL", + "website_url": "website_url", + "business_email": "business_email", + "description": "description", + "twitter_username": "twitter_username", + "instagram_username": "instagram_username", + "facebook_url": "facebook_url", + "logo_url": "logo_url", + "pos_background_url": "pos_background_url", + "mcc": "mcc", + "full_format_logo_url": "full_format_logo_url" + }, + { + "id": "3Z4V4WHQK64X9", + "name": "Midtown", + "address": { + "address_line_1": "1234 Peachtree St. NE", + "locality": "Atlanta", + "administrative_district_level_1": "GA", + "postal_code": "30309" + }, + "timezone": "America/New_York", + "capabilities": [ + "CREDIT_CARD_PROCESSING" + ], + "status": "ACTIVE", + "created_at": "2022-02-19T17:58:25.000Z", + "merchant_id": "3MYCJG5GVYQ8Q", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "phone_number": "phone_number", + "business_name": "Jet Fuel Coffee", + "type": "PHYSICAL", + "website_url": "website_url", + "business_email": "business_email", + "description": "Midtown Atlanta store", + "twitter_username": "twitter_username", + "instagram_username": "instagram_username", + "facebook_url": "facebook_url", + "coordinates": { + "latitude": 33.7889, + "longitude": -84.3841 + }, + "logo_url": "logo_url", + "pos_background_url": "pos_background_url", + "mcc": "7299", + "full_format_logo_url": "full_format_logo_url" + } + ] + } + """; + + Server + .Given(WireMock.RequestBuilders.Request.Create().WithPath("/v2/locations").UsingGet()) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.ListAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/Transactions/CaptureTest.cs b/src/Square.Test/Unit/MockServer/Locations/Transactions/CaptureTest.cs new file mode 100644 index 00000000..79c820f7 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/Transactions/CaptureTest.cs @@ -0,0 +1,56 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.Transactions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.Transactions; + +[TestFixture] +public class CaptureTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/transactions/transaction_id/capture") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.Transactions.CaptureAsync( + new CaptureTransactionsRequest + { + LocationId = "location_id", + TransactionId = "transaction_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/Transactions/GetTest.cs b/src/Square.Test/Unit/MockServer/Locations/Transactions/GetTest.cs new file mode 100644 index 00000000..77fc9590 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/Transactions/GetTest.cs @@ -0,0 +1,125 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.Transactions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.Transactions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "transaction": { + "id": "KnL67ZIwXCPtzOrqj0HrkxMF", + "location_id": "18YC4JDH91E1H", + "created_at": "2016-03-10T22:57:56.000Z", + "tenders": [ + { + "id": "MtZRYYdDrYNQbOvV7nbuBvMF", + "location_id": "18YC4JDH91E1H", + "transaction_id": "KnL67ZIwXCPtzOrqj0HrkxMF", + "created_at": "2016-03-10T22:57:56.000Z", + "note": "some optional note", + "amount_money": { + "amount": 5000, + "currency": "USD" + }, + "processing_fee_money": { + "amount": 138, + "currency": "USD" + }, + "type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111" + }, + "entry_method": "KEYED" + }, + "additional_recipients": [ + { + "location_id": "057P5VYJ4A5X1", + "description": "Application fees", + "amount_money": { + "amount": 20, + "currency": "USD" + } + } + ] + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "reference_id": "some optional reference id", + "product": "EXTERNAL_API", + "client_id": "client_id", + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "order_id": "order_id" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/transactions/transaction_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.Transactions.GetAsync( + new GetTransactionsRequest + { + LocationId = "location_id", + TransactionId = "transaction_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/Transactions/ListTest.cs b/src/Square.Test/Unit/MockServer/Locations/Transactions/ListTest.cs new file mode 100644 index 00000000..5bd18c1a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/Transactions/ListTest.cs @@ -0,0 +1,140 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.Transactions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.Transactions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "transactions": [ + { + "id": "KnL67ZIwXCPtzOrqj0HrkxMF", + "location_id": "18YC4JDH91E1H", + "created_at": "2016-01-20T22:57:56.000Z", + "tenders": [ + { + "id": "MtZRYYdDrYNQbOvV7nbuBvMF", + "location_id": "18YC4JDH91E1H", + "transaction_id": "KnL67ZIwXCPtzOrqj0HrkxMF", + "created_at": "2016-01-20T22:57:56.000Z", + "note": "some optional note", + "amount_money": { + "amount": 5000, + "currency": "USD" + }, + "processing_fee_money": { + "amount": 138, + "currency": "USD" + }, + "type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111" + }, + "entry_method": "KEYED" + }, + "additional_recipients": [ + { + "location_id": "057P5VYJ4A5X1", + "description": "Application fees", + "amount_money": { + "amount": 20, + "currency": "USD" + } + } + ] + } + ], + "refunds": [ + { + "id": "7a5RcVI0CxbOcJ2wMOkE", + "location_id": "18YC4JDH91E1H", + "transaction_id": "KnL67ZIwXCPtzOrqj0HrkxMF", + "tender_id": "MtZRYYdDrYNQbOvV7nbuBvMF", + "created_at": "2016-01-20T22:59:20.000Z", + "reason": "some reason why", + "amount_money": { + "amount": 5000, + "currency": "USD" + }, + "status": "APPROVED", + "processing_fee_money": { + "amount": 138, + "currency": "USD" + }, + "additional_recipients": [ + { + "location_id": "057P5VYJ4A5X1", + "description": "Application fees", + "amount_money": { + "amount": 100, + "currency": "USD" + } + } + ] + } + ], + "reference_id": "some optional reference id", + "product": "EXTERNAL_API", + "client_id": "client_id", + "order_id": "order_id" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/transactions") + .WithParam("begin_time", "begin_time") + .WithParam("end_time", "end_time") + .WithParam("sort_order", "DESC") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.Transactions.ListAsync( + new ListTransactionsRequest + { + LocationId = "location_id", + BeginTime = "begin_time", + EndTime = "end_time", + SortOrder = SortOrder.Desc, + Cursor = "cursor", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/Transactions/VoidTest.cs b/src/Square.Test/Unit/MockServer/Locations/Transactions/VoidTest.cs new file mode 100644 index 00000000..1d869662 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/Transactions/VoidTest.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations.Transactions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations.Transactions; + +[TestFixture] +public class VoidTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id/transactions/transaction_id/void") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.Transactions.VoidAsync( + new VoidTransactionsRequest + { + LocationId = "location_id", + TransactionId = "transaction_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Locations/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Locations/UpdateTest.cs new file mode 100644 index 00000000..eec2ca50 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Locations/UpdateTest.cs @@ -0,0 +1,184 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Locations; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Locations; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "location": { + "business_hours": { + "periods": [ + { + "day_of_week": "FRI", + "start_local_time": "07:00", + "end_local_time": "18:00" + }, + { + "day_of_week": "SAT", + "start_local_time": "07:00", + "end_local_time": "18:00" + }, + { + "day_of_week": "SUN", + "start_local_time": "09:00", + "end_local_time": "15:00" + } + ] + }, + "description": "Midtown Atlanta store - Open weekends" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "location": { + "id": "3Z4V4WHQK64X9", + "name": "Midtown", + "address": { + "address_line_1": "1234 Peachtree St. NE", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "Atlanta", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "GA", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "30309", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "timezone": "America/New_York", + "capabilities": [ + "CREDIT_CARD_PROCESSING" + ], + "status": "ACTIVE", + "created_at": "2022-02-19T17:58:25.000Z", + "merchant_id": "3MYCJG5GVYQ8Q", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "phone_number": "phone_number", + "business_name": "Jet Fuel Coffee", + "type": "PHYSICAL", + "website_url": "website_url", + "business_hours": { + "periods": [ + { + "day_of_week": "FRI", + "start_local_time": "07:00", + "end_local_time": "18:00" + }, + { + "day_of_week": "SAT", + "start_local_time": "07:00", + "end_local_time": "18:00" + }, + { + "day_of_week": "SUN", + "start_local_time": "09:00", + "end_local_time": "15:00" + } + ] + }, + "business_email": "business_email", + "description": "Midtown Atlanta store - Open weekends", + "twitter_username": "twitter_username", + "instagram_username": "instagram_username", + "facebook_url": "facebook_url", + "coordinates": { + "latitude": 33.7889, + "longitude": -84.3841 + }, + "logo_url": "logo_url", + "pos_background_url": "pos_background_url", + "mcc": "7299", + "full_format_logo_url": "full_format_logo_url", + "tax_ids": { + "eu_vat": "eu_vat", + "fr_siret": "fr_siret", + "fr_naf": "fr_naf", + "es_nif": "es_nif", + "jp_qii": "jp_qii" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/locations/location_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Locations.UpdateAsync( + new UpdateLocationRequest + { + LocationId = "location_id", + Location = new Location + { + BusinessHours = new BusinessHours + { + Periods = new List() + { + new BusinessHoursPeriod + { + DayOfWeek = Square.DayOfWeek.Fri, + StartLocalTime = "07:00", + EndLocalTime = "18:00", + }, + new BusinessHoursPeriod + { + DayOfWeek = Square.DayOfWeek.Sat, + StartLocalTime = "07:00", + EndLocalTime = "18:00", + }, + new BusinessHoursPeriod + { + DayOfWeek = Square.DayOfWeek.Sun, + StartLocalTime = "09:00", + EndLocalTime = "15:00", + }, + }, + }, + Description = "Midtown Atlanta store - Open weekends", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Accounts/AccumulatePointsTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/AccumulatePointsTest.cs new file mode 100644 index 00000000..50c52b96 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/AccumulatePointsTest.cs @@ -0,0 +1,144 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Accounts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Accounts; + +[TestFixture] +public class AccumulatePointsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "accumulate_points": { + "order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY" + }, + "idempotency_key": "58b90739-c3e8-4b11-85f7-e636d48d72cb", + "location_id": "P034NEENMD09F" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "event": { + "id": "id", + "type": "ACCUMULATE_POINTS", + "created_at": "created_at", + "accumulate_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1, + "order_id": "order_id" + }, + "create_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "points": 1 + }, + "redeem_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "order_id": "order_id" + }, + "delete_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "points": 1 + }, + "adjust_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1, + "reason": "reason" + }, + "loyalty_account_id": "loyalty_account_id", + "location_id": "location_id", + "source": "SQUARE", + "expire_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1 + }, + "other_event": { + "loyalty_program_id": "loyalty_program_id", + "points": 1 + }, + "accumulate_promotion_points": { + "loyalty_program_id": "loyalty_program_id", + "loyalty_promotion_id": "loyalty_promotion_id", + "points": 1, + "order_id": "order_id" + } + }, + "events": [ + { + "id": "ee46aafd-1af6-3695-a385-276e2ef0be26", + "type": "ACCUMULATE_POINTS", + "created_at": "2020-05-08T21:41:12.000Z", + "accumulate_points": { + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "points": 6, + "order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY" + }, + "adjust_points": { + "points": 1 + }, + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "location_id": "P034NEENMD09F", + "source": "LOYALTY_API", + "expire_points": { + "points": 1 + }, + "other_event": { + "points": 1 + } + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/accounts/account_id/accumulate") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Accounts.AccumulatePointsAsync( + new AccumulateLoyaltyPointsRequest + { + AccountId = "account_id", + AccumulatePoints = new LoyaltyEventAccumulatePoints + { + OrderId = "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY", + }, + IdempotencyKey = "58b90739-c3e8-4b11-85f7-e636d48d72cb", + LocationId = "P034NEENMD09F", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Accounts/AdjustTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/AdjustTest.cs new file mode 100644 index 00000000..9157a05c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/AdjustTest.cs @@ -0,0 +1,120 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Accounts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Accounts; + +[TestFixture] +public class AdjustTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "bc29a517-3dc9-450e-aa76-fae39ee849d1", + "adjust_points": { + "points": 10, + "reason": "Complimentary points" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "event": { + "id": "613a6fca-8d67-39d0-bad2-3b4bc45c8637", + "type": "ADJUST_POINTS", + "created_at": "2020-05-08T21:42:32.000Z", + "accumulate_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1, + "order_id": "order_id" + }, + "create_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "points": 1 + }, + "redeem_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "order_id": "order_id" + }, + "delete_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "points": 1 + }, + "adjust_points": { + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "points": 10, + "reason": "Complimentary points" + }, + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "location_id": "location_id", + "source": "LOYALTY_API", + "expire_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1 + }, + "other_event": { + "loyalty_program_id": "loyalty_program_id", + "points": 1 + }, + "accumulate_promotion_points": { + "loyalty_program_id": "loyalty_program_id", + "loyalty_promotion_id": "loyalty_promotion_id", + "points": 1, + "order_id": "order_id" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/accounts/account_id/adjust") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Accounts.AdjustAsync( + new AdjustLoyaltyPointsRequest + { + AccountId = "account_id", + IdempotencyKey = "bc29a517-3dc9-450e-aa76-fae39ee849d1", + AdjustPoints = new LoyaltyEventAdjustPoints + { + Points = 10, + Reason = "Complimentary points", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Accounts/CreateTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/CreateTest.cs new file mode 100644 index 00000000..3e2ec0f1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/CreateTest.cs @@ -0,0 +1,95 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Accounts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Accounts; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "loyalty_account": { + "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "mapping": { + "phone_number": "+14155551234" + } + }, + "idempotency_key": "ec78c477-b1c3-4899-a209-a4e71337c996" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_account": { + "id": "79b807d2-d786-46a9-933b-918028d7a8c5", + "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "balance": 0, + "lifetime_points": 0, + "customer_id": "QPTXM8PQNX3Q726ZYHPMNP46XC", + "enrolled_at": "enrolled_at", + "created_at": "2020-05-08T21:44:32.000Z", + "updated_at": "2020-05-08T21:44:32.000Z", + "mapping": { + "id": "66aaab3f-da99-49ed-8b19-b87f851c844f", + "created_at": "2020-05-08T21:44:32.000Z", + "phone_number": "+14155551234" + }, + "expiring_point_deadlines": [ + { + "points": 1, + "expires_at": "expires_at" + } + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/accounts") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Accounts.CreateAsync( + new CreateLoyaltyAccountRequest + { + LoyaltyAccount = new LoyaltyAccount + { + ProgramId = "d619f755-2d17-41f3-990d-c04ecedd64dd", + Mapping = new LoyaltyAccountMapping { PhoneNumber = "+14155551234" }, + }, + IdempotencyKey = "ec78c477-b1c3-4899-a209-a4e71337c996", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Accounts/GetTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/GetTest.cs new file mode 100644 index 00000000..457a59b8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/GetTest.cs @@ -0,0 +1,73 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Accounts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Accounts; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_account": { + "id": "79b807d2-d786-46a9-933b-918028d7a8c5", + "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "balance": 10, + "lifetime_points": 20, + "customer_id": "Q8002FAM9V1EZ0ADB2T5609X6NET1H0", + "enrolled_at": "enrolled_at", + "created_at": "2020-05-08T21:44:32.000Z", + "updated_at": "2020-05-08T21:44:32.000Z", + "mapping": { + "id": "66aaab3f-da99-49ed-8b19-b87f851c844f", + "created_at": "2020-05-08T21:44:32.000Z", + "phone_number": "+14155551234" + }, + "expiring_point_deadlines": [ + { + "points": 1, + "expires_at": "expires_at" + } + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/accounts/account_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Accounts.GetAsync( + new GetAccountsRequest { AccountId = "account_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Accounts/SearchTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/SearchTest.cs new file mode 100644 index 00000000..45bd0ac3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Accounts/SearchTest.cs @@ -0,0 +1,101 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Accounts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Accounts; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "mappings": [ + { + "phone_number": "+14155551234" + } + ] + }, + "limit": 10 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_accounts": [ + { + "id": "79b807d2-d786-46a9-933b-918028d7a8c5", + "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "balance": 10, + "lifetime_points": 20, + "customer_id": "Q8002FAM9V1EZ0ADB2T5609X6NET1H0", + "enrolled_at": "enrolled_at", + "created_at": "2020-05-08T21:44:32.000Z", + "updated_at": "2020-05-08T21:44:32.000Z", + "mapping": { + "id": "66aaab3f-da99-49ed-8b19-b87f851c844f", + "created_at": "2020-05-08T21:44:32.000Z", + "phone_number": "+14155551234" + }, + "expiring_point_deadlines": [ + { + "points": 1, + "expires_at": "expires_at" + } + ] + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/accounts/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Accounts.SearchAsync( + new SearchLoyaltyAccountsRequest + { + Query = new SearchLoyaltyAccountsRequestLoyaltyAccountQuery + { + Mappings = new List() + { + new LoyaltyAccountMapping { PhoneNumber = "+14155551234" }, + }, + }, + Limit = 10, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/CalculateTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/CalculateTest.cs new file mode 100644 index 00000000..4d7a8f6e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/CalculateTest.cs @@ -0,0 +1,68 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Programs; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs; + +[TestFixture] +public class CalculateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY", + "loyalty_account_id": "79b807d2-d786-46a9-933b-918028d7a8c5" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "points": 6, + "promotion_points": 12 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs/program_id/calculate") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Programs.CalculateAsync( + new CalculateLoyaltyPointsRequest + { + ProgramId = "program_id", + OrderId = "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY", + LoyaltyAccountId = "79b807d2-d786-46a9-933b-918028d7a8c5", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/GetTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/GetTest.cs new file mode 100644 index 00000000..7e4bb0f5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/GetTest.cs @@ -0,0 +1,101 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Programs; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "program": { + "id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "status": "ACTIVE", + "reward_tiers": [ + { + "id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "name": "10% off entire sale", + "created_at": "2020-04-20T16:55:11.000Z", + "pricing_rule_reference": { + "object_id": "74C4JSHESNLTB2A7ITO5HO6F", + "catalog_version": 1000000 + } + } + ], + "expiration_policy": { + "expiration_duration": "expiration_duration" + }, + "terminology": { + "one": "Point", + "other": "Points" + }, + "location_ids": [ + "P034NEENMD09F" + ], + "created_at": "2020-04-20T16:55:11.000Z", + "updated_at": "2020-05-01T02:00:02.000Z", + "accrual_rules": [ + { + "accrual_type": "SPEND", + "points": 1, + "spend_data": { + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "excluded_category_ids": [ + "7ZERJKO5PVYXCVUHV2JCZ2UG", + "FQKAOJE5C4FIMF5A2URMLW6V" + ], + "excluded_item_variation_ids": [ + "CBZXBUVVTYUBZGQO44RHMR6B", + "EDILT24Z2NISEXDKGY6HP7XV" + ], + "tax_mode": "BEFORE_TAX" + } + } + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs/program_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Programs.GetAsync( + new GetProgramsRequest { ProgramId = "program_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/ListTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/ListTest.cs new file mode 100644 index 00000000..535263ce --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/ListTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "programs": [ + { + "id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "status": "ACTIVE", + "reward_tiers": [ + { + "id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "name": "10% off entire sale", + "created_at": "2020-04-20T16:55:11.000Z", + "pricing_rule_reference": { + "object_id": "74C4JSHESNLTB2A7ITO5HO6F", + "catalog_version": 1000000 + } + } + ], + "expiration_policy": { + "expiration_duration": "expiration_duration" + }, + "terminology": { + "one": "Point", + "other": "Points" + }, + "location_ids": [ + "P034NEENMD09F" + ], + "created_at": "2020-04-20T16:55:11.000Z", + "updated_at": "2020-05-01T02:00:02.000Z", + "accrual_rules": [ + { + "accrual_type": "SPEND", + "points": 1, + "spend_data": { + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "excluded_category_ids": [ + "7ZERJKO5PVYXCVUHV2JCZ2UG", + "FQKAOJE5C4FIMF5A2URMLW6V" + ], + "excluded_item_variation_ids": [ + "CBZXBUVVTYUBZGQO44RHMR6B", + "EDILT24Z2NISEXDKGY6HP7XV" + ], + "tax_mode": "BEFORE_TAX" + } + } + ] + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Programs.ListAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CancelTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CancelTest.cs new file mode 100644 index 00000000..0d3120d5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CancelTest.cs @@ -0,0 +1,92 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Programs.Promotions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs.Promotions; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_promotion": { + "id": "loypromo_f0f9b849-725e-378d-b810-511237e07b67", + "name": "Tuesday Happy Hour Promo", + "incentive": { + "type": "POINTS_MULTIPLIER", + "points_multiplier_data": { + "points_multiplier": 3, + "multiplier": "3.000" + }, + "points_addition_data": { + "points_addition": 1 + } + }, + "available_time": { + "start_date": "2022-08-16", + "end_date": "end_date", + "time_periods": [ + "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT" + ] + }, + "trigger_limit": { + "times": 1, + "interval": "DAY" + }, + "status": "CANCELED", + "created_at": "2022-08-16T08:38:54.000Z", + "canceled_at": "2022-08-17T12:42:49.000Z", + "updated_at": "2022-08-17T12:42:49.000Z", + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "minimum_spend_amount_money": { + "amount": 2000, + "currency": "USD" + }, + "qualifying_item_variation_ids": [ + "qualifying_item_variation_ids" + ], + "qualifying_category_ids": [ + "XTQPYLR3IIU9C44VRCB3XD12" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs/program_id/promotions/promotion_id/cancel") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Programs.Promotions.CancelAsync( + new CancelPromotionsRequest { ProgramId = "program_id", PromotionId = "promotion_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CreateTest.cs new file mode 100644 index 00000000..4a400410 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/CreateTest.cs @@ -0,0 +1,155 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Programs.Promotions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs.Promotions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "loyalty_promotion": { + "name": "Tuesday Happy Hour Promo", + "incentive": { + "type": "POINTS_MULTIPLIER", + "points_multiplier_data": { + "multiplier": "3.0" + } + }, + "available_time": { + "time_periods": [ + "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT" + ] + }, + "trigger_limit": { + "times": 1, + "interval": "DAY" + }, + "minimum_spend_amount_money": { + "amount": 2000, + "currency": "USD" + }, + "qualifying_category_ids": [ + "XTQPYLR3IIU9C44VRCB3XD12" + ] + }, + "idempotency_key": "ec78c477-b1c3-4899-a209-a4e71337c996" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_promotion": { + "id": "loypromo_f0f9b849-725e-378d-b810-511237e07b67", + "name": "Tuesday Happy Hour Promo", + "incentive": { + "type": "POINTS_MULTIPLIER", + "points_multiplier_data": { + "points_multiplier": 3, + "multiplier": "3.000" + }, + "points_addition_data": { + "points_addition": 1 + } + }, + "available_time": { + "start_date": "2022-08-16", + "end_date": "end_date", + "time_periods": [ + "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT" + ] + }, + "trigger_limit": { + "times": 1, + "interval": "DAY" + }, + "status": "ACTIVE", + "created_at": "2022-08-16T08:38:54.000Z", + "canceled_at": "canceled_at", + "updated_at": "2022-08-16T08:38:54.000Z", + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "minimum_spend_amount_money": { + "amount": 2000, + "currency": "USD" + }, + "qualifying_item_variation_ids": [ + "qualifying_item_variation_ids" + ], + "qualifying_category_ids": [ + "XTQPYLR3IIU9C44VRCB3XD12" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs/program_id/promotions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Programs.Promotions.CreateAsync( + new CreateLoyaltyPromotionRequest + { + ProgramId = "program_id", + LoyaltyPromotion = new LoyaltyPromotion + { + Name = "Tuesday Happy Hour Promo", + Incentive = new LoyaltyPromotionIncentive + { + Type = LoyaltyPromotionIncentiveType.PointsMultiplier, + PointsMultiplierData = new LoyaltyPromotionIncentivePointsMultiplierData + { + Multiplier = "3.0", + }, + }, + AvailableTime = new LoyaltyPromotionAvailableTimeData + { + TimePeriods = new List() + { + "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT", + }, + }, + TriggerLimit = new LoyaltyPromotionTriggerLimit + { + Times = 1, + Interval = LoyaltyPromotionTriggerLimitInterval.Day, + }, + MinimumSpendAmountMoney = new Money { Amount = 2000, Currency = Currency.Usd }, + QualifyingCategoryIds = new List() { "XTQPYLR3IIU9C44VRCB3XD12" }, + }, + IdempotencyKey = "ec78c477-b1c3-4899-a209-a4e71337c996", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/GetTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/GetTest.cs new file mode 100644 index 00000000..e44edd21 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/GetTest.cs @@ -0,0 +1,93 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Programs.Promotions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs.Promotions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_promotion": { + "id": "loypromo_f0f9b849-725e-378d-b810-511237e07b67", + "name": "Tuesday Happy Hour Promo", + "incentive": { + "type": "POINTS_MULTIPLIER", + "points_multiplier_data": { + "points_multiplier": 3, + "multiplier": "3.000" + }, + "points_addition_data": { + "points_addition": 1 + } + }, + "available_time": { + "start_date": "2022-08-16", + "end_date": "end_date", + "time_periods": [ + "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT" + ] + }, + "trigger_limit": { + "times": 1, + "interval": "DAY" + }, + "status": "ACTIVE", + "created_at": "2022-08-16T08:38:54.000Z", + "canceled_at": "canceled_at", + "updated_at": "2022-08-16T08:38:54.000Z", + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "minimum_spend_amount_money": { + "amount": 2000, + "currency": "USD" + }, + "qualifying_item_variation_ids": [ + "CJ3RYL56ITAKMD4VRCM7XERS", + "AT3RYLR3TUA9C34VRCB7X5RR" + ], + "qualifying_category_ids": [ + "qualifying_category_ids" + ] + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs/program_id/promotions/promotion_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Programs.Promotions.GetAsync( + new GetPromotionsRequest { ProgramId = "program_id", PromotionId = "promotion_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/ListTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/ListTest.cs new file mode 100644 index 00000000..b97eb70e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Programs/Promotions/ListTest.cs @@ -0,0 +1,137 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Loyalty.Programs.Promotions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Programs.Promotions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "loyalty_promotions": [ + { + "id": "loypromo_f0f9b849-725e-378d-b810-511237e07b67", + "name": "Tuesday Happy Hour Promo", + "incentive": { + "type": "POINTS_MULTIPLIER", + "points_multiplier_data": { + "points_multiplier": 3, + "multiplier": "3.000" + } + }, + "available_time": { + "start_date": "2022-08-16", + "time_periods": [ + "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT" + ] + }, + "trigger_limit": { + "times": 1, + "interval": "DAY" + }, + "status": "ACTIVE", + "created_at": "2022-08-16T08:38:54.000Z", + "canceled_at": "canceled_at", + "updated_at": "2022-08-16T08:38:54.000Z", + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "qualifying_item_variation_ids": [ + "CJ3RYL56ITAKMD4VRCM7XERS", + "AT3RYLR3TUA9C34VRCB7X5RR" + ], + "qualifying_category_ids": [ + "qualifying_category_ids" + ] + }, + { + "id": "loypromo_e696f057-2286-35ff-8108-132241328106", + "name": "July Special", + "incentive": { + "type": "POINTS_MULTIPLIER", + "points_multiplier_data": { + "points_multiplier": 2, + "multiplier": "2.000" + } + }, + "available_time": { + "start_date": "2022-07-01", + "end_date": "2022-08-01", + "time_periods": [ + "BEGIN:VEVENT\nDTSTART:20220704T090000\nDURATION:PT8H\nRRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=MO\nEND:VEVENT", + "BEGIN:VEVENT\nDTSTART:20220705T090000\nDURATION:PT8H\nRRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=TU\nEND:VEVENT", + "BEGIN:VEVENT\nDTSTART:20220706T090000\nDURATION:PT8H\nRRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=WE\nEND:VEVENT", + "BEGIN:VEVENT\nDTSTART:20220707T090000\nDURATION:PT8H\nRRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=TH\nEND:VEVENT", + "BEGIN:VEVENT\nDTSTART:20220701T090000\nDURATION:PT8H\nRRULE:FREQ=WEEKLY;UNTIL=20220801T000000;BYDAY=FR\nEND:VEVENT" + ] + }, + "trigger_limit": { + "times": 5, + "interval": "ALL_TIME" + }, + "status": "ENDED", + "created_at": "2022-06-27T15:37:38.000Z", + "canceled_at": "canceled_at", + "updated_at": "2022-06-27T15:37:38.000Z", + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "minimum_spend_amount_money": { + "amount": 2000, + "currency": "USD" + }, + "qualifying_item_variation_ids": [ + "qualifying_item_variation_ids" + ], + "qualifying_category_ids": [ + "XTQPYLR3IIU9C44VRCB3XD12" + ] + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/programs/program_id/promotions") + .WithParam("status", "ACTIVE") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Loyalty.Programs.Promotions.ListAsync( + new ListPromotionsRequest + { + ProgramId = "program_id", + Status = LoyaltyPromotionStatus.Active, + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Rewards/CreateTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/CreateTest.cs new file mode 100644 index 00000000..22eaa3c1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/CreateTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Rewards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Rewards; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "reward": { + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY" + }, + "idempotency_key": "18c2e5ea-a620-4b1f-ad60-7b167285e451" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "reward": { + "id": "a8f43ebe-2ad6-3001-bdd5-7d7c2da08943", + "status": "ISSUED", + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY", + "created_at": "2020-05-01T21:49:54.000Z", + "updated_at": "2020-05-01T21:49:54.000Z", + "redeemed_at": "redeemed_at" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/rewards") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Rewards.CreateAsync( + new CreateLoyaltyRewardRequest + { + Reward = new LoyaltyReward + { + LoyaltyAccountId = "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + RewardTierId = "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + OrderId = "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY", + }, + IdempotencyKey = "18c2e5ea-a620-4b1f-ad60-7b167285e451", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Rewards/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/DeleteTest.cs new file mode 100644 index 00000000..9e2cda7e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Rewards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Rewards; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/rewards/reward_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Rewards.DeleteAsync( + new DeleteRewardsRequest { RewardId = "reward_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Rewards/GetTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/GetTest.cs new file mode 100644 index 00000000..dd072e63 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/GetTest.cs @@ -0,0 +1,63 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Rewards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Rewards; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "reward": { + "id": "9f18ac21-233a-31c3-be77-b45840f5a810", + "status": "REDEEMED", + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "order_id": "order_id", + "created_at": "2020-05-08T21:55:42.000Z", + "updated_at": "2020-05-08T21:56:00.000Z", + "redeemed_at": "2020-05-08T21:56:00.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/rewards/reward_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Rewards.GetAsync( + new GetRewardsRequest { RewardId = "reward_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Rewards/RedeemTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/RedeemTest.cs new file mode 100644 index 00000000..c456bb68 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/RedeemTest.cs @@ -0,0 +1,113 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Rewards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Rewards; + +[TestFixture] +public class RedeemTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "98adc7f7-6963-473b-b29c-f3c9cdd7d994", + "location_id": "P034NEENMD09F" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "event": { + "id": "67377a6e-dbdc-369d-aa16-2e7ed422e71f", + "type": "REDEEM_REWARD", + "created_at": "2020-05-08T21:56:00.000Z", + "accumulate_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1, + "order_id": "order_id" + }, + "create_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "points": 1 + }, + "redeem_reward": { + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "reward_id": "9f18ac21-233a-31c3-be77-b45840f5a810", + "order_id": "order_id" + }, + "delete_reward": { + "loyalty_program_id": "loyalty_program_id", + "reward_id": "reward_id", + "points": 1 + }, + "adjust_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1, + "reason": "reason" + }, + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "location_id": "P034NEENMD09F", + "source": "LOYALTY_API", + "expire_points": { + "loyalty_program_id": "loyalty_program_id", + "points": 1 + }, + "other_event": { + "loyalty_program_id": "loyalty_program_id", + "points": 1 + }, + "accumulate_promotion_points": { + "loyalty_program_id": "loyalty_program_id", + "loyalty_promotion_id": "loyalty_promotion_id", + "points": 1, + "order_id": "order_id" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/rewards/reward_id/redeem") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Rewards.RedeemAsync( + new RedeemLoyaltyRewardRequest + { + RewardId = "reward_id", + IdempotencyKey = "98adc7f7-6963-473b-b29c-f3c9cdd7d994", + LocationId = "P034NEENMD09F", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/Rewards/SearchTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/SearchTest.cs new file mode 100644 index 00000000..ff19c700 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/Rewards/SearchTest.cs @@ -0,0 +1,117 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty.Rewards; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty.Rewards; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd" + }, + "limit": 10 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "rewards": [ + { + "id": "d03f79f4-815f-3500-b851-cc1e68a457f9", + "status": "REDEEMED", + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "order_id": "PyATxhYLfsMqpVkcKJITPydgEYfZY", + "created_at": "2020-05-08T22:00:44.000Z", + "updated_at": "2020-05-08T22:01:17.000Z", + "redeemed_at": "2020-05-08T22:01:17.000Z" + }, + { + "id": "9f18ac21-233a-31c3-be77-b45840f5a810", + "status": "REDEEMED", + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "order_id": "order_id", + "created_at": "2020-05-08T21:55:42.000Z", + "updated_at": "2020-05-08T21:56:00.000Z", + "redeemed_at": "2020-05-08T21:56:00.000Z" + }, + { + "id": "a8f43ebe-2ad6-3001-bdd5-7d7c2da08943", + "status": "DELETED", + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "order_id": "5NB69ZNh3FbsOs1ox43bh1xrli6YY", + "created_at": "2020-05-01T21:49:54.000Z", + "updated_at": "2020-05-08T21:55:10.000Z", + "redeemed_at": "redeemed_at" + }, + { + "id": "a051254c-f840-3b45-8cf1-50bcd38ff92a", + "status": "ISSUED", + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "reward_tier_id": "e1b39225-9da5-43d1-a5db-782cdd8ad94f", + "points": 10, + "order_id": "LQQ16znvi2VIUKPVhUfJefzr1eEZY", + "created_at": "2020-05-01T20:20:37.000Z", + "updated_at": "2020-05-01T20:20:40.000Z", + "redeemed_at": "redeemed_at" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/rewards/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.Rewards.SearchAsync( + new SearchLoyaltyRewardsRequest + { + Query = new SearchLoyaltyRewardsRequestLoyaltyRewardQuery + { + LoyaltyAccountId = "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + }, + Limit = 10, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Loyalty/SearchEventsTest.cs b/src/Square.Test/Unit/MockServer/Loyalty/SearchEventsTest.cs new file mode 100644 index 00000000..fd9fa3b6 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Loyalty/SearchEventsTest.cs @@ -0,0 +1,149 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Loyalty; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Loyalty; + +[TestFixture] +public class SearchEventsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "order_filter": { + "order_id": "PyATxhYLfsMqpVkcKJITPydgEYfZY" + } + } + }, + "limit": 30 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "events": [ + { + "id": "c27c8465-806e-36f2-b4b3-71f5887b5ba8", + "type": "ACCUMULATE_POINTS", + "created_at": "2020-05-08T22:01:30.000Z", + "accumulate_points": { + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "points": 5, + "order_id": "PyATxhYLfsMqpVkcKJITPydgEYfZY" + }, + "adjust_points": { + "points": 1 + }, + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "location_id": "P034NEENMD09F", + "source": "LOYALTY_API", + "expire_points": { + "points": 1 + }, + "other_event": { + "points": 1 + } + }, + { + "id": "e4a5cbc3-a4d0-3779-98e9-e578885d9430", + "type": "REDEEM_REWARD", + "created_at": "2020-05-08T22:01:15.000Z", + "redeem_reward": { + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "reward_id": "d03f79f4-815f-3500-b851-cc1e68a457f9", + "order_id": "PyATxhYLfsMqpVkcKJITPydgEYfZY" + }, + "adjust_points": { + "points": 1 + }, + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "location_id": "P034NEENMD09F", + "source": "LOYALTY_API", + "expire_points": { + "points": 1 + }, + "other_event": { + "points": 1 + } + }, + { + "id": "5e127479-0b03-3671-ab1e-15faea8b7188", + "type": "CREATE_REWARD", + "created_at": "2020-05-08T22:00:44.000Z", + "create_reward": { + "loyalty_program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd", + "reward_id": "d03f79f4-815f-3500-b851-cc1e68a457f9", + "points": -10 + }, + "adjust_points": { + "points": 1 + }, + "loyalty_account_id": "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd", + "location_id": "location_id", + "source": "LOYALTY_API", + "expire_points": { + "points": 1 + }, + "other_event": { + "points": 1 + } + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/loyalty/events/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Loyalty.SearchEventsAsync( + new SearchLoyaltyEventsRequest + { + Query = new LoyaltyEventQuery + { + Filter = new LoyaltyEventFilter + { + OrderFilter = new LoyaltyEventOrderFilter + { + OrderId = "PyATxhYLfsMqpVkcKJITPydgEYfZY", + }, + }, + }, + Limit = 30, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/CreateTest.cs new file mode 100644 index 00000000..fcb47ea0 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/CreateTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Merchants.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributeDefinitions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "key": "alternative_seller_name", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Alternative Merchant Name", + "description": "This is the other name this merchant goes by.", + "visibility": "VISIBILITY_READ_ONLY" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "alternative_seller_name", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Alternative Merchant Name", + "description": "This is the other name this merchant goes by.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 1, + "updated_at": "2023-05-05T19:06:36.559Z", + "created_at": "2023-05-05T19:06:36.559Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attribute-definitions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributeDefinitions.CreateAsync( + new CreateMerchantCustomAttributeDefinitionRequest + { + CustomAttributeDefinition = new CustomAttributeDefinition + { + Key = "alternative_seller_name", + Schema = new Dictionary() + { + { + "$ref", + "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + }, + Name = "Alternative Merchant Name", + Description = "This is the other name this merchant goes by.", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadOnly, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/DeleteTest.cs new file mode 100644 index 00000000..edacaed2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/DeleteTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributeDefinitions; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attribute-definitions/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributeDefinitions.DeleteAsync( + new Square.Merchants.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/GetTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/GetTest.cs new file mode 100644 index 00000000..d8786c4b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/GetTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributeDefinitions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "alternative_seller_name", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Alternative Merchant Name", + "description": "This is the other name this merchant goes by.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 1, + "updated_at": "2023-05-05T19:06:36.559Z", + "created_at": "2023-05-05T19:06:36.559Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attribute-definitions/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributeDefinitions.GetAsync( + new Square.Merchants.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/ListTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/ListTest.cs new file mode 100644 index 00000000..5a67fc92 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/ListTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributeDefinitions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definitions": [ + { + "key": "has_seen_tutorial", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Boolean" + }, + "name": "NAME", + "description": "Whether the merchant has seen the tutorial screen for using the app.", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2023-05-05T16:50:21.832Z", + "created_at": "2023-05-05T16:50:21.832Z" + }, + { + "key": "alternative_seller_name", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Alternative Merchant Name", + "description": "This is the other name this merchant goes by.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 4, + "updated_at": "2023-05-05T10:17:52.341Z", + "created_at": "2023-05-05T19:06:36.559Z" + } + ], + "cursor": "ImfNzWVSiAYyiAR4gEcxDJ75KZAOSjX8H2BVHUTR0ofCtp4SdYvrUKbwYY2aCH2WqZ2FsfAuylEVUlTfaINg3ecIlFpP9Y5Ie66w9NSg9nqdI5fCJ6qdH2s0za5m2plFonsjIuFaoN89j78ROUwuSOzD6mFZPcJHhJ0CxEKc0SBH", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attribute-definitions") + .WithParam("visibility_filter", "ALL") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Merchants.CustomAttributeDefinitions.ListAsync( + new Square.Merchants.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + VisibilityFilter = VisibilityFilter.All, + Limit = 1, + Cursor = "cursor", + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/UpdateTest.cs new file mode 100644 index 00000000..1a0a0d28 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributeDefinitions/UpdateTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Merchants.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributeDefinitions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "alternative_seller_name", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String" + }, + "name": "Alternative Merchant Name", + "description": "Update the description as desired.", + "visibility": "VISIBILITY_READ_ONLY", + "version": 2, + "updated_at": "2023-05-05T19:34:10.181Z", + "created_at": "2023-05-05T19:06:36.559Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attribute-definitions/key") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributeDefinitions.UpdateAsync( + new UpdateMerchantCustomAttributeDefinitionRequest + { + Key = "key", + CustomAttributeDefinition = new CustomAttributeDefinition + { + Description = "Update the description as desired.", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadOnly, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchDeleteTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchDeleteTest.cs new file mode 100644 index 00000000..8a985188 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchDeleteTest.cs @@ -0,0 +1,109 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Merchants.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributes; + +[TestFixture] +public class BatchDeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "id1": { + "key": "alternative_seller_name" + }, + "id2": { + "key": "has_seen_tutorial" + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attributes/bulk-delete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributes.BatchDeleteAsync( + new BulkDeleteMerchantCustomAttributesRequest + { + Values = new Dictionary< + string, + BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest + >() + { + { + "id1", + new BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest + { + Key = "alternative_seller_name", + } + }, + { + "id2", + new BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest + { + Key = "has_seen_tutorial", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchUpsertTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchUpsertTest.cs new file mode 100644 index 00000000..4409c323 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/BatchUpsertTest.cs @@ -0,0 +1,145 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Merchants.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributes; + +[TestFixture] +public class BatchUpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "id1": { + "merchant_id": "DM7VKY8Q63GNP", + "custom_attribute": { + "key": "alternative_seller_name", + "value": "Ultimate Sneaker Store" + } + }, + "id2": { + "merchant_id": "DM7VKY8Q63GNP", + "custom_attribute": { + "key": "has_seen_tutorial", + "value": true + } + } + } + } + """; + + const string mockResponse = """ + { + "values": { + "id1": { + "merchant_id": "DM7VKY8Q63GNP", + "custom_attribute": { + "key": "alternative_seller_name", + "value": "Ultimate Sneaker Store", + "version": 2, + "visibility": "VISIBILITY_READ_ONLY", + "updated_at": "2023-05-06T19:21:04.551Z", + "created_at": "2023-05-06T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "id2": { + "merchant_id": "DM7VKY8Q63GNP", + "custom_attribute": { + "key": "has_seen_tutorial", + "value": true, + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2023-05-06T19:21:04.551Z", + "created_at": "2023-05-06T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/custom-attributes/bulk-upsert") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributes.BatchUpsertAsync( + new BulkUpsertMerchantCustomAttributesRequest + { + Values = new Dictionary< + string, + BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest + >() + { + { + "id1", + new BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest + { + MerchantId = "DM7VKY8Q63GNP", + CustomAttribute = new CustomAttribute + { + Key = "alternative_seller_name", + Value = "Ultimate Sneaker Store", + }, + } + }, + { + "id2", + new BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest + { + MerchantId = "DM7VKY8Q63GNP", + CustomAttribute = new CustomAttribute + { + Key = "has_seen_tutorial", + Value = true, + }, + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize(mockResponse) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/DeleteTest.cs new file mode 100644 index 00000000..84c10552 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/DeleteTest.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributes; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/merchant_id/custom-attributes/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributes.DeleteAsync( + new Square.Merchants.CustomAttributes.DeleteCustomAttributesRequest + { + MerchantId = "merchant_id", + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/GetTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/GetTest.cs new file mode 100644 index 00000000..19032cd3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/GetTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute": { + "key": "alternative_seller_name", + "value": "Ultimate Sneaker Store", + "version": 2, + "visibility": "VISIBILITY_READ_ONLY", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2023-05-06T19:21:04.551Z", + "created_at": "2023-05-06T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/merchant_id/custom-attributes/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributes.GetAsync( + new Square.Merchants.CustomAttributes.GetCustomAttributesRequest + { + MerchantId = "merchant_id", + Key = "key", + WithDefinition = true, + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/ListTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/ListTest.cs new file mode 100644 index 00000000..7e4e8bfe --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/ListTest.cs @@ -0,0 +1,79 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attributes": [ + { + "key": "has_seen_tutorial", + "value": true, + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2023-05-05T18:13:03.745Z", + "created_at": "2023-05-05T18:13:03.745Z" + }, + { + "key": "alternative_seller_name", + "value": "Ultimate Sneaker Store", + "version": 1, + "visibility": "VISIBILITY_READ_ONLY", + "updated_at": "2023-05-05T19:27:57.975Z", + "created_at": "2023-05-05T19:27:57.975Z" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/merchant_id/custom-attributes") + .WithParam("visibility_filter", "ALL") + .WithParam("limit", "1") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Merchants.CustomAttributes.ListAsync( + new Square.Merchants.CustomAttributes.ListCustomAttributesRequest + { + MerchantId = "merchant_id", + VisibilityFilter = VisibilityFilter.All, + Limit = 1, + Cursor = "cursor", + WithDefinitions = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/UpsertTest.cs new file mode 100644 index 00000000..9193edf2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/CustomAttributes/UpsertTest.cs @@ -0,0 +1,87 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Merchants.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants.CustomAttributes; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute": { + "value": "Ultimate Sneaker Store" + } + } + """; + + const string mockResponse = """ + { + "custom_attribute": { + "key": "alternative_seller_name", + "value": "Ultimate Sneaker Store", + "version": 2, + "visibility": "VISIBILITY_READ_ONLY", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2023-05-06T19:21:04.551Z", + "created_at": "2023-05-06T19:02:58.647Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/merchant_id/custom-attributes/key") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.CustomAttributes.UpsertAsync( + new UpsertMerchantCustomAttributeRequest + { + MerchantId = "merchant_id", + Key = "key", + CustomAttribute = new CustomAttribute { Value = "Ultimate Sneaker Store" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/GetTest.cs b/src/Square.Test/Unit/MockServer/Merchants/GetTest.cs new file mode 100644 index 00000000..bcfcbed2 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/GetTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Merchants; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "merchant": { + "id": "DM7VKY8Q63GNP", + "business_name": "Apple A Day", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "status": "ACTIVE", + "main_location_id": "9A65CGC72ZQG1", + "created_at": "2021-12-10T19:25:52.484Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants/merchant_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Merchants.GetAsync( + new GetMerchantsRequest { MerchantId = "merchant_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Merchants/ListTest.cs b/src/Square.Test/Unit/MockServer/Merchants/ListTest.cs new file mode 100644 index 00000000..afa16651 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Merchants/ListTest.cs @@ -0,0 +1,62 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Merchants; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Merchants; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "merchant": [ + { + "id": "DM7VKY8Q63GNP", + "business_name": "Apple A Day", + "country": "US", + "language_code": "en-US", + "currency": "USD", + "status": "ACTIVE", + "main_location_id": "9A65CGC72ZQG1", + "created_at": "2021-12-10T19:25:52.484Z" + } + ], + "cursor": 1 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/merchants") + .WithParam("cursor", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Merchants.ListAsync(new ListMerchantsRequest { Cursor = 1 }); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Mobile/AuthorizationCodeTest.cs b/src/Square.Test/Unit/MockServer/Mobile/AuthorizationCodeTest.cs new file mode 100644 index 00000000..c5c3e2b8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Mobile/AuthorizationCodeTest.cs @@ -0,0 +1,62 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Mobile; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Mobile; + +[TestFixture] +public class AuthorizationCodeTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "location_id": "YOUR_LOCATION_ID" + } + """; + + const string mockResponse = """ + { + "authorization_code": "YOUR_MOBILE_AUTHORIZATION_CODE", + "expires_at": "2019-01-10T19:42:08.000Z", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/mobile/authorization-code") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Mobile.AuthorizationCodeAsync( + new CreateMobileAuthorizationCodeRequest { LocationId = "YOUR_LOCATION_ID" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/OAuth/AuthorizeTest.cs b/src/Square.Test/Unit/MockServer/OAuth/AuthorizeTest.cs new file mode 100644 index 00000000..260ade1b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/OAuth/AuthorizeTest.cs @@ -0,0 +1,20 @@ +using NUnit.Framework; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.OAuth; + +[TestFixture] +public class AuthorizeTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public void MockServerTest() + { + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/oauth2/authorize").UsingGet() + ) + .RespondWith(WireMock.ResponseBuilders.Response.Create().WithStatusCode(200)); + + Assert.DoesNotThrowAsync(async () => await Client.OAuth.AuthorizeAsync()); + } +} diff --git a/src/Square.Test/Unit/MockServer/OAuth/ObtainTokenTest.cs b/src/Square.Test/Unit/MockServer/OAuth/ObtainTokenTest.cs new file mode 100644 index 00000000..e9642332 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/OAuth/ObtainTokenTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.OAuth; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.OAuth; + +[TestFixture] +public class ObtainTokenTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "client_id": "sq0idp-uaPHILoPzWZk3tlJqlML0g", + "client_secret": "sq0csp-30a-4C_tVOnTh14Piza2BfTPBXyLafLPWSzY1qAjeBfM", + "code": "sq0cgb-l0SBqxs4uwxErTVyYOdemg", + "grant_type": "authorization_code" + } + """; + + const string mockResponse = """ + { + "access_token": "EAAl3ikZIe18J-2-cHlV2bL4-EaZHGoJUhtEBT7QA6-7AgwIHw8Xe1IoUvGsNxA", + "token_type": "bearer", + "expires_at": "2025-04-03T18:31:06.000Z", + "merchant_id": "MLQW2MYBY81PZ", + "subscription_id": "subscription_id", + "plan_id": "plan_id", + "id_token": "id_token", + "refresh_token": "EQAAl0OcByu3IYJYScGGg-8E5YNf0r0b6jCTCMy5nOcRZ4ok0wbWAL8vY3tZWNcc", + "short_lived": false, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refresh_token_expires_at": "refresh_token_expires_at" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/oauth2/token") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.OAuth.ObtainTokenAsync( + new ObtainTokenRequest + { + ClientId = "sq0idp-uaPHILoPzWZk3tlJqlML0g", + ClientSecret = "sq0csp-30a-4C_tVOnTh14Piza2BfTPBXyLafLPWSzY1qAjeBfM", + Code = "sq0cgb-l0SBqxs4uwxErTVyYOdemg", + GrantType = "authorization_code", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/OAuth/RetrieveTokenStatusTest.cs b/src/Square.Test/Unit/MockServer/OAuth/RetrieveTokenStatusTest.cs new file mode 100644 index 00000000..0eaf958b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/OAuth/RetrieveTokenStatusTest.cs @@ -0,0 +1,56 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.OAuth; + +[TestFixture] +public class RetrieveTokenStatusTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "scopes": [ + "PAYMENTS_READ", + "PAYMENTS_WRITE" + ], + "expires_at": "2022-10-14T14:44:00.000Z", + "client_id": "CLIENT_ID", + "merchant_id": "MERCHANT_ID", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/oauth2/token/status") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.OAuth.RetrieveTokenStatusAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/OAuth/RevokeTokenTest.cs b/src/Square.Test/Unit/MockServer/OAuth/RevokeTokenTest.cs new file mode 100644 index 00000000..29537164 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/OAuth/RevokeTokenTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.OAuth; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.OAuth; + +[TestFixture] +public class RevokeTokenTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "client_id": "CLIENT_ID", + "access_token": "ACCESS_TOKEN" + } + """; + + const string mockResponse = """ + { + "success": true, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/oauth2/revoke") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.OAuth.RevokeTokenAsync( + new RevokeTokenRequest { ClientId = "CLIENT_ID", AccessToken = "ACCESS_TOKEN" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/BatchGetTest.cs b/src/Square.Test/Unit/MockServer/Orders/BatchGetTest.cs new file mode 100644 index 00000000..bd4efc85 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/BatchGetTest.cs @@ -0,0 +1,152 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class BatchGetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "location_id": "057P5VYJ4A5X1", + "order_ids": [ + "CAISEM82RcpmcFBM0TfOyiHV3es", + "CAISENgvlJ6jLWAzERDzjyHVybY" + ] + } + """; + + const string mockResponse = """ + { + "orders": [ + { + "id": "CAISEM82RcpmcFBM0TfOyiHV3es", + "location_id": "057P5VYJ4A5X1", + "reference_id": "my-order-001", + "customer_id": "customer_id", + "line_items": [ + { + "uid": "945986d1-9586-11e6-ad5a-28cfe92138cf", + "name": "Awesome product", + "quantity": "1", + "base_price_money": { + "amount": 1599, + "currency": "USD" + }, + "total_money": { + "amount": 1599, + "currency": "USD" + } + }, + { + "uid": "a8f4168c-9586-11e6-bdf0-28cfe92138cf", + "name": "Another awesome product", + "quantity": "3", + "base_price_money": { + "amount": 2000, + "currency": "USD" + }, + "total_money": { + "amount": 6000, + "currency": "USD" + } + } + ], + "taxes": [ + {} + ], + "discounts": [ + {} + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "created_at": "created_at", + "updated_at": "updated_at", + "closed_at": "closed_at", + "state": "OPEN", + "version": 1, + "total_money": { + "amount": 7599, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ] + } + ], + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/batch-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.BatchGetAsync( + new BatchGetOrdersRequest + { + LocationId = "057P5VYJ4A5X1", + OrderIds = new List() + { + "CAISEM82RcpmcFBM0TfOyiHV3es", + "CAISENgvlJ6jLWAzERDzjyHVybY", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CalculateTest.cs b/src/Square.Test/Unit/MockServer/Orders/CalculateTest.cs new file mode 100644 index 00000000..c2b3e9b1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CalculateTest.cs @@ -0,0 +1,321 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class CalculateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "order": { + "location_id": "D7AVYMEAPJ3A3", + "line_items": [ + { + "name": "Item 1", + "quantity": "1", + "base_price_money": { + "amount": 500, + "currency": "USD" + } + }, + { + "name": "Item 2", + "quantity": "2", + "base_price_money": { + "amount": 300, + "currency": "USD" + } + } + ], + "discounts": [ + { + "name": "50% Off", + "percentage": "50", + "scope": "ORDER" + } + ] + } + } + """; + + const string mockResponse = """ + { + "order": { + "id": "id", + "location_id": "D7AVYMEAPJ3A3", + "reference_id": "reference_id", + "source": { + "name": "name" + }, + "customer_id": "customer_id", + "line_items": [ + { + "uid": "ULkg0tQTRK2bkU9fNv3IJD", + "name": "Item 1", + "quantity": "1", + "applied_discounts": [ + { + "uid": "9zr9S4dxvPAixvn0lpa1VC", + "discount_uid": "zGsRZP69aqSSR9lq9euSPB", + "applied_money": { + "amount": 250, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 500, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 500, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 250, + "currency": "USD" + }, + "total_money": { + "amount": 250, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + { + "uid": "mumY8Nun4BC5aKe2yyx5a", + "name": "Item 2", + "quantity": "2", + "applied_discounts": [ + { + "uid": "qa8LwwZK82FgSEkQc2HYVC", + "discount_uid": "zGsRZP69aqSSR9lq9euSPB", + "applied_money": { + "amount": 300, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 300, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 600, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 600, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 300, + "currency": "USD" + }, + "total_money": { + "amount": 300, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "taxes": [ + {} + ], + "discounts": [ + { + "uid": "zGsRZP69aqSSR9lq9euSPB", + "name": "50% Off", + "type": "FIXED_PERCENTAGE", + "percentage": "50", + "applied_money": { + "amount": 550, + "currency": "USD" + }, + "scope": "ORDER" + } + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "net_amounts": { + "total_money": { + "amount": 550, + "currency": "USD" + }, + "tax_money": { + "amount": 0, + "currency": "USD" + }, + "discount_money": { + "amount": 550, + "currency": "USD" + }, + "tip_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "rounding_adjustment": { + "uid": "uid", + "name": "name" + }, + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "metadata": { + "key": "value" + }, + "created_at": "2020-05-18T16:30:49.614Z", + "updated_at": "2020-05-18T16:30:49.614Z", + "closed_at": "closed_at", + "state": "OPEN", + "version": 1, + "total_money": { + "amount": 550, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 550, + "currency": "USD" + }, + "total_tip_money": { + "amount": 0, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "pricing_options": { + "auto_apply_discounts": true, + "auto_apply_taxes": true + }, + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ], + "net_amount_due_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/calculate") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CalculateAsync( + new CalculateOrderRequest + { + Order = new Order + { + LocationId = "D7AVYMEAPJ3A3", + LineItems = new List() + { + new OrderLineItem + { + Name = "Item 1", + Quantity = "1", + BasePriceMoney = new Money { Amount = 500, Currency = Currency.Usd }, + }, + new OrderLineItem + { + Name = "Item 2", + Quantity = "2", + BasePriceMoney = new Money { Amount = 300, Currency = Currency.Usd }, + }, + }, + Discounts = new List() + { + new OrderLineItemDiscount + { + Name = "50% Off", + Percentage = "50", + Scope = OrderLineItemDiscountScope.Order, + }, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CloneTest.cs b/src/Square.Test/Unit/MockServer/Orders/CloneTest.cs new file mode 100644 index 00000000..fae430bb --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CloneTest.cs @@ -0,0 +1,368 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class CloneTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "order_id": "ZAISEM52YcpmcWAzERDOyiWS123", + "version": 3, + "idempotency_key": "UNIQUE_STRING" + } + """; + + const string mockResponse = """ + { + "order": { + "id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "location_id": "057P5VYJ4A5X1", + "reference_id": "my-order-001", + "source": { + "name": "My App" + }, + "customer_id": "customer_id", + "line_items": [ + { + "uid": "8uSwfzvUImn3IRrvciqlXC", + "name": "New York Strip Steak", + "quantity": "1", + "applied_taxes": [ + { + "uid": "aKG87ArnDpvMLSZJHxWUl", + "tax_uid": "state-sales-tax", + "applied_money": { + "amount": 136, + "currency": "USD" + } + } + ], + "applied_discounts": [ + { + "uid": "jWdgP1TpHPFBuVrz81mXVC", + "discount_uid": "membership-discount", + "applied_money": { + "amount": 8, + "currency": "USD" + } + }, + { + "uid": "jnZOjjVY57eRcQAVgEwFuC", + "discount_uid": "labor-day-sale", + "applied_money": { + "amount": 79, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 1599, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 1599, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 1599, + "currency": "USD" + }, + "total_tax_money": { + "amount": 136, + "currency": "USD" + }, + "total_discount_money": { + "amount": 87, + "currency": "USD" + }, + "total_money": { + "amount": 1648, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + { + "uid": "v8ZuEXpOJpb0bazLuvrLDB", + "name": "New York Steak", + "quantity": "2", + "catalog_object_id": "BEMYCSMIJL46OCDV4KYIKXIB", + "variation_name": "Larger", + "modifiers": [ + { + "uid": "Lo3qMMckDluu9Qsb58d4CC", + "catalog_object_id": "CHQX7Y4KY6N5KINJKZCFURPZ", + "name": "Well", + "base_price_money": { + "amount": 50, + "currency": "USD" + }, + "total_price_money": { + "amount": 100, + "currency": "USD" + } + } + ], + "applied_taxes": [ + { + "uid": "v1dAgrfUVUPTnVTf9sRPz", + "tax_uid": "state-sales-tax", + "applied_money": { + "amount": 374, + "currency": "USD" + } + } + ], + "applied_discounts": [ + { + "uid": "nUXvdsIItfKko0dbYtY58C", + "discount_uid": "membership-discount", + "applied_money": { + "amount": 22, + "currency": "USD" + } + }, + { + "uid": "qSdkOOOernlVQqsJ94SPjB", + "discount_uid": "labor-day-sale", + "applied_money": { + "amount": 224, + "currency": "USD" + } + }, + { + "uid": "y7bVl4njrWAnfDwmz19izB", + "discount_uid": "one-dollar-off", + "applied_money": { + "amount": 100, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 2200, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 4400, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 4500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 374, + "currency": "USD" + }, + "total_discount_money": { + "amount": 346, + "currency": "USD" + }, + "total_money": { + "amount": 4528, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "taxes": [ + { + "uid": "state-sales-tax", + "name": "State Sales Tax", + "type": "ADDITIVE", + "percentage": "9", + "applied_money": { + "amount": 510, + "currency": "USD" + }, + "scope": "ORDER" + } + ], + "discounts": [ + { + "uid": "membership-discount", + "catalog_object_id": "DB7L55ZH2BGWI4H23ULIWOQ7", + "name": "Membership Discount", + "type": "FIXED_PERCENTAGE", + "percentage": "0.5", + "applied_money": { + "amount": 30, + "currency": "USD" + }, + "scope": "ORDER" + }, + { + "uid": "labor-day-sale", + "name": "Labor Day Sale", + "type": "FIXED_PERCENTAGE", + "percentage": "5", + "applied_money": { + "amount": 303, + "currency": "USD" + }, + "scope": "ORDER" + }, + { + "uid": "one-dollar-off", + "name": "Sale - $1.00 off", + "type": "FIXED_AMOUNT", + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "applied_money": { + "amount": 100, + "currency": "USD" + }, + "scope": "LINE_ITEM" + } + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "net_amounts": { + "total_money": { + "amount": 6176, + "currency": "USD" + }, + "tax_money": { + "amount": 510, + "currency": "USD" + }, + "discount_money": { + "amount": 433, + "currency": "USD" + }, + "tip_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "rounding_adjustment": { + "uid": "uid", + "name": "name" + }, + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "metadata": { + "key": "value" + }, + "created_at": "2020-01-17T20:47:53.293Z", + "updated_at": "2020-01-17T20:47:53.293Z", + "closed_at": "closed_at", + "state": "DRAFT", + "version": 1, + "total_money": { + "amount": 6176, + "currency": "USD" + }, + "total_tax_money": { + "amount": 510, + "currency": "USD" + }, + "total_discount_money": { + "amount": 433, + "currency": "USD" + }, + "total_tip_money": { + "amount": 0, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "pricing_options": { + "auto_apply_discounts": true, + "auto_apply_taxes": true + }, + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ], + "net_amount_due_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/clone") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CloneAsync( + new CloneOrderRequest + { + OrderId = "ZAISEM52YcpmcWAzERDOyiWS123", + Version = 3, + IdempotencyKey = "UNIQUE_STRING", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CreateTest.cs b/src/Square.Test/Unit/MockServer/Orders/CreateTest.cs new file mode 100644 index 00000000..098b8683 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CreateTest.cs @@ -0,0 +1,484 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "order": { + "location_id": "057P5VYJ4A5X1", + "reference_id": "my-order-001", + "line_items": [ + { + "name": "New York Strip Steak", + "quantity": "1", + "base_price_money": { + "amount": 1599, + "currency": "USD" + } + }, + { + "quantity": "2", + "catalog_object_id": "BEMYCSMIJL46OCDV4KYIKXIB", + "modifiers": [ + { + "catalog_object_id": "CHQX7Y4KY6N5KINJKZCFURPZ" + } + ], + "applied_discounts": [ + { + "discount_uid": "one-dollar-off" + } + ] + } + ], + "taxes": [ + { + "uid": "state-sales-tax", + "name": "State Sales Tax", + "percentage": "9", + "scope": "ORDER" + } + ], + "discounts": [ + { + "uid": "labor-day-sale", + "name": "Labor Day Sale", + "percentage": "5", + "scope": "ORDER" + }, + { + "uid": "membership-discount", + "catalog_object_id": "DB7L55ZH2BGWI4H23ULIWOQ7", + "scope": "ORDER" + }, + { + "uid": "one-dollar-off", + "name": "Sale - $1.00 off", + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "scope": "LINE_ITEM" + } + ] + }, + "idempotency_key": "8193148c-9586-11e6-99f9-28cfe92138cf" + } + """; + + const string mockResponse = """ + { + "order": { + "id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "location_id": "057P5VYJ4A5X1", + "reference_id": "my-order-001", + "source": { + "name": "My App" + }, + "customer_id": "customer_id", + "line_items": [ + { + "uid": "8uSwfzvUImn3IRrvciqlXC", + "name": "New York Strip Steak", + "quantity": "1", + "applied_taxes": [ + { + "uid": "aKG87ArnDpvMLSZJHxWUl", + "tax_uid": "state-sales-tax", + "applied_money": { + "amount": 136, + "currency": "USD" + } + } + ], + "applied_discounts": [ + { + "uid": "jWdgP1TpHPFBuVrz81mXVC", + "discount_uid": "membership-discount", + "applied_money": { + "amount": 8, + "currency": "USD" + } + }, + { + "uid": "jnZOjjVY57eRcQAVgEwFuC", + "discount_uid": "labor-day-sale", + "applied_money": { + "amount": 79, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 1599, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 1599, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 1599, + "currency": "USD" + }, + "total_tax_money": { + "amount": 136, + "currency": "USD" + }, + "total_discount_money": { + "amount": 87, + "currency": "USD" + }, + "total_money": { + "amount": 1648, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + { + "uid": "v8ZuEXpOJpb0bazLuvrLDB", + "name": "New York Steak", + "quantity": "2", + "catalog_object_id": "BEMYCSMIJL46OCDV4KYIKXIB", + "variation_name": "Larger", + "modifiers": [ + { + "uid": "Lo3qMMckDluu9Qsb58d4CC", + "catalog_object_id": "CHQX7Y4KY6N5KINJKZCFURPZ", + "name": "Well", + "base_price_money": { + "amount": 50, + "currency": "USD" + }, + "total_price_money": { + "amount": 100, + "currency": "USD" + } + } + ], + "applied_taxes": [ + { + "uid": "v1dAgrfUVUPTnVTf9sRPz", + "tax_uid": "state-sales-tax", + "applied_money": { + "amount": 374, + "currency": "USD" + } + } + ], + "applied_discounts": [ + { + "uid": "nUXvdsIItfKko0dbYtY58C", + "discount_uid": "membership-discount", + "applied_money": { + "amount": 22, + "currency": "USD" + } + }, + { + "uid": "qSdkOOOernlVQqsJ94SPjB", + "discount_uid": "labor-day-sale", + "applied_money": { + "amount": 224, + "currency": "USD" + } + }, + { + "uid": "y7bVl4njrWAnfDwmz19izB", + "discount_uid": "one-dollar-off", + "applied_money": { + "amount": 100, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 2200, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 4400, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 4500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 374, + "currency": "USD" + }, + "total_discount_money": { + "amount": 346, + "currency": "USD" + }, + "total_money": { + "amount": 4528, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "taxes": [ + { + "uid": "state-sales-tax", + "name": "State Sales Tax", + "type": "ADDITIVE", + "percentage": "9", + "applied_money": { + "amount": 510, + "currency": "USD" + }, + "scope": "ORDER" + } + ], + "discounts": [ + { + "uid": "membership-discount", + "catalog_object_id": "DB7L55ZH2BGWI4H23ULIWOQ7", + "name": "Membership Discount", + "type": "FIXED_PERCENTAGE", + "percentage": "0.5", + "applied_money": { + "amount": 30, + "currency": "USD" + }, + "scope": "ORDER" + }, + { + "uid": "labor-day-sale", + "name": "Labor Day Sale", + "type": "FIXED_PERCENTAGE", + "percentage": "5", + "applied_money": { + "amount": 303, + "currency": "USD" + }, + "scope": "ORDER" + }, + { + "uid": "one-dollar-off", + "name": "Sale - $1.00 off", + "type": "FIXED_AMOUNT", + "amount_money": { + "amount": 100, + "currency": "USD" + }, + "applied_money": { + "amount": 100, + "currency": "USD" + }, + "scope": "LINE_ITEM" + } + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "net_amounts": { + "total_money": { + "amount": 6176, + "currency": "USD" + }, + "tax_money": { + "amount": 510, + "currency": "USD" + }, + "discount_money": { + "amount": 433, + "currency": "USD" + }, + "tip_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "rounding_adjustment": { + "uid": "uid", + "name": "name" + }, + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "metadata": { + "key": "value" + }, + "created_at": "2020-01-17T20:47:53.293Z", + "updated_at": "2020-01-17T20:47:53.293Z", + "closed_at": "closed_at", + "state": "OPEN", + "version": 1, + "total_money": { + "amount": 6176, + "currency": "USD" + }, + "total_tax_money": { + "amount": 510, + "currency": "USD" + }, + "total_discount_money": { + "amount": 433, + "currency": "USD" + }, + "total_tip_money": { + "amount": 0, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "pricing_options": { + "auto_apply_discounts": true, + "auto_apply_taxes": true + }, + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ], + "net_amount_due_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CreateAsync( + new CreateOrderRequest + { + Order = new Order + { + LocationId = "057P5VYJ4A5X1", + ReferenceId = "my-order-001", + LineItems = new List() + { + new OrderLineItem + { + Name = "New York Strip Steak", + Quantity = "1", + BasePriceMoney = new Money { Amount = 1599, Currency = Currency.Usd }, + }, + new OrderLineItem + { + Quantity = "2", + CatalogObjectId = "BEMYCSMIJL46OCDV4KYIKXIB", + Modifiers = new List() + { + new OrderLineItemModifier + { + CatalogObjectId = "CHQX7Y4KY6N5KINJKZCFURPZ", + }, + }, + AppliedDiscounts = new List() + { + new OrderLineItemAppliedDiscount { DiscountUid = "one-dollar-off" }, + }, + }, + }, + Taxes = new List() + { + new OrderLineItemTax + { + Uid = "state-sales-tax", + Name = "State Sales Tax", + Percentage = "9", + Scope = OrderLineItemTaxScope.Order, + }, + }, + Discounts = new List() + { + new OrderLineItemDiscount + { + Uid = "labor-day-sale", + Name = "Labor Day Sale", + Percentage = "5", + Scope = OrderLineItemDiscountScope.Order, + }, + new OrderLineItemDiscount + { + Uid = "membership-discount", + CatalogObjectId = "DB7L55ZH2BGWI4H23ULIWOQ7", + Scope = OrderLineItemDiscountScope.Order, + }, + new OrderLineItemDiscount + { + Uid = "one-dollar-off", + Name = "Sale - $1.00 off", + AmountMoney = new Money { Amount = 100, Currency = Currency.Usd }, + Scope = OrderLineItemDiscountScope.LineItem, + }, + }, + }, + IdempotencyKey = "8193148c-9586-11e6-99f9-28cfe92138cf", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/CreateTest.cs new file mode 100644 index 00000000..0c40e88b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/CreateTest.cs @@ -0,0 +1,102 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributeDefinitions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "key": "cover-count", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Cover count", + "description": "The number of people seated at a table", + "visibility": "VISIBILITY_READ_WRITE_VALUES" + }, + "idempotency_key": "IDEMPOTENCY_KEY" + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "cover-count", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Cover count", + "description": "The number of people seated at a table", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-10-06T16:53:23.141Z", + "created_at": "2022-10-06T16:53:23.141Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attribute-definitions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributeDefinitions.CreateAsync( + new CreateOrderCustomAttributeDefinitionRequest + { + CustomAttributeDefinition = new CustomAttributeDefinition + { + Key = "cover-count", + Schema = new Dictionary() + { + { + "$ref", + "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + }, + Name = "Cover count", + Description = "The number of people seated at a table", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadWriteValues, + }, + IdempotencyKey = "IDEMPOTENCY_KEY", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/DeleteTest.cs new file mode 100644 index 00000000..ad42004c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/DeleteTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributeDefinitions; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attribute-definitions/key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributeDefinitions.DeleteAsync( + new Square.Orders.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + { + Key = "key", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/GetTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/GetTest.cs new file mode 100644 index 00000000..d0676c90 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/GetTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributeDefinitions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "cover-count", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Cover count", + "description": "The number of people seated at a table", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-10-06T16:53:23.141Z", + "created_at": "2022-10-06T16:53:23.141Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attribute-definitions/key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributeDefinitions.GetAsync( + new Square.Orders.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + { + Key = "key", + Version = 1, + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/ListTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/ListTest.cs new file mode 100644 index 00000000..3cc7a6ea --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/ListTest.cs @@ -0,0 +1,97 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributeDefinitions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute_definitions": [ + { + "key": "cover-count", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Cover count", + "description": "The number of people seated at a table", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-11-16T18:03:44.051Z", + "created_at": "2022-11-16T18:03:44.051Z" + }, + { + "key": "seat-number", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Seat number", + "description": "The identifier for a particular seat", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-11-16T18:04:32.059Z", + "created_at": "2022-11-16T18:04:32.059Z" + }, + { + "key": "table-number", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Table number", + "description": "The identifier for a particular table", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "version": 1, + "updated_at": "2022-11-16T18:04:21.912Z", + "created_at": "2022-11-16T18:04:21.912Z" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attribute-definitions") + .WithParam("visibility_filter", "ALL") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Orders.CustomAttributeDefinitions.ListAsync( + new Square.Orders.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + { + VisibilityFilter = VisibilityFilter.All, + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/UpdateTest.cs new file mode 100644 index 00000000..11493258 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributeDefinitions/UpdateTest.cs @@ -0,0 +1,91 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders.CustomAttributeDefinitions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributeDefinitions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute_definition": { + "key": "cover-count", + "visibility": "VISIBILITY_READ_ONLY", + "version": 1 + }, + "idempotency_key": "IDEMPOTENCY_KEY" + } + """; + + const string mockResponse = """ + { + "custom_attribute_definition": { + "key": "cover-count", + "schema": { + "\\$ref": "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number" + }, + "name": "Cover count", + "description": "The number of people seated at a table", + "visibility": "VISIBILITY_READ_ONLY", + "version": 2, + "updated_at": "2022-11-16T17:44:11.436Z", + "created_at": "2022-11-16T16:53:23.141Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attribute-definitions/key") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributeDefinitions.UpdateAsync( + new UpdateOrderCustomAttributeDefinitionRequest + { + Key = "key", + CustomAttributeDefinition = new CustomAttributeDefinition + { + Key = "cover-count", + Visibility = CustomAttributeDefinitionVisibility.VisibilityReadOnly, + Version = 1, + }, + IdempotencyKey = "IDEMPOTENCY_KEY", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchDeleteTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchDeleteTest.cs new file mode 100644 index 00000000..81915b25 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchDeleteTest.cs @@ -0,0 +1,111 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributes; + +[TestFixture] +public class BatchDeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "cover-count": { + "key": "cover-count", + "order_id": "7BbXGEIWNldxAzrtGf9GPVZTwZ4F" + }, + "table-number": { + "key": "table-number", + "order_id": "7BbXGEIWNldxAzrtGf9GPVZTwZ4F" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "values": { + "cover-count": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "table-number": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attributes/bulk-delete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributes.BatchDeleteAsync( + new BulkDeleteOrderCustomAttributesRequest + { + Values = new Dictionary< + string, + BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute + >() + { + { + "cover-count", + new BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute + { + Key = "cover-count", + OrderId = "7BbXGEIWNldxAzrtGf9GPVZTwZ4F", + } + }, + { + "table-number", + new BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute + { + Key = "table-number", + OrderId = "7BbXGEIWNldxAzrtGf9GPVZTwZ4F", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchUpsertTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchUpsertTest.cs new file mode 100644 index 00000000..60d1bf16 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/BatchUpsertTest.cs @@ -0,0 +1,143 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributes; + +[TestFixture] +public class BatchUpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "values": { + "cover-count": { + "custom_attribute": { + "key": "cover-count", + "value": "6", + "version": 2 + }, + "order_id": "7BbXGEIWNldxAzrtGf9GPVZTwZ4F" + }, + "table-number": { + "custom_attribute": { + "key": "table-number", + "value": "11", + "version": 4 + }, + "order_id": "7BbXGEIWNldxAzrtGf9GPVZTwZ4F" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "values": { + "cover-count": { + "custom_attribute": { + "key": "cover-count", + "value": "6", + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-22T21:28:35.721Z", + "created_at": "2022-11-22T21:27:33.429Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "table-number": { + "custom_attribute": { + "key": "table-number", + "value": "11", + "visibility": "VISIBILITY_HIDDEN", + "updated_at": "2022-11-22T21:28:35.726Z", + "created_at": "2022-11-22T21:24:57.823Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/custom-attributes/bulk-upsert") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributes.BatchUpsertAsync( + new BulkUpsertOrderCustomAttributesRequest + { + Values = new Dictionary< + string, + BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute + >() + { + { + "cover-count", + new BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute + { + CustomAttribute = new CustomAttribute + { + Key = "cover-count", + Value = "6", + Version = 2, + }, + OrderId = "7BbXGEIWNldxAzrtGf9GPVZTwZ4F", + } + }, + { + "table-number", + new BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute + { + CustomAttribute = new CustomAttribute + { + Key = "table-number", + Value = "11", + Version = 4, + }, + OrderId = "7BbXGEIWNldxAzrtGf9GPVZTwZ4F", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/DeleteTest.cs new file mode 100644 index 00000000..35446491 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/DeleteTest.cs @@ -0,0 +1,55 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributes; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/order_id/custom-attributes/custom_attribute_key") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributes.DeleteAsync( + new Square.Orders.CustomAttributes.DeleteCustomAttributesRequest + { + OrderId = "order_id", + CustomAttributeKey = "custom_attribute_key", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/GetTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/GetTest.cs new file mode 100644 index 00000000..031c89ad --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/GetTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributes; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attribute": { + "key": "cover-count", + "value": "6", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2022-11-22T21:28:35.721Z", + "created_at": "2022-11-22T21:27:33.429Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/order_id/custom-attributes/custom_attribute_key") + .WithParam("version", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributes.GetAsync( + new Square.Orders.CustomAttributes.GetCustomAttributesRequest + { + OrderId = "order_id", + CustomAttributeKey = "custom_attribute_key", + Version = 1, + WithDefinition = true, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/ListTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/ListTest.cs new file mode 100644 index 00000000..94ee786e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/ListTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "custom_attributes": [ + { + "key": "wayne-test-15", + "value": "TEST", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "updated_at": "2022-11-10T17:31:36.111Z", + "created_at": "2022-11-10T17:31:36.111Z" + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/order_id/custom-attributes") + .WithParam("visibility_filter", "ALL") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Orders.CustomAttributes.ListAsync( + new Square.Orders.CustomAttributes.ListCustomAttributesRequest + { + OrderId = "order_id", + VisibilityFilter = VisibilityFilter.All, + Cursor = "cursor", + Limit = 1, + WithDefinitions = true, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/UpsertTest.cs new file mode 100644 index 00000000..b5cfb09c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/CustomAttributes/UpsertTest.cs @@ -0,0 +1,94 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders.CustomAttributes; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders.CustomAttributes; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "custom_attribute": { + "key": "table-number", + "value": "42", + "version": 1 + } + } + """; + + const string mockResponse = """ + { + "custom_attribute": { + "key": "table-number", + "value": "42", + "version": 1, + "visibility": "VISIBILITY_READ_WRITE_VALUES", + "definition": { + "key": "key", + "schema": { + "key": "value" + }, + "name": "name", + "description": "description", + "visibility": "VISIBILITY_HIDDEN", + "version": 1, + "updated_at": "updated_at", + "created_at": "created_at" + }, + "updated_at": "2022-10-06T20:41:22.673Z", + "created_at": "2022-10-06T20:41:22.673Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/order_id/custom-attributes/custom_attribute_key") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.CustomAttributes.UpsertAsync( + new UpsertOrderCustomAttributeRequest + { + OrderId = "order_id", + CustomAttributeKey = "custom_attribute_key", + CustomAttribute = new CustomAttribute + { + Key = "table-number", + Value = "42", + Version = 1, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/GetTest.cs b/src/Square.Test/Unit/MockServer/Orders/GetTest.cs new file mode 100644 index 00000000..9089a3f5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/GetTest.cs @@ -0,0 +1,251 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "order": { + "id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "location_id": "D7AVYMEAPJ3A3", + "reference_id": "reference_id", + "source": { + "name": "name" + }, + "customer_id": "customer_id", + "line_items": [ + { + "uid": "ULkg0tQTRK2bkU9fNv3IJD", + "name": "Item 1", + "quantity": "1", + "applied_discounts": [ + { + "uid": "9zr9S4dxvPAixvn0lpa1VC", + "discount_uid": "zGsRZP69aqSSR9lq9euSPB", + "applied_money": { + "amount": 250, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 500, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 500, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 250, + "currency": "USD" + }, + "total_money": { + "amount": 250, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + { + "uid": "mumY8Nun4BC5aKe2yyx5a", + "name": "Item 2", + "quantity": "2", + "applied_discounts": [ + { + "uid": "qa8LwwZK82FgSEkQc2HYVC", + "discount_uid": "zGsRZP69aqSSR9lq9euSPB", + "applied_money": { + "amount": 300, + "currency": "USD" + } + } + ], + "base_price_money": { + "amount": 300, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 600, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 600, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 300, + "currency": "USD" + }, + "total_money": { + "amount": 300, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "taxes": [ + {} + ], + "discounts": [ + { + "uid": "zGsRZP69aqSSR9lq9euSPB", + "name": "50% Off", + "type": "FIXED_PERCENTAGE", + "percentage": "50", + "applied_money": { + "amount": 550, + "currency": "USD" + }, + "scope": "ORDER" + } + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "net_amounts": { + "total_money": { + "amount": 550, + "currency": "USD" + }, + "tax_money": { + "amount": 0, + "currency": "USD" + }, + "discount_money": { + "amount": 550, + "currency": "USD" + }, + "tip_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "rounding_adjustment": { + "uid": "uid", + "name": "name" + }, + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "metadata": { + "key": "value" + }, + "created_at": "2020-05-18T16:30:49.614Z", + "updated_at": "2020-05-18T16:30:49.614Z", + "closed_at": "closed_at", + "state": "OPEN", + "version": 1, + "total_money": { + "amount": 550, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 550, + "currency": "USD" + }, + "total_tip_money": { + "amount": 0, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "pricing_options": { + "auto_apply_discounts": true, + "auto_apply_taxes": true + }, + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ], + "net_amount_due_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock.RequestBuilders.Request.Create().WithPath("/v2/orders/order_id").UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.GetAsync(new GetOrdersRequest { OrderId = "order_id" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/PayTest.cs b/src/Square.Test/Unit/MockServer/Orders/PayTest.cs new file mode 100644 index 00000000..3a09552c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/PayTest.cs @@ -0,0 +1,282 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class PayTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "c043a359-7ad9-4136-82a9-c3f1d66dcbff", + "payment_ids": [ + "EnZdNAlWCmfh6Mt5FMNST1o7taB", + "0LRiVlbXVwe8ozu4KbZxd12mvaB" + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "order": { + "id": "lgwOlEityYPJtcuvKTVKT1pA986YY", + "location_id": "P3CCK6HSNDAS7", + "reference_id": "reference_id", + "source": { + "name": "Source Name" + }, + "customer_id": "customer_id", + "line_items": [ + { + "uid": "QW6kofLHJK7JEKMjlSVP5C", + "name": "Item 1", + "quantity": "1", + "base_price_money": { + "amount": 500, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_money": { + "amount": 500, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + { + "uid": "zhw8MNfRGdFQMI2WE1UBJD", + "name": "Item 2", + "quantity": "2", + "base_price_money": { + "amount": 750, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 1500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_money": { + "amount": 1500, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "taxes": [ + {} + ], + "discounts": [ + {} + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "net_amounts": { + "total_money": { + "amount": 2000, + "currency": "USD" + }, + "tax_money": { + "amount": 0, + "currency": "USD" + }, + "discount_money": { + "amount": 0, + "currency": "USD" + }, + "tip_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "rounding_adjustment": { + "uid": "uid", + "name": "name" + }, + "tenders": [ + { + "id": "EnZdNAlWCmfh6Mt5FMNST1o7taB", + "location_id": "P3CCK6HSNDAS7", + "transaction_id": "lgwOlEityYPJtcuvKTVKT1pA986YY", + "created_at": "2019-08-06T02:47:36.293Z", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 2, + "exp_year": 2022, + "fingerprint": "sq-1-n_BL15KP87ClDa4-h2nXOI0fp5VnxNH6hfhzqhptTfAgxgLuGFcg6jIPngDz4IkkTQ" + }, + "entry_method": "KEYED" + }, + "payment_id": "EnZdNAlWCmfh6Mt5FMNST1o7taB" + }, + { + "id": "0LRiVlbXVwe8ozu4KbZxd12mvaB", + "location_id": "P3CCK6HSNDAS7", + "transaction_id": "lgwOlEityYPJtcuvKTVKT1pA986YY", + "created_at": "2019-08-06T02:47:36.809Z", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 2, + "exp_year": 2022, + "fingerprint": "sq-1-n_BL15KP87ClDa4-h2nXOI0fp5VnxNH6hfhzqhptTfAgxgLuGFcg6jIPngDz4IkkTQ" + }, + "entry_method": "KEYED" + }, + "payment_id": "0LRiVlbXVwe8ozu4KbZxd12mvaB" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "metadata": { + "key": "value" + }, + "created_at": "2019-08-06T02:47:35.693Z", + "updated_at": "2019-08-06T02:47:37.140Z", + "closed_at": "2019-08-06T02:47:37.140Z", + "state": "COMPLETED", + "version": 4, + "total_money": { + "amount": 2000, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "pricing_options": { + "auto_apply_discounts": true, + "auto_apply_taxes": true + }, + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ], + "net_amount_due_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/order_id/pay") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.PayAsync( + new PayOrderRequest + { + OrderId = "order_id", + IdempotencyKey = "c043a359-7ad9-4136-82a9-c3f1d66dcbff", + PaymentIds = new List() + { + "EnZdNAlWCmfh6Mt5FMNST1o7taB", + "0LRiVlbXVwe8ozu4KbZxd12mvaB", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/SearchTest.cs b/src/Square.Test/Unit/MockServer/Orders/SearchTest.cs new file mode 100644 index 00000000..aa0e6976 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/SearchTest.cs @@ -0,0 +1,183 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "location_ids": [ + "057P5VYJ4A5X1", + "18YC4JDH91E1H" + ], + "query": { + "filter": { + "state_filter": { + "states": [ + "COMPLETED" + ] + }, + "date_time_filter": { + "closed_at": { + "start_at": "2018-03-03T20:00:00.000Z", + "end_at": "2019-03-04T21:54:45.000Z" + } + } + }, + "sort": { + "sort_field": "CLOSED_AT", + "sort_order": "DESC" + } + }, + "limit": 3, + "return_entries": true + } + """; + + const string mockResponse = """ + { + "order_entries": [ + { + "order_id": "CAISEM82RcpmcFBM0TfOyiHV3es", + "version": 1, + "location_id": "057P5VYJ4A5X1" + }, + { + "order_id": "CAISENgvlJ6jLWAzERDzjyHVybY", + "version": 1, + "location_id": "18YC4JDH91E1H" + }, + { + "order_id": "CAISEM52YcpmcWAzERDOyiWS3ty", + "version": 1, + "location_id": "057P5VYJ4A5X1" + } + ], + "orders": [ + { + "id": "id", + "location_id": "location_id", + "reference_id": "reference_id", + "customer_id": "customer_id", + "line_items": [ + { + "quantity": "quantity" + } + ], + "taxes": [ + {} + ], + "discounts": [ + {} + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "created_at": "created_at", + "updated_at": "updated_at", + "closed_at": "closed_at", + "state": "OPEN", + "version": 1, + "ticket_name": "ticket_name", + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ] + } + ], + "cursor": "123", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.SearchAsync( + new SearchOrdersRequest + { + LocationIds = new List() { "057P5VYJ4A5X1", "18YC4JDH91E1H" }, + Query = new SearchOrdersQuery + { + Filter = new SearchOrdersFilter + { + StateFilter = new SearchOrdersStateFilter + { + States = new List() { OrderState.Completed }, + }, + DateTimeFilter = new SearchOrdersDateTimeFilter + { + ClosedAt = new TimeRange + { + StartAt = "2018-03-03T20:00:00+00:00", + EndAt = "2019-03-04T21:54:45+00:00", + }, + }, + }, + Sort = new SearchOrdersSort + { + SortField = SearchOrdersSortField.ClosedAt, + SortOrder = SortOrder.Desc, + }, + }, + Limit = 3, + ReturnEntries = true, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Orders/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Orders/UpdateTest.cs new file mode 100644 index 00000000..19f2ec4c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Orders/UpdateTest.cs @@ -0,0 +1,268 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Orders; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Orders; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "order": { + "location_id": "location_id", + "line_items": [ + { + "uid": "cookie_uid", + "name": "COOKIE", + "quantity": "2", + "base_price_money": { + "amount": 200, + "currency": "USD" + } + } + ], + "version": 1 + }, + "fields_to_clear": [ + "discounts" + ], + "idempotency_key": "UNIQUE_STRING" + } + """; + + const string mockResponse = """ + { + "order": { + "id": "DREk7wJcyXNHqULq8JJ2iPAsluJZY", + "location_id": "MXVQSVNDGN3C8", + "reference_id": "reference_id", + "source": { + "name": "Cookies" + }, + "customer_id": "customer_id", + "line_items": [ + { + "uid": "EuYkakhmu3ksHIds5Hiot", + "name": "Small Coffee", + "quantity": "1", + "base_price_money": { + "amount": 500, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 500, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 500, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_money": { + "amount": 500, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + { + "uid": "cookie_uid", + "name": "COOKIE", + "quantity": "2", + "base_price_money": { + "amount": 200, + "currency": "USD" + }, + "variation_total_price_money": { + "amount": 400, + "currency": "USD" + }, + "gross_sales_money": { + "amount": 400, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_money": { + "amount": 400, + "currency": "USD" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + } + } + ], + "taxes": [ + {} + ], + "discounts": [ + {} + ], + "service_charges": [ + {} + ], + "fulfillments": [ + {} + ], + "returns": [ + {} + ], + "net_amounts": { + "total_money": { + "amount": 900, + "currency": "USD" + }, + "tax_money": { + "amount": 0, + "currency": "USD" + }, + "discount_money": { + "amount": 0, + "currency": "USD" + }, + "service_charge_money": { + "amount": 0, + "currency": "USD" + } + }, + "rounding_adjustment": { + "uid": "uid", + "name": "name" + }, + "tenders": [ + { + "type": "CARD" + } + ], + "refunds": [ + { + "id": "id", + "location_id": "location_id", + "reason": "reason", + "amount_money": {}, + "status": "PENDING" + } + ], + "metadata": { + "key": "value" + }, + "created_at": "2019-08-23T18:26:18.243Z", + "updated_at": "2019-08-23T18:33:47.523Z", + "closed_at": "closed_at", + "state": "OPEN", + "version": 2, + "total_money": { + "amount": 900, + "currency": "USD" + }, + "total_tax_money": { + "amount": 0, + "currency": "USD" + }, + "total_discount_money": { + "amount": 0, + "currency": "USD" + }, + "total_tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "total_service_charge_money": { + "amount": 0, + "currency": "USD" + }, + "ticket_name": "ticket_name", + "pricing_options": { + "auto_apply_discounts": true, + "auto_apply_taxes": true + }, + "rewards": [ + { + "id": "id", + "reward_tier_id": "reward_tier_id" + } + ], + "net_amount_due_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/orders/order_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Orders.UpdateAsync( + new UpdateOrderRequest + { + OrderId = "order_id", + Order = new Order + { + LocationId = "location_id", + LineItems = new List() + { + new OrderLineItem + { + Uid = "cookie_uid", + Name = "COOKIE", + Quantity = "2", + BasePriceMoney = new Money { Amount = 200, Currency = Currency.Usd }, + }, + }, + Version = 1, + }, + FieldsToClear = new List() { "discounts" }, + IdempotencyKey = "UNIQUE_STRING", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/CancelByIdempotencyKeyTest.cs b/src/Square.Test/Unit/MockServer/Payments/CancelByIdempotencyKeyTest.cs new file mode 100644 index 00000000..b763a4ba --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/CancelByIdempotencyKeyTest.cs @@ -0,0 +1,63 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class CancelByIdempotencyKeyTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "a7e36d40-d24b-11e8-b568-0800200c9a66" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments/cancel") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payments.CancelByIdempotencyKeyAsync( + new CancelPaymentByIdempotencyKeyRequest + { + IdempotencyKey = "a7e36d40-d24b-11e8-b568-0800200c9a66", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/CancelTest.cs b/src/Square.Test/Unit/MockServer/Payments/CancelTest.cs new file mode 100644 index 00000000..f7eb8c1a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/CancelTest.cs @@ -0,0 +1,228 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment": { + "id": "1QjqpBVyrI9S4H9sTGDWU9JeiWdZY", + "created_at": "2021-10-13T20:26:44.191Z", + "updated_at": "2021-10-13T20:31:21.597Z", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "tip_money": { + "amount": 100, + "currency": "USD" + }, + "total_money": { + "amount": 1100, + "currency": "USD" + }, + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "approved_money": { + "amount": 1000, + "currency": "USD" + }, + "processing_fee": [ + {} + ], + "refunded_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "CANCELED", + "delay_duration": "PT168H", + "delay_action": "CANCEL", + "delayed_until": "2021-10-20T20:26:44.191Z", + "source_type": "CARD", + "card_details": { + "status": "VOIDED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ", + "card_type": "DEBIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111" + }, + "entry_method": "ON_FILE", + "cvv_status": "CVV_ACCEPTED", + "avs_status": "AVS_ACCEPTED", + "auth_result_code": "68aLBM", + "application_identifier": "application_identifier", + "application_name": "application_name", + "application_cryptogram": "application_cryptogram", + "verification_method": "verification_method", + "verification_results": "verification_results", + "statement_description": "SQ *EXAMPLE TEST GOSQ.C", + "card_payment_timeline": { + "authorized_at": "2021-10-13T20:26:44.364Z", + "voided_at": "2021-10-13T20:31:21.597Z" + }, + "refund_requires_card_presence": true, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "cash_details": { + "buyer_supplied_money": {} + }, + "bank_account_details": { + "bank_name": "bank_name", + "transfer_type": "transfer_type", + "account_ownership_type": "account_ownership_type", + "fingerprint": "fingerprint", + "country": "country", + "statement_description": "statement_description", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "external_details": { + "type": "type", + "source": "source", + "source_id": "source_id" + }, + "wallet_details": { + "status": "status", + "brand": "brand" + }, + "buy_now_pay_later_details": { + "brand": "brand" + }, + "square_account_details": { + "payment_source_token": "payment_source_token", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "location_id": "L88917AVBK2S5", + "order_id": "nUSN9TdxpiK3SrQg3wzmf6r8LP9YY", + "reference_id": "reference_id", + "customer_id": "W92WH6P11H4Z77CTET0RNTGFW8", + "employee_id": "employee_id", + "team_member_id": "team_member_id", + "refund_ids": [ + "refund_ids" + ], + "risk_evaluation": { + "created_at": "2021-10-13T20:26:45.271Z", + "risk_level": "NORMAL" + }, + "terminal_checkout_id": "terminal_checkout_id", + "buyer_email_address": "buyer_email_address", + "billing_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "note": "Example Note", + "statement_description_identifier": "statement_description_identifier", + "capabilities": [ + "capabilities" + ], + "receipt_number": "receipt_number", + "receipt_url": "receipt_url", + "device_details": { + "device_id": "device_id", + "device_installation_id": "device_installation_id", + "device_name": "device_name" + }, + "application_details": { + "square_product": "ECOMMERCE_API", + "application_id": "sq0ids-TcgftTEtKxJTRF1lCFJ9TA" + }, + "is_offline_payment": true, + "offline_payment_details": { + "client_created_at": "client_created_at" + }, + "version_token": "N8AGYgEjCiY9Q57Jw7aVHEpBq8bzGCDCQMRX8Vs56N06o" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments/payment_id/cancel") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payments.CancelAsync( + new CancelPaymentsRequest { PaymentId = "payment_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/CompleteTest.cs b/src/Square.Test/Unit/MockServer/Payments/CompleteTest.cs new file mode 100644 index 00000000..abb84b20 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/CompleteTest.cs @@ -0,0 +1,241 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class CompleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment": { + "id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "created_at": "2021-10-13T19:34:33.524Z", + "updated_at": "2021-10-13T19:34:34.339Z", + "amount_money": { + "amount": 555, + "currency": "USD" + }, + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "total_money": { + "amount": 555, + "currency": "USD" + }, + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "approved_money": { + "amount": 555, + "currency": "USD" + }, + "processing_fee": [ + { + "effective_at": "2021-10-13T21:34:35.000Z", + "type": "INITIAL", + "amount_money": { + "amount": 34, + "currency": "USD" + } + } + ], + "refunded_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "COMPLETED", + "delay_duration": "PT168H", + "delay_action": "CANCEL", + "delayed_until": "2021-10-20T19:34:33.524Z", + "source_type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ", + "card_type": "DEBIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111" + }, + "entry_method": "KEYED", + "cvv_status": "CVV_ACCEPTED", + "avs_status": "AVS_ACCEPTED", + "auth_result_code": "2Nkw7q", + "application_identifier": "application_identifier", + "application_name": "application_name", + "application_cryptogram": "application_cryptogram", + "verification_method": "verification_method", + "verification_results": "verification_results", + "statement_description": "SQ *EXAMPLE TEST GOSQ.C", + "card_payment_timeline": { + "authorized_at": "2021-10-13T19:34:33.680Z", + "captured_at": "2021-10-13T19:34:34.340Z" + }, + "refund_requires_card_presence": true, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "cash_details": { + "buyer_supplied_money": {} + }, + "bank_account_details": { + "bank_name": "bank_name", + "transfer_type": "transfer_type", + "account_ownership_type": "account_ownership_type", + "fingerprint": "fingerprint", + "country": "country", + "statement_description": "statement_description", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "external_details": { + "type": "type", + "source": "source", + "source_id": "source_id" + }, + "wallet_details": { + "status": "status", + "brand": "brand" + }, + "buy_now_pay_later_details": { + "brand": "brand" + }, + "square_account_details": { + "payment_source_token": "payment_source_token", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "location_id": "L88917AVBK2S5", + "order_id": "d7eKah653Z579f3gVtjlxpSlmUcZY", + "reference_id": "reference_id", + "customer_id": "customer_id", + "employee_id": "TMoK_ogh6rH1o4dV", + "team_member_id": "TMoK_ogh6rH1o4dV", + "refund_ids": [ + "refund_ids" + ], + "risk_evaluation": { + "created_at": "created_at", + "risk_level": "PENDING" + }, + "terminal_checkout_id": "terminal_checkout_id", + "buyer_email_address": "buyer_email_address", + "billing_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "note": "Test Note", + "statement_description_identifier": "statement_description_identifier", + "capabilities": [ + "capabilities" + ], + "receipt_number": "bP9m", + "receipt_url": "https://squareup.com/receipt/preview/bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "device_details": { + "device_id": "device_id", + "device_installation_id": "device_installation_id", + "device_name": "device_name" + }, + "application_details": { + "square_product": "VIRTUAL_TERMINAL", + "application_id": "sq0ids-Pw67AZAlLVB7hsRmwlJPuA" + }, + "is_offline_payment": true, + "offline_payment_details": { + "client_created_at": "client_created_at" + }, + "version_token": "56pRkL3slrzet2iQrTp9n0bdJVYTB9YEWdTNjQfZOPV6o" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments/payment_id/complete") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payments.CompleteAsync( + new CompletePaymentRequest { PaymentId = "payment_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/CreateTest.cs b/src/Square.Test/Unit/MockServer/Payments/CreateTest.cs new file mode 100644 index 00000000..f80eb9be --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/CreateTest.cs @@ -0,0 +1,261 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "source_id": "ccof:GaJGNaZa8x4OgDJn4GB", + "idempotency_key": "7b0f3ec5-086a-4871-8f13-3c81b3875218", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "app_fee_money": { + "amount": 10, + "currency": "USD" + }, + "autocomplete": true, + "customer_id": "W92WH6P11H4Z77CTET0RNTGFW8", + "location_id": "L88917AVBK2S5", + "reference_id": "123456", + "note": "Brief description" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment": { + "id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY", + "created_at": "2021-10-13T21:14:29.577Z", + "updated_at": "2021-10-13T21:14:30.504Z", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "total_money": { + "amount": 1000, + "currency": "USD" + }, + "app_fee_money": { + "amount": 10, + "currency": "USD" + }, + "approved_money": { + "amount": 1000, + "currency": "USD" + }, + "processing_fee": [ + {} + ], + "refunded_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "COMPLETED", + "delay_duration": "PT168H", + "delay_action": "CANCEL", + "delayed_until": "2021-10-20T21:14:29.577Z", + "source_type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ", + "card_type": "DEBIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111" + }, + "entry_method": "ON_FILE", + "cvv_status": "CVV_ACCEPTED", + "avs_status": "AVS_ACCEPTED", + "auth_result_code": "vNEn2f", + "application_identifier": "application_identifier", + "application_name": "application_name", + "application_cryptogram": "application_cryptogram", + "verification_method": "verification_method", + "verification_results": "verification_results", + "statement_description": "SQ *EXAMPLE TEST GOSQ.C", + "card_payment_timeline": { + "authorized_at": "2021-10-13T21:14:29.732Z", + "captured_at": "2021-10-13T21:14:30.504Z" + }, + "refund_requires_card_presence": true, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "cash_details": { + "buyer_supplied_money": {} + }, + "bank_account_details": { + "bank_name": "bank_name", + "transfer_type": "transfer_type", + "account_ownership_type": "account_ownership_type", + "fingerprint": "fingerprint", + "country": "country", + "statement_description": "statement_description", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "external_details": { + "type": "type", + "source": "source", + "source_id": "source_id" + }, + "wallet_details": { + "status": "status", + "brand": "brand" + }, + "buy_now_pay_later_details": { + "brand": "brand" + }, + "square_account_details": { + "payment_source_token": "payment_source_token", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "location_id": "L88917AVBK2S5", + "order_id": "pRsjRTgFWATl7so6DxdKBJa7ssbZY", + "reference_id": "123456", + "customer_id": "W92WH6P11H4Z77CTET0RNTGFW8", + "employee_id": "employee_id", + "team_member_id": "team_member_id", + "refund_ids": [ + "refund_ids" + ], + "risk_evaluation": { + "created_at": "2021-10-13T21:14:30.423Z", + "risk_level": "NORMAL" + }, + "terminal_checkout_id": "terminal_checkout_id", + "buyer_email_address": "buyer_email_address", + "billing_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "note": "Brief Description", + "statement_description_identifier": "statement_description_identifier", + "capabilities": [ + "capabilities" + ], + "receipt_number": "R2B3", + "receipt_url": "https://squareup.com/receipt/preview/EXAMPLE_RECEIPT_ID", + "device_details": { + "device_id": "device_id", + "device_installation_id": "device_installation_id", + "device_name": "device_name" + }, + "application_details": { + "square_product": "ECOMMERCE_API", + "application_id": "sq0ids-TcgftTEtKxJTRF1lCFJ9TA" + }, + "is_offline_payment": true, + "offline_payment_details": { + "client_created_at": "client_created_at" + }, + "version_token": "TPtNEOBOa6Qq6E3C3IjckSVOM6b3hMbfhjvTxHBQUsB6o" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payments.CreateAsync( + new CreatePaymentRequest + { + SourceId = "ccof:GaJGNaZa8x4OgDJn4GB", + IdempotencyKey = "7b0f3ec5-086a-4871-8f13-3c81b3875218", + AmountMoney = new Money { Amount = 1000, Currency = Currency.Usd }, + AppFeeMoney = new Money { Amount = 10, Currency = Currency.Usd }, + Autocomplete = true, + CustomerId = "W92WH6P11H4Z77CTET0RNTGFW8", + LocationId = "L88917AVBK2S5", + ReferenceId = "123456", + Note = "Brief description", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/GetTest.cs b/src/Square.Test/Unit/MockServer/Payments/GetTest.cs new file mode 100644 index 00000000..c14a3832 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/GetTest.cs @@ -0,0 +1,235 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment": { + "id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "created_at": "2021-10-13T19:34:33.524Z", + "updated_at": "2021-10-13T19:34:34.339Z", + "amount_money": { + "amount": 555, + "currency": "USD" + }, + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "total_money": { + "amount": 555, + "currency": "USD" + }, + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "approved_money": { + "amount": 555, + "currency": "USD" + }, + "processing_fee": [ + { + "effective_at": "2021-10-13T21:34:35.000Z", + "type": "INITIAL", + "amount_money": { + "amount": 34, + "currency": "USD" + } + } + ], + "refunded_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "COMPLETED", + "delay_duration": "PT168H", + "delay_action": "CANCEL", + "delayed_until": "2021-10-20T19:34:33.524Z", + "source_type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ", + "card_type": "DEBIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111" + }, + "entry_method": "KEYED", + "cvv_status": "CVV_ACCEPTED", + "avs_status": "AVS_ACCEPTED", + "auth_result_code": "2Nkw7q", + "application_identifier": "application_identifier", + "application_name": "application_name", + "application_cryptogram": "application_cryptogram", + "verification_method": "verification_method", + "verification_results": "verification_results", + "statement_description": "SQ *EXAMPLE TEST GOSQ.C", + "card_payment_timeline": { + "authorized_at": "2021-10-13T19:34:33.680Z", + "captured_at": "2021-10-13T19:34:34.340Z" + }, + "refund_requires_card_presence": true, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "cash_details": { + "buyer_supplied_money": {} + }, + "bank_account_details": { + "bank_name": "bank_name", + "transfer_type": "transfer_type", + "account_ownership_type": "account_ownership_type", + "fingerprint": "fingerprint", + "country": "country", + "statement_description": "statement_description", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "external_details": { + "type": "type", + "source": "source", + "source_id": "source_id" + }, + "wallet_details": { + "status": "status", + "brand": "brand" + }, + "buy_now_pay_later_details": { + "brand": "brand" + }, + "square_account_details": { + "payment_source_token": "payment_source_token", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "location_id": "L88917AVBK2S5", + "order_id": "d7eKah653Z579f3gVtjlxpSlmUcZY", + "reference_id": "reference_id", + "customer_id": "customer_id", + "employee_id": "TMoK_ogh6rH1o4dV", + "team_member_id": "TMoK_ogh6rH1o4dV", + "refund_ids": [ + "refund_ids" + ], + "risk_evaluation": { + "created_at": "created_at", + "risk_level": "PENDING" + }, + "terminal_checkout_id": "terminal_checkout_id", + "buyer_email_address": "buyer_email_address", + "billing_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "note": "Test Note", + "statement_description_identifier": "statement_description_identifier", + "capabilities": [ + "capabilities" + ], + "receipt_number": "bP9m", + "receipt_url": "https://squareup.com/receipt/preview/bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "device_details": { + "device_id": "device_id", + "device_installation_id": "device_installation_id", + "device_name": "device_name" + }, + "application_details": { + "square_product": "VIRTUAL_TERMINAL", + "application_id": "sq0ids-Pw67AZAlLVB7hsRmwlJPuA" + }, + "is_offline_payment": true, + "offline_payment_details": { + "client_created_at": "client_created_at" + }, + "version_token": "56pRkL3slrzet2iQrTp9n0bdJVYTB9YEWdTNjQfZOPV6o" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments/payment_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payments.GetAsync( + new GetPaymentsRequest { PaymentId = "payment_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/ListTest.cs b/src/Square.Test/Unit/MockServer/Payments/ListTest.cs new file mode 100644 index 00000000..d29b1414 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/ListTest.cs @@ -0,0 +1,170 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payments": [ + { + "id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "created_at": "2021-10-13T19:34:33.524Z", + "updated_at": "2021-10-13T19:34:37.261Z", + "amount_money": { + "amount": 555, + "currency": "USD" + }, + "total_money": { + "amount": 555, + "currency": "USD" + }, + "approved_money": { + "amount": 555, + "currency": "USD" + }, + "processing_fee": [ + { + "effective_at": "2021-10-13T21:34:35.000Z", + "type": "INITIAL", + "amount_money": { + "amount": 34, + "currency": "USD" + } + } + ], + "status": "COMPLETED", + "delay_duration": "PT168H", + "delay_action": "CANCEL", + "delayed_until": "2021-10-20T19:34:33.524Z", + "source_type": "CARD", + "card_details": { + "status": "CAPTURED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ", + "card_type": "DEBIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111" + }, + "entry_method": "KEYED", + "cvv_status": "CVV_ACCEPTED", + "avs_status": "AVS_ACCEPTED", + "auth_result_code": "2Nkw7q", + "statement_description": "SQ *EXAMPLE TEST GOSQ.C", + "card_payment_timeline": { + "authorized_at": "2021-10-13T19:34:33.680Z", + "captured_at": "2021-10-13T19:34:34.340Z" + } + }, + "cash_details": { + "buyer_supplied_money": {} + }, + "external_details": { + "type": "type", + "source": "source" + }, + "location_id": "L88917AVBK2S5", + "order_id": "d7eKah653Z579f3gVtjlxpSlmUcZY", + "reference_id": "reference_id", + "customer_id": "customer_id", + "employee_id": "TMoK_ogh6rH1o4dV", + "team_member_id": "TMoK_ogh6rH1o4dV", + "refund_ids": [ + "refund_ids" + ], + "terminal_checkout_id": "terminal_checkout_id", + "buyer_email_address": "buyer_email_address", + "note": "Test Note", + "statement_description_identifier": "statement_description_identifier", + "capabilities": [ + "capabilities" + ], + "receipt_number": "bP9m", + "receipt_url": "https://squareup.com/receipt/preview/bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "application_details": { + "square_product": "VIRTUAL_TERMINAL", + "application_id": "sq0ids-Pw67AZAlLVB7hsRmwlJPuA" + }, + "is_offline_payment": true, + "version_token": "vguW2km0KpVCdAXZcNTZ438qg5LlVPTP4HO5OpiHNfa6o" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments") + .WithParam("begin_time", "begin_time") + .WithParam("end_time", "end_time") + .WithParam("sort_order", "sort_order") + .WithParam("cursor", "cursor") + .WithParam("location_id", "location_id") + .WithParam("total", "1000000") + .WithParam("last_4", "last_4") + .WithParam("card_brand", "card_brand") + .WithParam("limit", "1") + .WithParam("offline_begin_time", "offline_begin_time") + .WithParam("offline_end_time", "offline_end_time") + .WithParam("updated_at_begin_time", "updated_at_begin_time") + .WithParam("updated_at_end_time", "updated_at_end_time") + .WithParam("sort_field", "CREATED_AT") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Payments.ListAsync( + new ListPaymentsRequest + { + BeginTime = "begin_time", + EndTime = "end_time", + SortOrder = "sort_order", + Cursor = "cursor", + LocationId = "location_id", + Total = 1000000, + Last4 = "last_4", + CardBrand = "card_brand", + Limit = 1, + IsOfflinePayment = true, + OfflineBeginTime = "offline_begin_time", + OfflineEndTime = "offline_end_time", + UpdatedAtBeginTime = "updated_at_begin_time", + UpdatedAtEndTime = "updated_at_end_time", + SortField = ListPaymentsRequestSortField.CreatedAt, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Payments/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Payments/UpdateTest.cs new file mode 100644 index 00000000..637d0cf9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payments/UpdateTest.cs @@ -0,0 +1,259 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payments; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payments; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "payment": { + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "tip_money": { + "amount": 100, + "currency": "USD" + }, + "version_token": "ODhwVQ35xwlzRuoZEwKXucfu7583sPTzK48c5zoGd0g6o" + }, + "idempotency_key": "956f8b13-e4ec-45d6-85e8-d1d95ef0c5de" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "payment": { + "id": "1QjqpBVyrI9S4H9sTGDWU9JeiWdZY", + "created_at": "2021-10-13T20:26:44.191Z", + "updated_at": "2021-10-13T20:26:44.364Z", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "tip_money": { + "amount": 100, + "currency": "USD" + }, + "total_money": { + "amount": 1100, + "currency": "USD" + }, + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "approved_money": { + "amount": 1000, + "currency": "USD" + }, + "processing_fee": [ + {} + ], + "refunded_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "status": "APPROVED", + "delay_duration": "PT168H", + "delay_action": "CANCEL", + "delayed_until": "2021-10-20T20:26:44.191Z", + "source_type": "CARD", + "card_details": { + "status": "AUTHORIZED", + "card": { + "card_brand": "VISA", + "last_4": "1111", + "exp_month": 11, + "exp_year": 2022, + "fingerprint": "sq-1-Hxim77tbdcbGejOejnoAklBVJed2YFLTmirfl8Q5XZzObTc8qY_U8RkwzoNL8dCEcQ", + "card_type": "DEBIT", + "prepaid_type": "NOT_PREPAID", + "bin": "411111" + }, + "entry_method": "ON_FILE", + "cvv_status": "CVV_ACCEPTED", + "avs_status": "AVS_ACCEPTED", + "auth_result_code": "68aLBM", + "application_identifier": "application_identifier", + "application_name": "application_name", + "application_cryptogram": "application_cryptogram", + "verification_method": "verification_method", + "verification_results": "verification_results", + "statement_description": "SQ *EXAMPLE TEST GOSQ.C", + "card_payment_timeline": { + "authorized_at": "2021-10-13T20:26:44.364Z" + }, + "refund_requires_card_presence": true, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "cash_details": { + "buyer_supplied_money": {} + }, + "bank_account_details": { + "bank_name": "bank_name", + "transfer_type": "transfer_type", + "account_ownership_type": "account_ownership_type", + "fingerprint": "fingerprint", + "country": "country", + "statement_description": "statement_description", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "external_details": { + "type": "type", + "source": "source", + "source_id": "source_id" + }, + "wallet_details": { + "status": "status", + "brand": "brand" + }, + "buy_now_pay_later_details": { + "brand": "brand" + }, + "square_account_details": { + "payment_source_token": "payment_source_token", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "location_id": "L88917AVBK2S5", + "order_id": "nUSN9TdxpiK3SrQg3wzmf6r8LP9YY", + "reference_id": "reference_id", + "customer_id": "W92WH6P11H4Z77CTET0RNTGFW8", + "employee_id": "employee_id", + "team_member_id": "team_member_id", + "refund_ids": [ + "refund_ids" + ], + "risk_evaluation": { + "created_at": "2021-10-13T20:26:45.271Z", + "risk_level": "NORMAL" + }, + "terminal_checkout_id": "terminal_checkout_id", + "buyer_email_address": "buyer_email_address", + "billing_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "note": "Example Note", + "statement_description_identifier": "statement_description_identifier", + "capabilities": [ + "EDIT_AMOUNT_UP", + "EDIT_AMOUNT_DOWN", + "EDIT_TIP_AMOUNT_UP", + "EDIT_TIP_AMOUNT_DOWN" + ], + "receipt_number": "1Qjq", + "receipt_url": "receipt_url", + "device_details": { + "device_id": "device_id", + "device_installation_id": "device_installation_id", + "device_name": "device_name" + }, + "application_details": { + "square_product": "ECOMMERCE_API", + "application_id": "sq0ids-TcgftTEtKxJTRF1lCFJ9TA" + }, + "is_offline_payment": true, + "offline_payment_details": { + "client_created_at": "client_created_at" + }, + "version_token": "rDrXnqiS7fJgexccgdpzmwqTiXui1aIKCp9EchZ7trE6o" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payments/payment_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payments.UpdateAsync( + new UpdatePaymentRequest + { + PaymentId = "payment_id", + Payment = new Payment + { + AmountMoney = new Money { Amount = 1000, Currency = Currency.Usd }, + TipMoney = new Money { Amount = 100, Currency = Currency.Usd }, + VersionToken = "ODhwVQ35xwlzRuoZEwKXucfu7583sPTzK48c5zoGd0g6o", + }, + IdempotencyKey = "956f8b13-e4ec-45d6-85e8-d1d95ef0c5de", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payouts/GetTest.cs b/src/Square.Test/Unit/MockServer/Payouts/GetTest.cs new file mode 100644 index 00000000..d61c7c2c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payouts/GetTest.cs @@ -0,0 +1,73 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Payouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payouts; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "payout": { + "id": "po_f3c0fb38-a5ce-427d-b858-52b925b72e45", + "status": "PAID", + "location_id": "L88917AVBK2S5", + "created_at": "2022-03-24T03:07:09.000Z", + "updated_at": "2022-03-24T03:07:09.000Z", + "amount_money": { + "amount": -103, + "currency": "UNKNOWN_CURRENCY" + }, + "destination": { + "type": "BANK_ACCOUNT", + "id": "bact:ZPp3oedR3AeEUNd3z7" + }, + "version": 1, + "type": "BATCH", + "payout_fee": [ + {} + ], + "arrival_date": "2022-03-24", + "end_to_end_id": "end_to_end_id" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payouts/payout_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Payouts.GetAsync( + new GetPayoutsRequest { PayoutId = "payout_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Payouts/ListEntriesTest.cs b/src/Square.Test/Unit/MockServer/Payouts/ListEntriesTest.cs new file mode 100644 index 00000000..d060b687 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payouts/ListEntriesTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Payouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payouts; + +[TestFixture] +public class ListEntriesTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "payout_entries": [ + { + "id": "poe_ZQWcw41d0SGJS6IWd4cSi8mKHk", + "payout_id": "po_4d28e6c4-7dd5-4de4-8ec9-a059277646a6", + "effective_at": "2021-12-14T23:31:49.000Z", + "type": "REFUND", + "gross_amount_money": { + "amount": -50 + }, + "fee_amount_money": { + "amount": -2 + }, + "net_amount_money": { + "amount": -48 + }, + "type_refund_details": { + "payment_id": "HVdG62HeMlti8YYf94oxrN", + "refund_id": "HVdG62HeMlti8YYf94oxrN_dR8Nztxg7umf94oxrN12Ji5r2KW14FAY" + } + }, + { + "id": "poe_EibbY9Ob1d0SGJS6IWd4cSiSi6wkaPk", + "payout_id": "po_4d28e6c4-7dd5-4de4-8ec9-a059277646a6", + "effective_at": "2021-12-14T23:31:49.000Z", + "type": "CHARGE", + "gross_amount_money": { + "amount": 100 + }, + "fee_amount_money": { + "amount": 19 + }, + "net_amount_money": { + "amount": 81 + }, + "type_charge_details": { + "payment_id": "HVdG62H5K3291d0SGJS6IWd4cSi8YY" + } + } + ], + "cursor": "TbfI80z98Xc2LdApCyZ2NvCYLpkPurYLR16GRIttpMJ55mrSIMzHgtkcRQdT0mOnTtfHO", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payouts/payout_id/payout-entries") + .WithParam("sort_order", "DESC") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Payouts.ListEntriesAsync( + new ListEntriesPayoutsRequest + { + PayoutId = "payout_id", + SortOrder = SortOrder.Desc, + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Payouts/ListTest.cs b/src/Square.Test/Unit/MockServer/Payouts/ListTest.cs new file mode 100644 index 00000000..e3cf9232 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Payouts/ListTest.cs @@ -0,0 +1,118 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Payouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Payouts; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "payouts": [ + { + "id": "po_b345d2c7-90b3-4f0b-a2aa-df1def7f8afc", + "status": "PAID", + "location_id": "L88917AVBK2S5", + "created_at": "2022-03-29T16:12:31.000Z", + "updated_at": "2022-03-30T01:07:22.875Z", + "amount_money": { + "amount": 6259 + }, + "destination": { + "type": "CARD", + "id": "ccof:ZPp3oedR3AeEUNd3z7" + }, + "version": 2, + "type": "BATCH", + "payout_fee": [ + { + "amount_money": { + "amount": 95 + }, + "effective_at": "2022-03-29T16:12:31.000Z", + "type": "TRANSFER_FEE" + } + ], + "arrival_date": "2022-03-29", + "end_to_end_id": "L2100000005" + }, + { + "id": "po_f3c0fb38-a5ce-427d-b858-52b925b72e45", + "status": "PAID", + "location_id": "L88917AVBK2S5", + "created_at": "2022-03-24T03:07:09.000Z", + "updated_at": "2022-03-24T03:07:09.000Z", + "amount_money": { + "amount": -103 + }, + "destination": { + "type": "BANK_ACCOUNT", + "id": "bact:ZPp3oedR3AeEUNd3z7" + }, + "version": 1, + "type": "BATCH", + "payout_fee": [ + {} + ], + "arrival_date": "2022-03-24", + "end_to_end_id": "L2100000006" + } + ], + "cursor": "EMPCyStibo64hS8wLayZPp3oedR3AeEUNd3z7u6zphi72LQZFIEMbkKVvot9eefpU", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/payouts") + .WithParam("location_id", "location_id") + .WithParam("status", "SENT") + .WithParam("begin_time", "begin_time") + .WithParam("end_time", "end_time") + .WithParam("sort_order", "DESC") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Payouts.ListAsync( + new ListPayoutsRequest + { + LocationId = "location_id", + Status = PayoutStatus.Sent, + BeginTime = "begin_time", + EndTime = "end_time", + SortOrder = SortOrder.Desc, + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Refunds/GetTest.cs b/src/Square.Test/Unit/MockServer/Refunds/GetTest.cs new file mode 100644 index 00000000..5d44531b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Refunds/GetTest.cs @@ -0,0 +1,92 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Refunds; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refund": { + "id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY_69MmgHubkLqx9wGhnmenRUHOaKitE6llfZuxcWYjGxd", + "status": "COMPLETED", + "location_id": "L88917AVBK2S5", + "unlinked": true, + "destination_type": "destination_type", + "destination_details": { + "cash_details": { + "seller_supplied_money": {} + }, + "external_details": { + "type": "type", + "source": "source" + } + }, + "amount_money": { + "amount": 555, + "currency": "USD" + }, + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "processing_fee": [ + { + "effective_at": "2021-10-13T21:34:35.000Z", + "type": "INITIAL", + "amount_money": { + "amount": -34, + "currency": "USD" + } + } + ], + "payment_id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "order_id": "9ltv0bx5PuvGXUYHYHxYSKEqC3IZY", + "reason": "Example Refund", + "created_at": "2021-10-13T19:59:05.073Z", + "updated_at": "2021-10-13T20:00:02.442Z", + "team_member_id": "team_member_id", + "terminal_refund_id": "terminal_refund_id" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/refunds/refund_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Refunds.GetAsync( + new Square.Refunds.GetRefundsRequest { RefundId = "refund_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Refunds/ListTest.cs b/src/Square.Test/Unit/MockServer/Refunds/ListTest.cs new file mode 100644 index 00000000..40bdb489 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Refunds/ListTest.cs @@ -0,0 +1,106 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Refunds; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Refunds; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refunds": [ + { + "id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY_69MmgHubkLqx9wGhnmenRUHOaKitE6llfZuxcWYjGxd", + "status": "COMPLETED", + "location_id": "L88917AVBK2S5", + "unlinked": true, + "destination_type": "destination_type", + "amount_money": { + "amount": 555, + "currency": "USD" + }, + "processing_fee": [ + { + "effective_at": "2021-10-13T21:34:35.000Z", + "type": "INITIAL", + "amount_money": { + "amount": -34, + "currency": "USD" + } + } + ], + "payment_id": "bP9mAsEMYPUGjjGNaNO5ZDVyLhSZY", + "order_id": "9ltv0bx5PuvGXUYHYHxYSKEqC3IZY", + "reason": "Example Refund", + "created_at": "2021-10-13T19:59:05.342Z", + "updated_at": "2021-10-13T20:00:03.497Z", + "team_member_id": "team_member_id", + "terminal_refund_id": "terminal_refund_id" + } + ], + "cursor": "5evquW1YswHoT4EoyUhzMmTsCnsSXBU9U0WJ4FU4623nrMQcocH0RGU6Up1YkwfiMcF59ood58EBTEGgzMTGHQJpocic7ExOL0NtrTXCeWcv0UJIJNk8eXb" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/refunds") + .WithParam("begin_time", "begin_time") + .WithParam("end_time", "end_time") + .WithParam("sort_order", "sort_order") + .WithParam("cursor", "cursor") + .WithParam("location_id", "location_id") + .WithParam("status", "status") + .WithParam("source_type", "source_type") + .WithParam("limit", "1") + .WithParam("updated_at_begin_time", "updated_at_begin_time") + .WithParam("updated_at_end_time", "updated_at_end_time") + .WithParam("sort_field", "CREATED_AT") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Refunds.ListAsync( + new ListRefundsRequest + { + BeginTime = "begin_time", + EndTime = "end_time", + SortOrder = "sort_order", + Cursor = "cursor", + LocationId = "location_id", + Status = "status", + SourceType = "source_type", + Limit = 1, + UpdatedAtBeginTime = "updated_at_begin_time", + UpdatedAtEndTime = "updated_at_end_time", + SortField = ListPaymentRefundsRequestSortField.CreatedAt, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Refunds/RefundPaymentTest.cs b/src/Square.Test/Unit/MockServer/Refunds/RefundPaymentTest.cs new file mode 100644 index 00000000..16ba8148 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Refunds/RefundPaymentTest.cs @@ -0,0 +1,110 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Refunds; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Refunds; + +[TestFixture] +public class RefundPaymentTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "9b7f2dcf-49da-4411-b23e-a2d6af21333a", + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "app_fee_money": { + "amount": 10, + "currency": "USD" + }, + "payment_id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY", + "reason": "Example" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refund": { + "id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY_KlWP8IC1557ddwc9QWTKrCVU6m0JXDz15R2Qym5eQfR", + "status": "PENDING", + "location_id": "L88917AVBK2S5", + "unlinked": true, + "destination_type": "destination_type", + "destination_details": { + "cash_details": { + "seller_supplied_money": {} + }, + "external_details": { + "type": "type", + "source": "source" + } + }, + "amount_money": { + "amount": 1000, + "currency": "USD" + }, + "app_fee_money": { + "amount": 10, + "currency": "USD" + }, + "processing_fee": [ + {} + ], + "payment_id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY", + "order_id": "1JLEUZeEooAIX8HMqm9kvWd69aQZY", + "reason": "Example", + "created_at": "2021-10-13T21:23:19.116Z", + "updated_at": "2021-10-13T21:23:19.508Z", + "team_member_id": "team_member_id", + "terminal_refund_id": "terminal_refund_id" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/refunds") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Refunds.RefundPaymentAsync( + new RefundPaymentRequest + { + IdempotencyKey = "9b7f2dcf-49da-4411-b23e-a2d6af21333a", + AmountMoney = new Money { Amount = 1000, Currency = Currency.Usd }, + AppFeeMoney = new Money { Amount = 10, Currency = Currency.Usd }, + PaymentId = "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY", + Reason = "Example", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Sites/ListTest.cs b/src/Square.Test/Unit/MockServer/Sites/ListTest.cs new file mode 100644 index 00000000..dd10af6c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Sites/ListTest.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Sites; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "sites": [ + { + "id": "site_278075276488921835", + "site_title": "My Second Site", + "domain": "mysite2.square.site", + "is_published": false, + "created_at": "2020-10-28T13:22:51.000Z", + "updated_at": "2020-10-28T13:22:51.000Z" + }, + { + "id": "site_102725345836253849", + "site_title": "My First Site", + "domain": "mysite1.square.site", + "is_published": true, + "created_at": "2020-06-18T17:45:13.000Z", + "updated_at": "2020-11-23T02:19:10.000Z" + } + ] + } + """; + + Server + .Given(WireMock.RequestBuilders.Request.Create().WithPath("/v2/sites").UsingGet()) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Sites.ListAsync(); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Snippets/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Snippets/DeleteTest.cs new file mode 100644 index 00000000..82fe0357 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Snippets/DeleteTest.cs @@ -0,0 +1,51 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Snippets; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Snippets; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/sites/site_id/snippet") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Snippets.DeleteAsync( + new DeleteSnippetsRequest { SiteId = "site_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Snippets/GetTest.cs b/src/Square.Test/Unit/MockServer/Snippets/GetTest.cs new file mode 100644 index 00000000..3ac66e2f --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Snippets/GetTest.cs @@ -0,0 +1,58 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Snippets; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Snippets; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "snippet": { + "id": "snippet_5d178150-a6c0-11eb-a9f1-437e6a2881e7", + "site_id": "site_278075276488921835", + "content": "", + "created_at": "2021-03-11T25:40:09.000000Z", + "updated_at": "2021-03-11T25:40:09.000000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/sites/site_id/snippet") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Snippets.GetAsync( + new GetSnippetsRequest { SiteId = "site_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Snippets/UpsertTest.cs b/src/Square.Test/Unit/MockServer/Snippets/UpsertTest.cs new file mode 100644 index 00000000..64eb911c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Snippets/UpsertTest.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Snippets; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Snippets; + +[TestFixture] +public class UpsertTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "snippet": { + "content": "" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "snippet": { + "id": "snippet_5d178150-a6c0-11eb-a9f1-437e6a2881e7", + "site_id": "site_278075276488921835", + "content": "", + "created_at": "2021-03-11T25:40:09.000000Z", + "updated_at": "2021-03-11T25:40:09.000000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/sites/site_id/snippet") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Snippets.UpsertAsync( + new UpsertSnippetRequest + { + SiteId = "site_id", + Snippet = new Snippet { Content = "" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/BulkSwapPlanTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/BulkSwapPlanTest.cs new file mode 100644 index 00000000..616c11d1 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/BulkSwapPlanTest.cs @@ -0,0 +1,67 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class BulkSwapPlanTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "new_plan_variation_id": "FQ7CDXXWSLUJRPM3GFJSJGZ7", + "old_plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "location_id": "S8GWD5R9QB376" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "affected_subscriptions": 12 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/bulk-swap-plan") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.BulkSwapPlanAsync( + new BulkSwapPlanRequest + { + NewPlanVariationId = "FQ7CDXXWSLUJRPM3GFJSJGZ7", + OldPlanVariationId = "6JHXF3B2CW3YKHDV4XEM674H", + LocationId = "S8GWD5R9QB376", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/CancelTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/CancelTest.cs new file mode 100644 index 00000000..a1a4bd45 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/CancelTest.cs @@ -0,0 +1,98 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "910afd30-464a-4e00-a8d8-2296e", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2022-01-19", + "canceled_date": "2023-06-05", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "inv:0-ChrcX_i3sNmfsHTGKhI4Wg2mceA" + ], + "price_override_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "version": 3, + "created_at": "2022-01-19T21:53:10.000Z", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "completed_date": "completed_date" + }, + "actions": [ + { + "id": "id", + "type": "CANCEL", + "effective_date": "effective_date", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "new_plan_variation_id": "new_plan_variation_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/cancel") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.CancelAsync( + new CancelSubscriptionsRequest { SubscriptionId = "subscription_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/ChangeBillingAnchorDateTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/ChangeBillingAnchorDateTest.cs new file mode 100644 index 00000000..b83a4546 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/ChangeBillingAnchorDateTest.cs @@ -0,0 +1,114 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class ChangeBillingAnchorDateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "monthly_billing_anchor_date": 1 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "9ba40961-995a-4a3d-8c53-048c40cafc13", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "FQ7CDXXWSLUJRPM3GFJSJGZ7", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "start_date", + "canceled_date": "canceled_date", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "price_override_money": { + "amount": 2000, + "currency": "USD" + }, + "version": 3, + "created_at": "2023-06-20T21:53:10.000Z", + "card_id": "card_id", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 20, + "phases": [ + { + "uid": "98d6f53b-40e1-4714-8827-032fd923be25", + "ordinal": 0, + "order_template_id": "E6oBY5WfQ2eN4pkYZwq4ka6n7KeZY", + "plan_phase_uid": "C66BKH3ASTDYGJJCEZXQQSS7" + } + ], + "completed_date": "completed_date" + }, + "actions": [ + { + "id": "f0a1dfdc-675b-3a14-a640-99f7ac1cee83", + "type": "CHANGE_BILLING_ANCHOR_DATE", + "effective_date": "2023-11-01", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "new_plan_variation_id": "new_plan_variation_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/billing-anchor") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.ChangeBillingAnchorDateAsync( + new ChangeBillingAnchorDateRequest + { + SubscriptionId = "subscription_id", + MonthlyBillingAnchorDate = 1, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/CreateTest.cs new file mode 100644 index 00000000..6f01fd7e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/CreateTest.cs @@ -0,0 +1,127 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "8193148c-9586-11e6-99f9-28cfe92138cf", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2023-06-20", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "phases": [ + { + "ordinal": 0, + "order_template_id": "U2NaowWxzXwpsZU697x7ZHOAnCNZY" + } + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2023-06-20", + "canceled_date": "canceled_date", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "price_override_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "version": 1, + "created_at": "2023-06-20T21:53:10.000Z", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + { + "uid": "873451e0-745b-4e87-ab0b-c574933fe616", + "ordinal": 0, + "order_template_id": "U2NaowWxzXwpsZU697x7ZHOAnCNZY", + "plan_phase_uid": "X2Q2AONPB3RB64Y27S25QCZP" + } + ], + "completed_date": "completed_date" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.CreateAsync( + new CreateSubscriptionRequest + { + IdempotencyKey = "8193148c-9586-11e6-99f9-28cfe92138cf", + LocationId = "S8GWD5R9QB376", + PlanVariationId = "6JHXF3B2CW3YKHDV4XEM674H", + CustomerId = "CHFGVKYY8RSV93M5KCYTG4PN0G", + StartDate = "2023-06-20", + CardId = "ccof:qy5x8hHGYsgLrp4Q4GB", + Timezone = "America/Los_Angeles", + Source = new SubscriptionSource { Name = "My Application" }, + Phases = new List() + { + new Phase { Ordinal = 0, OrderTemplateId = "U2NaowWxzXwpsZU697x7ZHOAnCNZY" }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/DeleteActionTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/DeleteActionTest.cs new file mode 100644 index 00000000..dd60b0ec --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/DeleteActionTest.cs @@ -0,0 +1,90 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class DeleteActionTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "8151fc89-da15-4eb9-a685-1a70883cebfc", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "start_date": "2022-07-27", + "canceled_date": "canceled_date", + "charged_through_date": "2023-11-20", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "inv:0-ChrcX_i3sNmfsHTGKhI4Wg2mceA" + ], + "price_override_money": { + "amount": 25000, + "currency": "USD" + }, + "version": 1000000, + "created_at": "2022-07-27T21:53:10.000Z", + "card_id": "ccof:IkWfpLj4tNHMyFii3GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "completed_date": "completed_date" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/actions/action_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.DeleteActionAsync( + new DeleteActionSubscriptionsRequest + { + SubscriptionId = "subscription_id", + ActionId = "action_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/GetTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/GetTest.cs new file mode 100644 index 00000000..2dcf4102 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/GetTest.cs @@ -0,0 +1,89 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "8151fc89-da15-4eb9-a685-1a70883cebfc", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "JDKYHBWT1D4F8MFH63DBMEN8Y4", + "start_date": "2022-07-27", + "canceled_date": "canceled_date", + "charged_through_date": "2023-11-20", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "inv:0-ChCHu2mZEabLeeHahQnXDjZQECY", + "inv:0-ChrcX_i3sNmfsHTGKhI4Wg2mceA" + ], + "price_override_money": { + "amount": 25000, + "currency": "USD" + }, + "version": 1000000, + "created_at": "2022-07-27T21:53:10.000Z", + "card_id": "ccof:IkWfpLj4tNHMyFii3GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "completed_date": "completed_date" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id") + .WithParam("include", "include") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.GetAsync( + new Square.Subscriptions.GetSubscriptionsRequest + { + SubscriptionId = "subscription_id", + Include = "include", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/ListEventsTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/ListEventsTest.cs new file mode 100644 index 00000000..5a700438 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/ListEventsTest.cs @@ -0,0 +1,134 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class ListEventsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription_events": [ + { + "id": "06809161-3867-4598-8269-8aea5be4f9de", + "subscription_event_type": "START_SUBSCRIPTION", + "effective_date": "2020-04-24", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H" + }, + { + "id": "f2736603-cd2e-47ec-8675-f815fff54f88", + "subscription_event_type": "DEACTIVATE_SUBSCRIPTION", + "effective_date": "2020-05-01", + "monthly_billing_anchor_date": 1, + "info": { + "detail": "The customer with ID `V74BMG0GPS2KNCWJE1BTYJ37Y0` does not have a name on record.", + "code": "CUSTOMER_NO_NAME" + }, + "phases": [ + {} + ], + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H" + }, + { + "id": "b426fc85-6859-450b-b0d0-fe3a5d1b565f", + "subscription_event_type": "RESUME_SUBSCRIPTION", + "effective_date": "2022-05-01", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H" + }, + { + "id": "09f14de1-2f53-4dae-9091-49aa53f83d01", + "subscription_event_type": "PAUSE_SUBSCRIPTION", + "effective_date": "2022-09-01", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H" + }, + { + "id": "f28a73ac-1a1b-4b0f-8eeb-709a72945776", + "subscription_event_type": "RESUME_SUBSCRIPTION", + "effective_date": "2022-12-01", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H" + }, + { + "id": "1eee8790-472d-4efe-8c69-8ad84e9cefe0", + "subscription_event_type": "PLAN_CHANGE", + "effective_date": "2023-04-01", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "plan_variation_id": "02CD53CFA4d1498AFAD42" + }, + { + "id": "a0c08083-5db0-4800-85c7-d398de4fbb6e", + "subscription_event_type": "STOP_SUBSCRIPTION", + "effective_date": "2023-06-21", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/events") + .WithParam("cursor", "cursor") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Subscriptions.ListEventsAsync( + new ListEventsSubscriptionsRequest + { + SubscriptionId = "subscription_id", + Cursor = "cursor", + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/PauseTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/PauseTest.cs new file mode 100644 index 00000000..33ccb6a6 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/PauseTest.cs @@ -0,0 +1,108 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class PauseTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2023-06-20", + "canceled_date": "canceled_date", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "price_override_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "version": 1, + "created_at": "2023-06-20T21:53:10.000Z", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + { + "uid": "873451e0-745b-4e87-ab0b-c574933fe616", + "ordinal": 0, + "order_template_id": "U2NaowWxzXwpsZU697x7ZHOAnCNZY", + "plan_phase_uid": "X2Q2AONPB3RB64Y27S25QCZP" + } + ], + "completed_date": "completed_date" + }, + "actions": [ + { + "id": "99b2439e-63f7-3ad5-95f7-ab2447a80673", + "type": "PAUSE", + "effective_date": "2023-11-17", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "new_plan_variation_id": "new_plan_variation_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/pause") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.PauseAsync( + new PauseSubscriptionRequest { SubscriptionId = "subscription_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/ResumeTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/ResumeTest.cs new file mode 100644 index 00000000..180845fb --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/ResumeTest.cs @@ -0,0 +1,108 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class ResumeTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2023-06-20", + "canceled_date": "canceled_date", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "price_override_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "version": 1, + "created_at": "2023-06-20T21:53:10.000Z", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + { + "uid": "873451e0-745b-4e87-ab0b-c574933fe616", + "ordinal": 0, + "order_template_id": "U2NaowWxzXwpsZU697x7ZHOAnCNZY", + "plan_phase_uid": "X2Q2AONPB3RB64Y27S25QCZP" + } + ], + "completed_date": "completed_date" + }, + "actions": [ + { + "id": "18ff74f4-3da4-30c5-929f-7d6fca84f115", + "type": "RESUME", + "effective_date": "2023-09-01", + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "new_plan_variation_id": "new_plan_variation_id" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/resume") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.ResumeAsync( + new ResumeSubscriptionRequest { SubscriptionId = "subscription_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/SearchTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/SearchTest.cs new file mode 100644 index 00000000..0a1cdbba --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/SearchTest.cs @@ -0,0 +1,183 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "customer_ids": [ + "CHFGVKYY8RSV93M5KCYTG4PN0G" + ], + "location_ids": [ + "S8GWD5R9QB376" + ], + "source_names": [ + "My App" + ] + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscriptions": [ + { + "id": "de86fc96-8664-474b-af1a-abbe59cacf0e", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "L3TJVDHVBEQEGQDEZL2JJM7R", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2021-10-20", + "canceled_date": "2021-10-30", + "charged_through_date": "2021-11-20", + "status": "CANCELED", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "version": 1000000, + "created_at": "2021-10-20T21:53:10.000Z", + "card_id": "ccof:mueUsvgajChmjEbp4GB", + "timezone": "UTC", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "completed_date": "completed_date" + }, + { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2022-01-19", + "canceled_date": "canceled_date", + "charged_through_date": "2022-08-19", + "status": "PAUSED", + "tax_percentage": "5", + "invoice_ids": [ + "grebK0Q_l8H4fqoMMVvt-Q", + "rcX_i3sNmHTGKhI4W2mceA" + ], + "price_override_money": { + "amount": 1000, + "currency": "USD" + }, + "version": 2, + "created_at": "2022-01-19T21:53:10.000Z", + "card_id": "card_id", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "completed_date": "completed_date" + }, + { + "id": "56214fb2-cc85-47a1-93bc-44f3766bb56f", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "6JHXF3B2CW3YKHDV4XEM674H", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "2023-06-20", + "canceled_date": "canceled_date", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "version": 1, + "created_at": "2023-06-20T21:53:10.000Z", + "card_id": "ccof:qy5x8hHGYsgLrp4Q4GB", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + { + "uid": "873451e0-745b-4e87-ab0b-c574933fe616", + "ordinal": 0, + "order_template_id": "U2NaowWxzXwpsZU697x7ZHOAnCNZY", + "plan_phase_uid": "X2Q2AONPB3RB64Y27S25QCZP" + } + ], + "completed_date": "completed_date" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.SearchAsync( + new SearchSubscriptionsRequest + { + Query = new SearchSubscriptionsQuery + { + Filter = new SearchSubscriptionsFilter + { + CustomerIds = new List() { "CHFGVKYY8RSV93M5KCYTG4PN0G" }, + LocationIds = new List() { "S8GWD5R9QB376" }, + SourceNames = new List() { "My App" }, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/SwapPlanTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/SwapPlanTest.cs new file mode 100644 index 00000000..da634405 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/SwapPlanTest.cs @@ -0,0 +1,130 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class SwapPlanTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "new_plan_variation_id": "FQ7CDXXWSLUJRPM3GFJSJGZ7", + "phases": [ + { + "ordinal": 0, + "order_template_id": "uhhnjH9osVv3shUADwaC0b3hNxQZY" + } + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "9ba40961-995a-4a3d-8c53-048c40cafc13", + "location_id": "S8GWD5R9QB376", + "plan_variation_id": "FQ7CDXXWSLUJRPM3GFJSJGZ7", + "customer_id": "CHFGVKYY8RSV93M5KCYTG4PN0G", + "start_date": "start_date", + "canceled_date": "canceled_date", + "charged_through_date": "charged_through_date", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "invoice_ids" + ], + "price_override_money": { + "amount": 2000, + "currency": "USD" + }, + "version": 3, + "created_at": "2023-06-20T21:53:10.000Z", + "card_id": "card_id", + "timezone": "America/Los_Angeles", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + { + "uid": "98d6f53b-40e1-4714-8827-032fd923be25", + "ordinal": 0, + "order_template_id": "E6oBY5WfQ2eN4pkYZwq4ka6n7KeZY", + "plan_phase_uid": "C66BKH3ASTDYGJJCEZXQQSS7" + } + ], + "completed_date": "completed_date" + }, + "actions": [ + { + "id": "f0a1dfdc-675b-3a14-a640-99f7ac1cee83", + "type": "SWAP_PLAN", + "effective_date": "2023-11-17", + "monthly_billing_anchor_date": 1, + "phases": [ + { + "ordinal": 0, + "order_template_id": "uhhnjH9osVv3shUADwaC0b3hNxQZY" + } + ], + "new_plan_variation_id": "FQ7CDXXWSLUJRPM3GFJSJGZ7" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id/swap-plan") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.SwapPlanAsync( + new SwapPlanRequest + { + SubscriptionId = "subscription_id", + NewPlanVariationId = "FQ7CDXXWSLUJRPM3GFJSJGZ7", + Phases = new List() + { + new PhaseInput + { + Ordinal = 0, + OrderTemplateId = "uhhnjH9osVv3shUADwaC0b3hNxQZY", + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Subscriptions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Subscriptions/UpdateTest.cs new file mode 100644 index 00000000..e02784b3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Subscriptions/UpdateTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Subscriptions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Subscriptions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "subscription": { + "card_id": "{NEW CARD ID}" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "7217d8ca-1fee-4446-a9e5-8540b5d8c9bb", + "location_id": "LPJKHYR7WFDKN", + "plan_variation_id": "XOUNEKCE6NSXQW5NTSQ73MMX", + "customer_id": "AM69AB81FT4479YH9HGWS1HZY8", + "start_date": "2023-01-30", + "canceled_date": "canceled_date", + "charged_through_date": "2023-03-13", + "status": "ACTIVE", + "tax_percentage": "tax_percentage", + "invoice_ids": [ + "inv:0-ChAPSfVYvNewckgf3x4iigN_ENMM", + "inv:0-ChBQaCCLfjcm9WEUBGxvuydJENMM" + ], + "price_override_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "version": 3, + "created_at": "2023-01-30T19:27:32.000Z", + "card_id": "{NEW CARD ID}", + "timezone": "UTC", + "source": { + "name": "My Application" + }, + "actions": [ + {} + ], + "monthly_billing_anchor_date": 1, + "phases": [ + {} + ], + "completed_date": "completed_date" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/subscriptions/subscription_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Subscriptions.UpdateAsync( + new UpdateSubscriptionRequest + { + SubscriptionId = "subscription_id", + Subscription = new Subscription { CardId = "{NEW CARD ID}" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Team/CreateJobTest.cs b/src/Square.Test/Unit/MockServer/Team/CreateJobTest.cs new file mode 100644 index 00000000..be631116 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Team/CreateJobTest.cs @@ -0,0 +1,75 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Team; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Team; + +[TestFixture] +public class CreateJobTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "job": { + "title": "Cashier", + "is_tip_eligible": true + }, + "idempotency_key": "idempotency-key-0" + } + """; + + const string mockResponse = """ + { + "job": { + "id": "1yJlHapkseYnNPETIU1B", + "title": "Cashier", + "is_tip_eligible": true, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z", + "version": 1 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/jobs") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Team.CreateJobAsync( + new CreateJobRequest + { + Job = new Job { Title = "Cashier", IsTipEligible = true }, + IdempotencyKey = "idempotency-key-0", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Team/ListJobsTest.cs b/src/Square.Test/Unit/MockServer/Team/ListJobsTest.cs new file mode 100644 index 00000000..9d66512c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Team/ListJobsTest.cs @@ -0,0 +1,69 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Team; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Team; + +[TestFixture] +public class ListJobsTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "jobs": [ + { + "id": "VDNpRv8da51NU8qZFC5zDWpF", + "title": "Cashier", + "is_tip_eligible": true, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z", + "version": 2 + }, + { + "id": "FjS8x95cqHiMenw4f1NAUH4P", + "title": "Chef", + "is_tip_eligible": false, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z", + "version": 1 + } + ], + "cursor": "cursor", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/jobs") + .WithParam("cursor", "cursor") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Team.ListJobsAsync(new ListJobsRequest { Cursor = "cursor" }); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Team/RetrieveJobTest.cs b/src/Square.Test/Unit/MockServer/Team/RetrieveJobTest.cs new file mode 100644 index 00000000..ceca6aa6 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Team/RetrieveJobTest.cs @@ -0,0 +1,59 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Team; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Team; + +[TestFixture] +public class RetrieveJobTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "job": { + "id": "1yJlHapkseYnNPETIU1B", + "title": "Cashier 1", + "is_tip_eligible": true, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z", + "version": 2 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/jobs/job_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Team.RetrieveJobAsync( + new RetrieveJobRequest { JobId = "job_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Team/UpdateJobTest.cs b/src/Square.Test/Unit/MockServer/Team/UpdateJobTest.cs new file mode 100644 index 00000000..1e21143c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Team/UpdateJobTest.cs @@ -0,0 +1,74 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Team; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Team; + +[TestFixture] +public class UpdateJobTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "job": { + "title": "Cashier 1", + "is_tip_eligible": true + } + } + """; + + const string mockResponse = """ + { + "job": { + "id": "1yJlHapkseYnNPETIU1B", + "title": "Cashier 1", + "is_tip_eligible": true, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-13T12:55:45.000Z", + "version": 2 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/jobs/job_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Team.UpdateJobAsync( + new UpdateJobRequest + { + JobId = "job_id", + Job = new Job { Title = "Cashier 1", IsTipEligible = true }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/BatchCreateTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/BatchCreateTest.cs new file mode 100644 index 00000000..1a4cbc52 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/BatchCreateTest.cs @@ -0,0 +1,185 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.TeamMembers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers; + +[TestFixture] +public class BatchCreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "team_members": { + "idempotency-key-1": { + "team_member": { + "reference_id": "reference_id_1", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@gmail.com", + "phone_number": "+14159283333", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "YSGH2WBKG94QZ", + "GA2Y9HSJ8KRYT" + ] + } + } + }, + "idempotency-key-2": { + "team_member": { + "reference_id": "reference_id_2", + "given_name": "Jane", + "family_name": "Smith", + "email_address": "jane_smith@gmail.com", + "phone_number": "+14159223334", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + } + } + } + } + """; + + const string mockResponse = """ + { + "team_members": { + "idempotency-key-1": { + "team_member": { + "id": "ywhG1qfIOoqsHfVRubFV", + "reference_id": "reference_id_1", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@gmail.com", + "phone_number": "+14159283333", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "GA2Y9HSJ8KRYT", + "YSGH2WBKG94QZ" + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "idempotency-key-2": { + "team_member": { + "id": "IF_Ncrg7fHhCqxVI9T6R", + "reference_id": "reference_id_2", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Jane", + "family_name": "Smith", + "email_address": "jane_smith@gmail.com", + "phone_number": "+14159223334", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/bulk-create") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.BatchCreateAsync( + new BatchCreateTeamMembersRequest + { + TeamMembers = new Dictionary() + { + { + "idempotency-key-1", + new CreateTeamMemberRequest + { + TeamMember = new TeamMember + { + ReferenceId = "reference_id_1", + GivenName = "Joe", + FamilyName = "Doe", + EmailAddress = "joe_doe@gmail.com", + PhoneNumber = "+14159283333", + AssignedLocations = new TeamMemberAssignedLocations + { + AssignmentType = + TeamMemberAssignedLocationsAssignmentType.ExplicitLocations, + LocationIds = new List() + { + "YSGH2WBKG94QZ", + "GA2Y9HSJ8KRYT", + }, + }, + }, + } + }, + { + "idempotency-key-2", + new CreateTeamMemberRequest + { + TeamMember = new TeamMember + { + ReferenceId = "reference_id_2", + GivenName = "Jane", + FamilyName = "Smith", + EmailAddress = "jane_smith@gmail.com", + PhoneNumber = "+14159223334", + AssignedLocations = new TeamMemberAssignedLocations + { + AssignmentType = + TeamMemberAssignedLocationsAssignmentType.AllCurrentAndFutureLocations, + }, + }, + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/BatchUpdateTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/BatchUpdateTest.cs new file mode 100644 index 00000000..b0150fb3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/BatchUpdateTest.cs @@ -0,0 +1,197 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.TeamMembers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers; + +[TestFixture] +public class BatchUpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "team_members": { + "AFMwA08kR-MIF-3Vs0OE": { + "team_member": { + "reference_id": "reference_id_2", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Jane", + "family_name": "Smith", + "email_address": "jane_smith@gmail.com", + "phone_number": "+14159223334", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + } + }, + "fpgteZNMaf0qOK-a4t6P": { + "team_member": { + "reference_id": "reference_id_1", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@gmail.com", + "phone_number": "+14159283333", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "YSGH2WBKG94QZ", + "GA2Y9HSJ8KRYT" + ] + } + } + } + } + } + """; + + const string mockResponse = """ + { + "team_members": { + "AFMwA08kR-MIF-3Vs0OE": { + "team_member": { + "id": "AFMwA08kR-MIF-3Vs0OE", + "reference_id": "reference_id_2", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Jane", + "family_name": "Smith", + "email_address": "jane_smith@example.com", + "phone_number": "+14159223334", + "created_at": "2020-03-24T18:14:00.000Z", + "updated_at": "2020-03-24T18:18:00.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + }, + "fpgteZNMaf0qOK-a4t6P": { + "team_member": { + "id": "fpgteZNMaf0qOK-a4t6P", + "reference_id": "reference_id_1", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@example.com", + "phone_number": "+14159283333", + "created_at": "2020-03-24T18:14:00.000Z", + "updated_at": "2020-03-24T18:18:00.000Z", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "GA2Y9HSJ8KRYT", + "YSGH2WBKG94QZ" + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ] + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/bulk-update") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.BatchUpdateAsync( + new BatchUpdateTeamMembersRequest + { + TeamMembers = new Dictionary() + { + { + "AFMwA08kR-MIF-3Vs0OE", + new UpdateTeamMemberRequest + { + TeamMember = new TeamMember + { + ReferenceId = "reference_id_2", + IsOwner = false, + Status = TeamMemberStatus.Active, + GivenName = "Jane", + FamilyName = "Smith", + EmailAddress = "jane_smith@gmail.com", + PhoneNumber = "+14159223334", + AssignedLocations = new TeamMemberAssignedLocations + { + AssignmentType = + TeamMemberAssignedLocationsAssignmentType.AllCurrentAndFutureLocations, + }, + }, + } + }, + { + "fpgteZNMaf0qOK-a4t6P", + new UpdateTeamMemberRequest + { + TeamMember = new TeamMember + { + ReferenceId = "reference_id_1", + IsOwner = false, + Status = TeamMemberStatus.Active, + GivenName = "Joe", + FamilyName = "Doe", + EmailAddress = "joe_doe@gmail.com", + PhoneNumber = "+14159283333", + AssignedLocations = new TeamMemberAssignedLocations + { + AssignmentType = + TeamMemberAssignedLocationsAssignmentType.ExplicitLocations, + LocationIds = new List() + { + "YSGH2WBKG94QZ", + "GA2Y9HSJ8KRYT", + }, + }, + }, + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/CreateTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/CreateTest.cs new file mode 100644 index 00000000..2f48e40b --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/CreateTest.cs @@ -0,0 +1,189 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "idempotency-key-0", + "team_member": { + "reference_id": "reference_id_1", + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@gmail.com", + "phone_number": "+14159283333", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "YSGH2WBKG94QZ", + "GA2Y9HSJ8KRYT" + ] + }, + "wage_setting": { + "job_assignments": [ + { + "pay_type": "SALARY", + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40, + "job_id": "FjS8x95cqHiMenw4f1NAUH4P" + }, + { + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true + } + } + } + """; + + const string mockResponse = """ + { + "team_member": { + "id": "1yJlHapkseYnNPETIU1B", + "reference_id": "reference_id_1", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@example.com", + "phone_number": "+14159283333", + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "GA2Y9HSJ8KRYT", + "YSGH2WBKG94QZ" + ] + }, + "wage_setting": { + "team_member_id": "1yJlHapkseYnNPETIU1B", + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "hourly_rate": { + "amount": 1443, + "currency": "USD" + }, + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40, + "job_id": "FjS8x95cqHiMenw4f1NAUH4P" + }, + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.CreateAsync( + new CreateTeamMemberRequest + { + IdempotencyKey = "idempotency-key-0", + TeamMember = new TeamMember + { + ReferenceId = "reference_id_1", + Status = TeamMemberStatus.Active, + GivenName = "Joe", + FamilyName = "Doe", + EmailAddress = "joe_doe@gmail.com", + PhoneNumber = "+14159283333", + AssignedLocations = new TeamMemberAssignedLocations + { + AssignmentType = + TeamMemberAssignedLocationsAssignmentType.ExplicitLocations, + LocationIds = new List() { "YSGH2WBKG94QZ", "GA2Y9HSJ8KRYT" }, + }, + WageSetting = new Square.WageSetting + { + JobAssignments = new List() + { + new JobAssignment + { + PayType = JobAssignmentPayType.Salary, + AnnualRate = new Money + { + Amount = 3000000, + Currency = Currency.Usd, + }, + WeeklyHours = 40, + JobId = "FjS8x95cqHiMenw4f1NAUH4P", + }, + new JobAssignment + { + PayType = JobAssignmentPayType.Hourly, + HourlyRate = new Money { Amount = 2000, Currency = Currency.Usd }, + JobId = "VDNpRv8da51NU8qZFC5zDWpF", + }, + }, + IsOvertimeExempt = true, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/GetTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/GetTest.cs new file mode 100644 index 00000000..f3f4fc58 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/GetTest.cs @@ -0,0 +1,102 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.TeamMembers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "team_member": { + "id": "1yJlHapkseYnNPETIU1B", + "reference_id": "reference_id_1", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@example.com", + "phone_number": "+14159283333", + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-15T17:38:05.000Z", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "GA2Y9HSJ8KRYT", + "YSGH2WBKG94QZ" + ] + }, + "wage_setting": { + "team_member_id": "1yJlHapkseYnNPETIU1B", + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "hourly_rate": { + "amount": 1443, + "currency": "USD" + }, + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40, + "job_id": "FjS8x95cqHiMenw4f1NAUH4P" + }, + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/team_member_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.GetAsync( + new GetTeamMembersRequest { TeamMemberId = "team_member_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/SearchTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/SearchTest.cs new file mode 100644 index 00000000..0eabb4df --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/SearchTest.cs @@ -0,0 +1,336 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.TeamMembers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "location_ids": [ + "0G5P3VGACMMQZ" + ], + "status": "ACTIVE" + } + }, + "limit": 10 + } + """; + + const string mockResponse = """ + { + "team_members": [ + { + "id": "-3oZQKPKVk6gUXU_V5Qa", + "reference_id": "12345678", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Johnny", + "family_name": "Cash", + "email_address": "johnny_cash@squareup.com", + "phone_number": "phone_number", + "created_at": "2019-07-10T17:26:48.000Z", + "updated_at": "2020-04-28T21:49:28.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + }, + "wage_setting": { + "team_member_id": "-3oZQKPKVk6gUXU_V5Qa", + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "hourly_rate": { + "amount": 1443, + "currency": "USD" + }, + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40, + "job_id": "FjS8x95cqHiMenw4f1NAUH4P" + }, + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z" + } + }, + { + "id": "1AVJj0DjkzbmbJw5r4KK", + "reference_id": "abcded", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Lombard", + "family_name": "Smith", + "email_address": "email_address", + "phone_number": "+14155552671", + "created_at": "2020-03-24T18:14:01.000Z", + "updated_at": "2020-06-09T17:38:05.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + }, + "wage_setting": { + "team_member_id": "1AVJj0DjkzbmbJw5r4KK", + "job_assignments": [ + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2400, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 2, + "created_at": "2020-03-24T18:14:01.000Z", + "updated_at": "2020-06-09T17:38:05.000Z" + } + }, + { + "id": "2JCmiJol_KKFs9z2Evim", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Monica", + "family_name": "Sway", + "email_address": "email_address", + "phone_number": "phone_number", + "created_at": "2020-03-24T01:09:25.000Z", + "updated_at": "2020-03-24T01:11:25.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + }, + "wage_setting": { + "team_member_id": "2JCmiJol_KKFs9z2Evim", + "job_assignments": [ + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2400, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2020-03-24T01:09:25.000Z", + "updated_at": "2020-03-24T01:09:25.000Z" + } + }, + { + "id": "4uXcJQSLtbk3F0UQHFNQ", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Elton", + "family_name": "Ipsum", + "email_address": "email_address", + "phone_number": "phone_number", + "created_at": "2020-03-24T01:09:23.000Z", + "updated_at": "2020-03-24T01:15:23.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + { + "id": "5CoUpyrw1YwGWcRd-eDL", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Steven", + "family_name": "Lo", + "email_address": "email_address", + "phone_number": "phone_number", + "created_at": "2020-03-24T01:09:23.000Z", + "updated_at": "2020-03-24T01:19:23.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + { + "id": "5MRPTTp8MMBLVSmzrGha", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Patrick", + "family_name": "Steward", + "email_address": "email_address", + "phone_number": "+14155552671", + "created_at": "2020-03-24T18:14:03.000Z", + "updated_at": "2020-03-24T18:18:03.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + }, + "wage_setting": { + "team_member_id": "5MRPTTp8MMBLVSmzrGha", + "job_assignments": [ + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2020-03-24T18:14:03.000Z", + "updated_at": "2020-03-24T18:14:03.000Z" + } + }, + { + "id": "7F5ZxsfRnkexhu1PTbfh", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Ivy", + "family_name": "Manny", + "email_address": "email_address", + "phone_number": "phone_number", + "created_at": "2020-03-24T01:09:25.000Z", + "updated_at": "2020-03-24T01:09:25.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + { + "id": "808X9HR72yKvVaigQXf4", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "John", + "family_name": "Smith", + "email_address": "john_smith@example.com", + "phone_number": "+14155552671", + "created_at": "2020-03-24T18:14:02.000Z", + "updated_at": "2020-03-24T18:14:02.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + { + "id": "9MVDVoY4hazkWKGo_OuZ", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Robert", + "family_name": "Wen", + "email_address": "r_wen@example.com", + "phone_number": "+14155552671", + "created_at": "2020-03-24T18:14:00.000Z", + "updated_at": "2020-03-24T18:14:00.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + } + }, + { + "id": "9UglUjOXQ13-hMFypCft", + "reference_id": "reference_id", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Ashley", + "family_name": "Simpson", + "email_address": "asimpson@example.com", + "phone_number": "+14155552671", + "created_at": "2020-03-24T18:14:00.000Z", + "updated_at": "2020-03-24T18:18:00.000Z", + "assigned_locations": { + "assignment_type": "ALL_CURRENT_AND_FUTURE_LOCATIONS" + }, + "wage_setting": { + "team_member_id": "9UglUjOXQ13-hMFypCft", + "job_assignments": [ + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2020-03-24T18:14:00.000Z", + "updated_at": "2020-03-24T18:14:03.000Z" + } + } + ], + "cursor": "N:9UglUjOXQ13-hMFypCft", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.SearchAsync( + new SearchTeamMembersRequest + { + Query = new SearchTeamMembersQuery + { + Filter = new SearchTeamMembersFilter + { + LocationIds = new List() { "0G5P3VGACMMQZ" }, + Status = TeamMemberStatus.Active, + }, + }, + Limit = 10, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/UpdateTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/UpdateTest.cs new file mode 100644 index 00000000..464d4930 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/UpdateTest.cs @@ -0,0 +1,196 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.TeamMembers; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "team_member": { + "reference_id": "reference_id_1", + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@gmail.com", + "phone_number": "+14159283333", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "YSGH2WBKG94QZ", + "GA2Y9HSJ8KRYT" + ] + }, + "wage_setting": { + "job_assignments": [ + { + "pay_type": "SALARY", + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40, + "job_id": "FjS8x95cqHiMenw4f1NAUH4P" + }, + { + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 1200, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true + } + } + } + """; + + const string mockResponse = """ + { + "team_member": { + "id": "1yJlHapkseYnNPETIU1B", + "reference_id": "reference_id_1", + "is_owner": false, + "status": "ACTIVE", + "given_name": "Joe", + "family_name": "Doe", + "email_address": "joe_doe@example.com", + "phone_number": "+14159283333", + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-15T17:38:05.000Z", + "assigned_locations": { + "assignment_type": "EXPLICIT_LOCATIONS", + "location_ids": [ + "GA2Y9HSJ8KRYT", + "YSGH2WBKG94QZ" + ] + }, + "wage_setting": { + "team_member_id": "1yJlHapkseYnNPETIU1B", + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "hourly_rate": { + "amount": 1443, + "currency": "USD" + }, + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40, + "job_id": "FjS8x95cqHiMenw4f1NAUH4P" + }, + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 1200, + "currency": "USD" + }, + "job_id": "VDNpRv8da51NU8qZFC5zDWpF" + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2021-06-11T22:55:45.000Z", + "updated_at": "2021-06-11T22:55:45.000Z" + } + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/team_member_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.UpdateAsync( + new UpdateTeamMembersRequest + { + TeamMemberId = "team_member_id", + Body = new UpdateTeamMemberRequest + { + TeamMember = new TeamMember + { + ReferenceId = "reference_id_1", + Status = TeamMemberStatus.Active, + GivenName = "Joe", + FamilyName = "Doe", + EmailAddress = "joe_doe@gmail.com", + PhoneNumber = "+14159283333", + AssignedLocations = new TeamMemberAssignedLocations + { + AssignmentType = + TeamMemberAssignedLocationsAssignmentType.ExplicitLocations, + LocationIds = new List() { "YSGH2WBKG94QZ", "GA2Y9HSJ8KRYT" }, + }, + WageSetting = new Square.WageSetting + { + JobAssignments = new List() + { + new JobAssignment + { + PayType = JobAssignmentPayType.Salary, + AnnualRate = new Money + { + Amount = 3000000, + Currency = Currency.Usd, + }, + WeeklyHours = 40, + JobId = "FjS8x95cqHiMenw4f1NAUH4P", + }, + new JobAssignment + { + PayType = JobAssignmentPayType.Hourly, + HourlyRate = new Money + { + Amount = 1200, + Currency = Currency.Usd, + }, + JobId = "VDNpRv8da51NU8qZFC5zDWpF", + }, + }, + IsOvertimeExempt = true, + }, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/GetTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/GetTest.cs new file mode 100644 index 00000000..806156de --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/GetTest.cs @@ -0,0 +1,75 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers.WageSetting; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "wage_setting": { + "team_member_id": "1yJlHapkseYnNPETIU1B", + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "hourly_rate": { + "amount": 2164, + "currency": "USD" + }, + "annual_rate": { + "amount": 4500000, + "currency": "USD" + }, + "weekly_hours": 40 + } + ], + "is_overtime_exempt": false, + "version": 1, + "created_at": "2020-06-11T23:01:21.000Z", + "updated_at": "2020-06-11T23:01:21.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/team_member_id/wage-setting") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.WageSetting.GetAsync( + new Square.TeamMembers.WageSetting.GetWageSettingRequest + { + TeamMemberId = "team_member_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/UpdateTest.cs b/src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/UpdateTest.cs new file mode 100644 index 00000000..9ce14c3a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TeamMembers/WageSetting/UpdateTest.cs @@ -0,0 +1,134 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.TeamMembers.WageSetting; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.TeamMembers.WageSetting; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "wage_setting": { + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40 + }, + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + } + } + ], + "is_overtime_exempt": true + } + } + """; + + const string mockResponse = """ + { + "wage_setting": { + "team_member_id": "-3oZQKPKVk6gUXU_V5Qa", + "job_assignments": [ + { + "job_title": "Manager", + "pay_type": "SALARY", + "hourly_rate": { + "amount": 1443, + "currency": "USD" + }, + "annual_rate": { + "amount": 3000000, + "currency": "USD" + }, + "weekly_hours": 40 + }, + { + "job_title": "Cashier", + "pay_type": "HOURLY", + "hourly_rate": { + "amount": 2000, + "currency": "USD" + } + } + ], + "is_overtime_exempt": true, + "version": 1, + "created_at": "2019-07-10T17:26:48.000Z", + "updated_at": "2020-06-11T23:12:04.000Z" + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/team-members/team_member_id/wage-setting") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TeamMembers.WageSetting.UpdateAsync( + new UpdateWageSettingRequest + { + TeamMemberId = "team_member_id", + WageSetting = new Square.WageSetting + { + JobAssignments = new List() + { + new JobAssignment + { + JobTitle = "Manager", + PayType = JobAssignmentPayType.Salary, + AnnualRate = new Money { Amount = 3000000, Currency = Currency.Usd }, + WeeklyHours = 40, + }, + new JobAssignment + { + JobTitle = "Cashier", + PayType = JobAssignmentPayType.Hourly, + HourlyRate = new Money { Amount = 2000, Currency = Currency.Usd }, + }, + }, + IsOvertimeExempt = true, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Actions/CancelTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Actions/CancelTest.cs new file mode 100644 index 00000000..584d6ab5 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Actions/CancelTest.cs @@ -0,0 +1,127 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Actions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Actions; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "action": { + "id": "termapia:jveJIAkkAjILHkdCE", + "device_id": "DEVICE_ID", + "deadline_duration": "PT5M", + "status": "CANCELED", + "cancel_reason": "SELLER_CANCELED", + "created_at": "2021-07-28T23:22:07.476Z", + "updated_at": "2021-07-28T23:22:29.511Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "type": "SAVE_CARD", + "qr_code_options": { + "title": "title", + "body": "body", + "barcode_contents": "barcode_contents" + }, + "save_card_options": { + "customer_id": "CUSTOMER_ID", + "card_id": "card_id", + "reference_id": "user-id-1" + }, + "signature_options": { + "title": "title", + "body": "body", + "signature": [ + {} + ] + }, + "confirmation_options": { + "title": "title", + "body": "body", + "agree_button_text": "agree_button_text", + "disagree_button_text": "disagree_button_text" + }, + "receipt_options": { + "payment_id": "payment_id", + "print_only": true, + "is_duplicate": true + }, + "data_collection_options": { + "title": "title", + "body": "body", + "input_type": "EMAIL" + }, + "select_options": { + "title": "title", + "body": "body", + "options": [ + { + "reference_id": "reference_id", + "title": "title" + } + ], + "selected_option": { + "reference_id": "reference_id", + "title": "title" + } + }, + "device_metadata": { + "battery_percentage": "battery_percentage", + "charging_state": "charging_state", + "location_id": "location_id", + "merchant_id": "merchant_id", + "network_connection_type": "network_connection_type", + "payment_region": "payment_region", + "serial_number": "serial_number", + "os_version": "os_version", + "app_version": "app_version", + "wifi_network_name": "wifi_network_name", + "wifi_network_strength": "wifi_network_strength", + "ip_address": "ip_address" + }, + "await_next_action": true, + "await_next_action_duration": "await_next_action_duration" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/actions/action_id/cancel") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Actions.CancelAsync( + new CancelActionsRequest { ActionId = "action_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Actions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Actions/CreateTest.cs new file mode 100644 index 00000000..b5da3676 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Actions/CreateTest.cs @@ -0,0 +1,158 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Actions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Actions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e", + "action": { + "device_id": "{{DEVICE_ID}}", + "deadline_duration": "PT5M", + "type": "SAVE_CARD", + "save_card_options": { + "customer_id": "{{CUSTOMER_ID}}", + "reference_id": "user-id-1" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "action": { + "id": "termapia:jveJIAkkAjILHkdCE", + "device_id": "DEVICE_ID", + "deadline_duration": "PT5M", + "status": "PENDING", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2021-07-28T23:22:07.476Z", + "updated_at": "2021-07-28T23:22:07.476Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "type": "SAVE_CARD", + "qr_code_options": { + "title": "title", + "body": "body", + "barcode_contents": "barcode_contents" + }, + "save_card_options": { + "customer_id": "CUSTOMER_ID", + "card_id": "card_id", + "reference_id": "user-id-1" + }, + "signature_options": { + "title": "title", + "body": "body", + "signature": [ + {} + ] + }, + "confirmation_options": { + "title": "title", + "body": "body", + "agree_button_text": "agree_button_text", + "disagree_button_text": "disagree_button_text" + }, + "receipt_options": { + "payment_id": "payment_id", + "print_only": true, + "is_duplicate": true + }, + "data_collection_options": { + "title": "title", + "body": "body", + "input_type": "EMAIL" + }, + "select_options": { + "title": "title", + "body": "body", + "options": [ + { + "reference_id": "reference_id", + "title": "title" + } + ], + "selected_option": { + "reference_id": "reference_id", + "title": "title" + } + }, + "device_metadata": { + "battery_percentage": "battery_percentage", + "charging_state": "charging_state", + "location_id": "location_id", + "merchant_id": "merchant_id", + "network_connection_type": "network_connection_type", + "payment_region": "payment_region", + "serial_number": "serial_number", + "os_version": "os_version", + "app_version": "app_version", + "wifi_network_name": "wifi_network_name", + "wifi_network_strength": "wifi_network_strength", + "ip_address": "ip_address" + }, + "await_next_action": true, + "await_next_action_duration": "await_next_action_duration" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/actions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Actions.CreateAsync( + new CreateTerminalActionRequest + { + IdempotencyKey = "thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e", + Action = new TerminalAction + { + DeviceId = "{{DEVICE_ID}}", + DeadlineDuration = "PT5M", + Type = TerminalActionActionType.SaveCard, + SaveCardOptions = new SaveCardOptions + { + CustomerId = "{{CUSTOMER_ID}}", + ReferenceId = "user-id-1", + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Actions/GetTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Actions/GetTest.cs new file mode 100644 index 00000000..088a1ae4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Actions/GetTest.cs @@ -0,0 +1,127 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Actions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Actions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "action": { + "id": "termapia:jveJIAkkAjILHkdCE", + "device_id": "DEVICE_ID", + "deadline_duration": "PT5M", + "status": "IN_PROGRESS", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2021-07-28T23:22:07.476Z", + "updated_at": "2021-07-28T23:22:08.301Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "type": "SAVE_CARD", + "qr_code_options": { + "title": "title", + "body": "body", + "barcode_contents": "barcode_contents" + }, + "save_card_options": { + "customer_id": "CUSTOMER_ID", + "card_id": "card_id", + "reference_id": "user-id-1" + }, + "signature_options": { + "title": "title", + "body": "body", + "signature": [ + {} + ] + }, + "confirmation_options": { + "title": "title", + "body": "body", + "agree_button_text": "agree_button_text", + "disagree_button_text": "disagree_button_text" + }, + "receipt_options": { + "payment_id": "payment_id", + "print_only": true, + "is_duplicate": true + }, + "data_collection_options": { + "title": "title", + "body": "body", + "input_type": "EMAIL" + }, + "select_options": { + "title": "title", + "body": "body", + "options": [ + { + "reference_id": "reference_id", + "title": "title" + } + ], + "selected_option": { + "reference_id": "reference_id", + "title": "title" + } + }, + "device_metadata": { + "battery_percentage": "battery_percentage", + "charging_state": "charging_state", + "location_id": "location_id", + "merchant_id": "merchant_id", + "network_connection_type": "network_connection_type", + "payment_region": "payment_region", + "serial_number": "serial_number", + "os_version": "os_version", + "app_version": "app_version", + "wifi_network_name": "wifi_network_name", + "wifi_network_strength": "wifi_network_strength", + "ip_address": "ip_address" + }, + "await_next_action": true, + "await_next_action_duration": "await_next_action_duration" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/actions/action_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Actions.GetAsync( + new GetActionsRequest { ActionId = "action_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Actions/SearchTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Actions/SearchTest.cs new file mode 100644 index 00000000..7b643032 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Actions/SearchTest.cs @@ -0,0 +1,185 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Actions; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Actions; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "created_at": { + "start_at": "2022-04-01T00:00:00.000Z" + } + }, + "sort": { + "sort_order": "DESC" + } + }, + "limit": 2 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "action": [ + { + "id": "termapia:oBGWlAats8xWCiCE", + "device_id": "DEVICE_ID", + "deadline_duration": "PT5M", + "status": "IN_PROGRESS", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2022-04-08T15:14:04.895Z", + "updated_at": "2022-04-08T15:14:05.446Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "type": "SAVE_CARD", + "qr_code_options": { + "title": "title", + "body": "body", + "barcode_contents": "barcode_contents" + }, + "save_card_options": { + "customer_id": "CUSTOMER_ID", + "reference_id": "user-id-1" + }, + "signature_options": { + "title": "title", + "body": "body" + }, + "confirmation_options": { + "title": "title", + "body": "body", + "agree_button_text": "agree_button_text" + }, + "receipt_options": { + "payment_id": "payment_id" + }, + "data_collection_options": { + "title": "title", + "body": "body", + "input_type": "EMAIL" + }, + "select_options": { + "title": "title", + "body": "body", + "options": [ + { + "reference_id": "reference_id", + "title": "title" + } + ] + }, + "await_next_action": true, + "await_next_action_duration": "await_next_action_duration" + }, + { + "id": "termapia:K2NY2YSSml3lTiCE", + "device_id": "DEVICE_ID", + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2022-04-08T15:14:01.210Z", + "updated_at": "2022-04-08T15:14:09.861Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "type": "SAVE_CARD", + "qr_code_options": { + "title": "title", + "body": "body", + "barcode_contents": "barcode_contents" + }, + "save_card_options": { + "customer_id": "CUSTOMER_ID", + "card_id": "ccof:CARD_ID", + "reference_id": "user-id-1" + }, + "signature_options": { + "title": "title", + "body": "body" + }, + "confirmation_options": { + "title": "title", + "body": "body", + "agree_button_text": "agree_button_text" + }, + "receipt_options": { + "payment_id": "payment_id" + }, + "data_collection_options": { + "title": "title", + "body": "body", + "input_type": "EMAIL" + }, + "select_options": { + "title": "title", + "body": "body", + "options": [ + { + "reference_id": "reference_id", + "title": "title" + } + ] + }, + "await_next_action": true, + "await_next_action_duration": "await_next_action_duration" + } + ], + "cursor": "CURSOR" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/actions/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Actions.SearchAsync( + new SearchTerminalActionsRequest + { + Query = new TerminalActionQuery + { + Filter = new TerminalActionQueryFilter + { + CreatedAt = new TimeRange { StartAt = "2022-04-01T00:00:00.000Z" }, + }, + Sort = new TerminalActionQuerySort { SortOrder = SortOrder.Desc }, + }, + Limit = 2, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Checkouts/CancelTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/CancelTest.cs new file mode 100644 index 00000000..a7b52027 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/CancelTest.cs @@ -0,0 +1,99 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Checkouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Checkouts; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "checkout": { + "id": "S1yDlPQx7slqO", + "amount_money": { + "amount": 123, + "currency": "USD" + }, + "reference_id": "id36815", + "note": "note", + "order_id": "order_id", + "payment_options": { + "autocomplete": true, + "delay_duration": "delay_duration", + "accept_partial_authorization": true, + "delay_action": "CANCEL" + }, + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003", + "skip_receipt_screen": true, + "collect_signature": true, + "tip_settings": { + "allow_tipping": true + }, + "show_itemized_cart": true + }, + "deadline_duration": "PT5M", + "status": "CANCELED", + "cancel_reason": "SELLER_CANCELED", + "payment_ids": [ + "payment_ids" + ], + "created_at": "2020-03-16T15:31:19.934Z", + "updated_at": "2020-03-16T15:31:45.787Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "payment_type": "CARD_PRESENT", + "team_member_id": "team_member_id", + "customer_id": "customer_id", + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "statement_description_identifier": "statement_description_identifier", + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/checkouts/checkout_id/cancel") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Checkouts.CancelAsync( + new CancelCheckoutsRequest { CheckoutId = "checkout_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Checkouts/CreateTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/CreateTest.cs new file mode 100644 index 00000000..4cd3ecd8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/CreateTest.cs @@ -0,0 +1,131 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Checkouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Checkouts; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "28a0c3bc-7839-11ea-bc55-0242ac130003", + "checkout": { + "amount_money": { + "amount": 2610, + "currency": "USD" + }, + "reference_id": "id11572", + "note": "A brief note", + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "checkout": { + "id": "08YceKh7B3ZqO", + "amount_money": { + "amount": 2610, + "currency": "USD" + }, + "reference_id": "id11572", + "note": "A brief note", + "order_id": "order_id", + "payment_options": { + "autocomplete": true, + "delay_duration": "delay_duration", + "accept_partial_authorization": true, + "delay_action": "CANCEL" + }, + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003", + "skip_receipt_screen": false, + "collect_signature": true, + "tip_settings": { + "allow_tipping": false + }, + "show_itemized_cart": true + }, + "deadline_duration": "PT5M", + "status": "PENDING", + "cancel_reason": "BUYER_CANCELED", + "payment_ids": [ + "payment_ids" + ], + "created_at": "2020-04-06T16:39:32.545Z", + "updated_at": "2020-04-06T16:39:32.545Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "payment_type": "CARD_PRESENT", + "team_member_id": "team_member_id", + "customer_id": "customer_id", + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "statement_description_identifier": "statement_description_identifier", + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/checkouts") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Checkouts.CreateAsync( + new CreateTerminalCheckoutRequest + { + IdempotencyKey = "28a0c3bc-7839-11ea-bc55-0242ac130003", + Checkout = new TerminalCheckout + { + AmountMoney = new Money { Amount = 2610, Currency = Currency.Usd }, + ReferenceId = "id11572", + Note = "A brief note", + DeviceOptions = new DeviceCheckoutOptions + { + DeviceId = "dbb5d83a-7838-11ea-bc55-0242ac130003", + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Checkouts/GetTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/GetTest.cs new file mode 100644 index 00000000..4f6c7306 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/GetTest.cs @@ -0,0 +1,99 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Checkouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Checkouts; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "checkout": { + "id": "08YceKh7B3ZqO", + "amount_money": { + "amount": 2610, + "currency": "USD" + }, + "reference_id": "id11572", + "note": "A brief note", + "order_id": "order_id", + "payment_options": { + "autocomplete": true, + "delay_duration": "delay_duration", + "accept_partial_authorization": true, + "delay_action": "CANCEL" + }, + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003", + "skip_receipt_screen": false, + "collect_signature": true, + "tip_settings": { + "allow_tipping": false + }, + "show_itemized_cart": true + }, + "deadline_duration": "PT5M", + "status": "IN_PROGRESS", + "cancel_reason": "BUYER_CANCELED", + "payment_ids": [ + "payment_ids" + ], + "created_at": "2020-04-06T16:39:32.545Z", + "updated_at": "2020-04-06T16:39:323.001Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "payment_type": "CARD_PRESENT", + "team_member_id": "team_member_id", + "customer_id": "customer_id", + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "statement_description_identifier": "statement_description_identifier", + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/checkouts/checkout_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Checkouts.GetAsync( + new GetCheckoutsRequest { CheckoutId = "checkout_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Checkouts/SearchTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/SearchTest.cs new file mode 100644 index 00000000..a11b0a8c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Checkouts/SearchTest.cs @@ -0,0 +1,137 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Checkouts; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Checkouts; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "status": "COMPLETED" + } + }, + "limit": 2 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "checkouts": [ + { + "id": "tsQPvzwBpMqqO", + "amount_money": { + "amount": 2610, + "currency": "USD" + }, + "reference_id": "id14467", + "note": "A brief note", + "order_id": "order_id", + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003", + "skip_receipt_screen": false, + "tip_settings": { + "allow_tipping": false + } + }, + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "payment_ids": [ + "rXnhZzywrEk4vR6pw76fPZfgvaB" + ], + "created_at": "2020-03-31T18:13:15.921Z", + "updated_at": "2020-03-31T18:13:52.725Z", + "app_id": "APP_ID", + "location_id": "location_id", + "payment_type": "CARD_PRESENT", + "team_member_id": "team_member_id", + "customer_id": "customer_id", + "statement_description_identifier": "statement_description_identifier" + }, + { + "id": "XlOPTgcEhrbqO", + "amount_money": { + "amount": 2610, + "currency": "USD" + }, + "reference_id": "id41623", + "note": "A brief note", + "order_id": "order_id", + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003", + "skip_receipt_screen": true, + "tip_settings": { + "allow_tipping": false + } + }, + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "payment_ids": [ + "VYBF861PaoKPP7Pih0TlbZiNvaB" + ], + "created_at": "2020-03-31T18:08:31.882Z", + "updated_at": "2020-03-31T18:08:41.635Z", + "app_id": "APP_ID", + "location_id": "location_id", + "payment_type": "CARD_PRESENT", + "team_member_id": "team_member_id", + "customer_id": "customer_id", + "statement_description_identifier": "statement_description_identifier" + } + ], + "cursor": "RiTJqBoTuXlbLmmrPvEkX9iG7XnQ4W4RjGnH" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/checkouts/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Checkouts.SearchAsync( + new SearchTerminalCheckoutsRequest + { + Query = new TerminalCheckoutQuery + { + Filter = new TerminalCheckoutQueryFilter { Status = "COMPLETED" }, + }, + Limit = 2, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalActionTest.cs b/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalActionTest.cs new file mode 100644 index 00000000..64d67707 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalActionTest.cs @@ -0,0 +1,130 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal; + +[TestFixture] +public class DismissTerminalActionTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "action": { + "id": "termapia:abcdefg1234567", + "device_id": "DEVICE_ID", + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2021-07-28T23:22:07.476Z", + "updated_at": "2021-07-28T23:22:29.511Z", + "app_id": "APP_ID", + "location_id": "location_id", + "type": "CONFIRMATION", + "qr_code_options": { + "title": "title", + "body": "body", + "barcode_contents": "barcode_contents" + }, + "save_card_options": { + "customer_id": "customer_id", + "card_id": "card_id", + "reference_id": "reference_id" + }, + "signature_options": { + "title": "title", + "body": "body", + "signature": [ + {} + ] + }, + "confirmation_options": { + "title": "Marketing communications", + "body": "I agree to receive promotional emails about future events and activities.", + "agree_button_text": "Agree", + "disagree_button_text": "Decline", + "decision": { + "has_agreed": true + } + }, + "receipt_options": { + "payment_id": "payment_id", + "print_only": true, + "is_duplicate": true + }, + "data_collection_options": { + "title": "title", + "body": "body", + "input_type": "EMAIL" + }, + "select_options": { + "title": "title", + "body": "body", + "options": [ + { + "reference_id": "reference_id", + "title": "title" + } + ], + "selected_option": { + "reference_id": "reference_id", + "title": "title" + } + }, + "device_metadata": { + "battery_percentage": "battery_percentage", + "charging_state": "charging_state", + "location_id": "location_id", + "merchant_id": "merchant_id", + "network_connection_type": "network_connection_type", + "payment_region": "payment_region", + "serial_number": "serial_number", + "os_version": "os_version", + "app_version": "app_version", + "wifi_network_name": "wifi_network_name", + "wifi_network_strength": "wifi_network_strength", + "ip_address": "ip_address" + }, + "await_next_action": true, + "await_next_action_duration": "PT5M" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/actions/action_id/dismiss") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.DismissTerminalActionAsync( + new DismissTerminalActionRequest { ActionId = "action_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalCheckoutTest.cs b/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalCheckoutTest.cs new file mode 100644 index 00000000..4c723650 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalCheckoutTest.cs @@ -0,0 +1,101 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal; + +[TestFixture] +public class DismissTerminalCheckoutTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "checkout": { + "id": "LmZEKbo3SBfqO", + "amount_money": { + "amount": 2610, + "currency": "USD" + }, + "reference_id": "reference_id", + "note": "note", + "order_id": "order_id", + "payment_options": { + "autocomplete": true, + "delay_duration": "delay_duration", + "accept_partial_authorization": true, + "delay_action": "CANCEL" + }, + "device_options": { + "device_id": "dbb5d83a-7838-11ea-bc55-0242ac130003", + "skip_receipt_screen": false, + "collect_signature": true, + "tip_settings": { + "allow_tipping": true, + "separate_tip_screen": true, + "custom_tip_field": false + }, + "show_itemized_cart": true + }, + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "payment_ids": [ + "D7vLJqMkvSoAlX4yyFzUitOy4EPZY" + ], + "created_at": "2023-11-29T14:59:50.682Z", + "updated_at": "2023-11-29T15:00:18.936Z", + "app_id": "APP_ID", + "location_id": "LOCATION_ID", + "payment_type": "CARD_PRESENT", + "team_member_id": "team_member_id", + "customer_id": "customer_id", + "app_fee_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + }, + "statement_description_identifier": "statement_description_identifier", + "tip_money": { + "amount": 1000000, + "currency": "UNKNOWN_CURRENCY" + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/checkouts/checkout_id/dismiss") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.DismissTerminalCheckoutAsync( + new DismissTerminalCheckoutRequest { CheckoutId = "checkout_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalRefundTest.cs b/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalRefundTest.cs new file mode 100644 index 00000000..30855188 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/DismissTerminalRefundTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal; + +[TestFixture] +public class DismissTerminalRefundTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refund": { + "id": "vjkNb2HD-xq5kiWWiJ7RhwrQnkxIn2N0l1nPZY", + "refund_id": "refund_id", + "payment_id": "xq5kiWWiJ7RhwrQnkxIn2N0l1nPZY", + "order_id": "s8OMhQcpEp1b61YywlccSHWqUaQZY", + "amount_money": { + "amount": 111, + "currency": "CAD" + }, + "reason": "Returning item", + "device_id": "47776348fd8b32b9", + "deadline_duration": "PT5M", + "status": "IN_PROGRESS", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2023-11-30T16:16:39.299Z", + "updated_at": "2023-11-30T16:16:57.863Z", + "app_id": "APP_ID", + "location_id": "location_id" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/refunds/terminal_refund_id/dismiss") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.DismissTerminalRefundAsync( + new DismissTerminalRefundRequest { TerminalRefundId = "terminal_refund_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Refunds/CancelTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Refunds/CancelTest.cs new file mode 100644 index 00000000..13004ba8 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Refunds/CancelTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Refunds; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Refunds; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refund": { + "id": "g6ycb6HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "refund_id": "refund_id", + "payment_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "order_id": "kcuKDKreRaI4gF4TjmEgZjHk8Z7YY", + "amount_money": { + "amount": 100, + "currency": "CAD" + }, + "reason": "reason", + "device_id": "42690809-faa2-4701-a24b-19d3d34c9aaa", + "deadline_duration": "PT5M", + "status": "CANCELED", + "cancel_reason": "SELLER_CANCELED", + "created_at": "2020-10-21T22:47:23.241Z", + "updated_at": "2020-10-21T22:47:30.096Z", + "app_id": "sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ", + "location_id": "76C9W6K8CNNQ5" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/refunds/terminal_refund_id/cancel") + .UsingPost() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Refunds.CancelAsync( + new CancelRefundsRequest { TerminalRefundId = "terminal_refund_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Refunds/CreateTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Refunds/CreateTest.cs new file mode 100644 index 00000000..0d72ce1a --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Refunds/CreateTest.cs @@ -0,0 +1,98 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Refunds; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Refunds; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "402a640b-b26f-401f-b406-46f839590c04", + "refund": { + "payment_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "amount_money": { + "amount": 111, + "currency": "CAD" + }, + "reason": "Returning items", + "device_id": "f72dfb8e-4d65-4e56-aade-ec3fb8d33291" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refund": { + "id": "009DP5HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "refund_id": "refund_id", + "payment_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "order_id": "kcuKDKreRaI4gF4TjmEgZjHk8Z7YY", + "amount_money": { + "amount": 111, + "currency": "CAD" + }, + "reason": "Returning items", + "device_id": "f72dfb8e-4d65-4e56-aade-ec3fb8d33291", + "deadline_duration": "PT5M", + "status": "PENDING", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2020-09-29T15:21:46.771Z", + "updated_at": "2020-09-29T15:21:46.771Z", + "app_id": "sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ", + "location_id": "76C9W6K8CNNQ5" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/refunds") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Refunds.CreateAsync( + new CreateTerminalRefundRequest + { + IdempotencyKey = "402a640b-b26f-401f-b406-46f839590c04", + Refund = new TerminalRefund + { + PaymentId = "5O5OvgkcNUhl7JBuINflcjKqUzXZY", + AmountMoney = new Money { Amount = 111, Currency = Currency.Cad }, + Reason = "Returning items", + DeviceId = "f72dfb8e-4d65-4e56-aade-ec3fb8d33291", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Refunds/GetTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Refunds/GetTest.cs new file mode 100644 index 00000000..b3cd0d46 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Refunds/GetTest.cs @@ -0,0 +1,73 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Refunds; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refund": { + "id": "009DP5HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "refund_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY_43Q4iGp7sNeATiWrUruA1EYeMRUXaddXXlDDJ1EQLvb", + "payment_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "order_id": "kcuKDKreRaI4gF4TjmEgZjHk8Z7YY", + "amount_money": { + "amount": 111, + "currency": "CAD" + }, + "reason": "Returning item", + "device_id": "f72dfb8e-4d65-4e56-aade-ec3fb8d33291", + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2020-09-29T15:21:46.771Z", + "updated_at": "2020-09-29T15:21:48.675Z", + "app_id": "sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ", + "location_id": "76C9W6K8CNNQ5" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/refunds/terminal_refund_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Refunds.GetAsync( + new Square.Terminal.Refunds.GetRefundsRequest + { + TerminalRefundId = "terminal_refund_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Terminal/Refunds/SearchTest.cs b/src/Square.Test/Unit/MockServer/Terminal/Refunds/SearchTest.cs new file mode 100644 index 00000000..e46ed815 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Terminal/Refunds/SearchTest.cs @@ -0,0 +1,94 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Terminal.Refunds; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Terminal.Refunds; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "status": "COMPLETED" + } + }, + "limit": 1 + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "refunds": [ + { + "id": "009DP5HD-5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "refund_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY_43Q4iGp7sNeATiWrUruA1EYeMRUXaddXXlDDJ1EQLvb", + "payment_id": "5O5OvgkcNUhl7JBuINflcjKqUzXZY", + "order_id": "kcuKDKreRaI4gF4TjmEgZjHk8Z7YY", + "amount_money": { + "amount": 111, + "currency": "CAD" + }, + "reason": "Returning item", + "device_id": "f72dfb8e-4d65-4e56-aade-ec3fb8d33291", + "deadline_duration": "PT5M", + "status": "COMPLETED", + "cancel_reason": "BUYER_CANCELED", + "created_at": "2020-09-29T15:21:46.771Z", + "updated_at": "2020-09-29T15:21:48.675Z", + "app_id": "sandbox-sq0idb-c2OuYt13YaCAeJq_2cd8OQ", + "location_id": "76C9W6K8CNNQ5" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/terminals/refunds/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Terminal.Refunds.SearchAsync( + new SearchTerminalRefundsRequest + { + Query = new TerminalRefundQuery + { + Filter = new TerminalRefundQueryFilter { Status = "COMPLETED" }, + }, + Limit = 1, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/CancelTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/CancelTest.cs new file mode 100644 index 00000000..b5aa0059 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/CancelTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class CancelTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "65cc0586-3e82-4d08-b524-3885cffd52", + "version": 1753117449752 + } + """; + + const string mockResponse = """ + { + "transfer_order": { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "CANCELED", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T10:45:00.000Z", + "expected_at": "2025-11-09T05:00:00.000Z", + "completed_at": "2025-01-15T10:45:00.000Z", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + "quantity_pending": "0", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "5" + }, + { + "uid": "2", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + "quantity_pending": "0", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "3" + } + ], + "version": 1753117461842 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/transfer_order_id/cancel") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.CancelAsync( + new CancelTransferOrderRequest + { + TransferOrderId = "transfer_order_id", + IdempotencyKey = "65cc0586-3e82-4d08-b524-3885cffd52", + Version = 1753117449752, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/CreateTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/CreateTest.cs new file mode 100644 index 00000000..3a663a82 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/CreateTest.cs @@ -0,0 +1,137 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "65cc0586-3e82-384s-b524-3885cffd52", + "transfer_order": { + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "expected_at": "2025-11-09T05:00:00.000Z", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5" + }, + { + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3" + } + ] + } + } + """; + + const string mockResponse = """ + { + "transfer_order": { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "DRAFT", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T10:30:00.000Z", + "expected_at": "2025-11-09T05:00:00.000Z", + "completed_at": "completed_at", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + "quantity_pending": "5", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + }, + { + "uid": "2", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + "quantity_pending": "3", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + } + ], + "version": 1753109537351 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.CreateAsync( + new CreateTransferOrderRequest + { + IdempotencyKey = "65cc0586-3e82-384s-b524-3885cffd52", + TransferOrder = new CreateTransferOrderData + { + SourceLocationId = "EXAMPLE_SOURCE_LOCATION_ID_123", + DestinationLocationId = "EXAMPLE_DEST_LOCATION_ID_456", + ExpectedAt = "2025-11-09T05:00:00Z", + Notes = "Example transfer order for inventory redistribution between locations", + TrackingNumber = "TRACK123456789", + CreatedByTeamMemberId = "EXAMPLE_TEAM_MEMBER_ID_789", + LineItems = new List() + { + new CreateTransferOrderLineData + { + ItemVariationId = "EXAMPLE_ITEM_VARIATION_ID_001", + QuantityOrdered = "5", + }, + new CreateTransferOrderLineData + { + ItemVariationId = "EXAMPLE_ITEM_VARIATION_ID_002", + QuantityOrdered = "3", + }, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/DeleteTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/DeleteTest.cs new file mode 100644 index 00000000..84d77e7e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/DeleteTest.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/transfer_order_id") + .WithParam("version", "1000000") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.DeleteAsync( + new DeleteTransferOrdersRequest + { + TransferOrderId = "transfer_order_id", + Version = 1000000, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/GetTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/GetTest.cs new file mode 100644 index 00000000..ce16ed92 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/GetTest.cs @@ -0,0 +1,86 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "transfer_order": { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "STARTED", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T10:35:00.000Z", + "expected_at": "2025-11-09T05:00:00.000Z", + "completed_at": "completed_at", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + "quantity_pending": "5", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + }, + { + "uid": "2", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + "quantity_pending": "3", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + } + ], + "version": 1753117449752 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/transfer_order_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.GetAsync( + new GetTransferOrdersRequest { TransferOrderId = "transfer_order_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/ReceiveTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/ReceiveTest.cs new file mode 100644 index 00000000..757fc0c4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/ReceiveTest.cs @@ -0,0 +1,134 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class ReceiveTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "EXAMPLE_IDEMPOTENCY_KEY_101", + "receipt": { + "line_items": [ + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "3", + "quantity_damaged": "1", + "quantity_canceled": "1" + }, + { + "transfer_order_line_uid": "transfer_order_line_uid", + "quantity_received": "2", + "quantity_canceled": "1" + } + ] + }, + "version": 1753118664873 + } + """; + + const string mockResponse = """ + { + "transfer_order": { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "COMPLETED", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T10:55:00.000Z", + "expected_at": "2025-11-09T05:00:00.000Z", + "completed_at": "2025-01-15T10:55:00.000Z", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + "quantity_pending": "0", + "quantity_received": "3", + "quantity_damaged": "1", + "quantity_canceled": "1" + }, + { + "uid": "2", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + "quantity_pending": "0", + "quantity_received": "2", + "quantity_damaged": "0", + "quantity_canceled": "1" + } + ], + "version": 1753118667248 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/transfer_order_id/receive") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.ReceiveAsync( + new ReceiveTransferOrderRequest + { + TransferOrderId = "transfer_order_id", + IdempotencyKey = "EXAMPLE_IDEMPOTENCY_KEY_101", + Receipt = new TransferOrderGoodsReceipt + { + LineItems = new List() + { + new TransferOrderGoodsReceiptLineItem + { + TransferOrderLineUid = "transfer_order_line_uid", + QuantityReceived = "3", + QuantityDamaged = "1", + QuantityCanceled = "1", + }, + new TransferOrderGoodsReceiptLineItem + { + TransferOrderLineUid = "transfer_order_line_uid", + QuantityReceived = "2", + QuantityCanceled = "1", + }, + }, + }, + Version = 1753118664873, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/SearchTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/SearchTest.cs new file mode 100644 index 00000000..1363afd4 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/SearchTest.cs @@ -0,0 +1,156 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "query": { + "filter": { + "source_location_ids": [ + "EXAMPLE_SOURCE_LOCATION_ID_123" + ], + "destination_location_ids": [ + "EXAMPLE_DEST_LOCATION_ID_456" + ], + "statuses": [ + "STARTED", + "PARTIALLY_RECEIVED" + ] + }, + "sort": { + "field": "UPDATED_AT", + "order": "DESC" + } + }, + "cursor": "eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9", + "limit": 10 + } + """; + + const string mockResponse = """ + { + "transfer_orders": [ + { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "STARTED", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T10:32:00.000Z", + "expected_at": "2025-11-09T05:00:00.000Z", + "completed_at": "completed_at", + "notes": "Inventory rebalance between stores", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + "quantity_pending": "5", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + } + ], + "version": 1753118664873 + }, + { + "id": "EXAMPLE_TRANSFER_ORDER_ID_456", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "PARTIALLY_RECEIVED", + "created_at": "2025-01-14T14:20:00.000Z", + "updated_at": "2025-01-15T09:45:00.000Z", + "expected_at": "2025-11-08T12:00:00.000Z", + "completed_at": "completed_at", + "notes": "Seasonal stock transfer", + "tracking_number": "tracking_number", + "created_by_team_member_id": "created_by_team_member_id", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "10", + "quantity_pending": "3", + "quantity_received": "7", + "quantity_damaged": "0", + "quantity_canceled": "0" + } + ], + "version": 1753115540123 + } + ], + "cursor": "eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTU1NDBfMTIzfQ==", + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.TransferOrders.SearchAsync( + new SearchTransferOrdersRequest + { + Query = new TransferOrderQuery + { + Filter = new TransferOrderFilter + { + SourceLocationIds = new List() { "EXAMPLE_SOURCE_LOCATION_ID_123" }, + DestinationLocationIds = new List() + { + "EXAMPLE_DEST_LOCATION_ID_456", + }, + Statuses = new List() + { + TransferOrderStatus.Started, + TransferOrderStatus.PartiallyReceived, + }, + }, + Sort = new TransferOrderSort + { + Field = TransferOrderSortField.UpdatedAt, + Order = SortOrder.Desc, + }, + }, + Cursor = "eyJsYXN0X3VwZGF0ZWRfYXQiOjE3NTMxMTg2NjQ4NzN9", + Limit = 10, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/StartTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/StartTest.cs new file mode 100644 index 00000000..c6fc4df9 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/StartTest.cs @@ -0,0 +1,100 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class StartTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "EXAMPLE_IDEMPOTENCY_KEY_789", + "version": 1753109537351 + } + """; + + const string mockResponse = """ + { + "transfer_order": { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_123", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_456", + "status": "STARTED", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T10:32:00.000Z", + "expected_at": "2025-11-09T05:00:00.000Z", + "completed_at": "completed_at", + "notes": "Example transfer order for inventory redistribution between locations", + "tracking_number": "TRACK123456789", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "5", + "quantity_pending": "5", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + }, + { + "uid": "2", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_002", + "quantity_ordered": "3", + "quantity_pending": "3", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + } + ], + "version": 1753118664873 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/transfer_order_id/start") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.StartAsync( + new StartTransferOrderRequest + { + TransferOrderId = "transfer_order_id", + IdempotencyKey = "EXAMPLE_IDEMPOTENCY_KEY_789", + Version = 1753109537351, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/TransferOrders/UpdateTest.cs b/src/Square.Test/Unit/MockServer/TransferOrders/UpdateTest.cs new file mode 100644 index 00000000..4c347067 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/TransferOrders/UpdateTest.cs @@ -0,0 +1,139 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.TransferOrders; + +namespace Square.Test.Unit.MockServer.TransferOrders; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "f47ac10b-58cc-4372-a567-0e02b2c3d479", + "transfer_order": { + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_789", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_101", + "expected_at": "2025-11-10T08:00:00.000Z", + "notes": "Updated: Priority transfer due to low stock at destination", + "tracking_number": "TRACK987654321", + "line_items": [ + { + "uid": "1", + "quantity_ordered": "7" + }, + { + "item_variation_id": "EXAMPLE_NEW_ITEM_VARIATION_ID_003", + "quantity_ordered": "2" + }, + { + "uid": "2", + "remove": true + } + ] + }, + "version": 1753109537351 + } + """; + + const string mockResponse = """ + { + "transfer_order": { + "id": "EXAMPLE_TRANSFER_ORDER_ID_123", + "source_location_id": "EXAMPLE_SOURCE_LOCATION_ID_789", + "destination_location_id": "EXAMPLE_DEST_LOCATION_ID_101", + "status": "DRAFT", + "created_at": "2025-01-15T10:30:00.000Z", + "updated_at": "2025-01-15T11:15:00.000Z", + "expected_at": "2025-11-10T08:00:00.000Z", + "completed_at": "completed_at", + "notes": "Updated: Priority transfer due to low stock at destination", + "tracking_number": "TRACK987654321", + "created_by_team_member_id": "EXAMPLE_TEAM_MEMBER_ID_789", + "line_items": [ + { + "uid": "1", + "item_variation_id": "EXAMPLE_ITEM_VARIATION_ID_001", + "quantity_ordered": "7", + "quantity_pending": "7", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + }, + { + "uid": "3", + "item_variation_id": "EXAMPLE_NEW_ITEM_VARIATION_ID_003", + "quantity_ordered": "2", + "quantity_pending": "2", + "quantity_received": "0", + "quantity_damaged": "0", + "quantity_canceled": "0" + } + ], + "version": 1753122900456 + }, + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/transfer-orders/transfer_order_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.TransferOrders.UpdateAsync( + new UpdateTransferOrderRequest + { + TransferOrderId = "transfer_order_id", + IdempotencyKey = "f47ac10b-58cc-4372-a567-0e02b2c3d479", + TransferOrder = new UpdateTransferOrderData + { + SourceLocationId = "EXAMPLE_SOURCE_LOCATION_ID_789", + DestinationLocationId = "EXAMPLE_DEST_LOCATION_ID_101", + ExpectedAt = "2025-11-10T08:00:00Z", + Notes = "Updated: Priority transfer due to low stock at destination", + TrackingNumber = "TRACK987654321", + LineItems = new List() + { + new UpdateTransferOrderLineData { Uid = "1", QuantityOrdered = "7" }, + new UpdateTransferOrderLineData + { + ItemVariationId = "EXAMPLE_NEW_ITEM_VARIATION_ID_003", + QuantityOrdered = "2", + }, + new UpdateTransferOrderLineData { Uid = "2", Remove = true }, + }, + }, + Version = 1753109537351, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/V1Transactions/V1ListOrdersTest.cs b/src/Square.Test/Unit/MockServer/V1Transactions/V1ListOrdersTest.cs new file mode 100644 index 00000000..f52eac37 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/V1Transactions/V1ListOrdersTest.cs @@ -0,0 +1,129 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.V1Transactions; + +namespace Square.Test.Unit.MockServer.V1Transactions; + +[TestFixture] +public class V1ListOrdersTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + [ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "id": "id", + "buyer_email": "buyer_email", + "recipient_name": "recipient_name", + "recipient_phone_number": "recipient_phone_number", + "state": "PENDING", + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "subtotal_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_shipping_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_tax_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_price_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_discount_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "created_at": "created_at", + "updated_at": "updated_at", + "expires_at": "expires_at", + "payment_id": "payment_id", + "buyer_note": "buyer_note", + "completed_note": "completed_note", + "refunded_note": "refunded_note", + "canceled_note": "canceled_note", + "tender": { + "id": "id", + "type": "CREDIT_CARD", + "name": "name", + "employee_id": "employee_id", + "receipt_url": "receipt_url", + "card_brand": "OTHER_BRAND", + "pan_suffix": "pan_suffix", + "entry_method": "MANUAL", + "payment_note": "payment_note", + "tendered_at": "tendered_at", + "settled_at": "settled_at", + "is_exchange": true + }, + "order_history": [ + {} + ], + "promo_code": "promo_code", + "btc_receive_address": "btc_receive_address", + "btc_price_satoshi": 1.1 + } + ] + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/location_id/orders") + .WithParam("order", "DESC") + .WithParam("limit", "1") + .WithParam("batch_token", "batch_token") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.V1Transactions.V1ListOrdersAsync( + new V1ListOrdersRequest + { + LocationId = "location_id", + Order = SortOrder.Desc, + Limit = 1, + BatchToken = "batch_token", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize>(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/V1Transactions/V1RetrieveOrderTest.cs b/src/Square.Test/Unit/MockServer/V1Transactions/V1RetrieveOrderTest.cs new file mode 100644 index 00000000..2bf0f90c --- /dev/null +++ b/src/Square.Test/Unit/MockServer/V1Transactions/V1RetrieveOrderTest.cs @@ -0,0 +1,139 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.V1Transactions; + +namespace Square.Test.Unit.MockServer.V1Transactions; + +[TestFixture] +public class V1RetrieveOrderTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "id": "id", + "buyer_email": "buyer_email", + "recipient_name": "recipient_name", + "recipient_phone_number": "recipient_phone_number", + "state": "PENDING", + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "subtotal_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_shipping_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_tax_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_price_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_discount_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "created_at": "created_at", + "updated_at": "updated_at", + "expires_at": "expires_at", + "payment_id": "payment_id", + "buyer_note": "buyer_note", + "completed_note": "completed_note", + "refunded_note": "refunded_note", + "canceled_note": "canceled_note", + "tender": { + "id": "id", + "type": "CREDIT_CARD", + "name": "name", + "employee_id": "employee_id", + "receipt_url": "receipt_url", + "card_brand": "OTHER_BRAND", + "pan_suffix": "pan_suffix", + "entry_method": "MANUAL", + "payment_note": "payment_note", + "total_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "tendered_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "tendered_at": "tendered_at", + "settled_at": "settled_at", + "change_back_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "refunded_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "is_exchange": true + }, + "order_history": [ + { + "action": "ORDER_PLACED", + "created_at": "created_at" + } + ], + "promo_code": "promo_code", + "btc_receive_address": "btc_receive_address", + "btc_price_satoshi": 1.1 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/location_id/orders/order_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.V1Transactions.V1RetrieveOrderAsync( + new V1RetrieveOrderRequest { LocationId = "location_id", OrderId = "order_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/V1Transactions/V1UpdateOrderTest.cs b/src/Square.Test/Unit/MockServer/V1Transactions/V1UpdateOrderTest.cs new file mode 100644 index 00000000..7d6a2683 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/V1Transactions/V1UpdateOrderTest.cs @@ -0,0 +1,152 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.V1Transactions; + +namespace Square.Test.Unit.MockServer.V1Transactions; + +[TestFixture] +public class V1UpdateOrderTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "action": "COMPLETE" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "id": "id", + "buyer_email": "buyer_email", + "recipient_name": "recipient_name", + "recipient_phone_number": "recipient_phone_number", + "state": "PENDING", + "shipping_address": { + "address_line_1": "address_line_1", + "address_line_2": "address_line_2", + "address_line_3": "address_line_3", + "locality": "locality", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "administrative_district_level_1", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "postal_code", + "country": "ZZ", + "first_name": "first_name", + "last_name": "last_name" + }, + "subtotal_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_shipping_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_tax_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_price_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "total_discount_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "created_at": "created_at", + "updated_at": "updated_at", + "expires_at": "expires_at", + "payment_id": "payment_id", + "buyer_note": "buyer_note", + "completed_note": "completed_note", + "refunded_note": "refunded_note", + "canceled_note": "canceled_note", + "tender": { + "id": "id", + "type": "CREDIT_CARD", + "name": "name", + "employee_id": "employee_id", + "receipt_url": "receipt_url", + "card_brand": "OTHER_BRAND", + "pan_suffix": "pan_suffix", + "entry_method": "MANUAL", + "payment_note": "payment_note", + "total_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "tendered_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "tendered_at": "tendered_at", + "settled_at": "settled_at", + "change_back_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "refunded_money": { + "amount": 1, + "currency_code": "UNKNOWN_CURRENCY" + }, + "is_exchange": true + }, + "order_history": [ + { + "action": "ORDER_PLACED", + "created_at": "created_at" + } + ], + "promo_code": "promo_code", + "btc_receive_address": "btc_receive_address", + "btc_price_satoshi": 1.1 + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/location_id/orders/order_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.V1Transactions.V1UpdateOrderAsync( + new V1UpdateOrderRequest + { + LocationId = "location_id", + OrderId = "order_id", + Action = V1UpdateOrderRequestAction.Complete, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/BatchCreateTest.cs b/src/Square.Test/Unit/MockServer/Vendors/BatchCreateTest.cs new file mode 100644 index 00000000..0f7281fe --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/BatchCreateTest.cs @@ -0,0 +1,152 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class BatchCreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "vendors": { + "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe": { + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "contacts": [ + { + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor" + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "responses": { + "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T10:21:54.859Z", + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor", + "version": 0, + "status": "ACTIVE" + } + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/bulk-create") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.BatchCreateAsync( + new BatchCreateVendorsRequest + { + Vendors = new Dictionary() + { + { + "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + new Vendor + { + Name = "Joe's Fresh Seafood", + Address = new Address + { + AddressLine1 = "505 Electric Ave", + AddressLine2 = "Suite 600", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + Contacts = new List() + { + new VendorContact + { + Name = "Joe Burrow", + EmailAddress = "joe@joesfreshseafood.com", + PhoneNumber = "1-212-555-4250", + Ordinal = 1, + }, + }, + AccountNumber = "4025391", + Note = "a vendor", + } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/BatchGetTest.cs b/src/Square.Test/Unit/MockServer/Vendors/BatchGetTest.cs new file mode 100644 index 00000000..957fa59e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/BatchGetTest.cs @@ -0,0 +1,101 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class BatchGetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "vendor_ids": [ + "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4" + ] + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "responses": { + "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T10:21:54.859Z", + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor", + "version": 1, + "status": "ACTIVE" + } + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/bulk-retrieve") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.BatchGetAsync( + new BatchGetVendorsRequest + { + VendorIds = new List() { "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4" }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/BatchUpdateTest.cs b/src/Square.Test/Unit/MockServer/Vendors/BatchUpdateTest.cs new file mode 100644 index 00000000..3c711aed --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/BatchUpdateTest.cs @@ -0,0 +1,149 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class BatchUpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "vendors": { + "FMCYHBWT1TPL8MFH52PBMEN92A": { + "vendor": {} + }, + "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4": { + "vendor": {} + } + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "responses": { + "INV_V_FMCYHBWT1TPL8MFH52PBMEN92A": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "vendor": { + "id": "INV_V_FMCYHBWT1TPL8MFH52PBMEN92A", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T20:21:54.859Z", + "name": "Annie’s Hot Sauce", + "address": { + "address_line_1": "202 Mill St", + "locality": "Moorestown", + "administrative_district_level_1": "NJ", + "postal_code": "08057", + "country": "US" + }, + "contacts": [ + { + "id": "INV_VC_ABYYHBWT1TPL8MFH52PBMENPJ4", + "name": "Annie Thomas", + "email_address": "annie@annieshotsauce.com", + "phone_number": "1-212-555-4250", + "ordinal": 0 + } + ], + "version": 11, + "status": "ACTIVE" + } + }, + "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4": { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR" + } + ], + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:10:54.859Z", + "updated_at": "2022-03-16T20:21:54.859Z", + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 0 + } + ], + "account_number": "4025391", + "note": "favorite vendor", + "version": 31, + "status": "ACTIVE" + } + } + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/bulk-update") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.BatchUpdateAsync( + new BatchUpdateVendorsRequest + { + Vendors = new Dictionary() + { + { + "FMCYHBWT1TPL8MFH52PBMEN92A", + new UpdateVendorRequest { Vendor = new Vendor() } + }, + { + "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + new UpdateVendorRequest { Vendor = new Vendor() } + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/CreateTest.cs b/src/Square.Test/Unit/MockServer/Vendors/CreateTest.cs new file mode 100644 index 00000000..eb5019e3 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/CreateTest.cs @@ -0,0 +1,143 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + "vendor": { + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "contacts": [ + { + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T10:21:54.859Z", + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor", + "version": 1, + "status": "ACTIVE" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/create") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.CreateAsync( + new CreateVendorRequest + { + IdempotencyKey = "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + Vendor = new Vendor + { + Name = "Joe's Fresh Seafood", + Address = new Address + { + AddressLine1 = "505 Electric Ave", + AddressLine2 = "Suite 600", + Locality = "New York", + AdministrativeDistrictLevel1 = "NY", + PostalCode = "10003", + Country = Country.Us, + }, + Contacts = new List() + { + new VendorContact + { + Name = "Joe Burrow", + EmailAddress = "joe@joesfreshseafood.com", + PhoneNumber = "1-212-555-4250", + Ordinal = 1, + }, + }, + AccountNumber = "4025391", + Note = "a vendor", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/GetTest.cs b/src/Square.Test/Unit/MockServer/Vendors/GetTest.cs new file mode 100644 index 00000000..65bf8c84 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/GetTest.cs @@ -0,0 +1,86 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T10:21:54.859Z", + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor", + "version": 1, + "status": "ACTIVE" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/vendor_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.GetAsync( + new GetVendorsRequest { VendorId = "vendor_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/SearchTest.cs b/src/Square.Test/Unit/MockServer/Vendors/SearchTest.cs new file mode 100644 index 00000000..e2336f15 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/SearchTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class SearchTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + {} + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "vendors": [ + { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T10:21:54.859Z", + "name": "Joe's Fresh Seafood", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "locality": "New York", + "administrative_district_level_1": "NY", + "postal_code": "10003", + "country": "US" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 1 + } + ], + "account_number": "4025391", + "note": "a vendor", + "version": 1, + "status": "ACTIVE" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/search") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.SearchAsync(new SearchVendorsRequest()); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Vendors/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Vendors/UpdateTest.cs new file mode 100644 index 00000000..a748ad66 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Vendors/UpdateTest.cs @@ -0,0 +1,114 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Vendors; + +namespace Square.Test.Unit.MockServer.Vendors; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "name": "Jack's Chicken Shack", + "version": 1, + "status": "ACTIVE" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "vendor": { + "id": "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + "created_at": "2022-03-16T10:21:54.859Z", + "updated_at": "2022-03-16T20:21:54.859Z", + "name": "Jack's Chicken Shack", + "address": { + "address_line_1": "505 Electric Ave", + "address_line_2": "Suite 600", + "address_line_3": "address_line_3", + "locality": "New York", + "sublocality": "sublocality", + "sublocality_2": "sublocality_2", + "sublocality_3": "sublocality_3", + "administrative_district_level_1": "NY", + "administrative_district_level_2": "administrative_district_level_2", + "administrative_district_level_3": "administrative_district_level_3", + "postal_code": "10003", + "country": "US", + "first_name": "first_name", + "last_name": "last_name" + }, + "contacts": [ + { + "id": "INV_VC_FMCYHBWT1TPL8MFH52PBMEN92A", + "name": "Joe Burrow", + "email_address": "joe@joesfreshseafood.com", + "phone_number": "1-212-555-4250", + "ordinal": 0 + } + ], + "account_number": "4025391", + "note": "note", + "version": 2, + "status": "ACTIVE" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/vendors/vendor_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Vendors.UpdateAsync( + new UpdateVendorsRequest + { + VendorId = "vendor_id", + Body = new UpdateVendorRequest + { + IdempotencyKey = "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe", + Vendor = new Vendor + { + Id = "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4", + Name = "Jack's Chicken Shack", + Version = 1, + Status = VendorStatus.Active, + }, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)).UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/EventTypes/ListTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/EventTypes/ListTest.cs new file mode 100644 index 00000000..f9c71a44 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/EventTypes/ListTest.cs @@ -0,0 +1,62 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Webhooks.EventTypes; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "event_types": [ + "inventory.count.updated" + ], + "metadata": [ + { + "event_type": "inventory.count.updated", + "api_version_introduced": "2018-07-12", + "release_status": "PUBLIC" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/event-types") + .WithParam("api_version", "api_version") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.EventTypes.ListAsync( + new Square.Webhooks.EventTypes.ListEventTypesRequest { ApiVersion = "api_version" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/CreateTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/CreateTest.cs new file mode 100644 index 00000000..2a8b68ec --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/CreateTest.cs @@ -0,0 +1,93 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Webhooks.Subscriptions; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class CreateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "63f84c6c-2200-4c99-846c-2670a1311fbf", + "subscription": { + "name": "Example Webhook Subscription", + "event_types": [ + "payment.created", + "payment.updated" + ], + "notification_url": "https://example-webhook-url.com", + "api_version": "2021-12-15" + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "wbhk_b35f6b3145074cf9ad513610786c19d5", + "name": "Example Webhook Subscription", + "enabled": true, + "event_types": [ + "payment.created", + "payment.updated" + ], + "notification_url": "https://example-webhook-url.com", + "api_version": "2021-12-15", + "signature_key": "1k9bIJKCeTmSQwyagtNRLg", + "created_at": "2022-01-10T23:29:48.000Z", + "updated_at": "2022-01-10T23:29:48.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.Subscriptions.CreateAsync( + new CreateWebhookSubscriptionRequest + { + IdempotencyKey = "63f84c6c-2200-4c99-846c-2670a1311fbf", + Subscription = new WebhookSubscription + { + Name = "Example Webhook Subscription", + EventTypes = new List() { "payment.created", "payment.updated" }, + NotificationUrl = "https://example-webhook-url.com", + ApiVersion = "2021-12-15", + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/DeleteTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/DeleteTest.cs new file mode 100644 index 00000000..41a86fa0 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/DeleteTest.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Webhooks.Subscriptions; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class DeleteTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ] + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions/subscription_id") + .UsingDelete() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.Subscriptions.DeleteAsync( + new DeleteSubscriptionsRequest { SubscriptionId = "subscription_id" } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/GetTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/GetTest.cs new file mode 100644 index 00000000..11ca2e4e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/GetTest.cs @@ -0,0 +1,68 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class GetTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "wbhk_b35f6b3145074cf9ad513610786c19d5", + "name": "Example Webhook Subscription", + "enabled": true, + "event_types": [ + "payment.created", + "payment.updated" + ], + "notification_url": "https://example-webhook-url.com", + "api_version": "2021-12-15", + "signature_key": "1k9bIJKCeTmSQwyagtNRLg", + "created_at": "2022-01-10T23:29:48.000Z", + "updated_at": "2022-01-10T23:29:48.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions/subscription_id") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.Subscriptions.GetAsync( + new Square.Webhooks.Subscriptions.GetSubscriptionsRequest + { + SubscriptionId = "subscription_id", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/ListTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/ListTest.cs new file mode 100644 index 00000000..48f719fd --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/ListTest.cs @@ -0,0 +1,77 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Test.Unit.MockServer; +using Square.Webhooks.Subscriptions; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class ListTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscriptions": [ + { + "id": "wbhk_b35f6b3145074cf9ad513610786c19d5", + "name": "Example Webhook Subscription", + "enabled": true, + "event_types": [ + "payment.created", + "payment.updated" + ], + "notification_url": "https://example-webhook-url.com", + "api_version": "2021-12-15", + "signature_key": "signature_key", + "created_at": "2022-01-10T23:29:48.000Z", + "updated_at": "2022-01-10T23:29:48.000Z" + } + ], + "cursor": "cursor" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions") + .WithParam("cursor", "cursor") + .WithParam("sort_order", "DESC") + .WithParam("limit", "1") + .UsingGet() + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var items = await Client.Webhooks.Subscriptions.ListAsync( + new ListSubscriptionsRequest + { + Cursor = "cursor", + IncludeDisabled = true, + SortOrder = SortOrder.Desc, + Limit = 1, + } + ); + await foreach (var item in items) + { + Assert.That(item, Is.Not.Null); + break; // Only check the first item + } + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/TestTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/TestTest.cs new file mode 100644 index 00000000..77428c31 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/TestTest.cs @@ -0,0 +1,71 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Webhooks.Subscriptions; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class TestTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "event_type": "payment.created" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription_test_result": { + "id": "23eed5a9-2b12-403e-b212-7e2889aea0f6", + "status_code": 404, + "payload": "{\"merchant_id\":\"1ZYMKZY1YFGBW\",\"type\":\"payment.created\",\"event_id\":\"23eed5a9-2b12-403e-b212-7e2889aea0f6\",\"created_at\":\"2022-01-11T00:06:48.322945116Z\",\"data\":{\"type\":\"payment\",\"id\":\"KkAkhdMsgzn59SM8A89WgKwekxLZY\",\"object\":{\"payment\":{\"amount_money\":{\"amount\":100,\"currency\":\"USD\"},\"approved_money\":{\"amount\":100,\"currency\":\"USD\"},\"capabilities\":[\"EDIT_TIP_AMOUNT\",\"EDIT_TIP_AMOUNT_UP\",\"EDIT_TIP_AMOUNT_DOWN\"],\"card_details\":{\"avs_status\":\"AVS_ACCEPTED\",\"card\":{\"bin\":\"540988\",\"card_brand\":\"MASTERCARD\",\"card_type\":\"CREDIT\",\"exp_month\":11,\"exp_year\":2022,\"fingerprint\":\"sq-1-Tvruf3vPQxlvI6n0IcKYfBukrcv6IqWr8UyBdViWXU2yzGn5VMJvrsHMKpINMhPmVg\",\"last_4\":\"9029\",\"prepaid_type\":\"NOT_PREPAID\"},\"card_payment_timeline\":{\"authorized_at\":\"2020-11-22T21:16:51.198Z\"},\"cvv_status\":\"CVV_ACCEPTED\",\"entry_method\":\"KEYED\",\"statement_description\":\"SQ *DEFAULT TEST ACCOUNT\",\"status\":\"AUTHORIZED\"},\"created_at\":\"2020-11-22T21:16:51.086Z\",\"delay_action\":\"CANCEL\",\"delay_duration\":\"PT168H\",\"delayed_until\":\"2020-11-29T21:16:51.086Z\",\"id\":\"hYy9pRFVxpDsO1FB05SunFWUe9JZY\",\"location_id\":\"S8GWD5R9QB376\",\"order_id\":\"03O3USaPaAaFnI6kkwB1JxGgBsUZY\",\"receipt_number\":\"hYy9\",\"risk_evaluation\":{\"created_at\":\"2020-11-22T21:16:51.198Z\",\"risk_level\":\"NORMAL\"},\"source_type\":\"CARD\",\"status\":\"APPROVED\",\"total_money\":{\"amount\":100,\"currency\":\"USD\"},\"updated_at\":\"2020-11-22T21:16:51.198Z\",\"version_token\":\"FfQhQJf9r3VSQIgyWBk1oqhIwiznLwVwJbVVA0bdyEv6o\"}}}}", + "created_at": "2022-01-11 00:06:48.322945116 +0000 UTC m=+3863.054453746", + "updated_at": "2022-01-11 00:06:48.322945116 +0000 UTC m=+3863.054453746" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions/subscription_id/test") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.Subscriptions.TestAsync( + new TestWebhookSubscriptionRequest + { + SubscriptionId = "subscription_id", + EventType = "payment.created", + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateSignatureKeyTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateSignatureKeyTest.cs new file mode 100644 index 00000000..7a5adf03 --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateSignatureKeyTest.cs @@ -0,0 +1,69 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Webhooks.Subscriptions; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class UpdateSignatureKeyTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "idempotency_key": "ed80ae6b-0654-473b-bbab-a39aee89a60d" + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "signature_key": "1k9bIJKCeTmSQwyagtNRLg" + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions/subscription_id/signature-key") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.Subscriptions.UpdateSignatureKeyAsync( + new UpdateWebhookSubscriptionSignatureKeyRequest + { + SubscriptionId = "subscription_id", + IdempotencyKey = "ed80ae6b-0654-473b-bbab-a39aee89a60d", + } + ); + Assert.That( + response, + Is.EqualTo( + JsonUtils.Deserialize( + mockResponse + ) + ) + .UsingDefaults() + ); + } +} diff --git a/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateTest.cs b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateTest.cs new file mode 100644 index 00000000..a883102e --- /dev/null +++ b/src/Square.Test/Unit/MockServer/Webhooks/Subscriptions/UpdateTest.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Square; +using Square.Core; +using Square.Test.Unit.MockServer; +using Square.Webhooks.Subscriptions; + +namespace Square.Test.Unit.MockServer.Webhooks.Subscriptions; + +[TestFixture] +public class UpdateTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest() + { + const string requestJson = """ + { + "subscription": { + "name": "Updated Example Webhook Subscription", + "enabled": false + } + } + """; + + const string mockResponse = """ + { + "errors": [ + { + "category": "API_ERROR", + "code": "INTERNAL_SERVER_ERROR", + "detail": "detail", + "field": "field" + } + ], + "subscription": { + "id": "wbhk_b35f6b3145074cf9ad513610786c19d5", + "name": "Updated Example Webhook Subscription", + "enabled": false, + "event_types": [ + "payment.created", + "payment.updated" + ], + "notification_url": "https://example-webhook-url.com", + "api_version": "2021-12-15", + "signature_key": "signature_key", + "created_at": "2022-01-10T23:29:48.000Z", + "updated_at": "2022-01-10T23:45:51.000Z" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v2/webhooks/subscriptions/subscription_id") + .WithHeader("Content-Type", "application/json") + .UsingPut() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Webhooks.Subscriptions.UpdateAsync( + new UpdateWebhookSubscriptionRequest + { + SubscriptionId = "subscription_id", + Subscription = new WebhookSubscription + { + Name = "Updated Example Webhook Subscription", + Enabled = false, + }, + } + ); + Assert.That( + response, + Is.EqualTo(JsonUtils.Deserialize(mockResponse)) + .UsingDefaults() + ); + } +} diff --git a/src/Square/ApplePay/ApplePayClient.cs b/src/Square/ApplePay/ApplePayClient.cs index bfbdc442..2855768b 100644 --- a/src/Square/ApplePay/ApplePayClient.cs +++ b/src/Square/ApplePay/ApplePayClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/ApplePay/Requests/RegisterDomainRequest.cs b/src/Square/ApplePay/Requests/RegisterDomainRequest.cs index bf17b957..d37c1ec5 100644 --- a/src/Square/ApplePay/Requests/RegisterDomainRequest.cs +++ b/src/Square/ApplePay/Requests/RegisterDomainRequest.cs @@ -3,6 +3,7 @@ namespace Square.ApplePay; +[Serializable] public record RegisterDomainRequest { /// diff --git a/src/Square/BankAccounts/BankAccountsClient.cs b/src/Square/BankAccounts/BankAccountsClient.cs index c36d3341..6bdb1807 100644 --- a/src/Square/BankAccounts/BankAccountsClient.cs +++ b/src/Square/BankAccounts/BankAccountsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/BankAccounts/Requests/GetBankAccountsRequest.cs b/src/Square/BankAccounts/Requests/GetBankAccountsRequest.cs index e7eef45d..ac66072a 100644 --- a/src/Square/BankAccounts/Requests/GetBankAccountsRequest.cs +++ b/src/Square/BankAccounts/Requests/GetBankAccountsRequest.cs @@ -3,6 +3,7 @@ namespace Square.BankAccounts; +[Serializable] public record GetBankAccountsRequest { /// diff --git a/src/Square/BankAccounts/Requests/GetByV1IdBankAccountsRequest.cs b/src/Square/BankAccounts/Requests/GetByV1IdBankAccountsRequest.cs index 64b12ec4..5d7bb604 100644 --- a/src/Square/BankAccounts/Requests/GetByV1IdBankAccountsRequest.cs +++ b/src/Square/BankAccounts/Requests/GetByV1IdBankAccountsRequest.cs @@ -3,6 +3,7 @@ namespace Square.BankAccounts; +[Serializable] public record GetByV1IdBankAccountsRequest { /// diff --git a/src/Square/BankAccounts/Requests/ListBankAccountsRequest.cs b/src/Square/BankAccounts/Requests/ListBankAccountsRequest.cs index 8b975538..1c9c5df2 100644 --- a/src/Square/BankAccounts/Requests/ListBankAccountsRequest.cs +++ b/src/Square/BankAccounts/Requests/ListBankAccountsRequest.cs @@ -3,6 +3,7 @@ namespace Square.BankAccounts; +[Serializable] public record ListBankAccountsRequest { /// diff --git a/src/Square/Bookings/BookingsClient.cs b/src/Square/Bookings/BookingsClient.cs index 4844f54d..b514ad78 100644 --- a/src/Square/Bookings/BookingsClient.cs +++ b/src/Square/Bookings/BookingsClient.cs @@ -1,9 +1,8 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; -using Square.Bookings.CustomAttributeDefinitions; -using Square.Bookings.CustomAttributes; using Square.Bookings.LocationProfiles; using Square.Bookings.TeamMemberProfiles; using Square.Core; @@ -17,15 +16,18 @@ public partial class BookingsClient internal BookingsClient(RawClient client) { _client = client; - CustomAttributeDefinitions = new CustomAttributeDefinitionsClient(_client); - CustomAttributes = new CustomAttributesClient(_client); + CustomAttributeDefinitions = + new Square.Bookings.CustomAttributeDefinitions.CustomAttributeDefinitionsClient( + _client + ); + CustomAttributes = new Square.Bookings.CustomAttributes.CustomAttributesClient(_client); LocationProfiles = new LocationProfilesClient(_client); TeamMemberProfiles = new TeamMemberProfilesClient(_client); } - public CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } + public Square.Bookings.CustomAttributeDefinitions.CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } - public CustomAttributesClient CustomAttributes { get; } + public Square.Bookings.CustomAttributes.CustomAttributesClient CustomAttributes { get; } public LocationProfilesClient LocationProfiles { get; } diff --git a/src/Square/Bookings/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs b/src/Square/Bookings/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs index 15b6f6f1..57cc3aec 100644 --- a/src/Square/Bookings/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs +++ b/src/Square/Bookings/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -82,7 +83,11 @@ private async Task ListInternalAs /// /// /// await client.Bookings.CustomAttributeDefinitions.ListAsync( - /// new ListCustomAttributeDefinitionsRequest { Limit = 1, Cursor = "cursor" } + /// new Square.Bookings.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + /// { + /// Limit = 1, + /// Cursor = "cursor", + /// } /// ); /// public async Task> ListAsync( @@ -188,7 +193,11 @@ public async Task CreateAsync( /// /// /// await client.Bookings.CustomAttributeDefinitions.GetAsync( - /// new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + /// new Square.Bookings.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// Version = 1, + /// } /// ); /// public async Task GetAsync( @@ -320,7 +329,10 @@ public async Task UpdateAsync( /// /// /// await client.Bookings.CustomAttributeDefinitions.DeleteAsync( - /// new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + /// new Square.Bookings.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Bookings/CustomAttributeDefinitions/Requests/CreateBookingCustomAttributeDefinitionRequest.cs b/src/Square/Bookings/CustomAttributeDefinitions/Requests/CreateBookingCustomAttributeDefinitionRequest.cs index 2cf7ec7a..15e5b01f 100644 --- a/src/Square/Bookings/CustomAttributeDefinitions/Requests/CreateBookingCustomAttributeDefinitionRequest.cs +++ b/src/Square/Bookings/CustomAttributeDefinitions/Requests/CreateBookingCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings.CustomAttributeDefinitions; +[Serializable] public record CreateBookingCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Bookings/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs b/src/Square/Bookings/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs index 6338d8d7..a359dff6 100644 --- a/src/Square/Bookings/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Bookings/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.CustomAttributeDefinitions; +[Serializable] public record DeleteCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Bookings/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs b/src/Square/Bookings/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs index 95eb12c9..3b1fa887 100644 --- a/src/Square/Bookings/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Bookings/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.CustomAttributeDefinitions; +[Serializable] public record GetCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Bookings/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs b/src/Square/Bookings/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs index eaec166d..d08ef2e4 100644 --- a/src/Square/Bookings/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Bookings/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.CustomAttributeDefinitions; +[Serializable] public record ListCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Bookings/CustomAttributeDefinitions/Requests/UpdateBookingCustomAttributeDefinitionRequest.cs b/src/Square/Bookings/CustomAttributeDefinitions/Requests/UpdateBookingCustomAttributeDefinitionRequest.cs index bc9ed6c8..84a1d4b6 100644 --- a/src/Square/Bookings/CustomAttributeDefinitions/Requests/UpdateBookingCustomAttributeDefinitionRequest.cs +++ b/src/Square/Bookings/CustomAttributeDefinitions/Requests/UpdateBookingCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings.CustomAttributeDefinitions; +[Serializable] public record UpdateBookingCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Bookings/CustomAttributes/CustomAttributesClient.cs b/src/Square/Bookings/CustomAttributes/CustomAttributesClient.cs index d371e172..6411d330 100644 --- a/src/Square/Bookings/CustomAttributes/CustomAttributesClient.cs +++ b/src/Square/Bookings/CustomAttributes/CustomAttributesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -227,7 +228,7 @@ public async Task BatchUpsertAsync( /// /// /// await client.Bookings.CustomAttributes.ListAsync( - /// new ListCustomAttributesRequest + /// new Square.Bookings.CustomAttributes.ListCustomAttributesRequest /// { /// BookingId = "booking_id", /// Limit = 1, @@ -277,7 +278,7 @@ public async Task> ListAsync( /// /// /// await client.Bookings.CustomAttributes.GetAsync( - /// new GetCustomAttributesRequest + /// new Square.Bookings.CustomAttributes.GetCustomAttributesRequest /// { /// BookingId = "booking_id", /// Key = "key", @@ -418,7 +419,11 @@ public async Task UpsertAsync( /// /// /// await client.Bookings.CustomAttributes.DeleteAsync( - /// new DeleteCustomAttributesRequest { BookingId = "booking_id", Key = "key" } + /// new Square.Bookings.CustomAttributes.DeleteCustomAttributesRequest + /// { + /// BookingId = "booking_id", + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Bookings/CustomAttributes/Requests/BulkDeleteBookingCustomAttributesRequest.cs b/src/Square/Bookings/CustomAttributes/Requests/BulkDeleteBookingCustomAttributesRequest.cs index e8a561aa..c570fbdd 100644 --- a/src/Square/Bookings/CustomAttributes/Requests/BulkDeleteBookingCustomAttributesRequest.cs +++ b/src/Square/Bookings/CustomAttributes/Requests/BulkDeleteBookingCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings.CustomAttributes; +[Serializable] public record BulkDeleteBookingCustomAttributesRequest { /// diff --git a/src/Square/Bookings/CustomAttributes/Requests/BulkUpsertBookingCustomAttributesRequest.cs b/src/Square/Bookings/CustomAttributes/Requests/BulkUpsertBookingCustomAttributesRequest.cs index 89c06bae..91516bf4 100644 --- a/src/Square/Bookings/CustomAttributes/Requests/BulkUpsertBookingCustomAttributesRequest.cs +++ b/src/Square/Bookings/CustomAttributes/Requests/BulkUpsertBookingCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings.CustomAttributes; +[Serializable] public record BulkUpsertBookingCustomAttributesRequest { /// diff --git a/src/Square/Bookings/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs b/src/Square/Bookings/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs index 0ac3e37c..3d1d5a3c 100644 --- a/src/Square/Bookings/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs +++ b/src/Square/Bookings/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.CustomAttributes; +[Serializable] public record DeleteCustomAttributesRequest { /// diff --git a/src/Square/Bookings/CustomAttributes/Requests/GetCustomAttributesRequest.cs b/src/Square/Bookings/CustomAttributes/Requests/GetCustomAttributesRequest.cs index 0f98b66b..3b17d9e4 100644 --- a/src/Square/Bookings/CustomAttributes/Requests/GetCustomAttributesRequest.cs +++ b/src/Square/Bookings/CustomAttributes/Requests/GetCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.CustomAttributes; +[Serializable] public record GetCustomAttributesRequest { /// diff --git a/src/Square/Bookings/CustomAttributes/Requests/ListCustomAttributesRequest.cs b/src/Square/Bookings/CustomAttributes/Requests/ListCustomAttributesRequest.cs index cb19166b..b2458250 100644 --- a/src/Square/Bookings/CustomAttributes/Requests/ListCustomAttributesRequest.cs +++ b/src/Square/Bookings/CustomAttributes/Requests/ListCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.CustomAttributes; +[Serializable] public record ListCustomAttributesRequest { /// diff --git a/src/Square/Bookings/CustomAttributes/Requests/UpsertBookingCustomAttributeRequest.cs b/src/Square/Bookings/CustomAttributes/Requests/UpsertBookingCustomAttributeRequest.cs index 229b7a1d..730ea709 100644 --- a/src/Square/Bookings/CustomAttributes/Requests/UpsertBookingCustomAttributeRequest.cs +++ b/src/Square/Bookings/CustomAttributes/Requests/UpsertBookingCustomAttributeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings.CustomAttributes; +[Serializable] public record UpsertBookingCustomAttributeRequest { /// diff --git a/src/Square/Bookings/LocationProfiles/LocationProfilesClient.cs b/src/Square/Bookings/LocationProfiles/LocationProfilesClient.cs index 6f27bd50..473122a2 100644 --- a/src/Square/Bookings/LocationProfiles/LocationProfilesClient.cs +++ b/src/Square/Bookings/LocationProfiles/LocationProfilesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Bookings/LocationProfiles/Requests/ListLocationProfilesRequest.cs b/src/Square/Bookings/LocationProfiles/Requests/ListLocationProfilesRequest.cs index 6ebd161e..556270a4 100644 --- a/src/Square/Bookings/LocationProfiles/Requests/ListLocationProfilesRequest.cs +++ b/src/Square/Bookings/LocationProfiles/Requests/ListLocationProfilesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.LocationProfiles; +[Serializable] public record ListLocationProfilesRequest { /// diff --git a/src/Square/Bookings/Requests/BulkRetrieveBookingsRequest.cs b/src/Square/Bookings/Requests/BulkRetrieveBookingsRequest.cs index 272fcf81..7987a366 100644 --- a/src/Square/Bookings/Requests/BulkRetrieveBookingsRequest.cs +++ b/src/Square/Bookings/Requests/BulkRetrieveBookingsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings; +[Serializable] public record BulkRetrieveBookingsRequest { /// diff --git a/src/Square/Bookings/Requests/BulkRetrieveTeamMemberBookingProfilesRequest.cs b/src/Square/Bookings/Requests/BulkRetrieveTeamMemberBookingProfilesRequest.cs index af943c18..6c1fc73e 100644 --- a/src/Square/Bookings/Requests/BulkRetrieveTeamMemberBookingProfilesRequest.cs +++ b/src/Square/Bookings/Requests/BulkRetrieveTeamMemberBookingProfilesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings; +[Serializable] public record BulkRetrieveTeamMemberBookingProfilesRequest { /// diff --git a/src/Square/Bookings/Requests/CancelBookingRequest.cs b/src/Square/Bookings/Requests/CancelBookingRequest.cs index f407b8d0..4044c0b2 100644 --- a/src/Square/Bookings/Requests/CancelBookingRequest.cs +++ b/src/Square/Bookings/Requests/CancelBookingRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings; +[Serializable] public record CancelBookingRequest { /// diff --git a/src/Square/Bookings/Requests/CreateBookingRequest.cs b/src/Square/Bookings/Requests/CreateBookingRequest.cs index d5a0d339..0680b8ac 100644 --- a/src/Square/Bookings/Requests/CreateBookingRequest.cs +++ b/src/Square/Bookings/Requests/CreateBookingRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings; +[Serializable] public record CreateBookingRequest { /// diff --git a/src/Square/Bookings/Requests/GetBookingsRequest.cs b/src/Square/Bookings/Requests/GetBookingsRequest.cs index d7f10a3b..043966f5 100644 --- a/src/Square/Bookings/Requests/GetBookingsRequest.cs +++ b/src/Square/Bookings/Requests/GetBookingsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings; +[Serializable] public record GetBookingsRequest { /// diff --git a/src/Square/Bookings/Requests/ListBookingsRequest.cs b/src/Square/Bookings/Requests/ListBookingsRequest.cs index d26699ac..e2c93c45 100644 --- a/src/Square/Bookings/Requests/ListBookingsRequest.cs +++ b/src/Square/Bookings/Requests/ListBookingsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings; +[Serializable] public record ListBookingsRequest { /// diff --git a/src/Square/Bookings/Requests/RetrieveLocationBookingProfileRequest.cs b/src/Square/Bookings/Requests/RetrieveLocationBookingProfileRequest.cs index fb1b9219..d25bbe70 100644 --- a/src/Square/Bookings/Requests/RetrieveLocationBookingProfileRequest.cs +++ b/src/Square/Bookings/Requests/RetrieveLocationBookingProfileRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings; +[Serializable] public record RetrieveLocationBookingProfileRequest { /// diff --git a/src/Square/Bookings/Requests/SearchAvailabilityRequest.cs b/src/Square/Bookings/Requests/SearchAvailabilityRequest.cs index e00eccb7..67d72489 100644 --- a/src/Square/Bookings/Requests/SearchAvailabilityRequest.cs +++ b/src/Square/Bookings/Requests/SearchAvailabilityRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings; +[Serializable] public record SearchAvailabilityRequest { /// diff --git a/src/Square/Bookings/Requests/UpdateBookingRequest.cs b/src/Square/Bookings/Requests/UpdateBookingRequest.cs index acaf1d49..fa22db6d 100644 --- a/src/Square/Bookings/Requests/UpdateBookingRequest.cs +++ b/src/Square/Bookings/Requests/UpdateBookingRequest.cs @@ -4,6 +4,7 @@ namespace Square.Bookings; +[Serializable] public record UpdateBookingRequest { /// diff --git a/src/Square/Bookings/TeamMemberProfiles/Requests/GetTeamMemberProfilesRequest.cs b/src/Square/Bookings/TeamMemberProfiles/Requests/GetTeamMemberProfilesRequest.cs index d7521c6e..eedbea03 100644 --- a/src/Square/Bookings/TeamMemberProfiles/Requests/GetTeamMemberProfilesRequest.cs +++ b/src/Square/Bookings/TeamMemberProfiles/Requests/GetTeamMemberProfilesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.TeamMemberProfiles; +[Serializable] public record GetTeamMemberProfilesRequest { /// diff --git a/src/Square/Bookings/TeamMemberProfiles/Requests/ListTeamMemberProfilesRequest.cs b/src/Square/Bookings/TeamMemberProfiles/Requests/ListTeamMemberProfilesRequest.cs index d505d988..134bed18 100644 --- a/src/Square/Bookings/TeamMemberProfiles/Requests/ListTeamMemberProfilesRequest.cs +++ b/src/Square/Bookings/TeamMemberProfiles/Requests/ListTeamMemberProfilesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Bookings.TeamMemberProfiles; +[Serializable] public record ListTeamMemberProfilesRequest { /// diff --git a/src/Square/Bookings/TeamMemberProfiles/TeamMemberProfilesClient.cs b/src/Square/Bookings/TeamMemberProfiles/TeamMemberProfilesClient.cs index bad7c5c9..8af18762 100644 --- a/src/Square/Bookings/TeamMemberProfiles/TeamMemberProfilesClient.cs +++ b/src/Square/Bookings/TeamMemberProfiles/TeamMemberProfilesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Cards/CardsClient.cs b/src/Square/Cards/CardsClient.cs index cc87654a..a5e2dce9 100644 --- a/src/Square/Cards/CardsClient.cs +++ b/src/Square/Cards/CardsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Cards/Requests/CreateCardRequest.cs b/src/Square/Cards/Requests/CreateCardRequest.cs index 886d15be..3d0cd81a 100644 --- a/src/Square/Cards/Requests/CreateCardRequest.cs +++ b/src/Square/Cards/Requests/CreateCardRequest.cs @@ -4,6 +4,7 @@ namespace Square.Cards; +[Serializable] public record CreateCardRequest { /// diff --git a/src/Square/Cards/Requests/DisableCardsRequest.cs b/src/Square/Cards/Requests/DisableCardsRequest.cs index 2a382fc3..f7149f87 100644 --- a/src/Square/Cards/Requests/DisableCardsRequest.cs +++ b/src/Square/Cards/Requests/DisableCardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Cards; +[Serializable] public record DisableCardsRequest { /// diff --git a/src/Square/Cards/Requests/GetCardsRequest.cs b/src/Square/Cards/Requests/GetCardsRequest.cs index c5e663c4..3a032846 100644 --- a/src/Square/Cards/Requests/GetCardsRequest.cs +++ b/src/Square/Cards/Requests/GetCardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Cards; +[Serializable] public record GetCardsRequest { /// diff --git a/src/Square/Cards/Requests/ListCardsRequest.cs b/src/Square/Cards/Requests/ListCardsRequest.cs index d94f40c4..e1ad0be5 100644 --- a/src/Square/Cards/Requests/ListCardsRequest.cs +++ b/src/Square/Cards/Requests/ListCardsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Cards; +[Serializable] public record ListCardsRequest { /// diff --git a/src/Square/CashDrawers/CashDrawersClient.cs b/src/Square/CashDrawers/CashDrawersClient.cs index eb735fc3..793096a8 100644 --- a/src/Square/CashDrawers/CashDrawersClient.cs +++ b/src/Square/CashDrawers/CashDrawersClient.cs @@ -1,4 +1,3 @@ -using Square.CashDrawers.Shifts; using Square.Core; namespace Square.CashDrawers; @@ -10,8 +9,8 @@ public partial class CashDrawersClient internal CashDrawersClient(RawClient client) { _client = client; - Shifts = new ShiftsClient(_client); + Shifts = new Square.CashDrawers.Shifts.ShiftsClient(_client); } - public ShiftsClient Shifts { get; } + public Square.CashDrawers.Shifts.ShiftsClient Shifts { get; } } diff --git a/src/Square/CashDrawers/Shifts/Requests/GetShiftsRequest.cs b/src/Square/CashDrawers/Shifts/Requests/GetShiftsRequest.cs index ab84470c..0cca4e82 100644 --- a/src/Square/CashDrawers/Shifts/Requests/GetShiftsRequest.cs +++ b/src/Square/CashDrawers/Shifts/Requests/GetShiftsRequest.cs @@ -3,6 +3,7 @@ namespace Square.CashDrawers.Shifts; +[Serializable] public record GetShiftsRequest { /// diff --git a/src/Square/CashDrawers/Shifts/Requests/ListEventsShiftsRequest.cs b/src/Square/CashDrawers/Shifts/Requests/ListEventsShiftsRequest.cs index e65477ce..5b9ac1b2 100644 --- a/src/Square/CashDrawers/Shifts/Requests/ListEventsShiftsRequest.cs +++ b/src/Square/CashDrawers/Shifts/Requests/ListEventsShiftsRequest.cs @@ -3,6 +3,7 @@ namespace Square.CashDrawers.Shifts; +[Serializable] public record ListEventsShiftsRequest { /// diff --git a/src/Square/CashDrawers/Shifts/Requests/ListShiftsRequest.cs b/src/Square/CashDrawers/Shifts/Requests/ListShiftsRequest.cs index 4f7d8b57..1949355b 100644 --- a/src/Square/CashDrawers/Shifts/Requests/ListShiftsRequest.cs +++ b/src/Square/CashDrawers/Shifts/Requests/ListShiftsRequest.cs @@ -4,6 +4,7 @@ namespace Square.CashDrawers.Shifts; +[Serializable] public record ListShiftsRequest { /// diff --git a/src/Square/CashDrawers/Shifts/ShiftsClient.cs b/src/Square/CashDrawers/Shifts/ShiftsClient.cs index f5bd0835..c3092073 100644 --- a/src/Square/CashDrawers/Shifts/ShiftsClient.cs +++ b/src/Square/CashDrawers/Shifts/ShiftsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -197,7 +198,11 @@ public async Task> ListAsync( /// /// /// await client.CashDrawers.Shifts.GetAsync( - /// new GetShiftsRequest { ShiftId = "shift_id", LocationId = "location_id" } + /// new Square.CashDrawers.Shifts.GetShiftsRequest + /// { + /// ShiftId = "shift_id", + /// LocationId = "location_id", + /// } /// ); /// public async Task GetAsync( diff --git a/src/Square/Catalog/CatalogClient.cs b/src/Square/Catalog/CatalogClient.cs index 1e8e8032..5896dbe4 100644 --- a/src/Square/Catalog/CatalogClient.cs +++ b/src/Square/Catalog/CatalogClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Catalog.Images; using Square.Catalog.Object; @@ -508,7 +509,7 @@ public async Task SearchAsync( /// new CustomAttributeFilter /// { /// Key = "VINTAGE", - /// NumberFilter = new Range { Min = "min", Max = "max" }, + /// NumberFilter = new Square.Range { Min = "min", Max = "max" }, /// }, /// new CustomAttributeFilter { CustomAttributeDefinitionId = "VARIETAL_DEFINITION_ID" }, /// }, diff --git a/src/Square/Catalog/Images/ImagesClient.cs b/src/Square/Catalog/Images/ImagesClient.cs index d234121e..7cbc8089 100644 --- a/src/Square/Catalog/Images/ImagesClient.cs +++ b/src/Square/Catalog/Images/ImagesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Catalog/Images/Requests/CreateImagesRequest.cs b/src/Square/Catalog/Images/Requests/CreateImagesRequest.cs index 1680d211..3f6b457e 100644 --- a/src/Square/Catalog/Images/Requests/CreateImagesRequest.cs +++ b/src/Square/Catalog/Images/Requests/CreateImagesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog.Images; +[Serializable] public record CreateImagesRequest { public CreateCatalogImageRequest? Request { get; set; } diff --git a/src/Square/Catalog/Images/Requests/UpdateImagesRequest.cs b/src/Square/Catalog/Images/Requests/UpdateImagesRequest.cs index 7be203df..71642d99 100644 --- a/src/Square/Catalog/Images/Requests/UpdateImagesRequest.cs +++ b/src/Square/Catalog/Images/Requests/UpdateImagesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Catalog.Images; +[Serializable] public record UpdateImagesRequest { /// diff --git a/src/Square/Catalog/Object/ObjectClient.cs b/src/Square/Catalog/Object/ObjectClient.cs index a7182f16..d535ec4c 100644 --- a/src/Square/Catalog/Object/ObjectClient.cs +++ b/src/Square/Catalog/Object/ObjectClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Catalog/Object/Requests/DeleteObjectRequest.cs b/src/Square/Catalog/Object/Requests/DeleteObjectRequest.cs index 85c9c085..a0e61802 100644 --- a/src/Square/Catalog/Object/Requests/DeleteObjectRequest.cs +++ b/src/Square/Catalog/Object/Requests/DeleteObjectRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog.Object; +[Serializable] public record DeleteObjectRequest { /// diff --git a/src/Square/Catalog/Object/Requests/GetObjectRequest.cs b/src/Square/Catalog/Object/Requests/GetObjectRequest.cs index 564d0270..10d76191 100644 --- a/src/Square/Catalog/Object/Requests/GetObjectRequest.cs +++ b/src/Square/Catalog/Object/Requests/GetObjectRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog.Object; +[Serializable] public record GetObjectRequest { /// diff --git a/src/Square/Catalog/Object/Requests/UpsertCatalogObjectRequest.cs b/src/Square/Catalog/Object/Requests/UpsertCatalogObjectRequest.cs index 7c7b600b..f702877a 100644 --- a/src/Square/Catalog/Object/Requests/UpsertCatalogObjectRequest.cs +++ b/src/Square/Catalog/Object/Requests/UpsertCatalogObjectRequest.cs @@ -4,6 +4,7 @@ namespace Square.Catalog.Object; +[Serializable] public record UpsertCatalogObjectRequest { /// diff --git a/src/Square/Catalog/Requests/BatchDeleteCatalogObjectsRequest.cs b/src/Square/Catalog/Requests/BatchDeleteCatalogObjectsRequest.cs index 2073f7d9..8f1cb016 100644 --- a/src/Square/Catalog/Requests/BatchDeleteCatalogObjectsRequest.cs +++ b/src/Square/Catalog/Requests/BatchDeleteCatalogObjectsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog; +[Serializable] public record BatchDeleteCatalogObjectsRequest { /// diff --git a/src/Square/Catalog/Requests/BatchGetCatalogObjectsRequest.cs b/src/Square/Catalog/Requests/BatchGetCatalogObjectsRequest.cs index 541fe66a..507a8bdf 100644 --- a/src/Square/Catalog/Requests/BatchGetCatalogObjectsRequest.cs +++ b/src/Square/Catalog/Requests/BatchGetCatalogObjectsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog; +[Serializable] public record BatchGetCatalogObjectsRequest { /// diff --git a/src/Square/Catalog/Requests/BatchUpsertCatalogObjectsRequest.cs b/src/Square/Catalog/Requests/BatchUpsertCatalogObjectsRequest.cs index 7ec10953..e5c8cf78 100644 --- a/src/Square/Catalog/Requests/BatchUpsertCatalogObjectsRequest.cs +++ b/src/Square/Catalog/Requests/BatchUpsertCatalogObjectsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Catalog; +[Serializable] public record BatchUpsertCatalogObjectsRequest { /// diff --git a/src/Square/Catalog/Requests/ListCatalogRequest.cs b/src/Square/Catalog/Requests/ListCatalogRequest.cs index 1e40512c..d5763a68 100644 --- a/src/Square/Catalog/Requests/ListCatalogRequest.cs +++ b/src/Square/Catalog/Requests/ListCatalogRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog; +[Serializable] public record ListCatalogRequest { /// diff --git a/src/Square/Catalog/Requests/SearchCatalogItemsRequest.cs b/src/Square/Catalog/Requests/SearchCatalogItemsRequest.cs index 3887bb35..2e3e0fd8 100644 --- a/src/Square/Catalog/Requests/SearchCatalogItemsRequest.cs +++ b/src/Square/Catalog/Requests/SearchCatalogItemsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Catalog; +[Serializable] public record SearchCatalogItemsRequest { /// diff --git a/src/Square/Catalog/Requests/SearchCatalogObjectsRequest.cs b/src/Square/Catalog/Requests/SearchCatalogObjectsRequest.cs index 89711db1..d53707c5 100644 --- a/src/Square/Catalog/Requests/SearchCatalogObjectsRequest.cs +++ b/src/Square/Catalog/Requests/SearchCatalogObjectsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Catalog; +[Serializable] public record SearchCatalogObjectsRequest { /// diff --git a/src/Square/Catalog/Requests/UpdateItemModifierListsRequest.cs b/src/Square/Catalog/Requests/UpdateItemModifierListsRequest.cs index 57947ea1..64f77825 100644 --- a/src/Square/Catalog/Requests/UpdateItemModifierListsRequest.cs +++ b/src/Square/Catalog/Requests/UpdateItemModifierListsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog; +[Serializable] public record UpdateItemModifierListsRequest { /// diff --git a/src/Square/Catalog/Requests/UpdateItemTaxesRequest.cs b/src/Square/Catalog/Requests/UpdateItemTaxesRequest.cs index 06627168..9ade9107 100644 --- a/src/Square/Catalog/Requests/UpdateItemTaxesRequest.cs +++ b/src/Square/Catalog/Requests/UpdateItemTaxesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Catalog; +[Serializable] public record UpdateItemTaxesRequest { /// diff --git a/src/Square/Channels/ChannelsClient.cs b/src/Square/Channels/ChannelsClient.cs index 291116c7..c49dedd0 100644 --- a/src/Square/Channels/ChannelsClient.cs +++ b/src/Square/Channels/ChannelsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Channels/Requests/BulkRetrieveChannelsRequest.cs b/src/Square/Channels/Requests/BulkRetrieveChannelsRequest.cs index fdc5c111..33ad9e84 100644 --- a/src/Square/Channels/Requests/BulkRetrieveChannelsRequest.cs +++ b/src/Square/Channels/Requests/BulkRetrieveChannelsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Channels; +[Serializable] public record BulkRetrieveChannelsRequest { [JsonPropertyName("channel_ids")] diff --git a/src/Square/Channels/Requests/GetChannelsRequest.cs b/src/Square/Channels/Requests/GetChannelsRequest.cs index 753dcfb3..4ec26d7c 100644 --- a/src/Square/Channels/Requests/GetChannelsRequest.cs +++ b/src/Square/Channels/Requests/GetChannelsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Channels; +[Serializable] public record GetChannelsRequest { /// diff --git a/src/Square/Channels/Requests/ListChannelsRequest.cs b/src/Square/Channels/Requests/ListChannelsRequest.cs index c321c788..367b7e47 100644 --- a/src/Square/Channels/Requests/ListChannelsRequest.cs +++ b/src/Square/Channels/Requests/ListChannelsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Channels; +[Serializable] public record ListChannelsRequest { /// diff --git a/src/Square/Checkout/CheckoutClient.cs b/src/Square/Checkout/CheckoutClient.cs index 74c189a0..96aea55d 100644 --- a/src/Square/Checkout/CheckoutClient.cs +++ b/src/Square/Checkout/CheckoutClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Checkout.PaymentLinks; using Square.Core; diff --git a/src/Square/Checkout/PaymentLinks/PaymentLinksClient.cs b/src/Square/Checkout/PaymentLinks/PaymentLinksClient.cs index d30fa08b..d8270a4f 100644 --- a/src/Square/Checkout/PaymentLinks/PaymentLinksClient.cs +++ b/src/Square/Checkout/PaymentLinks/PaymentLinksClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Checkout/PaymentLinks/Requests/CreatePaymentLinkRequest.cs b/src/Square/Checkout/PaymentLinks/Requests/CreatePaymentLinkRequest.cs index ff09edb7..43c490d5 100644 --- a/src/Square/Checkout/PaymentLinks/Requests/CreatePaymentLinkRequest.cs +++ b/src/Square/Checkout/PaymentLinks/Requests/CreatePaymentLinkRequest.cs @@ -4,6 +4,7 @@ namespace Square.Checkout.PaymentLinks; +[Serializable] public record CreatePaymentLinkRequest { /// diff --git a/src/Square/Checkout/PaymentLinks/Requests/DeletePaymentLinksRequest.cs b/src/Square/Checkout/PaymentLinks/Requests/DeletePaymentLinksRequest.cs index 48a981c2..5a0fbce6 100644 --- a/src/Square/Checkout/PaymentLinks/Requests/DeletePaymentLinksRequest.cs +++ b/src/Square/Checkout/PaymentLinks/Requests/DeletePaymentLinksRequest.cs @@ -3,6 +3,7 @@ namespace Square.Checkout.PaymentLinks; +[Serializable] public record DeletePaymentLinksRequest { /// diff --git a/src/Square/Checkout/PaymentLinks/Requests/GetPaymentLinksRequest.cs b/src/Square/Checkout/PaymentLinks/Requests/GetPaymentLinksRequest.cs index a36482db..f7e08f07 100644 --- a/src/Square/Checkout/PaymentLinks/Requests/GetPaymentLinksRequest.cs +++ b/src/Square/Checkout/PaymentLinks/Requests/GetPaymentLinksRequest.cs @@ -3,6 +3,7 @@ namespace Square.Checkout.PaymentLinks; +[Serializable] public record GetPaymentLinksRequest { /// diff --git a/src/Square/Checkout/PaymentLinks/Requests/ListPaymentLinksRequest.cs b/src/Square/Checkout/PaymentLinks/Requests/ListPaymentLinksRequest.cs index 501dbbb8..c23379f3 100644 --- a/src/Square/Checkout/PaymentLinks/Requests/ListPaymentLinksRequest.cs +++ b/src/Square/Checkout/PaymentLinks/Requests/ListPaymentLinksRequest.cs @@ -3,6 +3,7 @@ namespace Square.Checkout.PaymentLinks; +[Serializable] public record ListPaymentLinksRequest { /// diff --git a/src/Square/Checkout/PaymentLinks/Requests/UpdatePaymentLinkRequest.cs b/src/Square/Checkout/PaymentLinks/Requests/UpdatePaymentLinkRequest.cs index 55c57d34..f15c4d28 100644 --- a/src/Square/Checkout/PaymentLinks/Requests/UpdatePaymentLinkRequest.cs +++ b/src/Square/Checkout/PaymentLinks/Requests/UpdatePaymentLinkRequest.cs @@ -4,6 +4,7 @@ namespace Square.Checkout.PaymentLinks; +[Serializable] public record UpdatePaymentLinkRequest { /// diff --git a/src/Square/Checkout/Requests/RetrieveLocationSettingsRequest.cs b/src/Square/Checkout/Requests/RetrieveLocationSettingsRequest.cs index 5d5abf13..d5bfe047 100644 --- a/src/Square/Checkout/Requests/RetrieveLocationSettingsRequest.cs +++ b/src/Square/Checkout/Requests/RetrieveLocationSettingsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Checkout; +[Serializable] public record RetrieveLocationSettingsRequest { /// diff --git a/src/Square/Checkout/Requests/UpdateLocationSettingsRequest.cs b/src/Square/Checkout/Requests/UpdateLocationSettingsRequest.cs index f225aff4..b59e2957 100644 --- a/src/Square/Checkout/Requests/UpdateLocationSettingsRequest.cs +++ b/src/Square/Checkout/Requests/UpdateLocationSettingsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Checkout; +[Serializable] public record UpdateLocationSettingsRequest { /// diff --git a/src/Square/Checkout/Requests/UpdateMerchantSettingsRequest.cs b/src/Square/Checkout/Requests/UpdateMerchantSettingsRequest.cs index f1cad35d..219b981e 100644 --- a/src/Square/Checkout/Requests/UpdateMerchantSettingsRequest.cs +++ b/src/Square/Checkout/Requests/UpdateMerchantSettingsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Checkout; +[Serializable] public record UpdateMerchantSettingsRequest { /// diff --git a/src/Square/Checkout/Types/Checkout.cs b/src/Square/Checkout/Types/Checkout.cs index 2247d6f8..2ca0e234 100644 --- a/src/Square/Checkout/Types/Checkout.cs +++ b/src/Square/Checkout/Types/Checkout.cs @@ -9,8 +9,13 @@ namespace Square.Checkout; /// Square Checkout lets merchants accept online payments for supported /// payment types using a checkout workflow hosted on squareup.com. /// -public record Checkout +[Serializable] +public record Checkout : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// ID generated by Square Checkout when a new checkout is requested. /// @@ -101,15 +106,11 @@ public record Checkout [JsonPropertyName("additional_recipients")] public IEnumerable? AdditionalRecipients { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Core/CollectionItemSerializer.cs b/src/Square/Core/CollectionItemSerializer.cs index a9e69b10..a5e683cb 100644 --- a/src/Square/Core/CollectionItemSerializer.cs +++ b/src/Square/Core/CollectionItemSerializer.cs @@ -42,7 +42,7 @@ JsonSerializerOptions options { var item = (TDatatype)( JsonSerializer.Deserialize(ref reader, typeof(TDatatype), jsonSerializerOptions) - ?? throw new Exception( + ?? throw new global::System.Exception( $"Failed to deserialize collection item of type {typeof(TDatatype)}" ) ); diff --git a/src/Square/Core/DateOnlyConverter.cs b/src/Square/Core/DateOnlyConverter.cs index 18f165d7..882f381f 100644 --- a/src/Square/Core/DateOnlyConverter.cs +++ b/src/Square/Core/DateOnlyConverter.cs @@ -169,7 +169,6 @@ internal static class JsonConstants // ReSharper disable SuggestVarOrType_SimpleTypes // ReSharper disable SuggestVarOrType_BuiltInTypes - internal static class JsonHelpers { [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -611,7 +610,7 @@ public static void ThrowFormatException(DataType dataType) }; } - private static Exception GetInvalidOperationException( + private static global::System.Exception GetInvalidOperationException( string message, JsonTokenType tokenType ) diff --git a/src/Square/Core/Extensions.cs b/src/Square/Core/Extensions.cs index 43b2726d..26379382 100644 --- a/src/Square/Core/Extensions.cs +++ b/src/Square/Core/Extensions.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; namespace Square.Core; @@ -7,8 +8,48 @@ internal static class Extensions public static string Stringify(this Enum value) { var field = value.GetType().GetField(value.ToString()); - var attribute = (EnumMemberAttribute) - Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)); - return attribute?.Value ?? value.ToString(); + if (field != null) + { + var attribute = (EnumMemberAttribute?) + Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)); + return attribute?.Value ?? value.ToString(); + } + return value.ToString(); + } + + /// + /// Asserts that a condition is true, throwing an exception with the specified message if it is false. + /// + /// The condition to assert. + /// The exception message if the assertion fails. + /// Thrown when the condition is false. + internal static void Assert(this object value, bool condition, string message) + { + if (!condition) + { + throw new global::System.Exception(message); + } + } + + /// + /// Asserts that a value is not null, throwing an exception with the specified message if it is null. + /// + /// The type of the value to assert. + /// The value to assert is not null. + /// The exception message if the assertion fails. + /// The non-null value. + /// Thrown when the value is null. + internal static TValue Assert( + this object _unused, + [NotNull] TValue? value, + string message + ) + where TValue : class + { + if (value == null) + { + throw new global::System.Exception(message); + } + return value; } } diff --git a/src/Square/Core/IRequestOptions.cs b/src/Square/Core/IRequestOptions.cs index 7e46dc3b..22f17cad 100644 --- a/src/Square/Core/IRequestOptions.cs +++ b/src/Square/Core/IRequestOptions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Net.Http; diff --git a/src/Square/Core/JsonConfiguration.cs b/src/Square/Core/JsonConfiguration.cs index 78c15c3d..3d8c0637 100644 --- a/src/Square/Core/JsonConfiguration.cs +++ b/src/Square/Core/JsonConfiguration.cs @@ -1,3 +1,4 @@ +using global::System.Reflection; using global::System.Text.Json; using global::System.Text.Json.Nodes; using global::System.Text.Json.Serialization; @@ -70,6 +71,30 @@ static JsonOptions() propertyInfo.IsRequired = false; } } + + if ( + typeInfo.Kind == JsonTypeInfoKind.Object + && typeInfo.Properties.All(prop => !prop.IsExtensionData) + ) + { + var extensionProp = typeInfo + .Type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic) + .FirstOrDefault(prop => + prop.GetCustomAttribute() != null + ); + + if (extensionProp is not null) + { + var jsonPropertyInfo = typeInfo.CreateJsonPropertyInfo( + extensionProp.FieldType, + extensionProp.Name + ); + jsonPropertyInfo.Get = extensionProp.GetValue; + jsonPropertyInfo.Set = extensionProp.SetValue; + jsonPropertyInfo.IsExtensionData = true; + typeInfo.Properties.Add(jsonPropertyInfo); + } + } }, }, }, diff --git a/src/Square/Core/Pager.cs b/src/Square/Core/Pager.cs index 267cb360..40525387 100644 --- a/src/Square/Core/Pager.cs +++ b/src/Square/Core/Pager.cs @@ -446,9 +446,13 @@ SetCursor setCursor var items = getItems(response); var page = items is not null ? new Page(items) : Page.Empty; var cursor = getNextCursor(response); - var hasNextPage = cursor is not null; + var hasNextPage = cursor switch + { + null or "" => false, + _ => true, + }; setCursor(request, cursor); - if (cursor is null) + if (!hasNextPage) { return (default, false, page); } diff --git a/src/Square/Core/Public/AdditionalProperties.cs b/src/Square/Core/Public/AdditionalProperties.cs new file mode 100644 index 00000000..abc82a09 --- /dev/null +++ b/src/Square/Core/Public/AdditionalProperties.cs @@ -0,0 +1,353 @@ +using global::System.Collections; +using global::System.Collections.ObjectModel; +using global::System.Text.Json; +using global::System.Text.Json.Nodes; +using Square.Core; + +namespace Square; + +public record ReadOnlyAdditionalProperties : ReadOnlyAdditionalProperties +{ + internal ReadOnlyAdditionalProperties() { } + + internal ReadOnlyAdditionalProperties(IDictionary properties) + : base(properties) { } +} + +public record ReadOnlyAdditionalProperties : IReadOnlyDictionary +{ + private readonly Dictionary _extensionData = new(); + private readonly Dictionary _convertedCache = new(); + + internal ReadOnlyAdditionalProperties() + { + _extensionData = new Dictionary(); + _convertedCache = new Dictionary(); + } + + internal ReadOnlyAdditionalProperties(IDictionary properties) + { + _extensionData = new Dictionary(properties.Count); + _convertedCache = new Dictionary(properties.Count); + foreach (var kvp in properties) + { + if (kvp.Value is JsonElement element) + { + _extensionData.Add(kvp.Key, element); + } + else + { + _extensionData[kvp.Key] = JsonUtils.SerializeToElement(kvp.Value); + } + + _convertedCache[kvp.Key] = kvp.Value; + } + } + + private static T ConvertToT(JsonElement value) + { + if (typeof(T) == typeof(JsonElement)) + { + return (T)(object)value; + } + + return value.Deserialize(JsonOptions.JsonSerializerOptions)!; + } + + internal void CopyFromExtensionData(IDictionary extensionData) + { + _extensionData.Clear(); + _convertedCache.Clear(); + foreach (var kvp in extensionData) + { + _extensionData[kvp.Key] = kvp.Value; + if (kvp.Value is T value) + { + _convertedCache[kvp.Key] = value; + } + } + } + + private T GetCached(string key) + { + if (_convertedCache.TryGetValue(key, out var cached)) + { + return cached; + } + + var value = ConvertToT(_extensionData[key]); + _convertedCache[key] = value; + return value; + } + + public IEnumerator> GetEnumerator() + { + return _extensionData + .Select(kvp => new KeyValuePair(kvp.Key, GetCached(kvp.Key))) + .GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + public int Count => _extensionData.Count; + + public bool ContainsKey(string key) => _extensionData.ContainsKey(key); + + public bool TryGetValue(string key, out T value) + { + if (_convertedCache.TryGetValue(key, out value!)) + { + return true; + } + + if (_extensionData.TryGetValue(key, out var element)) + { + value = ConvertToT(element); + _convertedCache[key] = value; + return true; + } + + return false; + } + + public T this[string key] => GetCached(key); + + public IEnumerable Keys => _extensionData.Keys; + + public IEnumerable Values => Keys.Select(GetCached); +} + +public record AdditionalProperties : AdditionalProperties +{ + public AdditionalProperties() { } + + public AdditionalProperties(IDictionary properties) + : base(properties) { } +} + +public record AdditionalProperties : IDictionary +{ + private readonly Dictionary _extensionData; + private readonly Dictionary _convertedCache; + + public AdditionalProperties() + { + _extensionData = new Dictionary(); + _convertedCache = new Dictionary(); + } + + public AdditionalProperties(IDictionary properties) + { + _extensionData = new Dictionary(properties.Count); + _convertedCache = new Dictionary(properties.Count); + foreach (var kvp in properties) + { + _extensionData[kvp.Key] = kvp.Value; + _convertedCache[kvp.Key] = kvp.Value; + } + } + + private static T ConvertToT(object? extensionDataValue) + { + return extensionDataValue switch + { + T value => value, + JsonElement jsonElement => jsonElement.Deserialize( + JsonOptions.JsonSerializerOptions + )!, + JsonNode jsonNode => jsonNode.Deserialize(JsonOptions.JsonSerializerOptions)!, + _ => JsonUtils + .SerializeToElement(extensionDataValue) + .Deserialize(JsonOptions.JsonSerializerOptions)!, + }; + } + + internal void CopyFromExtensionData(IDictionary extensionData) + { + _extensionData.Clear(); + _convertedCache.Clear(); + foreach (var kvp in extensionData) + { + _extensionData[kvp.Key] = kvp.Value; + if (kvp.Value is T value) + { + _convertedCache[kvp.Key] = value; + } + } + } + + internal void CopyToExtensionData(IDictionary extensionData) + { + extensionData.Clear(); + foreach (var kvp in _extensionData) + { + extensionData[kvp.Key] = kvp.Value; + } + } + + public JsonObject ToJsonObject() => + ( + JsonUtils.SerializeToNode(_extensionData) + ?? throw new InvalidOperationException( + "Failed to serialize AdditionalProperties to JSON Node." + ) + ).AsObject(); + + public JsonNode ToJsonNode() => + JsonUtils.SerializeToNode(_extensionData) + ?? throw new InvalidOperationException( + "Failed to serialize AdditionalProperties to JSON Node." + ); + + public JsonElement ToJsonElement() => JsonUtils.SerializeToElement(_extensionData); + + public JsonDocument ToJsonDocument() => JsonUtils.SerializeToDocument(_extensionData); + + public IReadOnlyDictionary ToJsonElementDictionary() + { + return new ReadOnlyDictionary( + _extensionData.ToDictionary( + kvp => kvp.Key, + kvp => + { + if (kvp.Value is JsonElement jsonElement) + { + return jsonElement; + } + + return JsonUtils.SerializeToElement(kvp.Value); + } + ) + ); + } + + public ICollection Keys => _extensionData.Keys; + + public ICollection Values + { + get + { + var values = new T[_extensionData.Count]; + var i = 0; + foreach (var key in Keys) + { + values[i++] = GetCached(key); + } + + return values; + } + } + + private T GetCached(string key) + { + if (_convertedCache.TryGetValue(key, out var value)) + { + return value; + } + + value = ConvertToT(_extensionData[key]); + _convertedCache.Add(key, value); + return value; + } + + private void SetCached(string key, T value) + { + _extensionData[key] = value; + _convertedCache[key] = value; + } + + private void AddCached(string key, T value) + { + _extensionData.Add(key, value); + _convertedCache.Add(key, value); + } + + private bool RemoveCached(string key) + { + var isRemoved = _extensionData.Remove(key); + _convertedCache.Remove(key); + return isRemoved; + } + + public int Count => _extensionData.Count; + public bool IsReadOnly => false; + + public T this[string key] + { + get => GetCached(key); + set => SetCached(key, value); + } + + public void Add(string key, T value) => AddCached(key, value); + + public void Add(KeyValuePair item) => AddCached(item.Key, item.Value); + + public bool Remove(string key) => RemoveCached(key); + + public bool Remove(KeyValuePair item) => RemoveCached(item.Key); + + public bool ContainsKey(string key) => _extensionData.ContainsKey(key); + + public bool Contains(KeyValuePair item) + { + return _extensionData.ContainsKey(item.Key) + && EqualityComparer.Default.Equals(GetCached(item.Key), item.Value); + } + + public bool TryGetValue(string key, out T value) + { + if (_convertedCache.TryGetValue(key, out value!)) + { + return true; + } + + if (_extensionData.TryGetValue(key, out var extensionDataValue)) + { + value = ConvertToT(extensionDataValue); + _convertedCache[key] = value; + return true; + } + + return false; + } + + public void Clear() + { + _extensionData.Clear(); + _convertedCache.Clear(); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + if (array is null) + { + throw new ArgumentNullException(nameof(array)); + } + + if (arrayIndex < 0 || arrayIndex > array.Length) + { + throw new ArgumentOutOfRangeException(nameof(arrayIndex)); + } + + if (array.Length - arrayIndex < _extensionData.Count) + { + throw new ArgumentException( + "The array does not have enough space to copy the elements." + ); + } + + foreach (var kvp in _extensionData) + { + array[arrayIndex++] = new KeyValuePair(kvp.Key, GetCached(kvp.Key)); + } + } + + public IEnumerator> GetEnumerator() + { + return _extensionData + .Select(kvp => new KeyValuePair(kvp.Key, GetCached(kvp.Key))) + .GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); +} diff --git a/src/Square/Core/Public/ClientOptions.cs b/src/Square/Core/Public/ClientOptions.cs index a721f2ef..104f4a47 100644 --- a/src/Square/Core/Public/ClientOptions.cs +++ b/src/Square/Core/Public/ClientOptions.cs @@ -1,10 +1,10 @@ -using System; using System.Collections.Generic; using System.Net.Http; using Square.Core; namespace Square; +[Serializable] public partial class ClientOptions { /// diff --git a/src/Square/Core/Public/RequestOptions.cs b/src/Square/Core/Public/RequestOptions.cs index fb0bd51c..c8b50309 100644 --- a/src/Square/Core/Public/RequestOptions.cs +++ b/src/Square/Core/Public/RequestOptions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; @@ -6,6 +5,7 @@ namespace Square; +[Serializable] public partial class RequestOptions : IRequestOptions { /// diff --git a/src/Square/Core/Public/SquareEnvironment.cs b/src/Square/Core/Public/SquareEnvironment.cs index c69b90e6..98c60bec 100644 --- a/src/Square/Core/Public/SquareEnvironment.cs +++ b/src/Square/Core/Public/SquareEnvironment.cs @@ -1,5 +1,6 @@ namespace Square; +[Serializable] public class SquareEnvironment { public const string Production = "https://connect.squareup.com"; diff --git a/src/Square/Core/Public/SquareException.cs b/src/Square/Core/Public/SquareException.cs index 16d124a1..0d6aa4e8 100644 --- a/src/Square/Core/Public/SquareException.cs +++ b/src/Square/Core/Public/SquareException.cs @@ -1,5 +1,3 @@ -using System; - namespace Square; /// diff --git a/src/Square/Core/Public/Version.cs b/src/Square/Core/Public/Version.cs index fc1737b6..1550d431 100644 --- a/src/Square/Core/Public/Version.cs +++ b/src/Square/Core/Public/Version.cs @@ -1,6 +1,7 @@ namespace Square; +[Serializable] internal class Version { - public const string Current = "42.2.0"; + public const string Current = "42.2.1"; } diff --git a/src/Square/Core/QueryStringConverter.cs b/src/Square/Core/QueryStringConverter.cs index b3eba838..2737f452 100644 --- a/src/Square/Core/QueryStringConverter.cs +++ b/src/Square/Core/QueryStringConverter.cs @@ -66,7 +66,7 @@ private static void AssertRootJson(JsonElement json) case JsonValueKind.False: case JsonValueKind.Null: default: - throw new Exception( + throw new global::System.Exception( $"Only objects can be converted to query string collections. Given type is {json.ValueKind}." ); } diff --git a/src/Square/Core/RawClient.cs b/src/Square/Core/RawClient.cs index 20879c64..7c365a71 100644 --- a/src/Square/Core/RawClient.cs +++ b/src/Square/Core/RawClient.cs @@ -19,16 +19,16 @@ internal partial class RawClient(ClientOptions clientOptions) internal readonly ClientOptions Options = clientOptions; [Obsolete("Use SendRequestAsync instead.")] - internal Task MakeRequestAsync( - Square.Core.BaseRequest request, + internal Task MakeRequestAsync( + global::Square.Core.BaseRequest request, CancellationToken cancellationToken = default ) { return SendRequestAsync(request, cancellationToken); } - internal async Task SendRequestAsync( - Square.Core.BaseRequest request, + internal async Task SendRequestAsync( + global::Square.Core.BaseRequest request, CancellationToken cancellationToken = default ) { @@ -43,7 +43,7 @@ internal partial class RawClient(ClientOptions clientOptions) .ConfigureAwait(false); } - internal async Task SendRequestAsync( + internal async Task SendRequestAsync( HttpRequestMessage request, IRequestOptions? options, CancellationToken cancellationToken = default @@ -109,7 +109,7 @@ private static async Task CloneRequestAsync(HttpRequestMessa /// Sends the request with retries, unless the request content is not retryable, /// such as stream requests and multipart form data with stream content. /// - private async Task SendWithRetriesAsync( + private async Task SendWithRetriesAsync( HttpRequestMessage request, IRequestOptions? options, CancellationToken cancellationToken @@ -122,7 +122,7 @@ CancellationToken cancellationToken if (!isRetryableContent) { - return new Square.Core.ApiResponse + return new global::Square.Core.ApiResponse { StatusCode = (int)response.StatusCode, Raw = response, @@ -144,7 +144,7 @@ CancellationToken cancellationToken .ConfigureAwait(false); } - return new Square.Core.ApiResponse + return new global::Square.Core.ApiResponse { StatusCode = (int)response.StatusCode, Raw = response, @@ -168,7 +168,7 @@ private static bool IsRetryableContent(HttpRequestMessage request) }; } - internal HttpRequestMessage CreateHttpRequest(Square.Core.BaseRequest request) + internal HttpRequestMessage CreateHttpRequest(global::Square.Core.BaseRequest request) { var url = BuildUrl(request); var httpRequest = new HttpRequestMessage(request.Method, url); @@ -184,7 +184,7 @@ internal HttpRequestMessage CreateHttpRequest(Square.Core.BaseRequest request) return httpRequest; } - private static string BuildUrl(Square.Core.BaseRequest request) + private static string BuildUrl(global::Square.Core.BaseRequest request) { var baseUrl = request.Options?.BaseUrl ?? request.BaseUrl; var trimmedBaseUrl = baseUrl.TrimEnd('/'); @@ -208,7 +208,9 @@ and not string { var items = collection .Cast() - .Select(value => $"{queryItem.Key}={value}") + .Select(value => + $"{Uri.EscapeDataString(queryItem.Key)}={Uri.EscapeDataString(value?.ToString() ?? "")}" + ) .ToList(); if (items.Any()) { @@ -217,7 +219,8 @@ and not string } else { - current += $"{queryItem.Key}={queryItem.Value}&"; + current += + $"{Uri.EscapeDataString(queryItem.Key)}={Uri.EscapeDataString(queryItem.Value)}&"; } return current; @@ -228,7 +231,7 @@ and not string } private static List> GetQueryParameters( - Square.Core.BaseRequest request + global::Square.Core.BaseRequest request ) { var result = TransformToKeyValuePairs(request.Query); @@ -384,26 +387,26 @@ string mediaTypeFallback } /// - [Obsolete("Use Square.Core.ApiResponse instead.")] - internal record ApiResponse : Square.Core.ApiResponse; + [Obsolete("Use global::Square.Core.ApiResponse instead.")] + internal record ApiResponse : global::Square.Core.ApiResponse; /// - [Obsolete("Use Square.Core.BaseRequest instead.")] - internal abstract record BaseApiRequest : Square.Core.BaseRequest; + [Obsolete("Use global::Square.Core.BaseRequest instead.")] + internal abstract record BaseApiRequest : global::Square.Core.BaseRequest; /// - [Obsolete("Use Square.Core.EmptyRequest instead.")] - internal abstract record EmptyApiRequest : Square.Core.EmptyRequest; + [Obsolete("Use global::Square.Core.EmptyRequest instead.")] + internal abstract record EmptyApiRequest : global::Square.Core.EmptyRequest; /// - [Obsolete("Use Square.Core.JsonRequest instead.")] - internal abstract record JsonApiRequest : Square.Core.JsonRequest; + [Obsolete("Use global::Square.Core.JsonRequest instead.")] + internal abstract record JsonApiRequest : global::Square.Core.JsonRequest; /// - [Obsolete("Use Square.Core.MultipartFormRequest instead.")] - internal abstract record MultipartFormRequest : Square.Core.MultipartFormRequest; + [Obsolete("Use global::Square.Core.MultipartFormRequest instead.")] + internal abstract record MultipartFormRequest : global::Square.Core.MultipartFormRequest; /// - [Obsolete("Use Square.Core.StreamRequest instead.")] - internal abstract record StreamApiRequest : Square.Core.StreamRequest; + [Obsolete("Use global::Square.Core.StreamRequest instead.")] + internal abstract record StreamApiRequest : global::Square.Core.StreamRequest; } diff --git a/src/Square/Core/StringEnumSerializer.cs b/src/Square/Core/StringEnumSerializer.cs index bf90c0e0..4e9f6884 100644 --- a/src/Square/Core/StringEnumSerializer.cs +++ b/src/Square/Core/StringEnumSerializer.cs @@ -1,4 +1,3 @@ -using System.Runtime.Serialization; using System.Text.Json; using System.Text.Json.Serialization; @@ -9,14 +8,14 @@ internal class StringEnumSerializer : JsonConverter { public override T? Read( ref Utf8JsonReader reader, - Type typeToConvert, + global::System.Type typeToConvert, JsonSerializerOptions options ) { var stringValue = reader.GetString() - ?? throw new Exception("The JSON value could not be read as a string."); - return (T)Activator.CreateInstance(typeToConvert, stringValue); + ?? throw new global::System.Exception("The JSON value could not be read as a string."); + return (T?)Activator.CreateInstance(typeToConvert, stringValue); } public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) diff --git a/src/Square/Core/ValueConvert.cs b/src/Square/Core/ValueConvert.cs index ae90e582..d8cde230 100644 --- a/src/Square/Core/ValueConvert.cs +++ b/src/Square/Core/ValueConvert.cs @@ -29,6 +29,8 @@ public static class ValueConvert internal static string ToPathParameterString(ulong v) => ToString(v); + internal static string ToPathParameterString(string v) => ToString(v); + internal static string ToPathParameterString(char v) => ToString(v); internal static string ToPathParameterString(Guid v) => ToString(v); @@ -55,6 +57,8 @@ public static class ValueConvert internal static string ToQueryStringValue(ulong v) => ToString(v); + internal static string ToQueryStringValue(string v) => v is null ? "" : v; + internal static string ToQueryStringValue(char v) => ToString(v); internal static string ToQueryStringValue(Guid v) => ToString(v); @@ -105,5 +109,7 @@ internal static string ToString(T value) internal static string ToString(char v) => v.ToString(CultureInfo.InvariantCulture); + internal static string ToString(string v) => v; + internal static string ToString(Guid v) => v.ToString("D"); } diff --git a/src/Square/Customers/Cards/CardsClient.cs b/src/Square/Customers/Cards/CardsClient.cs index 34e838f3..f62fcd10 100644 --- a/src/Square/Customers/Cards/CardsClient.cs +++ b/src/Square/Customers/Cards/CardsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Customers/Cards/Requests/CreateCustomerCardRequest.cs b/src/Square/Customers/Cards/Requests/CreateCustomerCardRequest.cs index baa9af75..31b73467 100644 --- a/src/Square/Customers/Cards/Requests/CreateCustomerCardRequest.cs +++ b/src/Square/Customers/Cards/Requests/CreateCustomerCardRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.Cards; +[Serializable] public record CreateCustomerCardRequest { /// diff --git a/src/Square/Customers/Cards/Requests/DeleteCardsRequest.cs b/src/Square/Customers/Cards/Requests/DeleteCardsRequest.cs index f4897101..b3522749 100644 --- a/src/Square/Customers/Cards/Requests/DeleteCardsRequest.cs +++ b/src/Square/Customers/Cards/Requests/DeleteCardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Cards; +[Serializable] public record DeleteCardsRequest { /// diff --git a/src/Square/Customers/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs b/src/Square/Customers/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs index eff71a67..82aff4c9 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -86,7 +87,11 @@ private async Task ListInternalA /// /// /// await client.Customers.CustomAttributeDefinitions.ListAsync( - /// new ListCustomAttributeDefinitionsRequest { Limit = 1, Cursor = "cursor" } + /// new Square.Customers.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest + /// { + /// Limit = 1, + /// Cursor = "cursor", + /// } /// ); /// public async Task> ListAsync( @@ -142,7 +147,7 @@ public async Task> ListAsync( /// CustomAttributeDefinition = new CustomAttributeDefinition /// { /// Key = "favoritemovie", - /// Schema = new Dictionary<string, object>() + /// Schema = new Dictionary<string, object?>() /// { /// { /// "$ref", @@ -210,7 +215,11 @@ public async Task CreateAsync( /// /// /// await client.Customers.CustomAttributeDefinitions.GetAsync( - /// new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + /// new Square.Customers.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// Version = 1, + /// } /// ); /// public async Task GetAsync( @@ -345,7 +354,10 @@ public async Task UpdateAsync( /// /// /// await client.Customers.CustomAttributeDefinitions.DeleteAsync( - /// new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + /// new Square.Customers.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Customers/CustomAttributeDefinitions/Requests/BatchUpsertCustomerCustomAttributesRequest.cs b/src/Square/Customers/CustomAttributeDefinitions/Requests/BatchUpsertCustomerCustomAttributesRequest.cs index 252544dc..3a483ecb 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/Requests/BatchUpsertCustomerCustomAttributesRequest.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/Requests/BatchUpsertCustomerCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.CustomAttributeDefinitions; +[Serializable] public record BatchUpsertCustomerCustomAttributesRequest { /// diff --git a/src/Square/Customers/CustomAttributeDefinitions/Requests/CreateCustomerCustomAttributeDefinitionRequest.cs b/src/Square/Customers/CustomAttributeDefinitions/Requests/CreateCustomerCustomAttributeDefinitionRequest.cs index 0e992ce7..ef533b4d 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/Requests/CreateCustomerCustomAttributeDefinitionRequest.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/Requests/CreateCustomerCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.CustomAttributeDefinitions; +[Serializable] public record CreateCustomerCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Customers/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs b/src/Square/Customers/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs index 2acc9d6a..870c894d 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.CustomAttributeDefinitions; +[Serializable] public record DeleteCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Customers/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs b/src/Square/Customers/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs index 6033ec7a..500aaf10 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.CustomAttributeDefinitions; +[Serializable] public record GetCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Customers/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs b/src/Square/Customers/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs index 81708413..9aefc5df 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.CustomAttributeDefinitions; +[Serializable] public record ListCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Customers/CustomAttributeDefinitions/Requests/UpdateCustomerCustomAttributeDefinitionRequest.cs b/src/Square/Customers/CustomAttributeDefinitions/Requests/UpdateCustomerCustomAttributeDefinitionRequest.cs index 83d83a42..9ea5a9c5 100644 --- a/src/Square/Customers/CustomAttributeDefinitions/Requests/UpdateCustomerCustomAttributeDefinitionRequest.cs +++ b/src/Square/Customers/CustomAttributeDefinitions/Requests/UpdateCustomerCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.CustomAttributeDefinitions; +[Serializable] public record UpdateCustomerCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Customers/CustomAttributes/CustomAttributesClient.cs b/src/Square/Customers/CustomAttributes/CustomAttributesClient.cs index 9cb2c13d..80e72160 100644 --- a/src/Square/Customers/CustomAttributes/CustomAttributesClient.cs +++ b/src/Square/Customers/CustomAttributes/CustomAttributesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -95,7 +96,7 @@ private async Task ListInternalAsync( /// /// /// await client.Customers.CustomAttributes.ListAsync( - /// new ListCustomAttributesRequest + /// new Square.Customers.CustomAttributes.ListCustomAttributesRequest /// { /// CustomerId = "customer_id", /// Limit = 1, @@ -149,7 +150,7 @@ public async Task> ListAsync( /// /// /// await client.Customers.CustomAttributes.GetAsync( - /// new GetCustomAttributesRequest + /// new Square.Customers.CustomAttributes.GetCustomAttributesRequest /// { /// CustomerId = "customer_id", /// Key = "key", @@ -290,7 +291,11 @@ public async Task UpsertAsync( /// /// /// await client.Customers.CustomAttributes.DeleteAsync( - /// new DeleteCustomAttributesRequest { CustomerId = "customer_id", Key = "key" } + /// new Square.Customers.CustomAttributes.DeleteCustomAttributesRequest + /// { + /// CustomerId = "customer_id", + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Customers/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs b/src/Square/Customers/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs index 7f78b138..cdf55574 100644 --- a/src/Square/Customers/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs +++ b/src/Square/Customers/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.CustomAttributes; +[Serializable] public record DeleteCustomAttributesRequest { /// diff --git a/src/Square/Customers/CustomAttributes/Requests/GetCustomAttributesRequest.cs b/src/Square/Customers/CustomAttributes/Requests/GetCustomAttributesRequest.cs index e2579ce1..0f81f051 100644 --- a/src/Square/Customers/CustomAttributes/Requests/GetCustomAttributesRequest.cs +++ b/src/Square/Customers/CustomAttributes/Requests/GetCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.CustomAttributes; +[Serializable] public record GetCustomAttributesRequest { /// diff --git a/src/Square/Customers/CustomAttributes/Requests/ListCustomAttributesRequest.cs b/src/Square/Customers/CustomAttributes/Requests/ListCustomAttributesRequest.cs index 8c9559f5..e4a5d886 100644 --- a/src/Square/Customers/CustomAttributes/Requests/ListCustomAttributesRequest.cs +++ b/src/Square/Customers/CustomAttributes/Requests/ListCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.CustomAttributes; +[Serializable] public record ListCustomAttributesRequest { /// diff --git a/src/Square/Customers/CustomAttributes/Requests/UpsertCustomerCustomAttributeRequest.cs b/src/Square/Customers/CustomAttributes/Requests/UpsertCustomerCustomAttributeRequest.cs index 9b5a1470..86293cfb 100644 --- a/src/Square/Customers/CustomAttributes/Requests/UpsertCustomerCustomAttributeRequest.cs +++ b/src/Square/Customers/CustomAttributes/Requests/UpsertCustomerCustomAttributeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.CustomAttributes; +[Serializable] public record UpsertCustomerCustomAttributeRequest { /// diff --git a/src/Square/Customers/CustomersClient.cs b/src/Square/Customers/CustomersClient.cs index f48b43fd..18a42946 100644 --- a/src/Square/Customers/CustomersClient.cs +++ b/src/Square/Customers/CustomersClient.cs @@ -1,11 +1,9 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; -using Square.Customers.Cards; -using Square.Customers.CustomAttributeDefinitions; -using Square.Customers.CustomAttributes; using Square.Customers.Groups; using Square.Customers.Segments; @@ -18,22 +16,25 @@ public partial class CustomersClient internal CustomersClient(RawClient client) { _client = client; - CustomAttributeDefinitions = new CustomAttributeDefinitionsClient(_client); + CustomAttributeDefinitions = + new Square.Customers.CustomAttributeDefinitions.CustomAttributeDefinitionsClient( + _client + ); Groups = new GroupsClient(_client); Segments = new SegmentsClient(_client); - Cards = new CardsClient(_client); - CustomAttributes = new CustomAttributesClient(_client); + Cards = new Square.Customers.Cards.CardsClient(_client); + CustomAttributes = new Square.Customers.CustomAttributes.CustomAttributesClient(_client); } - public CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } + public Square.Customers.CustomAttributeDefinitions.CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } public GroupsClient Groups { get; } public SegmentsClient Segments { get; } - public CardsClient Cards { get; } + public Square.Customers.Cards.CardsClient Cards { get; } - public CustomAttributesClient CustomAttributes { get; } + public Square.Customers.CustomAttributes.CustomAttributesClient CustomAttributes { get; } /// /// Lists customer profiles associated with a Square account. diff --git a/src/Square/Customers/Groups/GroupsClient.cs b/src/Square/Customers/Groups/GroupsClient.cs index b638e6ad..e40c00d5 100644 --- a/src/Square/Customers/Groups/GroupsClient.cs +++ b/src/Square/Customers/Groups/GroupsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Customers/Groups/Requests/AddGroupsRequest.cs b/src/Square/Customers/Groups/Requests/AddGroupsRequest.cs index 7185787c..17ee64de 100644 --- a/src/Square/Customers/Groups/Requests/AddGroupsRequest.cs +++ b/src/Square/Customers/Groups/Requests/AddGroupsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Groups; +[Serializable] public record AddGroupsRequest { /// diff --git a/src/Square/Customers/Groups/Requests/CreateCustomerGroupRequest.cs b/src/Square/Customers/Groups/Requests/CreateCustomerGroupRequest.cs index bd9716db..b522fb9c 100644 --- a/src/Square/Customers/Groups/Requests/CreateCustomerGroupRequest.cs +++ b/src/Square/Customers/Groups/Requests/CreateCustomerGroupRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.Groups; +[Serializable] public record CreateCustomerGroupRequest { /// diff --git a/src/Square/Customers/Groups/Requests/DeleteGroupsRequest.cs b/src/Square/Customers/Groups/Requests/DeleteGroupsRequest.cs index 6c61f820..741165c1 100644 --- a/src/Square/Customers/Groups/Requests/DeleteGroupsRequest.cs +++ b/src/Square/Customers/Groups/Requests/DeleteGroupsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Groups; +[Serializable] public record DeleteGroupsRequest { /// diff --git a/src/Square/Customers/Groups/Requests/GetGroupsRequest.cs b/src/Square/Customers/Groups/Requests/GetGroupsRequest.cs index 2f988db0..d8a50675 100644 --- a/src/Square/Customers/Groups/Requests/GetGroupsRequest.cs +++ b/src/Square/Customers/Groups/Requests/GetGroupsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Groups; +[Serializable] public record GetGroupsRequest { /// diff --git a/src/Square/Customers/Groups/Requests/ListGroupsRequest.cs b/src/Square/Customers/Groups/Requests/ListGroupsRequest.cs index c610ade3..0adb4fb9 100644 --- a/src/Square/Customers/Groups/Requests/ListGroupsRequest.cs +++ b/src/Square/Customers/Groups/Requests/ListGroupsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Groups; +[Serializable] public record ListGroupsRequest { /// diff --git a/src/Square/Customers/Groups/Requests/RemoveGroupsRequest.cs b/src/Square/Customers/Groups/Requests/RemoveGroupsRequest.cs index 8f927603..1360309f 100644 --- a/src/Square/Customers/Groups/Requests/RemoveGroupsRequest.cs +++ b/src/Square/Customers/Groups/Requests/RemoveGroupsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Groups; +[Serializable] public record RemoveGroupsRequest { /// diff --git a/src/Square/Customers/Groups/Requests/UpdateCustomerGroupRequest.cs b/src/Square/Customers/Groups/Requests/UpdateCustomerGroupRequest.cs index dc8cf8ba..3fbd172f 100644 --- a/src/Square/Customers/Groups/Requests/UpdateCustomerGroupRequest.cs +++ b/src/Square/Customers/Groups/Requests/UpdateCustomerGroupRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers.Groups; +[Serializable] public record UpdateCustomerGroupRequest { /// diff --git a/src/Square/Customers/Requests/BulkCreateCustomersRequest.cs b/src/Square/Customers/Requests/BulkCreateCustomersRequest.cs index 6b6a6a73..3ae26492 100644 --- a/src/Square/Customers/Requests/BulkCreateCustomersRequest.cs +++ b/src/Square/Customers/Requests/BulkCreateCustomersRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers; +[Serializable] public record BulkCreateCustomersRequest { /// diff --git a/src/Square/Customers/Requests/BulkDeleteCustomersRequest.cs b/src/Square/Customers/Requests/BulkDeleteCustomersRequest.cs index 042c03dd..4db148be 100644 --- a/src/Square/Customers/Requests/BulkDeleteCustomersRequest.cs +++ b/src/Square/Customers/Requests/BulkDeleteCustomersRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers; +[Serializable] public record BulkDeleteCustomersRequest { /// diff --git a/src/Square/Customers/Requests/BulkRetrieveCustomersRequest.cs b/src/Square/Customers/Requests/BulkRetrieveCustomersRequest.cs index b16f3e0c..4d777f41 100644 --- a/src/Square/Customers/Requests/BulkRetrieveCustomersRequest.cs +++ b/src/Square/Customers/Requests/BulkRetrieveCustomersRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers; +[Serializable] public record BulkRetrieveCustomersRequest { /// diff --git a/src/Square/Customers/Requests/BulkUpdateCustomersRequest.cs b/src/Square/Customers/Requests/BulkUpdateCustomersRequest.cs index 33dd8117..6fc9b095 100644 --- a/src/Square/Customers/Requests/BulkUpdateCustomersRequest.cs +++ b/src/Square/Customers/Requests/BulkUpdateCustomersRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers; +[Serializable] public record BulkUpdateCustomersRequest { /// diff --git a/src/Square/Customers/Requests/CreateCustomerRequest.cs b/src/Square/Customers/Requests/CreateCustomerRequest.cs index 33cc898f..23f9a672 100644 --- a/src/Square/Customers/Requests/CreateCustomerRequest.cs +++ b/src/Square/Customers/Requests/CreateCustomerRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers; +[Serializable] public record CreateCustomerRequest { /// diff --git a/src/Square/Customers/Requests/DeleteCustomersRequest.cs b/src/Square/Customers/Requests/DeleteCustomersRequest.cs index 9876d153..7fae6ba8 100644 --- a/src/Square/Customers/Requests/DeleteCustomersRequest.cs +++ b/src/Square/Customers/Requests/DeleteCustomersRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers; +[Serializable] public record DeleteCustomersRequest { /// diff --git a/src/Square/Customers/Requests/GetCustomersRequest.cs b/src/Square/Customers/Requests/GetCustomersRequest.cs index c8c2e464..df753f78 100644 --- a/src/Square/Customers/Requests/GetCustomersRequest.cs +++ b/src/Square/Customers/Requests/GetCustomersRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers; +[Serializable] public record GetCustomersRequest { /// diff --git a/src/Square/Customers/Requests/ListCustomersRequest.cs b/src/Square/Customers/Requests/ListCustomersRequest.cs index 7cb7d471..74c883dc 100644 --- a/src/Square/Customers/Requests/ListCustomersRequest.cs +++ b/src/Square/Customers/Requests/ListCustomersRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers; +[Serializable] public record ListCustomersRequest { /// diff --git a/src/Square/Customers/Requests/SearchCustomersRequest.cs b/src/Square/Customers/Requests/SearchCustomersRequest.cs index 5d3b041e..3e077193 100644 --- a/src/Square/Customers/Requests/SearchCustomersRequest.cs +++ b/src/Square/Customers/Requests/SearchCustomersRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers; +[Serializable] public record SearchCustomersRequest { /// diff --git a/src/Square/Customers/Requests/UpdateCustomerRequest.cs b/src/Square/Customers/Requests/UpdateCustomerRequest.cs index 66379efd..5ff0f6f7 100644 --- a/src/Square/Customers/Requests/UpdateCustomerRequest.cs +++ b/src/Square/Customers/Requests/UpdateCustomerRequest.cs @@ -4,6 +4,7 @@ namespace Square.Customers; +[Serializable] public record UpdateCustomerRequest { /// diff --git a/src/Square/Customers/Segments/Requests/GetSegmentsRequest.cs b/src/Square/Customers/Segments/Requests/GetSegmentsRequest.cs index caa13ac4..6e184a29 100644 --- a/src/Square/Customers/Segments/Requests/GetSegmentsRequest.cs +++ b/src/Square/Customers/Segments/Requests/GetSegmentsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Segments; +[Serializable] public record GetSegmentsRequest { /// diff --git a/src/Square/Customers/Segments/Requests/ListSegmentsRequest.cs b/src/Square/Customers/Segments/Requests/ListSegmentsRequest.cs index 40aac4d4..4db71fd1 100644 --- a/src/Square/Customers/Segments/Requests/ListSegmentsRequest.cs +++ b/src/Square/Customers/Segments/Requests/ListSegmentsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Customers.Segments; +[Serializable] public record ListSegmentsRequest { /// diff --git a/src/Square/Customers/Segments/SegmentsClient.cs b/src/Square/Customers/Segments/SegmentsClient.cs index 6630d8fa..2c6d8d1d 100644 --- a/src/Square/Customers/Segments/SegmentsClient.cs +++ b/src/Square/Customers/Segments/SegmentsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Devices/Codes/CodesClient.cs b/src/Square/Devices/Codes/CodesClient.cs index e99c64f7..0dbfb2bb 100644 --- a/src/Square/Devices/Codes/CodesClient.cs +++ b/src/Square/Devices/Codes/CodesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Devices/Codes/Requests/CreateDeviceCodeRequest.cs b/src/Square/Devices/Codes/Requests/CreateDeviceCodeRequest.cs index 54da1d5f..5fc09e28 100644 --- a/src/Square/Devices/Codes/Requests/CreateDeviceCodeRequest.cs +++ b/src/Square/Devices/Codes/Requests/CreateDeviceCodeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Devices.Codes; +[Serializable] public record CreateDeviceCodeRequest { /// diff --git a/src/Square/Devices/Codes/Requests/GetCodesRequest.cs b/src/Square/Devices/Codes/Requests/GetCodesRequest.cs index ca968721..8afabda6 100644 --- a/src/Square/Devices/Codes/Requests/GetCodesRequest.cs +++ b/src/Square/Devices/Codes/Requests/GetCodesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Devices.Codes; +[Serializable] public record GetCodesRequest { /// diff --git a/src/Square/Devices/Codes/Requests/ListCodesRequest.cs b/src/Square/Devices/Codes/Requests/ListCodesRequest.cs index 0b4e0ec6..22319a14 100644 --- a/src/Square/Devices/Codes/Requests/ListCodesRequest.cs +++ b/src/Square/Devices/Codes/Requests/ListCodesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Devices.Codes; +[Serializable] public record ListCodesRequest { /// diff --git a/src/Square/Devices/DevicesClient.cs b/src/Square/Devices/DevicesClient.cs index c7d387b9..3dd7233f 100644 --- a/src/Square/Devices/DevicesClient.cs +++ b/src/Square/Devices/DevicesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.Devices.Codes; diff --git a/src/Square/Devices/Requests/GetDevicesRequest.cs b/src/Square/Devices/Requests/GetDevicesRequest.cs index 215ce6a7..f4b66548 100644 --- a/src/Square/Devices/Requests/GetDevicesRequest.cs +++ b/src/Square/Devices/Requests/GetDevicesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Devices; +[Serializable] public record GetDevicesRequest { /// diff --git a/src/Square/Devices/Requests/ListDevicesRequest.cs b/src/Square/Devices/Requests/ListDevicesRequest.cs index b18211a4..79b7614e 100644 --- a/src/Square/Devices/Requests/ListDevicesRequest.cs +++ b/src/Square/Devices/Requests/ListDevicesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Devices; +[Serializable] public record ListDevicesRequest { /// diff --git a/src/Square/Disputes/DisputesClient.cs b/src/Square/Disputes/DisputesClient.cs index 81286243..70f98b13 100644 --- a/src/Square/Disputes/DisputesClient.cs +++ b/src/Square/Disputes/DisputesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.Disputes.Evidence; diff --git a/src/Square/Disputes/Evidence/EvidenceClient.cs b/src/Square/Disputes/Evidence/EvidenceClient.cs index e633dd0c..9c64eef0 100644 --- a/src/Square/Disputes/Evidence/EvidenceClient.cs +++ b/src/Square/Disputes/Evidence/EvidenceClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Disputes/Evidence/Requests/DeleteEvidenceRequest.cs b/src/Square/Disputes/Evidence/Requests/DeleteEvidenceRequest.cs index 91104f3f..fadebee8 100644 --- a/src/Square/Disputes/Evidence/Requests/DeleteEvidenceRequest.cs +++ b/src/Square/Disputes/Evidence/Requests/DeleteEvidenceRequest.cs @@ -3,6 +3,7 @@ namespace Square.Disputes.Evidence; +[Serializable] public record DeleteEvidenceRequest { /// diff --git a/src/Square/Disputes/Evidence/Requests/GetEvidenceRequest.cs b/src/Square/Disputes/Evidence/Requests/GetEvidenceRequest.cs index 9b268d34..84b387dd 100644 --- a/src/Square/Disputes/Evidence/Requests/GetEvidenceRequest.cs +++ b/src/Square/Disputes/Evidence/Requests/GetEvidenceRequest.cs @@ -3,6 +3,7 @@ namespace Square.Disputes.Evidence; +[Serializable] public record GetEvidenceRequest { /// diff --git a/src/Square/Disputes/Evidence/Requests/ListEvidenceRequest.cs b/src/Square/Disputes/Evidence/Requests/ListEvidenceRequest.cs index 57a0657b..41c3a36a 100644 --- a/src/Square/Disputes/Evidence/Requests/ListEvidenceRequest.cs +++ b/src/Square/Disputes/Evidence/Requests/ListEvidenceRequest.cs @@ -3,6 +3,7 @@ namespace Square.Disputes.Evidence; +[Serializable] public record ListEvidenceRequest { /// diff --git a/src/Square/Disputes/Requests/AcceptDisputesRequest.cs b/src/Square/Disputes/Requests/AcceptDisputesRequest.cs index 67b25cd8..2f56264b 100644 --- a/src/Square/Disputes/Requests/AcceptDisputesRequest.cs +++ b/src/Square/Disputes/Requests/AcceptDisputesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Disputes; +[Serializable] public record AcceptDisputesRequest { /// diff --git a/src/Square/Disputes/Requests/CreateDisputeEvidenceTextRequest.cs b/src/Square/Disputes/Requests/CreateDisputeEvidenceTextRequest.cs index 05ff7522..0697cbba 100644 --- a/src/Square/Disputes/Requests/CreateDisputeEvidenceTextRequest.cs +++ b/src/Square/Disputes/Requests/CreateDisputeEvidenceTextRequest.cs @@ -4,6 +4,7 @@ namespace Square.Disputes; +[Serializable] public record CreateDisputeEvidenceTextRequest { /// diff --git a/src/Square/Disputes/Requests/CreateEvidenceFileDisputesRequest.cs b/src/Square/Disputes/Requests/CreateEvidenceFileDisputesRequest.cs index ae316090..be558466 100644 --- a/src/Square/Disputes/Requests/CreateEvidenceFileDisputesRequest.cs +++ b/src/Square/Disputes/Requests/CreateEvidenceFileDisputesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Disputes; +[Serializable] public record CreateEvidenceFileDisputesRequest { /// diff --git a/src/Square/Disputes/Requests/GetDisputesRequest.cs b/src/Square/Disputes/Requests/GetDisputesRequest.cs index d06597fc..952e4ec8 100644 --- a/src/Square/Disputes/Requests/GetDisputesRequest.cs +++ b/src/Square/Disputes/Requests/GetDisputesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Disputes; +[Serializable] public record GetDisputesRequest { /// diff --git a/src/Square/Disputes/Requests/ListDisputesRequest.cs b/src/Square/Disputes/Requests/ListDisputesRequest.cs index ddb07106..af5f41e5 100644 --- a/src/Square/Disputes/Requests/ListDisputesRequest.cs +++ b/src/Square/Disputes/Requests/ListDisputesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Disputes; +[Serializable] public record ListDisputesRequest { /// diff --git a/src/Square/Disputes/Requests/SubmitEvidenceDisputesRequest.cs b/src/Square/Disputes/Requests/SubmitEvidenceDisputesRequest.cs index d93164ac..3eb79674 100644 --- a/src/Square/Disputes/Requests/SubmitEvidenceDisputesRequest.cs +++ b/src/Square/Disputes/Requests/SubmitEvidenceDisputesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Disputes; +[Serializable] public record SubmitEvidenceDisputesRequest { /// diff --git a/src/Square/Employees/EmployeesClient.cs b/src/Square/Employees/EmployeesClient.cs index d2dcceab..516d1e39 100644 --- a/src/Square/Employees/EmployeesClient.cs +++ b/src/Square/Employees/EmployeesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Employees/Requests/GetEmployeesRequest.cs b/src/Square/Employees/Requests/GetEmployeesRequest.cs index a46ae16b..4d6f2cc2 100644 --- a/src/Square/Employees/Requests/GetEmployeesRequest.cs +++ b/src/Square/Employees/Requests/GetEmployeesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Employees; +[Serializable] public record GetEmployeesRequest { /// diff --git a/src/Square/Employees/Requests/ListEmployeesRequest.cs b/src/Square/Employees/Requests/ListEmployeesRequest.cs index 8faa718e..00be3287 100644 --- a/src/Square/Employees/Requests/ListEmployeesRequest.cs +++ b/src/Square/Employees/Requests/ListEmployeesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Employees; +[Serializable] public record ListEmployeesRequest { [JsonIgnore] diff --git a/src/Square/Events/EventsClient.cs b/src/Square/Events/EventsClient.cs index 401b1180..474ebd37 100644 --- a/src/Square/Events/EventsClient.cs +++ b/src/Square/Events/EventsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -162,7 +163,9 @@ public async Task EnableEventsAsync( /// Lists all event types that you can subscribe to as webhooks or query using the Events API. /// /// - /// await client.Events.ListEventTypesAsync(new ListEventTypesRequest { ApiVersion = "api_version" }); + /// await client.Events.ListEventTypesAsync( + /// new Square.Events.ListEventTypesRequest { ApiVersion = "api_version" } + /// ); /// public async Task ListEventTypesAsync( ListEventTypesRequest request, diff --git a/src/Square/Events/Requests/ListEventTypesRequest.cs b/src/Square/Events/Requests/ListEventTypesRequest.cs index f4789761..d7d835a8 100644 --- a/src/Square/Events/Requests/ListEventTypesRequest.cs +++ b/src/Square/Events/Requests/ListEventTypesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Events; +[Serializable] public record ListEventTypesRequest { /// diff --git a/src/Square/Events/Requests/SearchEventsRequest.cs b/src/Square/Events/Requests/SearchEventsRequest.cs index 75509910..abc274ac 100644 --- a/src/Square/Events/Requests/SearchEventsRequest.cs +++ b/src/Square/Events/Requests/SearchEventsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Events; +[Serializable] public record SearchEventsRequest { /// diff --git a/src/Square/GiftCards/Activities/ActivitiesClient.cs b/src/Square/GiftCards/Activities/ActivitiesClient.cs index e0f3598f..02a1d748 100644 --- a/src/Square/GiftCards/Activities/ActivitiesClient.cs +++ b/src/Square/GiftCards/Activities/ActivitiesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/GiftCards/Activities/Requests/CreateGiftCardActivityRequest.cs b/src/Square/GiftCards/Activities/Requests/CreateGiftCardActivityRequest.cs index 4a167822..724d1dd0 100644 --- a/src/Square/GiftCards/Activities/Requests/CreateGiftCardActivityRequest.cs +++ b/src/Square/GiftCards/Activities/Requests/CreateGiftCardActivityRequest.cs @@ -4,6 +4,7 @@ namespace Square.GiftCards.Activities; +[Serializable] public record CreateGiftCardActivityRequest { /// diff --git a/src/Square/GiftCards/Activities/Requests/ListActivitiesRequest.cs b/src/Square/GiftCards/Activities/Requests/ListActivitiesRequest.cs index dc4f6243..3976b102 100644 --- a/src/Square/GiftCards/Activities/Requests/ListActivitiesRequest.cs +++ b/src/Square/GiftCards/Activities/Requests/ListActivitiesRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards.Activities; +[Serializable] public record ListActivitiesRequest { /// diff --git a/src/Square/GiftCards/GiftCardsClient.cs b/src/Square/GiftCards/GiftCardsClient.cs index c2808b8b..adc54bda 100644 --- a/src/Square/GiftCards/GiftCardsClient.cs +++ b/src/Square/GiftCards/GiftCardsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.GiftCards.Activities; diff --git a/src/Square/GiftCards/Requests/CreateGiftCardRequest.cs b/src/Square/GiftCards/Requests/CreateGiftCardRequest.cs index 8ad237cb..c122da58 100644 --- a/src/Square/GiftCards/Requests/CreateGiftCardRequest.cs +++ b/src/Square/GiftCards/Requests/CreateGiftCardRequest.cs @@ -4,6 +4,7 @@ namespace Square.GiftCards; +[Serializable] public record CreateGiftCardRequest { /// diff --git a/src/Square/GiftCards/Requests/GetGiftCardFromGanRequest.cs b/src/Square/GiftCards/Requests/GetGiftCardFromGanRequest.cs index 28b915df..33ae8294 100644 --- a/src/Square/GiftCards/Requests/GetGiftCardFromGanRequest.cs +++ b/src/Square/GiftCards/Requests/GetGiftCardFromGanRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards; +[Serializable] public record GetGiftCardFromGanRequest { /// diff --git a/src/Square/GiftCards/Requests/GetGiftCardFromNonceRequest.cs b/src/Square/GiftCards/Requests/GetGiftCardFromNonceRequest.cs index b0bc8e60..e4bd8091 100644 --- a/src/Square/GiftCards/Requests/GetGiftCardFromNonceRequest.cs +++ b/src/Square/GiftCards/Requests/GetGiftCardFromNonceRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards; +[Serializable] public record GetGiftCardFromNonceRequest { /// diff --git a/src/Square/GiftCards/Requests/GetGiftCardsRequest.cs b/src/Square/GiftCards/Requests/GetGiftCardsRequest.cs index 0b2ffeed..b80ea34a 100644 --- a/src/Square/GiftCards/Requests/GetGiftCardsRequest.cs +++ b/src/Square/GiftCards/Requests/GetGiftCardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards; +[Serializable] public record GetGiftCardsRequest { /// diff --git a/src/Square/GiftCards/Requests/LinkCustomerToGiftCardRequest.cs b/src/Square/GiftCards/Requests/LinkCustomerToGiftCardRequest.cs index 660f88dd..28ee3dc3 100644 --- a/src/Square/GiftCards/Requests/LinkCustomerToGiftCardRequest.cs +++ b/src/Square/GiftCards/Requests/LinkCustomerToGiftCardRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards; +[Serializable] public record LinkCustomerToGiftCardRequest { /// diff --git a/src/Square/GiftCards/Requests/ListGiftCardsRequest.cs b/src/Square/GiftCards/Requests/ListGiftCardsRequest.cs index c7d0c113..6d64ae2d 100644 --- a/src/Square/GiftCards/Requests/ListGiftCardsRequest.cs +++ b/src/Square/GiftCards/Requests/ListGiftCardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards; +[Serializable] public record ListGiftCardsRequest { /// diff --git a/src/Square/GiftCards/Requests/UnlinkCustomerFromGiftCardRequest.cs b/src/Square/GiftCards/Requests/UnlinkCustomerFromGiftCardRequest.cs index 27820c17..1b244e4f 100644 --- a/src/Square/GiftCards/Requests/UnlinkCustomerFromGiftCardRequest.cs +++ b/src/Square/GiftCards/Requests/UnlinkCustomerFromGiftCardRequest.cs @@ -3,6 +3,7 @@ namespace Square.GiftCards; +[Serializable] public record UnlinkCustomerFromGiftCardRequest { /// diff --git a/src/Square/Inventory/InventoryClient.cs b/src/Square/Inventory/InventoryClient.cs index dee98e10..adbd1d4b 100644 --- a/src/Square/Inventory/InventoryClient.cs +++ b/src/Square/Inventory/InventoryClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Inventory/Requests/ChangesInventoryRequest.cs b/src/Square/Inventory/Requests/ChangesInventoryRequest.cs index 6f5fe502..6c65d697 100644 --- a/src/Square/Inventory/Requests/ChangesInventoryRequest.cs +++ b/src/Square/Inventory/Requests/ChangesInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record ChangesInventoryRequest { /// diff --git a/src/Square/Inventory/Requests/DeprecatedGetAdjustmentInventoryRequest.cs b/src/Square/Inventory/Requests/DeprecatedGetAdjustmentInventoryRequest.cs index 70f1d1d0..9af30313 100644 --- a/src/Square/Inventory/Requests/DeprecatedGetAdjustmentInventoryRequest.cs +++ b/src/Square/Inventory/Requests/DeprecatedGetAdjustmentInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record DeprecatedGetAdjustmentInventoryRequest { /// diff --git a/src/Square/Inventory/Requests/DeprecatedGetPhysicalCountInventoryRequest.cs b/src/Square/Inventory/Requests/DeprecatedGetPhysicalCountInventoryRequest.cs index 2f44777a..91dbca0e 100644 --- a/src/Square/Inventory/Requests/DeprecatedGetPhysicalCountInventoryRequest.cs +++ b/src/Square/Inventory/Requests/DeprecatedGetPhysicalCountInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record DeprecatedGetPhysicalCountInventoryRequest { /// diff --git a/src/Square/Inventory/Requests/GetAdjustmentInventoryRequest.cs b/src/Square/Inventory/Requests/GetAdjustmentInventoryRequest.cs index 2d05272c..85a6c76d 100644 --- a/src/Square/Inventory/Requests/GetAdjustmentInventoryRequest.cs +++ b/src/Square/Inventory/Requests/GetAdjustmentInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record GetAdjustmentInventoryRequest { /// diff --git a/src/Square/Inventory/Requests/GetInventoryRequest.cs b/src/Square/Inventory/Requests/GetInventoryRequest.cs index 598c95d5..b1e8d930 100644 --- a/src/Square/Inventory/Requests/GetInventoryRequest.cs +++ b/src/Square/Inventory/Requests/GetInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record GetInventoryRequest { /// diff --git a/src/Square/Inventory/Requests/GetPhysicalCountInventoryRequest.cs b/src/Square/Inventory/Requests/GetPhysicalCountInventoryRequest.cs index 9e8d8d49..9754a38e 100644 --- a/src/Square/Inventory/Requests/GetPhysicalCountInventoryRequest.cs +++ b/src/Square/Inventory/Requests/GetPhysicalCountInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record GetPhysicalCountInventoryRequest { /// diff --git a/src/Square/Inventory/Requests/GetTransferInventoryRequest.cs b/src/Square/Inventory/Requests/GetTransferInventoryRequest.cs index bb612063..e7c3ef15 100644 --- a/src/Square/Inventory/Requests/GetTransferInventoryRequest.cs +++ b/src/Square/Inventory/Requests/GetTransferInventoryRequest.cs @@ -3,6 +3,7 @@ namespace Square.Inventory; +[Serializable] public record GetTransferInventoryRequest { /// diff --git a/src/Square/Invoices/InvoicesClient.cs b/src/Square/Invoices/InvoicesClient.cs index 84e58647..40260c3d 100644 --- a/src/Square/Invoices/InvoicesClient.cs +++ b/src/Square/Invoices/InvoicesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Invoices/Requests/CancelInvoiceRequest.cs b/src/Square/Invoices/Requests/CancelInvoiceRequest.cs index 82905586..9b5b4721 100644 --- a/src/Square/Invoices/Requests/CancelInvoiceRequest.cs +++ b/src/Square/Invoices/Requests/CancelInvoiceRequest.cs @@ -3,6 +3,7 @@ namespace Square.Invoices; +[Serializable] public record CancelInvoiceRequest { /// diff --git a/src/Square/Invoices/Requests/CreateInvoiceAttachmentRequest.cs b/src/Square/Invoices/Requests/CreateInvoiceAttachmentRequest.cs index c833f843..0bc75695 100644 --- a/src/Square/Invoices/Requests/CreateInvoiceAttachmentRequest.cs +++ b/src/Square/Invoices/Requests/CreateInvoiceAttachmentRequest.cs @@ -4,6 +4,7 @@ namespace Square.Invoices; +[Serializable] public record CreateInvoiceAttachmentRequest { /// diff --git a/src/Square/Invoices/Requests/CreateInvoiceRequest.cs b/src/Square/Invoices/Requests/CreateInvoiceRequest.cs index 08fa0164..97028456 100644 --- a/src/Square/Invoices/Requests/CreateInvoiceRequest.cs +++ b/src/Square/Invoices/Requests/CreateInvoiceRequest.cs @@ -4,6 +4,7 @@ namespace Square.Invoices; +[Serializable] public record CreateInvoiceRequest { /// diff --git a/src/Square/Invoices/Requests/DeleteInvoiceAttachmentRequest.cs b/src/Square/Invoices/Requests/DeleteInvoiceAttachmentRequest.cs index 5398ed65..7897eafb 100644 --- a/src/Square/Invoices/Requests/DeleteInvoiceAttachmentRequest.cs +++ b/src/Square/Invoices/Requests/DeleteInvoiceAttachmentRequest.cs @@ -3,6 +3,7 @@ namespace Square.Invoices; +[Serializable] public record DeleteInvoiceAttachmentRequest { /// diff --git a/src/Square/Invoices/Requests/DeleteInvoicesRequest.cs b/src/Square/Invoices/Requests/DeleteInvoicesRequest.cs index b50caf13..b247966d 100644 --- a/src/Square/Invoices/Requests/DeleteInvoicesRequest.cs +++ b/src/Square/Invoices/Requests/DeleteInvoicesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Invoices; +[Serializable] public record DeleteInvoicesRequest { /// diff --git a/src/Square/Invoices/Requests/GetInvoicesRequest.cs b/src/Square/Invoices/Requests/GetInvoicesRequest.cs index 000329e2..c22fb797 100644 --- a/src/Square/Invoices/Requests/GetInvoicesRequest.cs +++ b/src/Square/Invoices/Requests/GetInvoicesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Invoices; +[Serializable] public record GetInvoicesRequest { /// diff --git a/src/Square/Invoices/Requests/ListInvoicesRequest.cs b/src/Square/Invoices/Requests/ListInvoicesRequest.cs index 70ac22b3..d554bc62 100644 --- a/src/Square/Invoices/Requests/ListInvoicesRequest.cs +++ b/src/Square/Invoices/Requests/ListInvoicesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Invoices; +[Serializable] public record ListInvoicesRequest { /// diff --git a/src/Square/Invoices/Requests/PublishInvoiceRequest.cs b/src/Square/Invoices/Requests/PublishInvoiceRequest.cs index 371dc30a..2f7e7137 100644 --- a/src/Square/Invoices/Requests/PublishInvoiceRequest.cs +++ b/src/Square/Invoices/Requests/PublishInvoiceRequest.cs @@ -3,6 +3,7 @@ namespace Square.Invoices; +[Serializable] public record PublishInvoiceRequest { /// diff --git a/src/Square/Invoices/Requests/SearchInvoicesRequest.cs b/src/Square/Invoices/Requests/SearchInvoicesRequest.cs index 0649c2ef..ba321cce 100644 --- a/src/Square/Invoices/Requests/SearchInvoicesRequest.cs +++ b/src/Square/Invoices/Requests/SearchInvoicesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Invoices; +[Serializable] public record SearchInvoicesRequest { /// diff --git a/src/Square/Invoices/Requests/UpdateInvoiceRequest.cs b/src/Square/Invoices/Requests/UpdateInvoiceRequest.cs index 187d15d7..6a656184 100644 --- a/src/Square/Invoices/Requests/UpdateInvoiceRequest.cs +++ b/src/Square/Invoices/Requests/UpdateInvoiceRequest.cs @@ -4,6 +4,7 @@ namespace Square.Invoices; +[Serializable] public record UpdateInvoiceRequest { /// diff --git a/src/Square/Labor/BreakTypes/BreakTypesClient.cs b/src/Square/Labor/BreakTypes/BreakTypesClient.cs index 89c04721..7baa450b 100644 --- a/src/Square/Labor/BreakTypes/BreakTypesClient.cs +++ b/src/Square/Labor/BreakTypes/BreakTypesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Labor/BreakTypes/Requests/CreateBreakTypeRequest.cs b/src/Square/Labor/BreakTypes/Requests/CreateBreakTypeRequest.cs index 7360c085..078e02b4 100644 --- a/src/Square/Labor/BreakTypes/Requests/CreateBreakTypeRequest.cs +++ b/src/Square/Labor/BreakTypes/Requests/CreateBreakTypeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor.BreakTypes; +[Serializable] public record CreateBreakTypeRequest { /// diff --git a/src/Square/Labor/BreakTypes/Requests/DeleteBreakTypesRequest.cs b/src/Square/Labor/BreakTypes/Requests/DeleteBreakTypesRequest.cs index e236c69b..5075be50 100644 --- a/src/Square/Labor/BreakTypes/Requests/DeleteBreakTypesRequest.cs +++ b/src/Square/Labor/BreakTypes/Requests/DeleteBreakTypesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.BreakTypes; +[Serializable] public record DeleteBreakTypesRequest { /// diff --git a/src/Square/Labor/BreakTypes/Requests/GetBreakTypesRequest.cs b/src/Square/Labor/BreakTypes/Requests/GetBreakTypesRequest.cs index 840b9aee..0fb70b69 100644 --- a/src/Square/Labor/BreakTypes/Requests/GetBreakTypesRequest.cs +++ b/src/Square/Labor/BreakTypes/Requests/GetBreakTypesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.BreakTypes; +[Serializable] public record GetBreakTypesRequest { /// diff --git a/src/Square/Labor/BreakTypes/Requests/ListBreakTypesRequest.cs b/src/Square/Labor/BreakTypes/Requests/ListBreakTypesRequest.cs index ca87cbed..37841005 100644 --- a/src/Square/Labor/BreakTypes/Requests/ListBreakTypesRequest.cs +++ b/src/Square/Labor/BreakTypes/Requests/ListBreakTypesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.BreakTypes; +[Serializable] public record ListBreakTypesRequest { /// diff --git a/src/Square/Labor/BreakTypes/Requests/UpdateBreakTypeRequest.cs b/src/Square/Labor/BreakTypes/Requests/UpdateBreakTypeRequest.cs index 046c4fc8..cc644c15 100644 --- a/src/Square/Labor/BreakTypes/Requests/UpdateBreakTypeRequest.cs +++ b/src/Square/Labor/BreakTypes/Requests/UpdateBreakTypeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor.BreakTypes; +[Serializable] public record UpdateBreakTypeRequest { /// diff --git a/src/Square/Labor/EmployeeWages/EmployeeWagesClient.cs b/src/Square/Labor/EmployeeWages/EmployeeWagesClient.cs index b3b3e691..754772e2 100644 --- a/src/Square/Labor/EmployeeWages/EmployeeWagesClient.cs +++ b/src/Square/Labor/EmployeeWages/EmployeeWagesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Labor/EmployeeWages/Requests/GetEmployeeWagesRequest.cs b/src/Square/Labor/EmployeeWages/Requests/GetEmployeeWagesRequest.cs index b2e34c3d..9db169da 100644 --- a/src/Square/Labor/EmployeeWages/Requests/GetEmployeeWagesRequest.cs +++ b/src/Square/Labor/EmployeeWages/Requests/GetEmployeeWagesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.EmployeeWages; +[Serializable] public record GetEmployeeWagesRequest { /// diff --git a/src/Square/Labor/EmployeeWages/Requests/ListEmployeeWagesRequest.cs b/src/Square/Labor/EmployeeWages/Requests/ListEmployeeWagesRequest.cs index 6bcb7988..3e89d810 100644 --- a/src/Square/Labor/EmployeeWages/Requests/ListEmployeeWagesRequest.cs +++ b/src/Square/Labor/EmployeeWages/Requests/ListEmployeeWagesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.EmployeeWages; +[Serializable] public record ListEmployeeWagesRequest { /// diff --git a/src/Square/Labor/LaborClient.cs b/src/Square/Labor/LaborClient.cs index 0aa45975..74fa98be 100644 --- a/src/Square/Labor/LaborClient.cs +++ b/src/Square/Labor/LaborClient.cs @@ -1,11 +1,11 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.Labor.BreakTypes; using Square.Labor.EmployeeWages; -using Square.Labor.Shifts; using Square.Labor.TeamMemberWages; using Square.Labor.WorkweekConfigs; @@ -20,7 +20,7 @@ internal LaborClient(RawClient client) _client = client; BreakTypes = new BreakTypesClient(_client); EmployeeWages = new EmployeeWagesClient(_client); - Shifts = new ShiftsClient(_client); + Shifts = new Square.Labor.Shifts.ShiftsClient(_client); TeamMemberWages = new TeamMemberWagesClient(_client); WorkweekConfigs = new WorkweekConfigsClient(_client); } @@ -29,7 +29,7 @@ internal LaborClient(RawClient client) public EmployeeWagesClient EmployeeWages { get; } - public ShiftsClient Shifts { get; } + public Square.Labor.Shifts.ShiftsClient Shifts { get; } public TeamMemberWagesClient TeamMemberWages { get; } diff --git a/src/Square/Labor/Requests/BulkPublishScheduledShiftsRequest.cs b/src/Square/Labor/Requests/BulkPublishScheduledShiftsRequest.cs index 1d590549..d3026b2a 100644 --- a/src/Square/Labor/Requests/BulkPublishScheduledShiftsRequest.cs +++ b/src/Square/Labor/Requests/BulkPublishScheduledShiftsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record BulkPublishScheduledShiftsRequest { /// diff --git a/src/Square/Labor/Requests/CreateScheduledShiftRequest.cs b/src/Square/Labor/Requests/CreateScheduledShiftRequest.cs index f9b117e0..ea540242 100644 --- a/src/Square/Labor/Requests/CreateScheduledShiftRequest.cs +++ b/src/Square/Labor/Requests/CreateScheduledShiftRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record CreateScheduledShiftRequest { /// diff --git a/src/Square/Labor/Requests/CreateTimecardRequest.cs b/src/Square/Labor/Requests/CreateTimecardRequest.cs index 893edb56..2a4cd714 100644 --- a/src/Square/Labor/Requests/CreateTimecardRequest.cs +++ b/src/Square/Labor/Requests/CreateTimecardRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record CreateTimecardRequest { /// diff --git a/src/Square/Labor/Requests/DeleteTimecardRequest.cs b/src/Square/Labor/Requests/DeleteTimecardRequest.cs index b00b0efe..3831543d 100644 --- a/src/Square/Labor/Requests/DeleteTimecardRequest.cs +++ b/src/Square/Labor/Requests/DeleteTimecardRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor; +[Serializable] public record DeleteTimecardRequest { /// diff --git a/src/Square/Labor/Requests/PublishScheduledShiftRequest.cs b/src/Square/Labor/Requests/PublishScheduledShiftRequest.cs index 5eea5ac1..da54b4d4 100644 --- a/src/Square/Labor/Requests/PublishScheduledShiftRequest.cs +++ b/src/Square/Labor/Requests/PublishScheduledShiftRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record PublishScheduledShiftRequest { /// diff --git a/src/Square/Labor/Requests/RetrieveScheduledShiftRequest.cs b/src/Square/Labor/Requests/RetrieveScheduledShiftRequest.cs index 258c4fa8..942d6e30 100644 --- a/src/Square/Labor/Requests/RetrieveScheduledShiftRequest.cs +++ b/src/Square/Labor/Requests/RetrieveScheduledShiftRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor; +[Serializable] public record RetrieveScheduledShiftRequest { /// diff --git a/src/Square/Labor/Requests/RetrieveTimecardRequest.cs b/src/Square/Labor/Requests/RetrieveTimecardRequest.cs index aad5618a..a039a00f 100644 --- a/src/Square/Labor/Requests/RetrieveTimecardRequest.cs +++ b/src/Square/Labor/Requests/RetrieveTimecardRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor; +[Serializable] public record RetrieveTimecardRequest { /// diff --git a/src/Square/Labor/Requests/SearchScheduledShiftsRequest.cs b/src/Square/Labor/Requests/SearchScheduledShiftsRequest.cs index 9b165649..b21893aa 100644 --- a/src/Square/Labor/Requests/SearchScheduledShiftsRequest.cs +++ b/src/Square/Labor/Requests/SearchScheduledShiftsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record SearchScheduledShiftsRequest { /// diff --git a/src/Square/Labor/Requests/SearchTimecardsRequest.cs b/src/Square/Labor/Requests/SearchTimecardsRequest.cs index 97efc1ee..3e6d1c0a 100644 --- a/src/Square/Labor/Requests/SearchTimecardsRequest.cs +++ b/src/Square/Labor/Requests/SearchTimecardsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record SearchTimecardsRequest { /// diff --git a/src/Square/Labor/Requests/UpdateScheduledShiftRequest.cs b/src/Square/Labor/Requests/UpdateScheduledShiftRequest.cs index d2782538..a89f27ef 100644 --- a/src/Square/Labor/Requests/UpdateScheduledShiftRequest.cs +++ b/src/Square/Labor/Requests/UpdateScheduledShiftRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record UpdateScheduledShiftRequest { /// diff --git a/src/Square/Labor/Requests/UpdateTimecardRequest.cs b/src/Square/Labor/Requests/UpdateTimecardRequest.cs index 51ba3f21..62910470 100644 --- a/src/Square/Labor/Requests/UpdateTimecardRequest.cs +++ b/src/Square/Labor/Requests/UpdateTimecardRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor; +[Serializable] public record UpdateTimecardRequest { /// diff --git a/src/Square/Labor/Shifts/Requests/CreateShiftRequest.cs b/src/Square/Labor/Shifts/Requests/CreateShiftRequest.cs index 233ff704..aeaccc55 100644 --- a/src/Square/Labor/Shifts/Requests/CreateShiftRequest.cs +++ b/src/Square/Labor/Shifts/Requests/CreateShiftRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor.Shifts; +[Serializable] public record CreateShiftRequest { /// diff --git a/src/Square/Labor/Shifts/Requests/DeleteShiftsRequest.cs b/src/Square/Labor/Shifts/Requests/DeleteShiftsRequest.cs index 0a7fe0a9..16a6ce28 100644 --- a/src/Square/Labor/Shifts/Requests/DeleteShiftsRequest.cs +++ b/src/Square/Labor/Shifts/Requests/DeleteShiftsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.Shifts; +[Serializable] public record DeleteShiftsRequest { /// diff --git a/src/Square/Labor/Shifts/Requests/GetShiftsRequest.cs b/src/Square/Labor/Shifts/Requests/GetShiftsRequest.cs index 3176b343..5fb3bc4c 100644 --- a/src/Square/Labor/Shifts/Requests/GetShiftsRequest.cs +++ b/src/Square/Labor/Shifts/Requests/GetShiftsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.Shifts; +[Serializable] public record GetShiftsRequest { /// diff --git a/src/Square/Labor/Shifts/Requests/SearchShiftsRequest.cs b/src/Square/Labor/Shifts/Requests/SearchShiftsRequest.cs index 274106e1..7588f0ed 100644 --- a/src/Square/Labor/Shifts/Requests/SearchShiftsRequest.cs +++ b/src/Square/Labor/Shifts/Requests/SearchShiftsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor.Shifts; +[Serializable] public record SearchShiftsRequest { /// diff --git a/src/Square/Labor/Shifts/Requests/UpdateShiftRequest.cs b/src/Square/Labor/Shifts/Requests/UpdateShiftRequest.cs index 05f3ae27..380b9f28 100644 --- a/src/Square/Labor/Shifts/Requests/UpdateShiftRequest.cs +++ b/src/Square/Labor/Shifts/Requests/UpdateShiftRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor.Shifts; +[Serializable] public record UpdateShiftRequest { /// diff --git a/src/Square/Labor/Shifts/ShiftsClient.cs b/src/Square/Labor/Shifts/ShiftsClient.cs index b2bd9544..0f43ea18 100644 --- a/src/Square/Labor/Shifts/ShiftsClient.cs +++ b/src/Square/Labor/Shifts/ShiftsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -195,7 +196,7 @@ public async Task SearchAsync( /// Returns a single `Shift` specified by `id`. /// /// - /// await client.Labor.Shifts.GetAsync(new GetShiftsRequest { Id = "id" }); + /// await client.Labor.Shifts.GetAsync(new Square.Labor.Shifts.GetShiftsRequest { Id = "id" }); /// public async Task GetAsync( GetShiftsRequest request, diff --git a/src/Square/Labor/TeamMemberWages/Requests/GetTeamMemberWagesRequest.cs b/src/Square/Labor/TeamMemberWages/Requests/GetTeamMemberWagesRequest.cs index fa595efe..f5e32586 100644 --- a/src/Square/Labor/TeamMemberWages/Requests/GetTeamMemberWagesRequest.cs +++ b/src/Square/Labor/TeamMemberWages/Requests/GetTeamMemberWagesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.TeamMemberWages; +[Serializable] public record GetTeamMemberWagesRequest { /// diff --git a/src/Square/Labor/TeamMemberWages/Requests/ListTeamMemberWagesRequest.cs b/src/Square/Labor/TeamMemberWages/Requests/ListTeamMemberWagesRequest.cs index f00424e6..00369141 100644 --- a/src/Square/Labor/TeamMemberWages/Requests/ListTeamMemberWagesRequest.cs +++ b/src/Square/Labor/TeamMemberWages/Requests/ListTeamMemberWagesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.TeamMemberWages; +[Serializable] public record ListTeamMemberWagesRequest { /// diff --git a/src/Square/Labor/TeamMemberWages/TeamMemberWagesClient.cs b/src/Square/Labor/TeamMemberWages/TeamMemberWagesClient.cs index e28075c0..5d218fe9 100644 --- a/src/Square/Labor/TeamMemberWages/TeamMemberWagesClient.cs +++ b/src/Square/Labor/TeamMemberWages/TeamMemberWagesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Labor/WorkweekConfigs/Requests/ListWorkweekConfigsRequest.cs b/src/Square/Labor/WorkweekConfigs/Requests/ListWorkweekConfigsRequest.cs index aa759f2d..90d9ad85 100644 --- a/src/Square/Labor/WorkweekConfigs/Requests/ListWorkweekConfigsRequest.cs +++ b/src/Square/Labor/WorkweekConfigs/Requests/ListWorkweekConfigsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Labor.WorkweekConfigs; +[Serializable] public record ListWorkweekConfigsRequest { /// diff --git a/src/Square/Labor/WorkweekConfigs/Requests/UpdateWorkweekConfigRequest.cs b/src/Square/Labor/WorkweekConfigs/Requests/UpdateWorkweekConfigRequest.cs index 9cbec76d..9d784759 100644 --- a/src/Square/Labor/WorkweekConfigs/Requests/UpdateWorkweekConfigRequest.cs +++ b/src/Square/Labor/WorkweekConfigs/Requests/UpdateWorkweekConfigRequest.cs @@ -4,6 +4,7 @@ namespace Square.Labor.WorkweekConfigs; +[Serializable] public record UpdateWorkweekConfigRequest { /// diff --git a/src/Square/Labor/WorkweekConfigs/WorkweekConfigsClient.cs b/src/Square/Labor/WorkweekConfigs/WorkweekConfigsClient.cs index 1b7520a0..8739aeda 100644 --- a/src/Square/Labor/WorkweekConfigs/WorkweekConfigsClient.cs +++ b/src/Square/Labor/WorkweekConfigs/WorkweekConfigsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Locations/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs b/src/Square/Locations/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs index a18d439a..e0837e07 100644 --- a/src/Square/Locations/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs +++ b/src/Square/Locations/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -86,7 +87,7 @@ private async Task ListInternalA /// /// /// await client.Locations.CustomAttributeDefinitions.ListAsync( - /// new ListCustomAttributeDefinitionsRequest + /// new Square.Locations.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest /// { /// VisibilityFilter = VisibilityFilter.All, /// Limit = 1, @@ -143,7 +144,7 @@ public async Task> ListAsync( /// CustomAttributeDefinition = new CustomAttributeDefinition /// { /// Key = "bestseller", - /// Schema = new Dictionary<string, object>() + /// Schema = new Dictionary<string, object?>() /// { /// { /// "$ref", @@ -209,7 +210,11 @@ public async Task CreateAsync( /// /// /// await client.Locations.CustomAttributeDefinitions.GetAsync( - /// new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + /// new Square.Locations.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// Version = 1, + /// } /// ); /// public async Task GetAsync( @@ -339,7 +344,10 @@ public async Task UpdateAsync( /// /// /// await client.Locations.CustomAttributeDefinitions.DeleteAsync( - /// new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + /// new Square.Locations.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Locations/CustomAttributeDefinitions/Requests/CreateLocationCustomAttributeDefinitionRequest.cs b/src/Square/Locations/CustomAttributeDefinitions/Requests/CreateLocationCustomAttributeDefinitionRequest.cs index f1774a0f..b6333215 100644 --- a/src/Square/Locations/CustomAttributeDefinitions/Requests/CreateLocationCustomAttributeDefinitionRequest.cs +++ b/src/Square/Locations/CustomAttributeDefinitions/Requests/CreateLocationCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributeDefinitions; +[Serializable] public record CreateLocationCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Locations/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs b/src/Square/Locations/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs index b0cff1b7..b614a377 100644 --- a/src/Square/Locations/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Locations/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.CustomAttributeDefinitions; +[Serializable] public record DeleteCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Locations/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs b/src/Square/Locations/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs index a79ebed5..5b3d961f 100644 --- a/src/Square/Locations/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Locations/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.CustomAttributeDefinitions; +[Serializable] public record GetCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Locations/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs b/src/Square/Locations/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs index d2ea7167..2bd4928d 100644 --- a/src/Square/Locations/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Locations/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributeDefinitions; +[Serializable] public record ListCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Locations/CustomAttributeDefinitions/Requests/UpdateLocationCustomAttributeDefinitionRequest.cs b/src/Square/Locations/CustomAttributeDefinitions/Requests/UpdateLocationCustomAttributeDefinitionRequest.cs index b005b62a..b100562e 100644 --- a/src/Square/Locations/CustomAttributeDefinitions/Requests/UpdateLocationCustomAttributeDefinitionRequest.cs +++ b/src/Square/Locations/CustomAttributeDefinitions/Requests/UpdateLocationCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributeDefinitions; +[Serializable] public record UpdateLocationCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Locations/CustomAttributes/CustomAttributesClient.cs b/src/Square/Locations/CustomAttributes/CustomAttributesClient.cs index 7e9f232f..5c887fda 100644 --- a/src/Square/Locations/CustomAttributes/CustomAttributesClient.cs +++ b/src/Square/Locations/CustomAttributes/CustomAttributesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -285,7 +286,7 @@ public async Task BatchUpsertAsync( /// /// /// await client.Locations.CustomAttributes.ListAsync( - /// new ListCustomAttributesRequest + /// new Square.Locations.CustomAttributes.ListCustomAttributesRequest /// { /// LocationId = "location_id", /// VisibilityFilter = VisibilityFilter.All, @@ -337,7 +338,7 @@ public async Task> ListAsync( /// /// /// await client.Locations.CustomAttributes.GetAsync( - /// new GetCustomAttributesRequest + /// new Square.Locations.CustomAttributes.GetCustomAttributesRequest /// { /// LocationId = "location_id", /// Key = "key", @@ -475,7 +476,11 @@ public async Task UpsertAsync( /// /// /// await client.Locations.CustomAttributes.DeleteAsync( - /// new DeleteCustomAttributesRequest { LocationId = "location_id", Key = "key" } + /// new Square.Locations.CustomAttributes.DeleteCustomAttributesRequest + /// { + /// LocationId = "location_id", + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Locations/CustomAttributes/Requests/BulkDeleteLocationCustomAttributesRequest.cs b/src/Square/Locations/CustomAttributes/Requests/BulkDeleteLocationCustomAttributesRequest.cs index 5840ff32..cc16fad7 100644 --- a/src/Square/Locations/CustomAttributes/Requests/BulkDeleteLocationCustomAttributesRequest.cs +++ b/src/Square/Locations/CustomAttributes/Requests/BulkDeleteLocationCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributes; +[Serializable] public record BulkDeleteLocationCustomAttributesRequest { /// diff --git a/src/Square/Locations/CustomAttributes/Requests/BulkUpsertLocationCustomAttributesRequest.cs b/src/Square/Locations/CustomAttributes/Requests/BulkUpsertLocationCustomAttributesRequest.cs index 8f831c59..693c4e9e 100644 --- a/src/Square/Locations/CustomAttributes/Requests/BulkUpsertLocationCustomAttributesRequest.cs +++ b/src/Square/Locations/CustomAttributes/Requests/BulkUpsertLocationCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributes; +[Serializable] public record BulkUpsertLocationCustomAttributesRequest { /// diff --git a/src/Square/Locations/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs b/src/Square/Locations/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs index 24fd53f7..33c5ae03 100644 --- a/src/Square/Locations/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs +++ b/src/Square/Locations/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.CustomAttributes; +[Serializable] public record DeleteCustomAttributesRequest { /// diff --git a/src/Square/Locations/CustomAttributes/Requests/GetCustomAttributesRequest.cs b/src/Square/Locations/CustomAttributes/Requests/GetCustomAttributesRequest.cs index 902f5c8c..5706eec8 100644 --- a/src/Square/Locations/CustomAttributes/Requests/GetCustomAttributesRequest.cs +++ b/src/Square/Locations/CustomAttributes/Requests/GetCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.CustomAttributes; +[Serializable] public record GetCustomAttributesRequest { /// diff --git a/src/Square/Locations/CustomAttributes/Requests/ListCustomAttributesRequest.cs b/src/Square/Locations/CustomAttributes/Requests/ListCustomAttributesRequest.cs index 0ac51843..7586d835 100644 --- a/src/Square/Locations/CustomAttributes/Requests/ListCustomAttributesRequest.cs +++ b/src/Square/Locations/CustomAttributes/Requests/ListCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributes; +[Serializable] public record ListCustomAttributesRequest { /// diff --git a/src/Square/Locations/CustomAttributes/Requests/UpsertLocationCustomAttributeRequest.cs b/src/Square/Locations/CustomAttributes/Requests/UpsertLocationCustomAttributeRequest.cs index 752a2a1d..67e0b94b 100644 --- a/src/Square/Locations/CustomAttributes/Requests/UpsertLocationCustomAttributeRequest.cs +++ b/src/Square/Locations/CustomAttributes/Requests/UpsertLocationCustomAttributeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.CustomAttributes; +[Serializable] public record UpsertLocationCustomAttributeRequest { /// diff --git a/src/Square/Locations/LocationsClient.cs b/src/Square/Locations/LocationsClient.cs index 4a1026c2..8516c4d7 100644 --- a/src/Square/Locations/LocationsClient.cs +++ b/src/Square/Locations/LocationsClient.cs @@ -1,10 +1,9 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; -using Square.Locations.CustomAttributeDefinitions; -using Square.Locations.CustomAttributes; using Square.Locations.Transactions; namespace Square.Locations; @@ -16,14 +15,17 @@ public partial class LocationsClient internal LocationsClient(RawClient client) { _client = client; - CustomAttributeDefinitions = new CustomAttributeDefinitionsClient(_client); - CustomAttributes = new CustomAttributesClient(_client); + CustomAttributeDefinitions = + new Square.Locations.CustomAttributeDefinitions.CustomAttributeDefinitionsClient( + _client + ); + CustomAttributes = new Square.Locations.CustomAttributes.CustomAttributesClient(_client); Transactions = new TransactionsClient(_client); } - public CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } + public Square.Locations.CustomAttributeDefinitions.CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } - public CustomAttributesClient CustomAttributes { get; } + public Square.Locations.CustomAttributes.CustomAttributesClient CustomAttributes { get; } public TransactionsClient Transactions { get; } @@ -212,19 +214,19 @@ public async Task GetAsync( /// { /// new BusinessHoursPeriod /// { - /// DayOfWeek = DayOfWeek.Fri, + /// DayOfWeek = Square.DayOfWeek.Fri, /// StartLocalTime = "07:00", /// EndLocalTime = "18:00", /// }, /// new BusinessHoursPeriod /// { - /// DayOfWeek = DayOfWeek.Sat, + /// DayOfWeek = Square.DayOfWeek.Sat, /// StartLocalTime = "07:00", /// EndLocalTime = "18:00", /// }, /// new BusinessHoursPeriod /// { - /// DayOfWeek = DayOfWeek.Sun, + /// DayOfWeek = Square.DayOfWeek.Sun, /// StartLocalTime = "09:00", /// EndLocalTime = "15:00", /// }, diff --git a/src/Square/Locations/Requests/CreateCheckoutRequest.cs b/src/Square/Locations/Requests/CreateCheckoutRequest.cs index 46573c81..438836fd 100644 --- a/src/Square/Locations/Requests/CreateCheckoutRequest.cs +++ b/src/Square/Locations/Requests/CreateCheckoutRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations; +[Serializable] public record CreateCheckoutRequest { /// diff --git a/src/Square/Locations/Requests/CreateLocationRequest.cs b/src/Square/Locations/Requests/CreateLocationRequest.cs index 47177f02..ff540e30 100644 --- a/src/Square/Locations/Requests/CreateLocationRequest.cs +++ b/src/Square/Locations/Requests/CreateLocationRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations; +[Serializable] public record CreateLocationRequest { /// diff --git a/src/Square/Locations/Requests/GetLocationsRequest.cs b/src/Square/Locations/Requests/GetLocationsRequest.cs index 9a4b8d05..26da041b 100644 --- a/src/Square/Locations/Requests/GetLocationsRequest.cs +++ b/src/Square/Locations/Requests/GetLocationsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations; +[Serializable] public record GetLocationsRequest { /// diff --git a/src/Square/Locations/Requests/UpdateLocationRequest.cs b/src/Square/Locations/Requests/UpdateLocationRequest.cs index c6febb04..70cad1f7 100644 --- a/src/Square/Locations/Requests/UpdateLocationRequest.cs +++ b/src/Square/Locations/Requests/UpdateLocationRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations; +[Serializable] public record UpdateLocationRequest { /// diff --git a/src/Square/Locations/Transactions/Requests/CaptureTransactionsRequest.cs b/src/Square/Locations/Transactions/Requests/CaptureTransactionsRequest.cs index ef52e72e..471202d4 100644 --- a/src/Square/Locations/Transactions/Requests/CaptureTransactionsRequest.cs +++ b/src/Square/Locations/Transactions/Requests/CaptureTransactionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.Transactions; +[Serializable] public record CaptureTransactionsRequest { [JsonIgnore] diff --git a/src/Square/Locations/Transactions/Requests/GetTransactionsRequest.cs b/src/Square/Locations/Transactions/Requests/GetTransactionsRequest.cs index 5165d517..cd645262 100644 --- a/src/Square/Locations/Transactions/Requests/GetTransactionsRequest.cs +++ b/src/Square/Locations/Transactions/Requests/GetTransactionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.Transactions; +[Serializable] public record GetTransactionsRequest { /// diff --git a/src/Square/Locations/Transactions/Requests/ListTransactionsRequest.cs b/src/Square/Locations/Transactions/Requests/ListTransactionsRequest.cs index 5799708b..e734b8c6 100644 --- a/src/Square/Locations/Transactions/Requests/ListTransactionsRequest.cs +++ b/src/Square/Locations/Transactions/Requests/ListTransactionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Locations.Transactions; +[Serializable] public record ListTransactionsRequest { /// diff --git a/src/Square/Locations/Transactions/Requests/VoidTransactionsRequest.cs b/src/Square/Locations/Transactions/Requests/VoidTransactionsRequest.cs index 18024a69..d22a0a57 100644 --- a/src/Square/Locations/Transactions/Requests/VoidTransactionsRequest.cs +++ b/src/Square/Locations/Transactions/Requests/VoidTransactionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Locations.Transactions; +[Serializable] public record VoidTransactionsRequest { [JsonIgnore] diff --git a/src/Square/Locations/Transactions/TransactionsClient.cs b/src/Square/Locations/Transactions/TransactionsClient.cs index c8bd6a96..28ec5f02 100644 --- a/src/Square/Locations/Transactions/TransactionsClient.cs +++ b/src/Square/Locations/Transactions/TransactionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Loyalty/Accounts/AccountsClient.cs b/src/Square/Loyalty/Accounts/AccountsClient.cs index 39f21beb..892389b9 100644 --- a/src/Square/Loyalty/Accounts/AccountsClient.cs +++ b/src/Square/Loyalty/Accounts/AccountsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Loyalty/Accounts/Requests/AccumulateLoyaltyPointsRequest.cs b/src/Square/Loyalty/Accounts/Requests/AccumulateLoyaltyPointsRequest.cs index c07cd680..82fbe466 100644 --- a/src/Square/Loyalty/Accounts/Requests/AccumulateLoyaltyPointsRequest.cs +++ b/src/Square/Loyalty/Accounts/Requests/AccumulateLoyaltyPointsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Accounts; +[Serializable] public record AccumulateLoyaltyPointsRequest { /// diff --git a/src/Square/Loyalty/Accounts/Requests/AdjustLoyaltyPointsRequest.cs b/src/Square/Loyalty/Accounts/Requests/AdjustLoyaltyPointsRequest.cs index 000e22de..d551181d 100644 --- a/src/Square/Loyalty/Accounts/Requests/AdjustLoyaltyPointsRequest.cs +++ b/src/Square/Loyalty/Accounts/Requests/AdjustLoyaltyPointsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Accounts; +[Serializable] public record AdjustLoyaltyPointsRequest { /// diff --git a/src/Square/Loyalty/Accounts/Requests/CreateLoyaltyAccountRequest.cs b/src/Square/Loyalty/Accounts/Requests/CreateLoyaltyAccountRequest.cs index 8f693ebb..60e3de21 100644 --- a/src/Square/Loyalty/Accounts/Requests/CreateLoyaltyAccountRequest.cs +++ b/src/Square/Loyalty/Accounts/Requests/CreateLoyaltyAccountRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Accounts; +[Serializable] public record CreateLoyaltyAccountRequest { /// diff --git a/src/Square/Loyalty/Accounts/Requests/GetAccountsRequest.cs b/src/Square/Loyalty/Accounts/Requests/GetAccountsRequest.cs index 3b56a6fc..9e524ee8 100644 --- a/src/Square/Loyalty/Accounts/Requests/GetAccountsRequest.cs +++ b/src/Square/Loyalty/Accounts/Requests/GetAccountsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Accounts; +[Serializable] public record GetAccountsRequest { /// diff --git a/src/Square/Loyalty/Accounts/Requests/SearchLoyaltyAccountsRequest.cs b/src/Square/Loyalty/Accounts/Requests/SearchLoyaltyAccountsRequest.cs index 10600f77..26547dc5 100644 --- a/src/Square/Loyalty/Accounts/Requests/SearchLoyaltyAccountsRequest.cs +++ b/src/Square/Loyalty/Accounts/Requests/SearchLoyaltyAccountsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Accounts; +[Serializable] public record SearchLoyaltyAccountsRequest { /// diff --git a/src/Square/Loyalty/LoyaltyClient.cs b/src/Square/Loyalty/LoyaltyClient.cs index 8f958526..ffd59a95 100644 --- a/src/Square/Loyalty/LoyaltyClient.cs +++ b/src/Square/Loyalty/LoyaltyClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.Loyalty.Accounts; diff --git a/src/Square/Loyalty/Programs/ProgramsClient.cs b/src/Square/Loyalty/Programs/ProgramsClient.cs index f9525b45..c6af64de 100644 --- a/src/Square/Loyalty/Programs/ProgramsClient.cs +++ b/src/Square/Loyalty/Programs/ProgramsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.Loyalty.Programs.Promotions; diff --git a/src/Square/Loyalty/Programs/Promotions/PromotionsClient.cs b/src/Square/Loyalty/Programs/Promotions/PromotionsClient.cs index da23e1f7..96a83646 100644 --- a/src/Square/Loyalty/Programs/Promotions/PromotionsClient.cs +++ b/src/Square/Loyalty/Programs/Promotions/PromotionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Loyalty/Programs/Promotions/Requests/CancelPromotionsRequest.cs b/src/Square/Loyalty/Programs/Promotions/Requests/CancelPromotionsRequest.cs index 755cd8b9..38c66f53 100644 --- a/src/Square/Loyalty/Programs/Promotions/Requests/CancelPromotionsRequest.cs +++ b/src/Square/Loyalty/Programs/Promotions/Requests/CancelPromotionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Programs.Promotions; +[Serializable] public record CancelPromotionsRequest { /// diff --git a/src/Square/Loyalty/Programs/Promotions/Requests/CreateLoyaltyPromotionRequest.cs b/src/Square/Loyalty/Programs/Promotions/Requests/CreateLoyaltyPromotionRequest.cs index fc85f8ae..a0944813 100644 --- a/src/Square/Loyalty/Programs/Promotions/Requests/CreateLoyaltyPromotionRequest.cs +++ b/src/Square/Loyalty/Programs/Promotions/Requests/CreateLoyaltyPromotionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Programs.Promotions; +[Serializable] public record CreateLoyaltyPromotionRequest { /// diff --git a/src/Square/Loyalty/Programs/Promotions/Requests/GetPromotionsRequest.cs b/src/Square/Loyalty/Programs/Promotions/Requests/GetPromotionsRequest.cs index 3ad62dec..39e0a9e8 100644 --- a/src/Square/Loyalty/Programs/Promotions/Requests/GetPromotionsRequest.cs +++ b/src/Square/Loyalty/Programs/Promotions/Requests/GetPromotionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Programs.Promotions; +[Serializable] public record GetPromotionsRequest { /// diff --git a/src/Square/Loyalty/Programs/Promotions/Requests/ListPromotionsRequest.cs b/src/Square/Loyalty/Programs/Promotions/Requests/ListPromotionsRequest.cs index 610a2eeb..71a3a434 100644 --- a/src/Square/Loyalty/Programs/Promotions/Requests/ListPromotionsRequest.cs +++ b/src/Square/Loyalty/Programs/Promotions/Requests/ListPromotionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Programs.Promotions; +[Serializable] public record ListPromotionsRequest { /// diff --git a/src/Square/Loyalty/Programs/Requests/CalculateLoyaltyPointsRequest.cs b/src/Square/Loyalty/Programs/Requests/CalculateLoyaltyPointsRequest.cs index 3c6903e7..27cfce37 100644 --- a/src/Square/Loyalty/Programs/Requests/CalculateLoyaltyPointsRequest.cs +++ b/src/Square/Loyalty/Programs/Requests/CalculateLoyaltyPointsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Programs; +[Serializable] public record CalculateLoyaltyPointsRequest { /// diff --git a/src/Square/Loyalty/Programs/Requests/GetProgramsRequest.cs b/src/Square/Loyalty/Programs/Requests/GetProgramsRequest.cs index b4bab6c4..6342b87c 100644 --- a/src/Square/Loyalty/Programs/Requests/GetProgramsRequest.cs +++ b/src/Square/Loyalty/Programs/Requests/GetProgramsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Programs; +[Serializable] public record GetProgramsRequest { /// diff --git a/src/Square/Loyalty/Requests/SearchLoyaltyEventsRequest.cs b/src/Square/Loyalty/Requests/SearchLoyaltyEventsRequest.cs index 99ce1938..64ffb4a6 100644 --- a/src/Square/Loyalty/Requests/SearchLoyaltyEventsRequest.cs +++ b/src/Square/Loyalty/Requests/SearchLoyaltyEventsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty; +[Serializable] public record SearchLoyaltyEventsRequest { /// diff --git a/src/Square/Loyalty/Rewards/Requests/CreateLoyaltyRewardRequest.cs b/src/Square/Loyalty/Rewards/Requests/CreateLoyaltyRewardRequest.cs index 47a6e86e..c9189b64 100644 --- a/src/Square/Loyalty/Rewards/Requests/CreateLoyaltyRewardRequest.cs +++ b/src/Square/Loyalty/Rewards/Requests/CreateLoyaltyRewardRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Rewards; +[Serializable] public record CreateLoyaltyRewardRequest { /// diff --git a/src/Square/Loyalty/Rewards/Requests/DeleteRewardsRequest.cs b/src/Square/Loyalty/Rewards/Requests/DeleteRewardsRequest.cs index 72eb15c0..8528908d 100644 --- a/src/Square/Loyalty/Rewards/Requests/DeleteRewardsRequest.cs +++ b/src/Square/Loyalty/Rewards/Requests/DeleteRewardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Rewards; +[Serializable] public record DeleteRewardsRequest { /// diff --git a/src/Square/Loyalty/Rewards/Requests/GetRewardsRequest.cs b/src/Square/Loyalty/Rewards/Requests/GetRewardsRequest.cs index 59720bf2..d7c25a69 100644 --- a/src/Square/Loyalty/Rewards/Requests/GetRewardsRequest.cs +++ b/src/Square/Loyalty/Rewards/Requests/GetRewardsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Rewards; +[Serializable] public record GetRewardsRequest { /// diff --git a/src/Square/Loyalty/Rewards/Requests/RedeemLoyaltyRewardRequest.cs b/src/Square/Loyalty/Rewards/Requests/RedeemLoyaltyRewardRequest.cs index ef1cd046..286ee18d 100644 --- a/src/Square/Loyalty/Rewards/Requests/RedeemLoyaltyRewardRequest.cs +++ b/src/Square/Loyalty/Rewards/Requests/RedeemLoyaltyRewardRequest.cs @@ -3,6 +3,7 @@ namespace Square.Loyalty.Rewards; +[Serializable] public record RedeemLoyaltyRewardRequest { /// diff --git a/src/Square/Loyalty/Rewards/Requests/SearchLoyaltyRewardsRequest.cs b/src/Square/Loyalty/Rewards/Requests/SearchLoyaltyRewardsRequest.cs index aae72fc7..849a955b 100644 --- a/src/Square/Loyalty/Rewards/Requests/SearchLoyaltyRewardsRequest.cs +++ b/src/Square/Loyalty/Rewards/Requests/SearchLoyaltyRewardsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Loyalty.Rewards; +[Serializable] public record SearchLoyaltyRewardsRequest { /// diff --git a/src/Square/Loyalty/Rewards/RewardsClient.cs b/src/Square/Loyalty/Rewards/RewardsClient.cs index 122aa1a1..a6080759 100644 --- a/src/Square/Loyalty/Rewards/RewardsClient.cs +++ b/src/Square/Loyalty/Rewards/RewardsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Merchants/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs b/src/Square/Merchants/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs index c71128fc..ac3f12f7 100644 --- a/src/Square/Merchants/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs +++ b/src/Square/Merchants/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -86,7 +87,7 @@ private async Task ListInternalA /// /// /// await client.Merchants.CustomAttributeDefinitions.ListAsync( - /// new ListCustomAttributeDefinitionsRequest + /// new Square.Merchants.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest /// { /// VisibilityFilter = VisibilityFilter.All, /// Limit = 1, @@ -143,7 +144,7 @@ public async Task> ListAsync( /// CustomAttributeDefinition = new CustomAttributeDefinition /// { /// Key = "alternative_seller_name", - /// Schema = new Dictionary<string, object>() + /// Schema = new Dictionary<string, object?>() /// { /// { /// "$ref", @@ -209,7 +210,11 @@ public async Task CreateAsync( /// /// /// await client.Merchants.CustomAttributeDefinitions.GetAsync( - /// new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + /// new Square.Merchants.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// Version = 1, + /// } /// ); /// public async Task GetAsync( @@ -339,7 +344,10 @@ public async Task UpdateAsync( /// /// /// await client.Merchants.CustomAttributeDefinitions.DeleteAsync( - /// new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + /// new Square.Merchants.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Merchants/CustomAttributeDefinitions/Requests/CreateMerchantCustomAttributeDefinitionRequest.cs b/src/Square/Merchants/CustomAttributeDefinitions/Requests/CreateMerchantCustomAttributeDefinitionRequest.cs index 4ff4aa3f..3c19ed43 100644 --- a/src/Square/Merchants/CustomAttributeDefinitions/Requests/CreateMerchantCustomAttributeDefinitionRequest.cs +++ b/src/Square/Merchants/CustomAttributeDefinitions/Requests/CreateMerchantCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributeDefinitions; +[Serializable] public record CreateMerchantCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Merchants/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs b/src/Square/Merchants/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs index aacbabfa..f95dc920 100644 --- a/src/Square/Merchants/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Merchants/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Merchants.CustomAttributeDefinitions; +[Serializable] public record DeleteCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Merchants/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs b/src/Square/Merchants/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs index 68811639..5c515823 100644 --- a/src/Square/Merchants/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Merchants/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Merchants.CustomAttributeDefinitions; +[Serializable] public record GetCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Merchants/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs b/src/Square/Merchants/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs index 4e0dd88e..00c81eba 100644 --- a/src/Square/Merchants/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Merchants/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributeDefinitions; +[Serializable] public record ListCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Merchants/CustomAttributeDefinitions/Requests/UpdateMerchantCustomAttributeDefinitionRequest.cs b/src/Square/Merchants/CustomAttributeDefinitions/Requests/UpdateMerchantCustomAttributeDefinitionRequest.cs index dba2efa2..160304ff 100644 --- a/src/Square/Merchants/CustomAttributeDefinitions/Requests/UpdateMerchantCustomAttributeDefinitionRequest.cs +++ b/src/Square/Merchants/CustomAttributeDefinitions/Requests/UpdateMerchantCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributeDefinitions; +[Serializable] public record UpdateMerchantCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Merchants/CustomAttributes/CustomAttributesClient.cs b/src/Square/Merchants/CustomAttributes/CustomAttributesClient.cs index e8682f71..904c7753 100644 --- a/src/Square/Merchants/CustomAttributes/CustomAttributesClient.cs +++ b/src/Square/Merchants/CustomAttributes/CustomAttributesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -266,7 +267,7 @@ public async Task BatchUpsertAsync( /// /// /// await client.Merchants.CustomAttributes.ListAsync( - /// new ListCustomAttributesRequest + /// new Square.Merchants.CustomAttributes.ListCustomAttributesRequest /// { /// MerchantId = "merchant_id", /// VisibilityFilter = VisibilityFilter.All, @@ -318,7 +319,7 @@ public async Task> ListAsync( /// /// /// await client.Merchants.CustomAttributes.GetAsync( - /// new GetCustomAttributesRequest + /// new Square.Merchants.CustomAttributes.GetCustomAttributesRequest /// { /// MerchantId = "merchant_id", /// Key = "key", @@ -456,7 +457,11 @@ public async Task UpsertAsync( /// /// /// await client.Merchants.CustomAttributes.DeleteAsync( - /// new DeleteCustomAttributesRequest { MerchantId = "merchant_id", Key = "key" } + /// new Square.Merchants.CustomAttributes.DeleteCustomAttributesRequest + /// { + /// MerchantId = "merchant_id", + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Merchants/CustomAttributes/Requests/BulkDeleteMerchantCustomAttributesRequest.cs b/src/Square/Merchants/CustomAttributes/Requests/BulkDeleteMerchantCustomAttributesRequest.cs index e839a3af..c1529f44 100644 --- a/src/Square/Merchants/CustomAttributes/Requests/BulkDeleteMerchantCustomAttributesRequest.cs +++ b/src/Square/Merchants/CustomAttributes/Requests/BulkDeleteMerchantCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributes; +[Serializable] public record BulkDeleteMerchantCustomAttributesRequest { /// diff --git a/src/Square/Merchants/CustomAttributes/Requests/BulkUpsertMerchantCustomAttributesRequest.cs b/src/Square/Merchants/CustomAttributes/Requests/BulkUpsertMerchantCustomAttributesRequest.cs index 39808967..bedea590 100644 --- a/src/Square/Merchants/CustomAttributes/Requests/BulkUpsertMerchantCustomAttributesRequest.cs +++ b/src/Square/Merchants/CustomAttributes/Requests/BulkUpsertMerchantCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributes; +[Serializable] public record BulkUpsertMerchantCustomAttributesRequest { /// diff --git a/src/Square/Merchants/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs b/src/Square/Merchants/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs index 62af7617..dbf34815 100644 --- a/src/Square/Merchants/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs +++ b/src/Square/Merchants/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Merchants.CustomAttributes; +[Serializable] public record DeleteCustomAttributesRequest { /// diff --git a/src/Square/Merchants/CustomAttributes/Requests/GetCustomAttributesRequest.cs b/src/Square/Merchants/CustomAttributes/Requests/GetCustomAttributesRequest.cs index 895d1950..1e6f2f0b 100644 --- a/src/Square/Merchants/CustomAttributes/Requests/GetCustomAttributesRequest.cs +++ b/src/Square/Merchants/CustomAttributes/Requests/GetCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Merchants.CustomAttributes; +[Serializable] public record GetCustomAttributesRequest { /// diff --git a/src/Square/Merchants/CustomAttributes/Requests/ListCustomAttributesRequest.cs b/src/Square/Merchants/CustomAttributes/Requests/ListCustomAttributesRequest.cs index 76a5bb9d..97741d14 100644 --- a/src/Square/Merchants/CustomAttributes/Requests/ListCustomAttributesRequest.cs +++ b/src/Square/Merchants/CustomAttributes/Requests/ListCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributes; +[Serializable] public record ListCustomAttributesRequest { /// diff --git a/src/Square/Merchants/CustomAttributes/Requests/UpsertMerchantCustomAttributeRequest.cs b/src/Square/Merchants/CustomAttributes/Requests/UpsertMerchantCustomAttributeRequest.cs index d125288c..7584859e 100644 --- a/src/Square/Merchants/CustomAttributes/Requests/UpsertMerchantCustomAttributeRequest.cs +++ b/src/Square/Merchants/CustomAttributes/Requests/UpsertMerchantCustomAttributeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Merchants.CustomAttributes; +[Serializable] public record UpsertMerchantCustomAttributeRequest { /// diff --git a/src/Square/Merchants/MerchantsClient.cs b/src/Square/Merchants/MerchantsClient.cs index 40d6ed05..e09b65a8 100644 --- a/src/Square/Merchants/MerchantsClient.cs +++ b/src/Square/Merchants/MerchantsClient.cs @@ -1,10 +1,9 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; -using Square.Merchants.CustomAttributeDefinitions; -using Square.Merchants.CustomAttributes; namespace Square.Merchants; @@ -15,13 +14,16 @@ public partial class MerchantsClient internal MerchantsClient(RawClient client) { _client = client; - CustomAttributeDefinitions = new CustomAttributeDefinitionsClient(_client); - CustomAttributes = new CustomAttributesClient(_client); + CustomAttributeDefinitions = + new Square.Merchants.CustomAttributeDefinitions.CustomAttributeDefinitionsClient( + _client + ); + CustomAttributes = new Square.Merchants.CustomAttributes.CustomAttributesClient(_client); } - public CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } + public Square.Merchants.CustomAttributeDefinitions.CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } - public CustomAttributesClient CustomAttributes { get; } + public Square.Merchants.CustomAttributes.CustomAttributesClient CustomAttributes { get; } /// /// Provides details about the merchant associated with a given access token. diff --git a/src/Square/Merchants/Requests/GetMerchantsRequest.cs b/src/Square/Merchants/Requests/GetMerchantsRequest.cs index 66bf9ed5..cd0fa576 100644 --- a/src/Square/Merchants/Requests/GetMerchantsRequest.cs +++ b/src/Square/Merchants/Requests/GetMerchantsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Merchants; +[Serializable] public record GetMerchantsRequest { /// diff --git a/src/Square/Merchants/Requests/ListMerchantsRequest.cs b/src/Square/Merchants/Requests/ListMerchantsRequest.cs index ec12e26a..ff3d8ea0 100644 --- a/src/Square/Merchants/Requests/ListMerchantsRequest.cs +++ b/src/Square/Merchants/Requests/ListMerchantsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Merchants; +[Serializable] public record ListMerchantsRequest { /// diff --git a/src/Square/Mobile/MobileClient.cs b/src/Square/Mobile/MobileClient.cs index 1ec9b7bb..af5983e1 100644 --- a/src/Square/Mobile/MobileClient.cs +++ b/src/Square/Mobile/MobileClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Mobile/Requests/CreateMobileAuthorizationCodeRequest.cs b/src/Square/Mobile/Requests/CreateMobileAuthorizationCodeRequest.cs index d96b8ff1..c9559e50 100644 --- a/src/Square/Mobile/Requests/CreateMobileAuthorizationCodeRequest.cs +++ b/src/Square/Mobile/Requests/CreateMobileAuthorizationCodeRequest.cs @@ -3,6 +3,7 @@ namespace Square.Mobile; +[Serializable] public record CreateMobileAuthorizationCodeRequest { /// diff --git a/src/Square/OAuth/OAuthClient.cs b/src/Square/OAuth/OAuthClient.cs index f102ae6a..3af59a30 100644 --- a/src/Square/OAuth/OAuthClient.cs +++ b/src/Square/OAuth/OAuthClient.cs @@ -1,7 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; -using global::System.Threading.Tasks; +using System.Threading.Tasks; using Square; using Square.Core; @@ -219,7 +219,7 @@ public async Task RetrieveTokenStatusAsync( /// /// await client.OAuth.AuthorizeAsync(); /// - public async global::System.Threading.Tasks.Task AuthorizeAsync( + public async Task AuthorizeAsync( RequestOptions? options = null, CancellationToken cancellationToken = default ) diff --git a/src/Square/OAuth/Requests/ObtainTokenRequest.cs b/src/Square/OAuth/Requests/ObtainTokenRequest.cs index 4a209748..7801885c 100644 --- a/src/Square/OAuth/Requests/ObtainTokenRequest.cs +++ b/src/Square/OAuth/Requests/ObtainTokenRequest.cs @@ -3,6 +3,7 @@ namespace Square.OAuth; +[Serializable] public record ObtainTokenRequest { /// diff --git a/src/Square/OAuth/Requests/RevokeTokenRequest.cs b/src/Square/OAuth/Requests/RevokeTokenRequest.cs index fd7ae003..834a5e8a 100644 --- a/src/Square/OAuth/Requests/RevokeTokenRequest.cs +++ b/src/Square/OAuth/Requests/RevokeTokenRequest.cs @@ -3,6 +3,7 @@ namespace Square.OAuth; +[Serializable] public record RevokeTokenRequest { /// diff --git a/src/Square/Orders/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs b/src/Square/Orders/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs index a4358923..77109875 100644 --- a/src/Square/Orders/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs +++ b/src/Square/Orders/CustomAttributeDefinitions/CustomAttributeDefinitionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -90,7 +91,7 @@ private async Task ListInternalAsyn /// /// /// await client.Orders.CustomAttributeDefinitions.ListAsync( - /// new ListCustomAttributeDefinitionsRequest + /// new Square.Orders.CustomAttributeDefinitions.ListCustomAttributeDefinitionsRequest /// { /// VisibilityFilter = VisibilityFilter.All, /// Cursor = "cursor", @@ -145,7 +146,7 @@ public async Task> ListAsync( /// CustomAttributeDefinition = new CustomAttributeDefinition /// { /// Key = "cover-count", - /// Schema = new Dictionary<string, object>() + /// Schema = new Dictionary<string, object?>() /// { /// { /// "$ref", @@ -214,7 +215,11 @@ public async Task CreateAsync( /// /// /// await client.Orders.CustomAttributeDefinitions.GetAsync( - /// new GetCustomAttributeDefinitionsRequest { Key = "key", Version = 1 } + /// new Square.Orders.CustomAttributeDefinitions.GetCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// Version = 1, + /// } /// ); /// public async Task GetAsync( @@ -344,7 +349,10 @@ public async Task UpdateAsync( /// /// /// await client.Orders.CustomAttributeDefinitions.DeleteAsync( - /// new DeleteCustomAttributeDefinitionsRequest { Key = "key" } + /// new Square.Orders.CustomAttributeDefinitions.DeleteCustomAttributeDefinitionsRequest + /// { + /// Key = "key", + /// } /// ); /// public async Task DeleteAsync( diff --git a/src/Square/Orders/CustomAttributeDefinitions/Requests/CreateOrderCustomAttributeDefinitionRequest.cs b/src/Square/Orders/CustomAttributeDefinitions/Requests/CreateOrderCustomAttributeDefinitionRequest.cs index dfb66646..844a5a62 100644 --- a/src/Square/Orders/CustomAttributeDefinitions/Requests/CreateOrderCustomAttributeDefinitionRequest.cs +++ b/src/Square/Orders/CustomAttributeDefinitions/Requests/CreateOrderCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributeDefinitions; +[Serializable] public record CreateOrderCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Orders/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs b/src/Square/Orders/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs index d42c0d7b..bb38bae8 100644 --- a/src/Square/Orders/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Orders/CustomAttributeDefinitions/Requests/DeleteCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders.CustomAttributeDefinitions; +[Serializable] public record DeleteCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Orders/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs b/src/Square/Orders/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs index a00d4f26..22e20085 100644 --- a/src/Square/Orders/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Orders/CustomAttributeDefinitions/Requests/GetCustomAttributeDefinitionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders.CustomAttributeDefinitions; +[Serializable] public record GetCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Orders/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs b/src/Square/Orders/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs index 790a262f..38233b30 100644 --- a/src/Square/Orders/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs +++ b/src/Square/Orders/CustomAttributeDefinitions/Requests/ListCustomAttributeDefinitionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributeDefinitions; +[Serializable] public record ListCustomAttributeDefinitionsRequest { /// diff --git a/src/Square/Orders/CustomAttributeDefinitions/Requests/UpdateOrderCustomAttributeDefinitionRequest.cs b/src/Square/Orders/CustomAttributeDefinitions/Requests/UpdateOrderCustomAttributeDefinitionRequest.cs index 78ce86cc..96549665 100644 --- a/src/Square/Orders/CustomAttributeDefinitions/Requests/UpdateOrderCustomAttributeDefinitionRequest.cs +++ b/src/Square/Orders/CustomAttributeDefinitions/Requests/UpdateOrderCustomAttributeDefinitionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributeDefinitions; +[Serializable] public record UpdateOrderCustomAttributeDefinitionRequest { /// diff --git a/src/Square/Orders/CustomAttributes/CustomAttributesClient.cs b/src/Square/Orders/CustomAttributes/CustomAttributesClient.cs index 572e17b5..a821066a 100644 --- a/src/Square/Orders/CustomAttributes/CustomAttributesClient.cs +++ b/src/Square/Orders/CustomAttributes/CustomAttributesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -289,7 +290,7 @@ public async Task BatchUpsertAsync( /// /// /// await client.Orders.CustomAttributes.ListAsync( - /// new ListCustomAttributesRequest + /// new Square.Orders.CustomAttributes.ListCustomAttributesRequest /// { /// OrderId = "order_id", /// VisibilityFilter = VisibilityFilter.All, @@ -344,7 +345,7 @@ public async Task> ListAsync( /// /// /// await client.Orders.CustomAttributes.GetAsync( - /// new GetCustomAttributesRequest + /// new Square.Orders.CustomAttributes.GetCustomAttributesRequest /// { /// OrderId = "order_id", /// CustomAttributeKey = "custom_attribute_key", @@ -490,7 +491,7 @@ public async Task UpsertAsync( /// /// /// await client.Orders.CustomAttributes.DeleteAsync( - /// new DeleteCustomAttributesRequest + /// new Square.Orders.CustomAttributes.DeleteCustomAttributesRequest /// { /// OrderId = "order_id", /// CustomAttributeKey = "custom_attribute_key", diff --git a/src/Square/Orders/CustomAttributes/Requests/BulkDeleteOrderCustomAttributesRequest.cs b/src/Square/Orders/CustomAttributes/Requests/BulkDeleteOrderCustomAttributesRequest.cs index 0b437795..5ef858c0 100644 --- a/src/Square/Orders/CustomAttributes/Requests/BulkDeleteOrderCustomAttributesRequest.cs +++ b/src/Square/Orders/CustomAttributes/Requests/BulkDeleteOrderCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributes; +[Serializable] public record BulkDeleteOrderCustomAttributesRequest { /// diff --git a/src/Square/Orders/CustomAttributes/Requests/BulkUpsertOrderCustomAttributesRequest.cs b/src/Square/Orders/CustomAttributes/Requests/BulkUpsertOrderCustomAttributesRequest.cs index db4a8edd..45430f9d 100644 --- a/src/Square/Orders/CustomAttributes/Requests/BulkUpsertOrderCustomAttributesRequest.cs +++ b/src/Square/Orders/CustomAttributes/Requests/BulkUpsertOrderCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributes; +[Serializable] public record BulkUpsertOrderCustomAttributesRequest { /// diff --git a/src/Square/Orders/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs b/src/Square/Orders/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs index b40ddf8d..dae82171 100644 --- a/src/Square/Orders/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs +++ b/src/Square/Orders/CustomAttributes/Requests/DeleteCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders.CustomAttributes; +[Serializable] public record DeleteCustomAttributesRequest { /// diff --git a/src/Square/Orders/CustomAttributes/Requests/GetCustomAttributesRequest.cs b/src/Square/Orders/CustomAttributes/Requests/GetCustomAttributesRequest.cs index 583381f4..76ed3c59 100644 --- a/src/Square/Orders/CustomAttributes/Requests/GetCustomAttributesRequest.cs +++ b/src/Square/Orders/CustomAttributes/Requests/GetCustomAttributesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders.CustomAttributes; +[Serializable] public record GetCustomAttributesRequest { /// diff --git a/src/Square/Orders/CustomAttributes/Requests/ListCustomAttributesRequest.cs b/src/Square/Orders/CustomAttributes/Requests/ListCustomAttributesRequest.cs index 50842d87..89c27f1d 100644 --- a/src/Square/Orders/CustomAttributes/Requests/ListCustomAttributesRequest.cs +++ b/src/Square/Orders/CustomAttributes/Requests/ListCustomAttributesRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributes; +[Serializable] public record ListCustomAttributesRequest { /// diff --git a/src/Square/Orders/CustomAttributes/Requests/UpsertOrderCustomAttributeRequest.cs b/src/Square/Orders/CustomAttributes/Requests/UpsertOrderCustomAttributeRequest.cs index 8c40c109..6e6f3e2b 100644 --- a/src/Square/Orders/CustomAttributes/Requests/UpsertOrderCustomAttributeRequest.cs +++ b/src/Square/Orders/CustomAttributes/Requests/UpsertOrderCustomAttributeRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders.CustomAttributes; +[Serializable] public record UpsertOrderCustomAttributeRequest { /// diff --git a/src/Square/Orders/OrdersClient.cs b/src/Square/Orders/OrdersClient.cs index 570e852a..5601eaf9 100644 --- a/src/Square/Orders/OrdersClient.cs +++ b/src/Square/Orders/OrdersClient.cs @@ -1,10 +1,9 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; -using Square.Orders.CustomAttributeDefinitions; -using Square.Orders.CustomAttributes; namespace Square.Orders; @@ -15,13 +14,14 @@ public partial class OrdersClient internal OrdersClient(RawClient client) { _client = client; - CustomAttributeDefinitions = new CustomAttributeDefinitionsClient(_client); - CustomAttributes = new CustomAttributesClient(_client); + CustomAttributeDefinitions = + new Square.Orders.CustomAttributeDefinitions.CustomAttributeDefinitionsClient(_client); + CustomAttributes = new Square.Orders.CustomAttributes.CustomAttributesClient(_client); } - public CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } + public Square.Orders.CustomAttributeDefinitions.CustomAttributeDefinitionsClient CustomAttributeDefinitions { get; } - public CustomAttributesClient CustomAttributes { get; } + public Square.Orders.CustomAttributes.CustomAttributesClient CustomAttributes { get; } /// /// Creates a new [order](entity:Order) that can include information about products for diff --git a/src/Square/Orders/Requests/BatchGetOrdersRequest.cs b/src/Square/Orders/Requests/BatchGetOrdersRequest.cs index 90773e5c..513f0421 100644 --- a/src/Square/Orders/Requests/BatchGetOrdersRequest.cs +++ b/src/Square/Orders/Requests/BatchGetOrdersRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders; +[Serializable] public record BatchGetOrdersRequest { /// diff --git a/src/Square/Orders/Requests/CalculateOrderRequest.cs b/src/Square/Orders/Requests/CalculateOrderRequest.cs index fbd10602..b4e41e7a 100644 --- a/src/Square/Orders/Requests/CalculateOrderRequest.cs +++ b/src/Square/Orders/Requests/CalculateOrderRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders; +[Serializable] public record CalculateOrderRequest { /// diff --git a/src/Square/Orders/Requests/CloneOrderRequest.cs b/src/Square/Orders/Requests/CloneOrderRequest.cs index e93cf0da..e4c9a407 100644 --- a/src/Square/Orders/Requests/CloneOrderRequest.cs +++ b/src/Square/Orders/Requests/CloneOrderRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders; +[Serializable] public record CloneOrderRequest { /// diff --git a/src/Square/Orders/Requests/GetOrdersRequest.cs b/src/Square/Orders/Requests/GetOrdersRequest.cs index 0ee3e66e..16f7a0bb 100644 --- a/src/Square/Orders/Requests/GetOrdersRequest.cs +++ b/src/Square/Orders/Requests/GetOrdersRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders; +[Serializable] public record GetOrdersRequest { /// diff --git a/src/Square/Orders/Requests/PayOrderRequest.cs b/src/Square/Orders/Requests/PayOrderRequest.cs index 55f7b85b..eee09ff1 100644 --- a/src/Square/Orders/Requests/PayOrderRequest.cs +++ b/src/Square/Orders/Requests/PayOrderRequest.cs @@ -3,6 +3,7 @@ namespace Square.Orders; +[Serializable] public record PayOrderRequest { /// diff --git a/src/Square/Orders/Requests/SearchOrdersRequest.cs b/src/Square/Orders/Requests/SearchOrdersRequest.cs index b71c5226..f27a5d1e 100644 --- a/src/Square/Orders/Requests/SearchOrdersRequest.cs +++ b/src/Square/Orders/Requests/SearchOrdersRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders; +[Serializable] public record SearchOrdersRequest { /// diff --git a/src/Square/Orders/Requests/UpdateOrderRequest.cs b/src/Square/Orders/Requests/UpdateOrderRequest.cs index cba34322..cd966dd9 100644 --- a/src/Square/Orders/Requests/UpdateOrderRequest.cs +++ b/src/Square/Orders/Requests/UpdateOrderRequest.cs @@ -4,6 +4,7 @@ namespace Square.Orders; +[Serializable] public record UpdateOrderRequest { /// diff --git a/src/Square/Payments/PaymentsClient.cs b/src/Square/Payments/PaymentsClient.cs index f7d693be..9f8bdfcc 100644 --- a/src/Square/Payments/PaymentsClient.cs +++ b/src/Square/Payments/PaymentsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Payments/Requests/CancelPaymentByIdempotencyKeyRequest.cs b/src/Square/Payments/Requests/CancelPaymentByIdempotencyKeyRequest.cs index 542c4a36..7fb39441 100644 --- a/src/Square/Payments/Requests/CancelPaymentByIdempotencyKeyRequest.cs +++ b/src/Square/Payments/Requests/CancelPaymentByIdempotencyKeyRequest.cs @@ -3,6 +3,7 @@ namespace Square.Payments; +[Serializable] public record CancelPaymentByIdempotencyKeyRequest { /// diff --git a/src/Square/Payments/Requests/CancelPaymentsRequest.cs b/src/Square/Payments/Requests/CancelPaymentsRequest.cs index 604b74fd..24557d96 100644 --- a/src/Square/Payments/Requests/CancelPaymentsRequest.cs +++ b/src/Square/Payments/Requests/CancelPaymentsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Payments; +[Serializable] public record CancelPaymentsRequest { /// diff --git a/src/Square/Payments/Requests/CompletePaymentRequest.cs b/src/Square/Payments/Requests/CompletePaymentRequest.cs index be1095f7..8b8cef30 100644 --- a/src/Square/Payments/Requests/CompletePaymentRequest.cs +++ b/src/Square/Payments/Requests/CompletePaymentRequest.cs @@ -3,6 +3,7 @@ namespace Square.Payments; +[Serializable] public record CompletePaymentRequest { /// diff --git a/src/Square/Payments/Requests/CreatePaymentRequest.cs b/src/Square/Payments/Requests/CreatePaymentRequest.cs index 77a227de..eb82f5bb 100644 --- a/src/Square/Payments/Requests/CreatePaymentRequest.cs +++ b/src/Square/Payments/Requests/CreatePaymentRequest.cs @@ -4,6 +4,7 @@ namespace Square.Payments; +[Serializable] public record CreatePaymentRequest { /// diff --git a/src/Square/Payments/Requests/GetPaymentsRequest.cs b/src/Square/Payments/Requests/GetPaymentsRequest.cs index 03a6aebc..8eafa1f1 100644 --- a/src/Square/Payments/Requests/GetPaymentsRequest.cs +++ b/src/Square/Payments/Requests/GetPaymentsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Payments; +[Serializable] public record GetPaymentsRequest { /// diff --git a/src/Square/Payments/Requests/ListPaymentsRequest.cs b/src/Square/Payments/Requests/ListPaymentsRequest.cs index fc2fd425..b712bc4c 100644 --- a/src/Square/Payments/Requests/ListPaymentsRequest.cs +++ b/src/Square/Payments/Requests/ListPaymentsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Payments; +[Serializable] public record ListPaymentsRequest { /// diff --git a/src/Square/Payments/Requests/UpdatePaymentRequest.cs b/src/Square/Payments/Requests/UpdatePaymentRequest.cs index 7ec01689..d6ff4f40 100644 --- a/src/Square/Payments/Requests/UpdatePaymentRequest.cs +++ b/src/Square/Payments/Requests/UpdatePaymentRequest.cs @@ -4,6 +4,7 @@ namespace Square.Payments; +[Serializable] public record UpdatePaymentRequest { /// diff --git a/src/Square/Payouts/PayoutsClient.cs b/src/Square/Payouts/PayoutsClient.cs index b2121943..739c1084 100644 --- a/src/Square/Payouts/PayoutsClient.cs +++ b/src/Square/Payouts/PayoutsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Payouts/Requests/GetPayoutsRequest.cs b/src/Square/Payouts/Requests/GetPayoutsRequest.cs index cb1af296..f74eb52a 100644 --- a/src/Square/Payouts/Requests/GetPayoutsRequest.cs +++ b/src/Square/Payouts/Requests/GetPayoutsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Payouts; +[Serializable] public record GetPayoutsRequest { /// diff --git a/src/Square/Payouts/Requests/ListEntriesPayoutsRequest.cs b/src/Square/Payouts/Requests/ListEntriesPayoutsRequest.cs index 817c0f21..f5dfa71c 100644 --- a/src/Square/Payouts/Requests/ListEntriesPayoutsRequest.cs +++ b/src/Square/Payouts/Requests/ListEntriesPayoutsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Payouts; +[Serializable] public record ListEntriesPayoutsRequest { /// diff --git a/src/Square/Payouts/Requests/ListPayoutsRequest.cs b/src/Square/Payouts/Requests/ListPayoutsRequest.cs index 67cc1dcf..affe85e6 100644 --- a/src/Square/Payouts/Requests/ListPayoutsRequest.cs +++ b/src/Square/Payouts/Requests/ListPayoutsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Payouts; +[Serializable] public record ListPayoutsRequest { /// diff --git a/src/Square/Refunds/RefundsClient.cs b/src/Square/Refunds/RefundsClient.cs index 0dbef095..b36c4ac8 100644 --- a/src/Square/Refunds/RefundsClient.cs +++ b/src/Square/Refunds/RefundsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -234,7 +235,7 @@ public async Task RefundPaymentAsync( /// Retrieves a specific refund using the `refund_id`. /// /// - /// await client.Refunds.GetAsync(new GetRefundsRequest { RefundId = "refund_id" }); + /// await client.Refunds.GetAsync(new Square.Refunds.GetRefundsRequest { RefundId = "refund_id" }); /// public async Task GetAsync( GetRefundsRequest request, diff --git a/src/Square/Refunds/Requests/GetRefundsRequest.cs b/src/Square/Refunds/Requests/GetRefundsRequest.cs index f6eaf495..2e494098 100644 --- a/src/Square/Refunds/Requests/GetRefundsRequest.cs +++ b/src/Square/Refunds/Requests/GetRefundsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Refunds; +[Serializable] public record GetRefundsRequest { /// diff --git a/src/Square/Refunds/Requests/ListRefundsRequest.cs b/src/Square/Refunds/Requests/ListRefundsRequest.cs index b52efa3b..1a77ca7b 100644 --- a/src/Square/Refunds/Requests/ListRefundsRequest.cs +++ b/src/Square/Refunds/Requests/ListRefundsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Refunds; +[Serializable] public record ListRefundsRequest { /// diff --git a/src/Square/Refunds/Requests/RefundPaymentRequest.cs b/src/Square/Refunds/Requests/RefundPaymentRequest.cs index 1283e76c..70d745a3 100644 --- a/src/Square/Refunds/Requests/RefundPaymentRequest.cs +++ b/src/Square/Refunds/Requests/RefundPaymentRequest.cs @@ -4,6 +4,7 @@ namespace Square.Refunds; +[Serializable] public record RefundPaymentRequest { /// diff --git a/src/Square/Sites/SitesClient.cs b/src/Square/Sites/SitesClient.cs index 9e100c62..30851479 100644 --- a/src/Square/Sites/SitesClient.cs +++ b/src/Square/Sites/SitesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Snippets/Requests/DeleteSnippetsRequest.cs b/src/Square/Snippets/Requests/DeleteSnippetsRequest.cs index 80ce5414..668bd91b 100644 --- a/src/Square/Snippets/Requests/DeleteSnippetsRequest.cs +++ b/src/Square/Snippets/Requests/DeleteSnippetsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Snippets; +[Serializable] public record DeleteSnippetsRequest { /// diff --git a/src/Square/Snippets/Requests/GetSnippetsRequest.cs b/src/Square/Snippets/Requests/GetSnippetsRequest.cs index 0e11eeb2..91767f58 100644 --- a/src/Square/Snippets/Requests/GetSnippetsRequest.cs +++ b/src/Square/Snippets/Requests/GetSnippetsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Snippets; +[Serializable] public record GetSnippetsRequest { /// diff --git a/src/Square/Snippets/Requests/UpsertSnippetRequest.cs b/src/Square/Snippets/Requests/UpsertSnippetRequest.cs index 184b7e76..8cdc4d96 100644 --- a/src/Square/Snippets/Requests/UpsertSnippetRequest.cs +++ b/src/Square/Snippets/Requests/UpsertSnippetRequest.cs @@ -4,6 +4,7 @@ namespace Square.Snippets; +[Serializable] public record UpsertSnippetRequest { /// diff --git a/src/Square/Snippets/SnippetsClient.cs b/src/Square/Snippets/SnippetsClient.cs index fbfd9fd9..820102a4 100644 --- a/src/Square/Snippets/SnippetsClient.cs +++ b/src/Square/Snippets/SnippetsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Square.csproj b/src/Square/Square.csproj index 88a9d180..8d753dfc 100644 --- a/src/Square/Square.csproj +++ b/src/Square/Square.csproj @@ -1,55 +1,49 @@ - - - Square - net462;net8.0;net7.0;net6.0;netstandard2.0 - enable - 12 - enable - 42.2.0 - $(Version) - $(Version) - README.md - MIT - https://github.com/square/square-dotnet-sdk - true - - - - false - - - $(DefineConstants);USE_PORTABLE_DATE_ONLY - true - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - - - <_Parameter1>Square.Test - - - - + + Square + net462;net8.0;net7.0;net6.0;netstandard2.0 + enable + 12 + enable + 42.2.1 + $(Version) + $(Version) + README.md + MIT + https://github.com/square/square-dotnet-sdk + true + + + false + + + $(DefineConstants);USE_PORTABLE_DATE_ONLY + true + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + <_Parameter1>Square.Test + + + diff --git a/src/Square/SquareClient.cs b/src/Square/SquareClient.cs index 3ee79eca..6b1361e3 100644 --- a/src/Square/SquareClient.cs +++ b/src/Square/SquareClient.cs @@ -1,7 +1,6 @@ using Square.ApplePay; using Square.BankAccounts; using Square.Bookings; -using Square.Cards; using Square.CashDrawers; using Square.Catalog; using Square.Channels; @@ -24,10 +23,8 @@ using Square.Orders; using Square.Payments; using Square.Payouts; -using Square.Refunds; using Square.Sites; using Square.Snippets; -using Square.Subscriptions; using Square.Team; using Square.TeamMembers; using Square.Terminal; @@ -56,7 +53,7 @@ public SquareClient(string? token = null, ClientOptions? clientOptions = null) { "X-Fern-Language", "C#" }, { "X-Fern-SDK-Name", "Square" }, { "X-Fern-SDK-Version", Version.Current }, - { "User-Agent", "Square/42.2.0" }, + { "User-Agent", "Square/42.2.1" }, } ); clientOptions ??= new ClientOptions(); @@ -78,7 +75,7 @@ public SquareClient(string? token = null, ClientOptions? clientOptions = null) ApplePay = new ApplePayClient(_client); BankAccounts = new BankAccountsClient(_client); Bookings = new BookingsClient(_client); - Cards = new CardsClient(_client); + Cards = new Square.Cards.CardsClient(_client); Catalog = new CatalogClient(_client); Channels = new ChannelsClient(_client); Customers = new CustomersClient(_client); @@ -97,10 +94,10 @@ public SquareClient(string? token = null, ClientOptions? clientOptions = null) Orders = new OrdersClient(_client); Payments = new PaymentsClient(_client); Payouts = new PayoutsClient(_client); - Refunds = new RefundsClient(_client); + Refunds = new Square.Refunds.RefundsClient(_client); Sites = new SitesClient(_client); Snippets = new SnippetsClient(_client); - Subscriptions = new SubscriptionsClient(_client); + Subscriptions = new Square.Subscriptions.SubscriptionsClient(_client); TeamMembers = new TeamMembersClient(_client); Team = new TeamClient(_client); Terminal = new TerminalClient(_client); @@ -122,7 +119,7 @@ public SquareClient(string? token = null, ClientOptions? clientOptions = null) public BookingsClient Bookings { get; } - public CardsClient Cards { get; } + public Square.Cards.CardsClient Cards { get; } public CatalogClient Catalog { get; } @@ -160,13 +157,13 @@ public SquareClient(string? token = null, ClientOptions? clientOptions = null) public PayoutsClient Payouts { get; } - public RefundsClient Refunds { get; } + public Square.Refunds.RefundsClient Refunds { get; } public SitesClient Sites { get; } public SnippetsClient Snippets { get; } - public SubscriptionsClient Subscriptions { get; } + public Square.Subscriptions.SubscriptionsClient Subscriptions { get; } public TeamMembersClient TeamMembers { get; } diff --git a/src/Square/Subscriptions/Requests/BulkSwapPlanRequest.cs b/src/Square/Subscriptions/Requests/BulkSwapPlanRequest.cs index 2e8a1cda..11674519 100644 --- a/src/Square/Subscriptions/Requests/BulkSwapPlanRequest.cs +++ b/src/Square/Subscriptions/Requests/BulkSwapPlanRequest.cs @@ -3,6 +3,7 @@ namespace Square.Subscriptions; +[Serializable] public record BulkSwapPlanRequest { /// diff --git a/src/Square/Subscriptions/Requests/CancelSubscriptionsRequest.cs b/src/Square/Subscriptions/Requests/CancelSubscriptionsRequest.cs index 3366f783..a38e37f8 100644 --- a/src/Square/Subscriptions/Requests/CancelSubscriptionsRequest.cs +++ b/src/Square/Subscriptions/Requests/CancelSubscriptionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Subscriptions; +[Serializable] public record CancelSubscriptionsRequest { /// diff --git a/src/Square/Subscriptions/Requests/ChangeBillingAnchorDateRequest.cs b/src/Square/Subscriptions/Requests/ChangeBillingAnchorDateRequest.cs index b311deef..7a7ad7a0 100644 --- a/src/Square/Subscriptions/Requests/ChangeBillingAnchorDateRequest.cs +++ b/src/Square/Subscriptions/Requests/ChangeBillingAnchorDateRequest.cs @@ -3,6 +3,7 @@ namespace Square.Subscriptions; +[Serializable] public record ChangeBillingAnchorDateRequest { /// diff --git a/src/Square/Subscriptions/Requests/CreateSubscriptionRequest.cs b/src/Square/Subscriptions/Requests/CreateSubscriptionRequest.cs index e6c6c07e..bb6b867e 100644 --- a/src/Square/Subscriptions/Requests/CreateSubscriptionRequest.cs +++ b/src/Square/Subscriptions/Requests/CreateSubscriptionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Subscriptions; +[Serializable] public record CreateSubscriptionRequest { /// diff --git a/src/Square/Subscriptions/Requests/DeleteActionSubscriptionsRequest.cs b/src/Square/Subscriptions/Requests/DeleteActionSubscriptionsRequest.cs index 09fce45d..346ce7aa 100644 --- a/src/Square/Subscriptions/Requests/DeleteActionSubscriptionsRequest.cs +++ b/src/Square/Subscriptions/Requests/DeleteActionSubscriptionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Subscriptions; +[Serializable] public record DeleteActionSubscriptionsRequest { /// diff --git a/src/Square/Subscriptions/Requests/GetSubscriptionsRequest.cs b/src/Square/Subscriptions/Requests/GetSubscriptionsRequest.cs index b246e747..6a388652 100644 --- a/src/Square/Subscriptions/Requests/GetSubscriptionsRequest.cs +++ b/src/Square/Subscriptions/Requests/GetSubscriptionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Subscriptions; +[Serializable] public record GetSubscriptionsRequest { /// diff --git a/src/Square/Subscriptions/Requests/ListEventsSubscriptionsRequest.cs b/src/Square/Subscriptions/Requests/ListEventsSubscriptionsRequest.cs index b323ab16..ec4bd8e0 100644 --- a/src/Square/Subscriptions/Requests/ListEventsSubscriptionsRequest.cs +++ b/src/Square/Subscriptions/Requests/ListEventsSubscriptionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Subscriptions; +[Serializable] public record ListEventsSubscriptionsRequest { /// diff --git a/src/Square/Subscriptions/Requests/PauseSubscriptionRequest.cs b/src/Square/Subscriptions/Requests/PauseSubscriptionRequest.cs index c1192a28..3b97a004 100644 --- a/src/Square/Subscriptions/Requests/PauseSubscriptionRequest.cs +++ b/src/Square/Subscriptions/Requests/PauseSubscriptionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Subscriptions; +[Serializable] public record PauseSubscriptionRequest { /// diff --git a/src/Square/Subscriptions/Requests/ResumeSubscriptionRequest.cs b/src/Square/Subscriptions/Requests/ResumeSubscriptionRequest.cs index 13b18876..67f9d49f 100644 --- a/src/Square/Subscriptions/Requests/ResumeSubscriptionRequest.cs +++ b/src/Square/Subscriptions/Requests/ResumeSubscriptionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Subscriptions; +[Serializable] public record ResumeSubscriptionRequest { /// diff --git a/src/Square/Subscriptions/Requests/SearchSubscriptionsRequest.cs b/src/Square/Subscriptions/Requests/SearchSubscriptionsRequest.cs index e637f30d..d826bd7f 100644 --- a/src/Square/Subscriptions/Requests/SearchSubscriptionsRequest.cs +++ b/src/Square/Subscriptions/Requests/SearchSubscriptionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Subscriptions; +[Serializable] public record SearchSubscriptionsRequest { /// diff --git a/src/Square/Subscriptions/Requests/SwapPlanRequest.cs b/src/Square/Subscriptions/Requests/SwapPlanRequest.cs index f0a56335..cd8cadf2 100644 --- a/src/Square/Subscriptions/Requests/SwapPlanRequest.cs +++ b/src/Square/Subscriptions/Requests/SwapPlanRequest.cs @@ -4,6 +4,7 @@ namespace Square.Subscriptions; +[Serializable] public record SwapPlanRequest { /// diff --git a/src/Square/Subscriptions/Requests/UpdateSubscriptionRequest.cs b/src/Square/Subscriptions/Requests/UpdateSubscriptionRequest.cs index 96072c29..4ddfad38 100644 --- a/src/Square/Subscriptions/Requests/UpdateSubscriptionRequest.cs +++ b/src/Square/Subscriptions/Requests/UpdateSubscriptionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Subscriptions; +[Serializable] public record UpdateSubscriptionRequest { /// diff --git a/src/Square/Subscriptions/SubscriptionsClient.cs b/src/Square/Subscriptions/SubscriptionsClient.cs index e5f8fac0..613f8399 100644 --- a/src/Square/Subscriptions/SubscriptionsClient.cs +++ b/src/Square/Subscriptions/SubscriptionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -281,7 +282,11 @@ public async Task SearchAsync( /// /// /// await client.Subscriptions.GetAsync( - /// new GetSubscriptionsRequest { SubscriptionId = "subscription_id", Include = "include" } + /// new Square.Subscriptions.GetSubscriptionsRequest + /// { + /// SubscriptionId = "subscription_id", + /// Include = "include", + /// } /// ); /// public async Task GetAsync( diff --git a/src/Square/Team/Requests/CreateJobRequest.cs b/src/Square/Team/Requests/CreateJobRequest.cs index 77ecddfa..a7a198ac 100644 --- a/src/Square/Team/Requests/CreateJobRequest.cs +++ b/src/Square/Team/Requests/CreateJobRequest.cs @@ -4,6 +4,7 @@ namespace Square.Team; +[Serializable] public record CreateJobRequest { /// diff --git a/src/Square/Team/Requests/ListJobsRequest.cs b/src/Square/Team/Requests/ListJobsRequest.cs index 4ebf57bc..c8c367ea 100644 --- a/src/Square/Team/Requests/ListJobsRequest.cs +++ b/src/Square/Team/Requests/ListJobsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Team; +[Serializable] public record ListJobsRequest { /// diff --git a/src/Square/Team/Requests/RetrieveJobRequest.cs b/src/Square/Team/Requests/RetrieveJobRequest.cs index b33f87eb..2897b072 100644 --- a/src/Square/Team/Requests/RetrieveJobRequest.cs +++ b/src/Square/Team/Requests/RetrieveJobRequest.cs @@ -3,6 +3,7 @@ namespace Square.Team; +[Serializable] public record RetrieveJobRequest { /// diff --git a/src/Square/Team/Requests/UpdateJobRequest.cs b/src/Square/Team/Requests/UpdateJobRequest.cs index a88a9931..29b6e70d 100644 --- a/src/Square/Team/Requests/UpdateJobRequest.cs +++ b/src/Square/Team/Requests/UpdateJobRequest.cs @@ -4,6 +4,7 @@ namespace Square.Team; +[Serializable] public record UpdateJobRequest { /// diff --git a/src/Square/Team/TeamClient.cs b/src/Square/Team/TeamClient.cs index 2408b122..c986c613 100644 --- a/src/Square/Team/TeamClient.cs +++ b/src/Square/Team/TeamClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/TeamMembers/Requests/BatchCreateTeamMembersRequest.cs b/src/Square/TeamMembers/Requests/BatchCreateTeamMembersRequest.cs index 0cbd6772..828bd255 100644 --- a/src/Square/TeamMembers/Requests/BatchCreateTeamMembersRequest.cs +++ b/src/Square/TeamMembers/Requests/BatchCreateTeamMembersRequest.cs @@ -4,6 +4,7 @@ namespace Square.TeamMembers; +[Serializable] public record BatchCreateTeamMembersRequest { /// diff --git a/src/Square/TeamMembers/Requests/BatchUpdateTeamMembersRequest.cs b/src/Square/TeamMembers/Requests/BatchUpdateTeamMembersRequest.cs index d23a39c6..4123920e 100644 --- a/src/Square/TeamMembers/Requests/BatchUpdateTeamMembersRequest.cs +++ b/src/Square/TeamMembers/Requests/BatchUpdateTeamMembersRequest.cs @@ -4,6 +4,7 @@ namespace Square.TeamMembers; +[Serializable] public record BatchUpdateTeamMembersRequest { /// diff --git a/src/Square/TeamMembers/Requests/GetTeamMembersRequest.cs b/src/Square/TeamMembers/Requests/GetTeamMembersRequest.cs index 2813181d..7d8787eb 100644 --- a/src/Square/TeamMembers/Requests/GetTeamMembersRequest.cs +++ b/src/Square/TeamMembers/Requests/GetTeamMembersRequest.cs @@ -3,6 +3,7 @@ namespace Square.TeamMembers; +[Serializable] public record GetTeamMembersRequest { /// diff --git a/src/Square/TeamMembers/Requests/SearchTeamMembersRequest.cs b/src/Square/TeamMembers/Requests/SearchTeamMembersRequest.cs index d09535cf..264d6d9e 100644 --- a/src/Square/TeamMembers/Requests/SearchTeamMembersRequest.cs +++ b/src/Square/TeamMembers/Requests/SearchTeamMembersRequest.cs @@ -4,6 +4,7 @@ namespace Square.TeamMembers; +[Serializable] public record SearchTeamMembersRequest { /// diff --git a/src/Square/TeamMembers/Requests/UpdateTeamMembersRequest.cs b/src/Square/TeamMembers/Requests/UpdateTeamMembersRequest.cs index 52d58b6c..22a2065d 100644 --- a/src/Square/TeamMembers/Requests/UpdateTeamMembersRequest.cs +++ b/src/Square/TeamMembers/Requests/UpdateTeamMembersRequest.cs @@ -4,6 +4,7 @@ namespace Square.TeamMembers; +[Serializable] public record UpdateTeamMembersRequest { /// diff --git a/src/Square/TeamMembers/TeamMembersClient.cs b/src/Square/TeamMembers/TeamMembersClient.cs index 6f25613d..d14c10f9 100644 --- a/src/Square/TeamMembers/TeamMembersClient.cs +++ b/src/Square/TeamMembers/TeamMembersClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.TeamMembers.WageSetting; diff --git a/src/Square/TeamMembers/WageSetting/Requests/GetWageSettingRequest.cs b/src/Square/TeamMembers/WageSetting/Requests/GetWageSettingRequest.cs index c75b1c90..8153cdb9 100644 --- a/src/Square/TeamMembers/WageSetting/Requests/GetWageSettingRequest.cs +++ b/src/Square/TeamMembers/WageSetting/Requests/GetWageSettingRequest.cs @@ -3,6 +3,7 @@ namespace Square.TeamMembers.WageSetting; +[Serializable] public record GetWageSettingRequest { /// diff --git a/src/Square/TeamMembers/WageSetting/Requests/UpdateWageSettingRequest.cs b/src/Square/TeamMembers/WageSetting/Requests/UpdateWageSettingRequest.cs index c8ae43e0..476cd866 100644 --- a/src/Square/TeamMembers/WageSetting/Requests/UpdateWageSettingRequest.cs +++ b/src/Square/TeamMembers/WageSetting/Requests/UpdateWageSettingRequest.cs @@ -3,6 +3,7 @@ namespace Square.TeamMembers.WageSetting; +[Serializable] public record UpdateWageSettingRequest { /// diff --git a/src/Square/TeamMembers/WageSetting/WageSettingClient.cs b/src/Square/TeamMembers/WageSetting/WageSettingClient.cs index c911ce5e..7b26b13b 100644 --- a/src/Square/TeamMembers/WageSetting/WageSettingClient.cs +++ b/src/Square/TeamMembers/WageSetting/WageSettingClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Terminal/Actions/ActionsClient.cs b/src/Square/Terminal/Actions/ActionsClient.cs index 0c12bbdc..40c1c59e 100644 --- a/src/Square/Terminal/Actions/ActionsClient.cs +++ b/src/Square/Terminal/Actions/ActionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Terminal/Actions/Requests/CancelActionsRequest.cs b/src/Square/Terminal/Actions/Requests/CancelActionsRequest.cs index f95070a9..6ca7c6bd 100644 --- a/src/Square/Terminal/Actions/Requests/CancelActionsRequest.cs +++ b/src/Square/Terminal/Actions/Requests/CancelActionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal.Actions; +[Serializable] public record CancelActionsRequest { /// diff --git a/src/Square/Terminal/Actions/Requests/CreateTerminalActionRequest.cs b/src/Square/Terminal/Actions/Requests/CreateTerminalActionRequest.cs index 10939771..23ce9dde 100644 --- a/src/Square/Terminal/Actions/Requests/CreateTerminalActionRequest.cs +++ b/src/Square/Terminal/Actions/Requests/CreateTerminalActionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Terminal.Actions; +[Serializable] public record CreateTerminalActionRequest { /// diff --git a/src/Square/Terminal/Actions/Requests/GetActionsRequest.cs b/src/Square/Terminal/Actions/Requests/GetActionsRequest.cs index 64479216..b4dc4590 100644 --- a/src/Square/Terminal/Actions/Requests/GetActionsRequest.cs +++ b/src/Square/Terminal/Actions/Requests/GetActionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal.Actions; +[Serializable] public record GetActionsRequest { /// diff --git a/src/Square/Terminal/Actions/Requests/SearchTerminalActionsRequest.cs b/src/Square/Terminal/Actions/Requests/SearchTerminalActionsRequest.cs index 22aa632c..41e838c3 100644 --- a/src/Square/Terminal/Actions/Requests/SearchTerminalActionsRequest.cs +++ b/src/Square/Terminal/Actions/Requests/SearchTerminalActionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Terminal.Actions; +[Serializable] public record SearchTerminalActionsRequest { /// diff --git a/src/Square/Terminal/Checkouts/CheckoutsClient.cs b/src/Square/Terminal/Checkouts/CheckoutsClient.cs index d3955cad..d165f34d 100644 --- a/src/Square/Terminal/Checkouts/CheckoutsClient.cs +++ b/src/Square/Terminal/Checkouts/CheckoutsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Terminal/Checkouts/Requests/CancelCheckoutsRequest.cs b/src/Square/Terminal/Checkouts/Requests/CancelCheckoutsRequest.cs index 488fd374..54ee7f68 100644 --- a/src/Square/Terminal/Checkouts/Requests/CancelCheckoutsRequest.cs +++ b/src/Square/Terminal/Checkouts/Requests/CancelCheckoutsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal.Checkouts; +[Serializable] public record CancelCheckoutsRequest { /// diff --git a/src/Square/Terminal/Checkouts/Requests/CreateTerminalCheckoutRequest.cs b/src/Square/Terminal/Checkouts/Requests/CreateTerminalCheckoutRequest.cs index f871faae..b7fc6e4f 100644 --- a/src/Square/Terminal/Checkouts/Requests/CreateTerminalCheckoutRequest.cs +++ b/src/Square/Terminal/Checkouts/Requests/CreateTerminalCheckoutRequest.cs @@ -4,6 +4,7 @@ namespace Square.Terminal.Checkouts; +[Serializable] public record CreateTerminalCheckoutRequest { /// diff --git a/src/Square/Terminal/Checkouts/Requests/GetCheckoutsRequest.cs b/src/Square/Terminal/Checkouts/Requests/GetCheckoutsRequest.cs index fac81bfe..7b69a813 100644 --- a/src/Square/Terminal/Checkouts/Requests/GetCheckoutsRequest.cs +++ b/src/Square/Terminal/Checkouts/Requests/GetCheckoutsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal.Checkouts; +[Serializable] public record GetCheckoutsRequest { /// diff --git a/src/Square/Terminal/Checkouts/Requests/SearchTerminalCheckoutsRequest.cs b/src/Square/Terminal/Checkouts/Requests/SearchTerminalCheckoutsRequest.cs index d97b86d7..54ad07be 100644 --- a/src/Square/Terminal/Checkouts/Requests/SearchTerminalCheckoutsRequest.cs +++ b/src/Square/Terminal/Checkouts/Requests/SearchTerminalCheckoutsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Terminal.Checkouts; +[Serializable] public record SearchTerminalCheckoutsRequest { /// diff --git a/src/Square/Terminal/Refunds/RefundsClient.cs b/src/Square/Terminal/Refunds/RefundsClient.cs index eec4583e..0c36faf1 100644 --- a/src/Square/Terminal/Refunds/RefundsClient.cs +++ b/src/Square/Terminal/Refunds/RefundsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -139,7 +140,7 @@ public async Task SearchAsync( /// /// /// await client.Terminal.Refunds.GetAsync( - /// new GetRefundsRequest { TerminalRefundId = "terminal_refund_id" } + /// new Square.Terminal.Refunds.GetRefundsRequest { TerminalRefundId = "terminal_refund_id" } /// ); /// public async Task GetAsync( diff --git a/src/Square/Terminal/Refunds/Requests/CancelRefundsRequest.cs b/src/Square/Terminal/Refunds/Requests/CancelRefundsRequest.cs index c1636846..2a798fa4 100644 --- a/src/Square/Terminal/Refunds/Requests/CancelRefundsRequest.cs +++ b/src/Square/Terminal/Refunds/Requests/CancelRefundsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal.Refunds; +[Serializable] public record CancelRefundsRequest { /// diff --git a/src/Square/Terminal/Refunds/Requests/CreateTerminalRefundRequest.cs b/src/Square/Terminal/Refunds/Requests/CreateTerminalRefundRequest.cs index 1c9b4eb1..8ce3e653 100644 --- a/src/Square/Terminal/Refunds/Requests/CreateTerminalRefundRequest.cs +++ b/src/Square/Terminal/Refunds/Requests/CreateTerminalRefundRequest.cs @@ -4,6 +4,7 @@ namespace Square.Terminal.Refunds; +[Serializable] public record CreateTerminalRefundRequest { /// diff --git a/src/Square/Terminal/Refunds/Requests/GetRefundsRequest.cs b/src/Square/Terminal/Refunds/Requests/GetRefundsRequest.cs index 6e87795a..e66a975e 100644 --- a/src/Square/Terminal/Refunds/Requests/GetRefundsRequest.cs +++ b/src/Square/Terminal/Refunds/Requests/GetRefundsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal.Refunds; +[Serializable] public record GetRefundsRequest { /// diff --git a/src/Square/Terminal/Refunds/Requests/SearchTerminalRefundsRequest.cs b/src/Square/Terminal/Refunds/Requests/SearchTerminalRefundsRequest.cs index 8baecdc3..24c56950 100644 --- a/src/Square/Terminal/Refunds/Requests/SearchTerminalRefundsRequest.cs +++ b/src/Square/Terminal/Refunds/Requests/SearchTerminalRefundsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Terminal.Refunds; +[Serializable] public record SearchTerminalRefundsRequest { /// diff --git a/src/Square/Terminal/Requests/DismissTerminalActionRequest.cs b/src/Square/Terminal/Requests/DismissTerminalActionRequest.cs index ca7d2eff..bded9e8e 100644 --- a/src/Square/Terminal/Requests/DismissTerminalActionRequest.cs +++ b/src/Square/Terminal/Requests/DismissTerminalActionRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal; +[Serializable] public record DismissTerminalActionRequest { /// diff --git a/src/Square/Terminal/Requests/DismissTerminalCheckoutRequest.cs b/src/Square/Terminal/Requests/DismissTerminalCheckoutRequest.cs index 3949a24c..7af610a1 100644 --- a/src/Square/Terminal/Requests/DismissTerminalCheckoutRequest.cs +++ b/src/Square/Terminal/Requests/DismissTerminalCheckoutRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal; +[Serializable] public record DismissTerminalCheckoutRequest { /// diff --git a/src/Square/Terminal/Requests/DismissTerminalRefundRequest.cs b/src/Square/Terminal/Requests/DismissTerminalRefundRequest.cs index 6d6861f7..95ff9dc5 100644 --- a/src/Square/Terminal/Requests/DismissTerminalRefundRequest.cs +++ b/src/Square/Terminal/Requests/DismissTerminalRefundRequest.cs @@ -3,6 +3,7 @@ namespace Square.Terminal; +[Serializable] public record DismissTerminalRefundRequest { /// diff --git a/src/Square/Terminal/TerminalClient.cs b/src/Square/Terminal/TerminalClient.cs index 96b6ca35..be09e8f4 100644 --- a/src/Square/Terminal/TerminalClient.cs +++ b/src/Square/Terminal/TerminalClient.cs @@ -1,11 +1,11 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; using Square.Terminal.Actions; using Square.Terminal.Checkouts; -using Square.Terminal.Refunds; namespace Square.Terminal; @@ -18,14 +18,14 @@ internal TerminalClient(RawClient client) _client = client; Actions = new ActionsClient(_client); Checkouts = new CheckoutsClient(_client); - Refunds = new RefundsClient(_client); + Refunds = new Square.Terminal.Refunds.RefundsClient(_client); } public ActionsClient Actions { get; } public CheckoutsClient Checkouts { get; } - public RefundsClient Refunds { get; } + public Square.Terminal.Refunds.RefundsClient Refunds { get; } /// /// Dismisses a Terminal action request if the status and type of the request permits it. diff --git a/src/Square/TransferOrders/Requests/CancelTransferOrderRequest.cs b/src/Square/TransferOrders/Requests/CancelTransferOrderRequest.cs index c9a3a9d1..4f3283b2 100644 --- a/src/Square/TransferOrders/Requests/CancelTransferOrderRequest.cs +++ b/src/Square/TransferOrders/Requests/CancelTransferOrderRequest.cs @@ -3,6 +3,7 @@ namespace Square.TransferOrders; +[Serializable] public record CancelTransferOrderRequest { /// diff --git a/src/Square/TransferOrders/Requests/CreateTransferOrderRequest.cs b/src/Square/TransferOrders/Requests/CreateTransferOrderRequest.cs index 4e860b4f..1ea1ee8a 100644 --- a/src/Square/TransferOrders/Requests/CreateTransferOrderRequest.cs +++ b/src/Square/TransferOrders/Requests/CreateTransferOrderRequest.cs @@ -4,6 +4,7 @@ namespace Square.TransferOrders; +[Serializable] public record CreateTransferOrderRequest { /// diff --git a/src/Square/TransferOrders/Requests/DeleteTransferOrdersRequest.cs b/src/Square/TransferOrders/Requests/DeleteTransferOrdersRequest.cs index 1e4d7da9..12d66cb9 100644 --- a/src/Square/TransferOrders/Requests/DeleteTransferOrdersRequest.cs +++ b/src/Square/TransferOrders/Requests/DeleteTransferOrdersRequest.cs @@ -3,6 +3,7 @@ namespace Square.TransferOrders; +[Serializable] public record DeleteTransferOrdersRequest { /// diff --git a/src/Square/TransferOrders/Requests/GetTransferOrdersRequest.cs b/src/Square/TransferOrders/Requests/GetTransferOrdersRequest.cs index 7b5b83e0..20b21a05 100644 --- a/src/Square/TransferOrders/Requests/GetTransferOrdersRequest.cs +++ b/src/Square/TransferOrders/Requests/GetTransferOrdersRequest.cs @@ -3,6 +3,7 @@ namespace Square.TransferOrders; +[Serializable] public record GetTransferOrdersRequest { /// diff --git a/src/Square/TransferOrders/Requests/ReceiveTransferOrderRequest.cs b/src/Square/TransferOrders/Requests/ReceiveTransferOrderRequest.cs index 1134afa6..4b7b871b 100644 --- a/src/Square/TransferOrders/Requests/ReceiveTransferOrderRequest.cs +++ b/src/Square/TransferOrders/Requests/ReceiveTransferOrderRequest.cs @@ -4,6 +4,7 @@ namespace Square.TransferOrders; +[Serializable] public record ReceiveTransferOrderRequest { /// diff --git a/src/Square/TransferOrders/Requests/SearchTransferOrdersRequest.cs b/src/Square/TransferOrders/Requests/SearchTransferOrdersRequest.cs index 39744afa..900760a4 100644 --- a/src/Square/TransferOrders/Requests/SearchTransferOrdersRequest.cs +++ b/src/Square/TransferOrders/Requests/SearchTransferOrdersRequest.cs @@ -4,6 +4,7 @@ namespace Square.TransferOrders; +[Serializable] public record SearchTransferOrdersRequest { /// diff --git a/src/Square/TransferOrders/Requests/StartTransferOrderRequest.cs b/src/Square/TransferOrders/Requests/StartTransferOrderRequest.cs index 34e71227..0ad18304 100644 --- a/src/Square/TransferOrders/Requests/StartTransferOrderRequest.cs +++ b/src/Square/TransferOrders/Requests/StartTransferOrderRequest.cs @@ -3,6 +3,7 @@ namespace Square.TransferOrders; +[Serializable] public record StartTransferOrderRequest { /// diff --git a/src/Square/TransferOrders/Requests/UpdateTransferOrderRequest.cs b/src/Square/TransferOrders/Requests/UpdateTransferOrderRequest.cs index 7370eb1f..a9b72ef6 100644 --- a/src/Square/TransferOrders/Requests/UpdateTransferOrderRequest.cs +++ b/src/Square/TransferOrders/Requests/UpdateTransferOrderRequest.cs @@ -4,6 +4,7 @@ namespace Square.TransferOrders; +[Serializable] public record UpdateTransferOrderRequest { /// diff --git a/src/Square/TransferOrders/TransferOrdersClient.cs b/src/Square/TransferOrders/TransferOrdersClient.cs index 9320cdea..aab8389e 100644 --- a/src/Square/TransferOrders/TransferOrdersClient.cs +++ b/src/Square/TransferOrders/TransferOrdersClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Types/AcceptDisputeResponse.cs b/src/Square/Types/AcceptDisputeResponse.cs index 409251d1..a8ff3780 100644 --- a/src/Square/Types/AcceptDisputeResponse.cs +++ b/src/Square/Types/AcceptDisputeResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the fields in an `AcceptDispute` response. /// -public record AcceptDisputeResponse +[Serializable] +public record AcceptDisputeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record AcceptDisputeResponse [JsonPropertyName("dispute")] public Dispute? Dispute { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/AcceptedPaymentMethods.cs b/src/Square/Types/AcceptedPaymentMethods.cs index d811b2ea..371051f6 100644 --- a/src/Square/Types/AcceptedPaymentMethods.cs +++ b/src/Square/Types/AcceptedPaymentMethods.cs @@ -4,8 +4,13 @@ namespace Square; -public record AcceptedPaymentMethods +[Serializable] +public record AcceptedPaymentMethods : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Whether Apple Pay is accepted at checkout. /// @@ -30,15 +35,11 @@ public record AcceptedPaymentMethods [JsonPropertyName("afterpay_clearpay")] public bool? AfterpayClearpay { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/AccumulateLoyaltyPointsResponse.cs b/src/Square/Types/AccumulateLoyaltyPointsResponse.cs index 62dd6b92..0f60a13e 100644 --- a/src/Square/Types/AccumulateLoyaltyPointsResponse.cs +++ b/src/Square/Types/AccumulateLoyaltyPointsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an [AccumulateLoyaltyPoints](api-endpoint:Loyalty-AccumulateLoyaltyPoints) response. /// -public record AccumulateLoyaltyPointsResponse +[Serializable] +public record AccumulateLoyaltyPointsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -29,15 +34,11 @@ public record AccumulateLoyaltyPointsResponse [JsonPropertyName("events")] public IEnumerable? Events { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/AchDetails.cs b/src/Square/Types/AchDetails.cs index c947c61b..830d0f82 100644 --- a/src/Square/Types/AchDetails.cs +++ b/src/Square/Types/AchDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// ACH-specific details about `BANK_ACCOUNT` type payments with the `transfer_type` of `ACH`. /// -public record AchDetails +[Serializable] +public record AchDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The routing number for the bank account. /// @@ -28,15 +33,11 @@ public record AchDetails [JsonPropertyName("account_type")] public string? AccountType { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ActionCancelReason.cs b/src/Square/Types/ActionCancelReason.cs index a5fe9c1f..e2c086df 100644 --- a/src/Square/Types/ActionCancelReason.cs +++ b/src/Square/Types/ActionCancelReason.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ActionCancelReason : IStringEnum { public static readonly ActionCancelReason BuyerCanceled = new(Values.BuyerCanceled); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string BuyerCanceled = "BUYER_CANCELED"; diff --git a/src/Square/Types/ActivityType.cs b/src/Square/Types/ActivityType.cs index 1de2e01c..8c612334 100644 --- a/src/Square/Types/ActivityType.cs +++ b/src/Square/Types/ActivityType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ActivityType : IStringEnum { public static readonly ActivityType Adjustment = new(Values.Adjustment); @@ -196,6 +197,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Adjustment = "ADJUSTMENT"; diff --git a/src/Square/Types/AddGroupToCustomerResponse.cs b/src/Square/Types/AddGroupToCustomerResponse.cs index 33773ad7..2c5d7757 100644 --- a/src/Square/Types/AddGroupToCustomerResponse.cs +++ b/src/Square/Types/AddGroupToCustomerResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [AddGroupToCustomer](api-endpoint:Customers-AddGroupToCustomer) endpoint. /// -public record AddGroupToCustomerResponse +[Serializable] +public record AddGroupToCustomerResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/AdditionalRecipient.cs b/src/Square/Types/AdditionalRecipient.cs index 009815fb..a77751da 100644 --- a/src/Square/Types/AdditionalRecipient.cs +++ b/src/Square/Types/AdditionalRecipient.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an additional recipient (other than the merchant) receiving a portion of this tender. /// -public record AdditionalRecipient +[Serializable] +public record AdditionalRecipient : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The location ID for a recipient (other than the merchant) receiving a portion of this tender. /// @@ -33,15 +38,11 @@ public record AdditionalRecipient [JsonPropertyName("receivable_id")] public string? ReceivableId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Address.cs b/src/Square/Types/Address.cs index bfda020f..64065e61 100644 --- a/src/Square/Types/Address.cs +++ b/src/Square/Types/Address.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a postal address in a country. /// For more information, see [Working with Addresses](https://developer.squareup.com/docs/build-basics/working-with-addresses). /// -public record Address +[Serializable] +public record Address : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The first line of the address. /// @@ -103,15 +108,11 @@ public record Address [JsonPropertyName("last_name")] public string? LastName { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/AdjustLoyaltyPointsResponse.cs b/src/Square/Types/AdjustLoyaltyPointsResponse.cs index e439795c..c6f67bac 100644 --- a/src/Square/Types/AdjustLoyaltyPointsResponse.cs +++ b/src/Square/Types/AdjustLoyaltyPointsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an [AdjustLoyaltyPoints](api-endpoint:Loyalty-AdjustLoyaltyPoints) request. /// -public record AdjustLoyaltyPointsResponse +[Serializable] +public record AdjustLoyaltyPointsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record AdjustLoyaltyPointsResponse [JsonPropertyName("event")] public LoyaltyEvent? Event { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/AfterpayDetails.cs b/src/Square/Types/AfterpayDetails.cs index e068f611..ae411e5f 100644 --- a/src/Square/Types/AfterpayDetails.cs +++ b/src/Square/Types/AfterpayDetails.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Additional details about Afterpay payments. /// -public record AfterpayDetails +[Serializable] +public record AfterpayDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Email address on the buyer's Afterpay account. /// [JsonPropertyName("email_address")] public string? EmailAddress { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ApplicationDetails.cs b/src/Square/Types/ApplicationDetails.cs index 2bf0849b..9b2face4 100644 --- a/src/Square/Types/ApplicationDetails.cs +++ b/src/Square/Types/ApplicationDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Details about the application that took the payment. /// -public record ApplicationDetails +[Serializable] +public record ApplicationDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square product, such as Square Point of Sale (POS), /// Square Invoices, or Square Virtual Terminal. @@ -29,15 +34,11 @@ public record ApplicationDetails [JsonPropertyName("application_id")] public string? ApplicationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ApplicationDetailsExternalSquareProduct.cs b/src/Square/Types/ApplicationDetailsExternalSquareProduct.cs index 2d58be1a..34bb75ff 100644 --- a/src/Square/Types/ApplicationDetailsExternalSquareProduct.cs +++ b/src/Square/Types/ApplicationDetailsExternalSquareProduct.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ApplicationDetailsExternalSquareProduct : IStringEnum { public static readonly ApplicationDetailsExternalSquareProduct Appointments = new( @@ -86,6 +87,7 @@ public static explicit operator ApplicationDetailsExternalSquareProduct(string v /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Appointments = "APPOINTMENTS"; diff --git a/src/Square/Types/AppointmentSegment.cs b/src/Square/Types/AppointmentSegment.cs index 0cf73a36..bbc2206e 100644 --- a/src/Square/Types/AppointmentSegment.cs +++ b/src/Square/Types/AppointmentSegment.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines an appointment segment of a booking. /// -public record AppointmentSegment +[Serializable] +public record AppointmentSegment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The time span in minutes of an appointment segment. /// @@ -54,15 +59,11 @@ public record AppointmentSegment [JsonPropertyName("resource_ids")] public IEnumerable? ResourceIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ArchivedState.cs b/src/Square/Types/ArchivedState.cs index fce37e42..2ad09e43 100644 --- a/src/Square/Types/ArchivedState.cs +++ b/src/Square/Types/ArchivedState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ArchivedState : IStringEnum { public static readonly ArchivedState ArchivedStateNotArchived = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ArchivedStateNotArchived = "ARCHIVED_STATE_NOT_ARCHIVED"; diff --git a/src/Square/Types/Availability.cs b/src/Square/Types/Availability.cs index f9af227b..3d1ad796 100644 --- a/src/Square/Types/Availability.cs +++ b/src/Square/Types/Availability.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines an appointment slot that encapsulates the appointment segments, location and starting time available for booking. /// -public record Availability +[Serializable] +public record Availability : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The RFC 3339 timestamp specifying the beginning time of the slot available for booking. /// @@ -28,15 +33,11 @@ public record Availability [JsonPropertyName("appointment_segments")] public IEnumerable? AppointmentSegments { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccount.cs b/src/Square/Types/BankAccount.cs index 3b98fd26..ef98cd58 100644 --- a/src/Square/Types/BankAccount.cs +++ b/src/Square/Types/BankAccount.cs @@ -9,8 +9,13 @@ namespace Square; /// linking a bank account to a Square account, see /// [Bank Accounts API](https://developer.squareup.com/docs/bank-accounts-api). /// -public record BankAccount +[Serializable] +public record BankAccount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique, Square-issued identifier for the bank account. /// @@ -128,15 +133,11 @@ public record BankAccount [JsonPropertyName("bank_name")] public string? BankName { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountCreatedEvent.cs b/src/Square/Types/BankAccountCreatedEvent.cs index 86654d8c..f7198e5c 100644 --- a/src/Square/Types/BankAccountCreatedEvent.cs +++ b/src/Square/Types/BankAccountCreatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// account in the Seller Dashboard. Square sets the initial status to /// `VERIFICATION_IN_PROGRESS` and publishes the event. /// -public record BankAccountCreatedEvent +[Serializable] +public record BankAccountCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record BankAccountCreatedEvent [JsonPropertyName("data")] public BankAccountCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountCreatedEventData.cs b/src/Square/Types/BankAccountCreatedEventData.cs index af28bf76..e6d44f1b 100644 --- a/src/Square/Types/BankAccountCreatedEventData.cs +++ b/src/Square/Types/BankAccountCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record BankAccountCreatedEventData +[Serializable] +public record BankAccountCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"bank_account"`. /// @@ -24,15 +29,11 @@ public record BankAccountCreatedEventData [JsonPropertyName("object")] public BankAccountCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountCreatedEventObject.cs b/src/Square/Types/BankAccountCreatedEventObject.cs index 95c683f0..fe7dd543 100644 --- a/src/Square/Types/BankAccountCreatedEventObject.cs +++ b/src/Square/Types/BankAccountCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record BankAccountCreatedEventObject +[Serializable] +public record BankAccountCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created bank account. /// [JsonPropertyName("bank_account")] public BankAccount? BankAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountDisabledEvent.cs b/src/Square/Types/BankAccountDisabledEvent.cs index 0c0bb452..d69b80cc 100644 --- a/src/Square/Types/BankAccountDisabledEvent.cs +++ b/src/Square/Types/BankAccountDisabledEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when Square sets the status of a /// [BankAccount](entity:BankAccount) to `DISABLED`. /// -public record BankAccountDisabledEvent +[Serializable] +public record BankAccountDisabledEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -47,15 +52,11 @@ public record BankAccountDisabledEvent [JsonPropertyName("data")] public BankAccountDisabledEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountDisabledEventData.cs b/src/Square/Types/BankAccountDisabledEventData.cs index d9ffb7eb..3b1d8422 100644 --- a/src/Square/Types/BankAccountDisabledEventData.cs +++ b/src/Square/Types/BankAccountDisabledEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record BankAccountDisabledEventData +[Serializable] +public record BankAccountDisabledEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"bank_account"`. /// @@ -24,15 +29,11 @@ public record BankAccountDisabledEventData [JsonPropertyName("object")] public BankAccountDisabledEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountDisabledEventObject.cs b/src/Square/Types/BankAccountDisabledEventObject.cs index fff64c58..dbad600b 100644 --- a/src/Square/Types/BankAccountDisabledEventObject.cs +++ b/src/Square/Types/BankAccountDisabledEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record BankAccountDisabledEventObject +[Serializable] +public record BankAccountDisabledEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The disabled bank account. /// [JsonPropertyName("bank_account")] public BankAccount? BankAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountPaymentDetails.cs b/src/Square/Types/BankAccountPaymentDetails.cs index 48cf5a45..a92c0e7a 100644 --- a/src/Square/Types/BankAccountPaymentDetails.cs +++ b/src/Square/Types/BankAccountPaymentDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Additional details about BANK_ACCOUNT type payments. /// -public record BankAccountPaymentDetails +[Serializable] +public record BankAccountPaymentDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the bank associated with the bank account. /// @@ -60,15 +65,11 @@ public record BankAccountPaymentDetails [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountStatus.cs b/src/Square/Types/BankAccountStatus.cs index 59191aa0..70b293f0 100644 --- a/src/Square/Types/BankAccountStatus.cs +++ b/src/Square/Types/BankAccountStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BankAccountStatus : IStringEnum { public static readonly BankAccountStatus VerificationInProgress = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string VerificationInProgress = "VERIFICATION_IN_PROGRESS"; diff --git a/src/Square/Types/BankAccountType.cs b/src/Square/Types/BankAccountType.cs index a224ce0b..0a3efd7b 100644 --- a/src/Square/Types/BankAccountType.cs +++ b/src/Square/Types/BankAccountType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BankAccountType : IStringEnum { public static readonly BankAccountType Checking = new(Values.Checking); @@ -60,6 +61,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Checking = "CHECKING"; diff --git a/src/Square/Types/BankAccountVerifiedEvent.cs b/src/Square/Types/BankAccountVerifiedEvent.cs index 41fc5bb8..959b5247 100644 --- a/src/Square/Types/BankAccountVerifiedEvent.cs +++ b/src/Square/Types/BankAccountVerifiedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when Square sets the status of a /// [BankAccount](entity:BankAccount) to `VERIFIED`. /// -public record BankAccountVerifiedEvent +[Serializable] +public record BankAccountVerifiedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -47,15 +52,11 @@ public record BankAccountVerifiedEvent [JsonPropertyName("data")] public BankAccountVerifiedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountVerifiedEventData.cs b/src/Square/Types/BankAccountVerifiedEventData.cs index 42ff4c84..fa511775 100644 --- a/src/Square/Types/BankAccountVerifiedEventData.cs +++ b/src/Square/Types/BankAccountVerifiedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record BankAccountVerifiedEventData +[Serializable] +public record BankAccountVerifiedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"bank_account"`. /// @@ -24,15 +29,11 @@ public record BankAccountVerifiedEventData [JsonPropertyName("object")] public BankAccountVerifiedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BankAccountVerifiedEventObject.cs b/src/Square/Types/BankAccountVerifiedEventObject.cs index a1a6d136..808a05bc 100644 --- a/src/Square/Types/BankAccountVerifiedEventObject.cs +++ b/src/Square/Types/BankAccountVerifiedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record BankAccountVerifiedEventObject +[Serializable] +public record BankAccountVerifiedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The verified bank account. /// [JsonPropertyName("bank_account")] public BankAccount? BankAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchChangeInventoryRequest.cs b/src/Square/Types/BatchChangeInventoryRequest.cs index becdc46b..51f2884e 100644 --- a/src/Square/Types/BatchChangeInventoryRequest.cs +++ b/src/Square/Types/BatchChangeInventoryRequest.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchChangeInventoryRequest +[Serializable] +public record BatchChangeInventoryRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A client-supplied, universally unique identifier (UUID) for the /// request. @@ -32,15 +37,11 @@ public record BatchChangeInventoryRequest [JsonPropertyName("ignore_unchanged_counts")] public bool? IgnoreUnchangedCounts { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchChangeInventoryResponse.cs b/src/Square/Types/BatchChangeInventoryResponse.cs index 8ecbb1d6..c66c1514 100644 --- a/src/Square/Types/BatchChangeInventoryResponse.cs +++ b/src/Square/Types/BatchChangeInventoryResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchChangeInventoryResponse +[Serializable] +public record BatchChangeInventoryResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record BatchChangeInventoryResponse [JsonPropertyName("changes")] public IEnumerable? Changes { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchCreateTeamMembersResponse.cs b/src/Square/Types/BatchCreateTeamMembersResponse.cs index ff3e4933..87e38586 100644 --- a/src/Square/Types/BatchCreateTeamMembersResponse.cs +++ b/src/Square/Types/BatchCreateTeamMembersResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a bulk create request containing the created `TeamMember` objects or error messages. /// -public record BatchCreateTeamMembersResponse +[Serializable] +public record BatchCreateTeamMembersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully created `TeamMember` objects. Each key is the `idempotency_key` that maps to the `CreateTeamMemberRequest`. /// @@ -21,15 +26,11 @@ public record BatchCreateTeamMembersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchCreateVendorsResponse.cs b/src/Square/Types/BatchCreateVendorsResponse.cs index 00ad9ffc..08028442 100644 --- a/src/Square/Types/BatchCreateVendorsResponse.cs +++ b/src/Square/Types/BatchCreateVendorsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [BulkCreateVendors](api-endpoint:Vendors-BulkCreateVendors). /// -public record BatchCreateVendorsResponse +[Serializable] +public record BatchCreateVendorsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record BatchCreateVendorsResponse [JsonPropertyName("responses")] public Dictionary? Responses { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchDeleteCatalogObjectsResponse.cs b/src/Square/Types/BatchDeleteCatalogObjectsResponse.cs index 50684909..423a5043 100644 --- a/src/Square/Types/BatchDeleteCatalogObjectsResponse.cs +++ b/src/Square/Types/BatchDeleteCatalogObjectsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchDeleteCatalogObjectsResponse +[Serializable] +public record BatchDeleteCatalogObjectsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record BatchDeleteCatalogObjectsResponse [JsonPropertyName("deleted_at")] public string? DeletedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchGetCatalogObjectsResponse.cs b/src/Square/Types/BatchGetCatalogObjectsResponse.cs index 438c6c8d..ba7168d7 100644 --- a/src/Square/Types/BatchGetCatalogObjectsResponse.cs +++ b/src/Square/Types/BatchGetCatalogObjectsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchGetCatalogObjectsResponse +[Serializable] +public record BatchGetCatalogObjectsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record BatchGetCatalogObjectsResponse [JsonPropertyName("related_objects")] public IEnumerable? RelatedObjects { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchGetInventoryChangesResponse.cs b/src/Square/Types/BatchGetInventoryChangesResponse.cs index 064dc99b..54c1f22b 100644 --- a/src/Square/Types/BatchGetInventoryChangesResponse.cs +++ b/src/Square/Types/BatchGetInventoryChangesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchGetInventoryChangesResponse +[Serializable] +public record BatchGetInventoryChangesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -27,15 +32,11 @@ public record BatchGetInventoryChangesResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchGetInventoryCountsRequest.cs b/src/Square/Types/BatchGetInventoryCountsRequest.cs index de894887..7b5caf0b 100644 --- a/src/Square/Types/BatchGetInventoryCountsRequest.cs +++ b/src/Square/Types/BatchGetInventoryCountsRequest.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchGetInventoryCountsRequest +[Serializable] +public record BatchGetInventoryCountsRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The filter to return results by `CatalogObject` ID. /// The filter is applicable only when set. The default is null. @@ -51,15 +56,11 @@ public record BatchGetInventoryCountsRequest [JsonPropertyName("limit")] public int? Limit { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchGetInventoryCountsResponse.cs b/src/Square/Types/BatchGetInventoryCountsResponse.cs index 73043cf2..0154ba81 100644 --- a/src/Square/Types/BatchGetInventoryCountsResponse.cs +++ b/src/Square/Types/BatchGetInventoryCountsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchGetInventoryCountsResponse +[Serializable] +public record BatchGetInventoryCountsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -28,15 +33,11 @@ public record BatchGetInventoryCountsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchGetOrdersResponse.cs b/src/Square/Types/BatchGetOrdersResponse.cs index 105f1b5d..21e72463 100644 --- a/src/Square/Types/BatchGetOrdersResponse.cs +++ b/src/Square/Types/BatchGetOrdersResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the `BatchRetrieveOrders` endpoint. /// -public record BatchGetOrdersResponse +[Serializable] +public record BatchGetOrdersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested orders. This will omit any requested orders that do not exist. /// @@ -22,15 +27,11 @@ public record BatchGetOrdersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchGetVendorsResponse.cs b/src/Square/Types/BatchGetVendorsResponse.cs index 30df18df..a885db23 100644 --- a/src/Square/Types/BatchGetVendorsResponse.cs +++ b/src/Square/Types/BatchGetVendorsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [BulkRetrieveVendors](api-endpoint:Vendors-BulkRetrieveVendors). /// -public record BatchGetVendorsResponse +[Serializable] +public record BatchGetVendorsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -23,15 +28,11 @@ public record BatchGetVendorsResponse [JsonPropertyName("responses")] public Dictionary? Responses { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchRetrieveInventoryChangesRequest.cs b/src/Square/Types/BatchRetrieveInventoryChangesRequest.cs index 73fbec46..137bce5d 100644 --- a/src/Square/Types/BatchRetrieveInventoryChangesRequest.cs +++ b/src/Square/Types/BatchRetrieveInventoryChangesRequest.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchRetrieveInventoryChangesRequest +[Serializable] +public record BatchRetrieveInventoryChangesRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The filter to return results by `CatalogObject` ID. /// The filter is only applicable when set. The default value is null. @@ -66,15 +71,11 @@ public record BatchRetrieveInventoryChangesRequest [JsonPropertyName("limit")] public int? Limit { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchUpdateTeamMembersResponse.cs b/src/Square/Types/BatchUpdateTeamMembersResponse.cs index 7991eaf4..1a64d7cf 100644 --- a/src/Square/Types/BatchUpdateTeamMembersResponse.cs +++ b/src/Square/Types/BatchUpdateTeamMembersResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a bulk update request containing the updated `TeamMember` objects or error messages. /// -public record BatchUpdateTeamMembersResponse +[Serializable] +public record BatchUpdateTeamMembersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully updated `TeamMember` objects. Each key is the `team_member_id` that maps to the `UpdateTeamMemberRequest`. /// @@ -21,15 +26,11 @@ public record BatchUpdateTeamMembersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchUpdateVendorsResponse.cs b/src/Square/Types/BatchUpdateVendorsResponse.cs index f80a7e6c..40699313 100644 --- a/src/Square/Types/BatchUpdateVendorsResponse.cs +++ b/src/Square/Types/BatchUpdateVendorsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [BulkUpdateVendors](api-endpoint:Vendors-BulkUpdateVendors). /// -public record BatchUpdateVendorsResponse +[Serializable] +public record BatchUpdateVendorsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered when the request fails. /// @@ -23,15 +28,11 @@ public record BatchUpdateVendorsResponse [JsonPropertyName("responses")] public Dictionary? Responses { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchUpsertCatalogObjectsResponse.cs b/src/Square/Types/BatchUpsertCatalogObjectsResponse.cs index 3d0c446c..7ddbd3f1 100644 --- a/src/Square/Types/BatchUpsertCatalogObjectsResponse.cs +++ b/src/Square/Types/BatchUpsertCatalogObjectsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record BatchUpsertCatalogObjectsResponse +[Serializable] +public record BatchUpsertCatalogObjectsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -30,15 +35,11 @@ public record BatchUpsertCatalogObjectsResponse [JsonPropertyName("id_mappings")] public IEnumerable? IdMappings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest.cs b/src/Square/Types/BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest.cs index 6c1c0242..ce0cc62e 100644 --- a/src/Square/Types/BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest.cs +++ b/src/Square/Types/BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest.cs @@ -9,8 +9,14 @@ namespace Square; /// request. An individual request contains a customer ID, the custom attribute to create or update, /// and an optional idempotency key. /// +[Serializable] public record BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeUpsertRequest + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target [customer profile](entity:Customer). /// @@ -40,15 +46,11 @@ public record BatchUpsertCustomerCustomAttributesRequestCustomerCustomAttributeU [JsonPropertyName("idempotency_key")] public string? IdempotencyKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchUpsertCustomerCustomAttributesResponse.cs b/src/Square/Types/BatchUpsertCustomerCustomAttributesResponse.cs index 7bdd1727..d79a270c 100644 --- a/src/Square/Types/BatchUpsertCustomerCustomAttributesResponse.cs +++ b/src/Square/Types/BatchUpsertCustomerCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkUpsertCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-BulkUpsertCustomerCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual upsert request. /// -public record BatchUpsertCustomerCustomAttributesResponse +[Serializable] +public record BatchUpsertCustomerCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual upsert requests. Each response has the /// same ID as the corresponding request and contains either a `customer_id` and `custom_attribute` or an `errors` field. @@ -26,15 +31,11 @@ public Dictionary< [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttributeUpsertResponse.cs b/src/Square/Types/BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttributeUpsertResponse.cs index 51a48a78..d50df159 100644 --- a/src/Square/Types/BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttributeUpsertResponse.cs +++ b/src/Square/Types/BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttributeUpsertResponse.cs @@ -7,8 +7,14 @@ namespace Square; /// /// Represents a response for an individual upsert request in a [BulkUpsertCustomerCustomAttributes](api-endpoint:CustomerCustomAttributes-BulkUpsertCustomerCustomAttributes) operation. /// +[Serializable] public record BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttributeUpsertResponse + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the customer profile associated with the custom attribute. /// @@ -27,15 +33,11 @@ public record BatchUpsertCustomerCustomAttributesResponseCustomerCustomAttribute [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Booking.cs b/src/Square/Types/Booking.cs index e704182b..c5fc0b38 100644 --- a/src/Square/Types/Booking.cs +++ b/src/Square/Types/Booking.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a booking as a time-bound service contract for a seller's staff member to provide a specified service /// at a given location to a requesting customer in one or more appointment segments. /// -public record Booking +[Serializable] +public record Booking : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID of this object representing a booking. /// @@ -123,15 +128,11 @@ public record Booking [JsonPropertyName("address")] public Address? Address { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingBookingSource.cs b/src/Square/Types/BookingBookingSource.cs index bfb947c6..fdfe1ee9 100644 --- a/src/Square/Types/BookingBookingSource.cs +++ b/src/Square/Types/BookingBookingSource.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BookingBookingSource : IStringEnum { public static readonly BookingBookingSource FirstPartyMerchant = new(Values.FirstPartyMerchant); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string FirstPartyMerchant = "FIRST_PARTY_MERCHANT"; diff --git a/src/Square/Types/BookingCreatedEvent.cs b/src/Square/Types/BookingCreatedEvent.cs index 525f2902..7f623d08 100644 --- a/src/Square/Types/BookingCreatedEvent.cs +++ b/src/Square/Types/BookingCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// To receive this event with buyer-level permissions, you must have `APPOINTMENTS_READ` set for the OAuth scope. /// To receive this event with seller-level permissions, you must have `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` set for the OAuth scope. /// -public record BookingCreatedEvent +[Serializable] +public record BookingCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -43,15 +48,11 @@ public record BookingCreatedEvent [JsonPropertyName("data")] public BookingCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCreatedEventData.cs b/src/Square/Types/BookingCreatedEventData.cs index e4d0e4ca..2fac79ae 100644 --- a/src/Square/Types/BookingCreatedEventData.cs +++ b/src/Square/Types/BookingCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record BookingCreatedEventData +[Serializable] +public record BookingCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"booking"`. /// @@ -24,15 +29,11 @@ public record BookingCreatedEventData [JsonPropertyName("object")] public BookingCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCreatedEventObject.cs b/src/Square/Types/BookingCreatedEventObject.cs index 46dce9f0..cdd8388e 100644 --- a/src/Square/Types/BookingCreatedEventObject.cs +++ b/src/Square/Types/BookingCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record BookingCreatedEventObject +[Serializable] +public record BookingCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created booking. /// [JsonPropertyName("booking")] public Booking? Booking { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCreatorDetails.cs b/src/Square/Types/BookingCreatorDetails.cs index 03d29a84..58cb90a4 100644 --- a/src/Square/Types/BookingCreatorDetails.cs +++ b/src/Square/Types/BookingCreatorDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Information about a booking creator. /// -public record BookingCreatorDetails +[Serializable] +public record BookingCreatorDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The seller-accessible type of the creator of the booking. /// See [BookingCreatorDetailsCreatorType](#type-bookingcreatordetailscreatortype) for possible values @@ -32,15 +37,11 @@ public record BookingCreatorDetails [JsonPropertyName("customer_id")] public string? CustomerId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCreatorDetailsCreatorType.cs b/src/Square/Types/BookingCreatorDetailsCreatorType.cs index 81c8537f..bbb2223c 100644 --- a/src/Square/Types/BookingCreatorDetailsCreatorType.cs +++ b/src/Square/Types/BookingCreatorDetailsCreatorType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BookingCreatorDetailsCreatorType : IStringEnum { public static readonly BookingCreatorDetailsCreatorType TeamMember = new(Values.TeamMember); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string TeamMember = "TEAM_MEMBER"; diff --git a/src/Square/Types/BookingCustomAttributeDefinitionOwnedCreatedEvent.cs b/src/Square/Types/BookingCustomAttributeDefinitionOwnedCreatedEvent.cs index ae8e776d..b83793ca 100644 --- a/src/Square/Types/BookingCustomAttributeDefinitionOwnedCreatedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeDefinitionOwnedCreatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is created by the subscribing application. Subscribe to this event to be notified /// when your application creates a booking custom attribute definition. /// -public record BookingCustomAttributeDefinitionOwnedCreatedEvent +[Serializable] +public record BookingCustomAttributeDefinitionOwnedCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record BookingCustomAttributeDefinitionOwnedCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDefinitionOwnedDeletedEvent.cs b/src/Square/Types/BookingCustomAttributeDefinitionOwnedDeletedEvent.cs index dfc6b6ff..16a4f55f 100644 --- a/src/Square/Types/BookingCustomAttributeDefinitionOwnedDeletedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeDefinitionOwnedDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is deleted by the subscribing application. Subscribe to this event to be notified /// when your application deletes a booking custom attribute definition. /// -public record BookingCustomAttributeDefinitionOwnedDeletedEvent +[Serializable] +public record BookingCustomAttributeDefinitionOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record BookingCustomAttributeDefinitionOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDefinitionOwnedUpdatedEvent.cs b/src/Square/Types/BookingCustomAttributeDefinitionOwnedUpdatedEvent.cs index 8b51dfa7..4187aec0 100644 --- a/src/Square/Types/BookingCustomAttributeDefinitionOwnedUpdatedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeDefinitionOwnedUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is updated by the subscribing application. Subscribe to this event to be notified /// when your application updates a booking custom attribute definition. /// -public record BookingCustomAttributeDefinitionOwnedUpdatedEvent +[Serializable] +public record BookingCustomAttributeDefinitionOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record BookingCustomAttributeDefinitionOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDefinitionVisibleCreatedEvent.cs b/src/Square/Types/BookingCustomAttributeDefinitionVisibleCreatedEvent.cs index 7632ec5a..4f8f5570 100644 --- a/src/Square/Types/BookingCustomAttributeDefinitionVisibleCreatedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeDefinitionVisibleCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a booking custom attribute definition is created /// by any application for which the subscribing application has read access to the booking custom attribute definition. /// -public record BookingCustomAttributeDefinitionVisibleCreatedEvent +[Serializable] +public record BookingCustomAttributeDefinitionVisibleCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record BookingCustomAttributeDefinitionVisibleCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDefinitionVisibleDeletedEvent.cs b/src/Square/Types/BookingCustomAttributeDefinitionVisibleDeletedEvent.cs index 53496bfc..eeedd411 100644 --- a/src/Square/Types/BookingCustomAttributeDefinitionVisibleDeletedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeDefinitionVisibleDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a booking custom attribute definition is deleted /// by any application for which the subscribing application has read access to the booking custom attribute definition. /// -public record BookingCustomAttributeDefinitionVisibleDeletedEvent +[Serializable] +public record BookingCustomAttributeDefinitionVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record BookingCustomAttributeDefinitionVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDefinitionVisibleUpdatedEvent.cs b/src/Square/Types/BookingCustomAttributeDefinitionVisibleUpdatedEvent.cs index dc06328d..475d42ac 100644 --- a/src/Square/Types/BookingCustomAttributeDefinitionVisibleUpdatedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeDefinitionVisibleUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a booking custom attribute definition is updated /// by any application for which the subscribing application has read access to the booking custom attribute definition. /// -public record BookingCustomAttributeDefinitionVisibleUpdatedEvent +[Serializable] +public record BookingCustomAttributeDefinitionVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record BookingCustomAttributeDefinitionVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDeleteRequest.cs b/src/Square/Types/BookingCustomAttributeDeleteRequest.cs index 26aff62d..a7bccfab 100644 --- a/src/Square/Types/BookingCustomAttributeDeleteRequest.cs +++ b/src/Square/Types/BookingCustomAttributeDeleteRequest.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an individual delete request in a [BulkDeleteBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkDeleteBookingCustomAttributes) /// request. An individual request contains a booking ID, the custom attribute to delete, and an optional idempotency key. /// -public record BookingCustomAttributeDeleteRequest +[Serializable] +public record BookingCustomAttributeDeleteRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target [booking](entity:Booking). /// @@ -24,15 +29,11 @@ public record BookingCustomAttributeDeleteRequest [JsonPropertyName("key")] public required string Key { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeDeleteResponse.cs b/src/Square/Types/BookingCustomAttributeDeleteResponse.cs index d15a43ae..d23cc09f 100644 --- a/src/Square/Types/BookingCustomAttributeDeleteResponse.cs +++ b/src/Square/Types/BookingCustomAttributeDeleteResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response for an individual upsert request in a [BulkDeleteBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkDeleteBookingCustomAttributes) operation. /// -public record BookingCustomAttributeDeleteResponse +[Serializable] +public record BookingCustomAttributeDeleteResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [booking](entity:Booking) associated with the custom attribute. /// @@ -21,15 +26,11 @@ public record BookingCustomAttributeDeleteResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeOwnedDeletedEvent.cs b/src/Square/Types/BookingCustomAttributeOwnedDeletedEvent.cs index 0ce94630..5fbcbed9 100644 --- a/src/Square/Types/BookingCustomAttributeOwnedDeletedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeOwnedDeletedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// Subscribe to this event to be notified /// when your application deletes a booking custom attribute. /// -public record BookingCustomAttributeOwnedDeletedEvent +[Serializable] +public record BookingCustomAttributeOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -44,15 +49,11 @@ public record BookingCustomAttributeOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeOwnedUpdatedEvent.cs b/src/Square/Types/BookingCustomAttributeOwnedUpdatedEvent.cs index e1875c25..fb780dee 100644 --- a/src/Square/Types/BookingCustomAttributeOwnedUpdatedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeOwnedUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is updated by the subscribing application. Subscribe to this event to be notified /// when your application updates a booking custom attribute. /// -public record BookingCustomAttributeOwnedUpdatedEvent +[Serializable] +public record BookingCustomAttributeOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record BookingCustomAttributeOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeUpsertRequest.cs b/src/Square/Types/BookingCustomAttributeUpsertRequest.cs index b2ff7fec..cbd2c6a3 100644 --- a/src/Square/Types/BookingCustomAttributeUpsertRequest.cs +++ b/src/Square/Types/BookingCustomAttributeUpsertRequest.cs @@ -9,8 +9,13 @@ namespace Square; /// request. An individual request contains a booking ID, the custom attribute to create or update, /// and an optional idempotency key. /// -public record BookingCustomAttributeUpsertRequest +[Serializable] +public record BookingCustomAttributeUpsertRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target [booking](entity:Booking). /// @@ -40,15 +45,11 @@ public record BookingCustomAttributeUpsertRequest [JsonPropertyName("idempotency_key")] public string? IdempotencyKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeUpsertResponse.cs b/src/Square/Types/BookingCustomAttributeUpsertResponse.cs index c2345a17..778eefdb 100644 --- a/src/Square/Types/BookingCustomAttributeUpsertResponse.cs +++ b/src/Square/Types/BookingCustomAttributeUpsertResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response for an individual upsert request in a [BulkUpsertBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkUpsertBookingCustomAttributes) operation. /// -public record BookingCustomAttributeUpsertResponse +[Serializable] +public record BookingCustomAttributeUpsertResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [booking](entity:Booking) associated with the custom attribute. /// @@ -27,15 +32,11 @@ public record BookingCustomAttributeUpsertResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeVisibleDeletedEvent.cs b/src/Square/Types/BookingCustomAttributeVisibleDeletedEvent.cs index 3a91aaf6..d2d6b3ee 100644 --- a/src/Square/Types/BookingCustomAttributeVisibleDeletedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeVisibleDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a booking custom attribute is deleted /// by any application for which the subscribing application has read access to the booking custom attribute. /// -public record BookingCustomAttributeVisibleDeletedEvent +[Serializable] +public record BookingCustomAttributeVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record BookingCustomAttributeVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingCustomAttributeVisibleUpdatedEvent.cs b/src/Square/Types/BookingCustomAttributeVisibleUpdatedEvent.cs index 46becfdd..3067d6fd 100644 --- a/src/Square/Types/BookingCustomAttributeVisibleUpdatedEvent.cs +++ b/src/Square/Types/BookingCustomAttributeVisibleUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a booking custom attribute is updated /// by any application for which the subscribing application has read access to the booking custom attribute. /// -public record BookingCustomAttributeVisibleUpdatedEvent +[Serializable] +public record BookingCustomAttributeVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record BookingCustomAttributeVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingStatus.cs b/src/Square/Types/BookingStatus.cs index 9c284cff..00720145 100644 --- a/src/Square/Types/BookingStatus.cs +++ b/src/Square/Types/BookingStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BookingStatus : IStringEnum { public static readonly BookingStatus Pending = new(Values.Pending); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/BookingUpdatedEvent.cs b/src/Square/Types/BookingUpdatedEvent.cs index 0be71d1c..247a2c05 100644 --- a/src/Square/Types/BookingUpdatedEvent.cs +++ b/src/Square/Types/BookingUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// To receive this event with buyer-level permissions, you must have `APPOINTMENTS_READ` set for the OAuth scope. /// To receive this event with seller-level permissions, you must have `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` set for the OAuth scope. /// -public record BookingUpdatedEvent +[Serializable] +public record BookingUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -43,15 +48,11 @@ public record BookingUpdatedEvent [JsonPropertyName("data")] public BookingUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingUpdatedEventData.cs b/src/Square/Types/BookingUpdatedEventData.cs index b5eb059c..3251d3cd 100644 --- a/src/Square/Types/BookingUpdatedEventData.cs +++ b/src/Square/Types/BookingUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record BookingUpdatedEventData +[Serializable] +public record BookingUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"booking"`. /// @@ -24,15 +29,11 @@ public record BookingUpdatedEventData [JsonPropertyName("object")] public BookingUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BookingUpdatedEventObject.cs b/src/Square/Types/BookingUpdatedEventObject.cs index 27556c56..696b21b9 100644 --- a/src/Square/Types/BookingUpdatedEventObject.cs +++ b/src/Square/Types/BookingUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record BookingUpdatedEventObject +[Serializable] +public record BookingUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated booking. /// [JsonPropertyName("booking")] public Booking? Booking { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Break.cs b/src/Square/Types/Break.cs index 28521906..6592a200 100644 --- a/src/Square/Types/Break.cs +++ b/src/Square/Types/Break.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A record of a team member's break on a [timecard](entity:Timecard). /// -public record Break +[Serializable] +public record Break : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The UUID for this object. /// @@ -57,15 +62,11 @@ public record Break [JsonPropertyName("is_paid")] public required bool IsPaid { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BreakType.cs b/src/Square/Types/BreakType.cs index dc012ee8..d84461b3 100644 --- a/src/Square/Types/BreakType.cs +++ b/src/Square/Types/BreakType.cs @@ -8,8 +8,13 @@ namespace Square; /// A template for a type of [break](entity:Break) that can be added to a /// [timecard](entity:Timecard), including the expected duration and paid status. /// -public record BreakType +[Serializable] +public record BreakType : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The UUID for this object. /// @@ -68,15 +73,11 @@ public record BreakType [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkCreateCustomerData.cs b/src/Square/Types/BulkCreateCustomerData.cs index 203d6fc4..c0add8d7 100644 --- a/src/Square/Types/BulkCreateCustomerData.cs +++ b/src/Square/Types/BulkCreateCustomerData.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the customer data provided in individual create requests for a /// [BulkCreateCustomers](api-endpoint:Customers-BulkCreateCustomers) operation. /// -public record BulkCreateCustomerData +[Serializable] +public record BulkCreateCustomerData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The given name (that is, the first name) associated with the customer profile. /// @@ -86,15 +91,11 @@ public record BulkCreateCustomerData [JsonPropertyName("tax_ids")] public CustomerTaxIds? TaxIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkCreateCustomersResponse.cs b/src/Square/Types/BulkCreateCustomersResponse.cs index afada1ad..05d55a32 100644 --- a/src/Square/Types/BulkCreateCustomersResponse.cs +++ b/src/Square/Types/BulkCreateCustomersResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields included in the response body from the /// [BulkCreateCustomers](api-endpoint:Customers-BulkCreateCustomers) endpoint. /// -public record BulkCreateCustomersResponse +[Serializable] +public record BulkCreateCustomersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual create requests, represented by /// key-value pairs. @@ -28,15 +33,11 @@ public record BulkCreateCustomersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteBookingCustomAttributesResponse.cs b/src/Square/Types/BulkDeleteBookingCustomAttributesResponse.cs index 4b4ba034..d33d9eb7 100644 --- a/src/Square/Types/BulkDeleteBookingCustomAttributesResponse.cs +++ b/src/Square/Types/BulkDeleteBookingCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkDeleteBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkDeleteBookingCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual delete request. /// -public record BulkDeleteBookingCustomAttributesResponse +[Serializable] +public record BulkDeleteBookingCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual delete requests. Each response has the /// same ID as the corresponding request and contains `booking_id` and `errors` field. @@ -23,15 +28,11 @@ public record BulkDeleteBookingCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteCustomersResponse.cs b/src/Square/Types/BulkDeleteCustomersResponse.cs index b052ff70..eb4b5c9d 100644 --- a/src/Square/Types/BulkDeleteCustomersResponse.cs +++ b/src/Square/Types/BulkDeleteCustomersResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields included in the response body from the /// [BulkDeleteCustomers](api-endpoint:Customers-BulkDeleteCustomers) endpoint. /// -public record BulkDeleteCustomersResponse +[Serializable] +public record BulkDeleteCustomersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual delete requests, represented by /// key-value pairs. @@ -28,15 +33,11 @@ public record BulkDeleteCustomersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest.cs b/src/Square/Types/BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest.cs index d8bebf90..29c28a49 100644 --- a/src/Square/Types/BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest.cs +++ b/src/Square/Types/BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest.cs @@ -9,8 +9,14 @@ namespace Square; /// request. An individual request contains an optional ID of the associated custom attribute definition /// and optional key of the associated custom attribute definition. /// +[Serializable] public record BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDeleteRequest + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The key of the associated custom attribute definition. /// Represented as a qualified key if the requesting app is not the definition owner. @@ -19,15 +25,11 @@ public record BulkDeleteLocationCustomAttributesRequestLocationCustomAttributeDe [JsonPropertyName("key")] public string? Key { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteLocationCustomAttributesResponse.cs b/src/Square/Types/BulkDeleteLocationCustomAttributesResponse.cs index 52498d97..47052af5 100644 --- a/src/Square/Types/BulkDeleteLocationCustomAttributesResponse.cs +++ b/src/Square/Types/BulkDeleteLocationCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkDeleteLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkDeleteLocationCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual delete request. /// -public record BulkDeleteLocationCustomAttributesResponse +[Serializable] +public record BulkDeleteLocationCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual delete requests. Each response has the /// same key as the corresponding request. @@ -30,15 +35,11 @@ public Dictionary< [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeDeleteResponse.cs b/src/Square/Types/BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeDeleteResponse.cs index 3f0f0438..d9c2e0be 100644 --- a/src/Square/Types/BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeDeleteResponse.cs +++ b/src/Square/Types/BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeDeleteResponse.cs @@ -8,8 +8,14 @@ namespace Square; /// Represents an individual delete response in a [BulkDeleteLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkDeleteLocationCustomAttributes) /// request. /// +[Serializable] public record BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeDeleteResponse + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the location associated with the custom attribute. /// @@ -22,15 +28,11 @@ public record BulkDeleteLocationCustomAttributesResponseLocationCustomAttributeD [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest.cs b/src/Square/Types/BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest.cs index 37f724d5..0d79aa64 100644 --- a/src/Square/Types/BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest.cs +++ b/src/Square/Types/BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest.cs @@ -9,8 +9,14 @@ namespace Square; /// request. An individual request contains an optional ID of the associated custom attribute definition /// and optional key of the associated custom attribute definition. /// +[Serializable] public record BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDeleteRequest + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The key of the associated custom attribute definition. /// Represented as a qualified key if the requesting app is not the definition owner. @@ -19,15 +25,11 @@ public record BulkDeleteMerchantCustomAttributesRequestMerchantCustomAttributeDe [JsonPropertyName("key")] public string? Key { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteMerchantCustomAttributesResponse.cs b/src/Square/Types/BulkDeleteMerchantCustomAttributesResponse.cs index a1b4268e..3ccb38b2 100644 --- a/src/Square/Types/BulkDeleteMerchantCustomAttributesResponse.cs +++ b/src/Square/Types/BulkDeleteMerchantCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkDeleteMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkDeleteMerchantCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual delete request. /// -public record BulkDeleteMerchantCustomAttributesResponse +[Serializable] +public record BulkDeleteMerchantCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual delete requests. Each response has the /// same key as the corresponding request. @@ -30,15 +35,11 @@ public Dictionary< [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteMerchantCustomAttributesResponseMerchantCustomAttributeDeleteResponse.cs b/src/Square/Types/BulkDeleteMerchantCustomAttributesResponseMerchantCustomAttributeDeleteResponse.cs index 289c9761..0668e636 100644 --- a/src/Square/Types/BulkDeleteMerchantCustomAttributesResponseMerchantCustomAttributeDeleteResponse.cs +++ b/src/Square/Types/BulkDeleteMerchantCustomAttributesResponseMerchantCustomAttributeDeleteResponse.cs @@ -8,23 +8,25 @@ namespace Square; /// Represents an individual delete response in a [BulkDeleteMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkDeleteMerchantCustomAttributes) /// request. /// +[Serializable] public record BulkDeleteMerchantCustomAttributesResponseMerchantCustomAttributeDeleteResponse + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors that occurred while processing the individual MerchantCustomAttributeDeleteRequest request /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute.cs b/src/Square/Types/BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute.cs index 31d68c04..c93e3a7e 100644 --- a/src/Square/Types/BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute.cs +++ b/src/Square/Types/BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents one delete within the bulk operation. /// -public record BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute +[Serializable] +public record BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The key of the custom attribute to delete. This key must match the key /// of an existing custom attribute definition. @@ -23,15 +28,11 @@ public record BulkDeleteOrderCustomAttributesRequestDeleteCustomAttribute [JsonPropertyName("order_id")] public required string OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkDeleteOrderCustomAttributesResponse.cs b/src/Square/Types/BulkDeleteOrderCustomAttributesResponse.cs index 1f82ace2..9584ff0b 100644 --- a/src/Square/Types/BulkDeleteOrderCustomAttributesResponse.cs +++ b/src/Square/Types/BulkDeleteOrderCustomAttributesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from deleting one or more order custom attributes. /// -public record BulkDeleteOrderCustomAttributesResponse +[Serializable] +public record BulkDeleteOrderCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -23,15 +28,11 @@ public record BulkDeleteOrderCustomAttributesResponse public Dictionary Values { get; set; } = new Dictionary(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkPublishScheduledShiftsData.cs b/src/Square/Types/BulkPublishScheduledShiftsData.cs index 990d969e..951784f6 100644 --- a/src/Square/Types/BulkPublishScheduledShiftsData.cs +++ b/src/Square/Types/BulkPublishScheduledShiftsData.cs @@ -9,8 +9,13 @@ namespace Square; /// [BulkPublishScheduledShifts](api-endpoint:Labor-BulkPublishScheduledShifts) /// operation, provided as the value in a key-value pair. /// -public record BulkPublishScheduledShiftsData +[Serializable] +public record BulkPublishScheduledShiftsData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The current version of the scheduled shift, used to enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency) /// control. If the provided version doesn't match the server version, the request fails. @@ -19,15 +24,11 @@ public record BulkPublishScheduledShiftsData [JsonPropertyName("version")] public int? Version { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkPublishScheduledShiftsResponse.cs b/src/Square/Types/BulkPublishScheduledShiftsResponse.cs index 6f9be479..fed042c0 100644 --- a/src/Square/Types/BulkPublishScheduledShiftsResponse.cs +++ b/src/Square/Types/BulkPublishScheduledShiftsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkPublishScheduledShifts](api-endpoint:Labor-BulkPublishScheduledShifts) response. /// Either `scheduled_shifts` or `errors` is present in the response. /// -public record BulkPublishScheduledShiftsResponse +[Serializable] +public record BulkPublishScheduledShiftsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of key-value pairs that represent responses for individual publish requests. /// The order of responses might differ from the order in which the requests were provided. @@ -28,15 +33,11 @@ public record BulkPublishScheduledShiftsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkRetrieveBookingsResponse.cs b/src/Square/Types/BulkRetrieveBookingsResponse.cs index 93cd77a6..94393f76 100644 --- a/src/Square/Types/BulkRetrieveBookingsResponse.cs +++ b/src/Square/Types/BulkRetrieveBookingsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response payload for bulk retrieval of bookings. /// -public record BulkRetrieveBookingsResponse +[Serializable] +public record BulkRetrieveBookingsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Requested bookings returned as a map containing `booking_id` as the key and `RetrieveBookingResponse` as the value. /// @@ -21,15 +26,11 @@ public record BulkRetrieveBookingsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkRetrieveChannelsResponse.cs b/src/Square/Types/BulkRetrieveChannelsResponse.cs index 4a447aa4..453f99a2 100644 --- a/src/Square/Types/BulkRetrieveChannelsResponse.cs +++ b/src/Square/Types/BulkRetrieveChannelsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the request body for the /// [BulkRetrieveChannels](api-endpoint:Channels-BulkRetrieveChannels) endpoint. /// -public record BulkRetrieveChannelsResponse +[Serializable] +public record BulkRetrieveChannelsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -25,15 +30,11 @@ public record BulkRetrieveChannelsResponse [JsonPropertyName("responses")] public Dictionary? Responses { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkRetrieveCustomersResponse.cs b/src/Square/Types/BulkRetrieveCustomersResponse.cs index a2fa13c1..13323d55 100644 --- a/src/Square/Types/BulkRetrieveCustomersResponse.cs +++ b/src/Square/Types/BulkRetrieveCustomersResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields included in the response body from the /// [BulkRetrieveCustomers](api-endpoint:Customers-BulkRetrieveCustomers) endpoint. /// -public record BulkRetrieveCustomersResponse +[Serializable] +public record BulkRetrieveCustomersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual retrieve requests, represented by /// key-value pairs. @@ -28,15 +33,11 @@ public record BulkRetrieveCustomersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkRetrieveTeamMemberBookingProfilesResponse.cs b/src/Square/Types/BulkRetrieveTeamMemberBookingProfilesResponse.cs index e7703971..2f9e09f7 100644 --- a/src/Square/Types/BulkRetrieveTeamMemberBookingProfilesResponse.cs +++ b/src/Square/Types/BulkRetrieveTeamMemberBookingProfilesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response payload for the [BulkRetrieveTeamMemberBookingProfiles](api-endpoint:Bookings-BulkRetrieveTeamMemberBookingProfiles) endpoint. /// -public record BulkRetrieveTeamMemberBookingProfilesResponse +[Serializable] +public record BulkRetrieveTeamMemberBookingProfilesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The returned team members' booking profiles, as a map with `team_member_id` as the key and [TeamMemberBookingProfile](entity:TeamMemberBookingProfile) the value. /// @@ -24,15 +29,11 @@ public Dictionary< [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkSwapPlanResponse.cs b/src/Square/Types/BulkSwapPlanResponse.cs index 791743e3..f14b08dc 100644 --- a/src/Square/Types/BulkSwapPlanResponse.cs +++ b/src/Square/Types/BulkSwapPlanResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response of the /// [BulkSwapPlan](api-endpoint:Subscriptions-BulkSwapPlan) endpoint. /// -public record BulkSwapPlanResponse +[Serializable] +public record BulkSwapPlanResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -22,15 +27,11 @@ public record BulkSwapPlanResponse [JsonPropertyName("affected_subscriptions")] public int? AffectedSubscriptions { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpdateCustomerData.cs b/src/Square/Types/BulkUpdateCustomerData.cs index cc57a9e0..c248079b 100644 --- a/src/Square/Types/BulkUpdateCustomerData.cs +++ b/src/Square/Types/BulkUpdateCustomerData.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the customer data provided in individual update requests for a /// [BulkUpdateCustomers](api-endpoint:Customers-BulkUpdateCustomers) operation. /// -public record BulkUpdateCustomerData +[Serializable] +public record BulkUpdateCustomerData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The given name (that is, the first name) associated with the customer profile. /// @@ -96,15 +101,11 @@ public record BulkUpdateCustomerData [JsonPropertyName("version")] public long? Version { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpdateCustomersResponse.cs b/src/Square/Types/BulkUpdateCustomersResponse.cs index 0b08eaa3..7482fbb8 100644 --- a/src/Square/Types/BulkUpdateCustomersResponse.cs +++ b/src/Square/Types/BulkUpdateCustomersResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields included in the response body from the /// [BulkUpdateCustomers](api-endpoint:Customers-BulkUpdateCustomers) endpoint. /// -public record BulkUpdateCustomersResponse +[Serializable] +public record BulkUpdateCustomersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual update requests, represented by /// key-value pairs. @@ -28,15 +33,11 @@ public record BulkUpdateCustomersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertBookingCustomAttributesResponse.cs b/src/Square/Types/BulkUpsertBookingCustomAttributesResponse.cs index 7a71a622..01360880 100644 --- a/src/Square/Types/BulkUpsertBookingCustomAttributesResponse.cs +++ b/src/Square/Types/BulkUpsertBookingCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkUpsertBookingCustomAttributes](api-endpoint:BookingCustomAttributes-BulkUpsertBookingCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual upsert request. /// -public record BulkUpsertBookingCustomAttributesResponse +[Serializable] +public record BulkUpsertBookingCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual upsert requests. Each response has the /// same ID as the corresponding request and contains either a `booking_id` and `custom_attribute` or an `errors` field. @@ -23,15 +28,11 @@ public record BulkUpsertBookingCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest.cs b/src/Square/Types/BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest.cs index 3a1493da..9b96a577 100644 --- a/src/Square/Types/BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest.cs +++ b/src/Square/Types/BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest.cs @@ -9,8 +9,14 @@ namespace Square; /// request. An individual request contains a location ID, the custom attribute to create or update, /// and an optional idempotency key. /// +[Serializable] public record BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUpsertRequest + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target [location](entity:Location). /// @@ -37,15 +43,11 @@ public record BulkUpsertLocationCustomAttributesRequestLocationCustomAttributeUp [JsonPropertyName("idempotency_key")] public string? IdempotencyKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertLocationCustomAttributesResponse.cs b/src/Square/Types/BulkUpsertLocationCustomAttributesResponse.cs index 4f566e17..90c3bd5e 100644 --- a/src/Square/Types/BulkUpsertLocationCustomAttributesResponse.cs +++ b/src/Square/Types/BulkUpsertLocationCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkUpsertLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkUpsertLocationCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual upsert request. /// -public record BulkUpsertLocationCustomAttributesResponse +[Serializable] +public record BulkUpsertLocationCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual upsert requests. Each response has the /// same ID as the corresponding request and contains either a `location_id` and `custom_attribute` or an `errors` field. @@ -26,15 +31,11 @@ public Dictionary< [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeUpsertResponse.cs b/src/Square/Types/BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeUpsertResponse.cs index 7c67a98f..d55156e7 100644 --- a/src/Square/Types/BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeUpsertResponse.cs +++ b/src/Square/Types/BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeUpsertResponse.cs @@ -7,8 +7,14 @@ namespace Square; /// /// Represents a response for an individual upsert request in a [BulkUpsertLocationCustomAttributes](api-endpoint:LocationCustomAttributes-BulkUpsertLocationCustomAttributes) operation. /// +[Serializable] public record BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeUpsertResponse + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the location associated with the custom attribute. /// @@ -27,15 +33,11 @@ public record BulkUpsertLocationCustomAttributesResponseLocationCustomAttributeU [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest.cs b/src/Square/Types/BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest.cs index 8ba007d3..f882c555 100644 --- a/src/Square/Types/BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest.cs +++ b/src/Square/Types/BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest.cs @@ -9,8 +9,14 @@ namespace Square; /// request. An individual request contains a merchant ID, the custom attribute to create or update, /// and an optional idempotency key. /// +[Serializable] public record BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUpsertRequest + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target [merchant](entity:Merchant). /// @@ -37,15 +43,11 @@ public record BulkUpsertMerchantCustomAttributesRequestMerchantCustomAttributeUp [JsonPropertyName("idempotency_key")] public string? IdempotencyKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertMerchantCustomAttributesResponse.cs b/src/Square/Types/BulkUpsertMerchantCustomAttributesResponse.cs index a6b18d6b..19cf56a6 100644 --- a/src/Square/Types/BulkUpsertMerchantCustomAttributesResponse.cs +++ b/src/Square/Types/BulkUpsertMerchantCustomAttributesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) response, /// which contains a map of responses that each corresponds to an individual upsert request. /// -public record BulkUpsertMerchantCustomAttributesResponse +[Serializable] +public record BulkUpsertMerchantCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A map of responses that correspond to individual upsert requests. Each response has the /// same ID as the corresponding request and contains either a `merchant_id` and `custom_attribute` or an `errors` field. @@ -26,15 +31,11 @@ public Dictionary< [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeUpsertResponse.cs b/src/Square/Types/BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeUpsertResponse.cs index 08f45b9b..e55cabaf 100644 --- a/src/Square/Types/BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeUpsertResponse.cs +++ b/src/Square/Types/BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeUpsertResponse.cs @@ -7,8 +7,14 @@ namespace Square; /// /// Represents a response for an individual upsert request in a [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) operation. /// +[Serializable] public record BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeUpsertResponse + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the custom attribute. /// @@ -27,15 +33,11 @@ public record BulkUpsertMerchantCustomAttributesResponseMerchantCustomAttributeU [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute.cs b/src/Square/Types/BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute.cs index a863c66f..857cb94f 100644 --- a/src/Square/Types/BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute.cs +++ b/src/Square/Types/BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents one upsert within the bulk operation. /// -public record BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute +[Serializable] +public record BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The custom attribute to create or update, with the following fields: /// @@ -34,15 +39,11 @@ public record BulkUpsertOrderCustomAttributesRequestUpsertCustomAttribute [JsonPropertyName("order_id")] public required string OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BulkUpsertOrderCustomAttributesResponse.cs b/src/Square/Types/BulkUpsertOrderCustomAttributesResponse.cs index 20e88cd7..420b4cd3 100644 --- a/src/Square/Types/BulkUpsertOrderCustomAttributesResponse.cs +++ b/src/Square/Types/BulkUpsertOrderCustomAttributesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a bulk upsert of order custom attributes. /// -public record BulkUpsertOrderCustomAttributesResponse +[Serializable] +public record BulkUpsertOrderCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record BulkUpsertOrderCustomAttributesResponse public Dictionary Values { get; set; } = new Dictionary(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BusinessAppointmentSettings.cs b/src/Square/Types/BusinessAppointmentSettings.cs index a3a9c5c4..46607e66 100644 --- a/src/Square/Types/BusinessAppointmentSettings.cs +++ b/src/Square/Types/BusinessAppointmentSettings.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The service appointment settings, including where and how the service is provided. /// -public record BusinessAppointmentSettings +[Serializable] +public record BusinessAppointmentSettings : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Types of the location allowed for bookings. /// See [BusinessAppointmentSettingsBookingLocationType](#type-businessappointmentsettingsbookinglocationtype) for possible values @@ -93,15 +98,11 @@ public record BusinessAppointmentSettings [JsonPropertyName("skip_booking_flow_staff_selection")] public bool? SkipBookingFlowStaffSelection { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BusinessAppointmentSettingsAlignmentTime.cs b/src/Square/Types/BusinessAppointmentSettingsAlignmentTime.cs index 07c24a60..2cb483ca 100644 --- a/src/Square/Types/BusinessAppointmentSettingsAlignmentTime.cs +++ b/src/Square/Types/BusinessAppointmentSettingsAlignmentTime.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BusinessAppointmentSettingsAlignmentTime : IStringEnum { public static readonly BusinessAppointmentSettingsAlignmentTime ServiceDuration = new( @@ -70,6 +71,7 @@ public static explicit operator BusinessAppointmentSettingsAlignmentTime(string /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ServiceDuration = "SERVICE_DURATION"; diff --git a/src/Square/Types/BusinessAppointmentSettingsBookingLocationType.cs b/src/Square/Types/BusinessAppointmentSettingsBookingLocationType.cs index bd04db29..d197777a 100644 --- a/src/Square/Types/BusinessAppointmentSettingsBookingLocationType.cs +++ b/src/Square/Types/BusinessAppointmentSettingsBookingLocationType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BusinessAppointmentSettingsBookingLocationType : IStringEnum { public static readonly BusinessAppointmentSettingsBookingLocationType BusinessLocation = new( @@ -66,6 +67,7 @@ public static explicit operator BusinessAppointmentSettingsBookingLocationType(s /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string BusinessLocation = "BUSINESS_LOCATION"; diff --git a/src/Square/Types/BusinessAppointmentSettingsCancellationPolicy.cs b/src/Square/Types/BusinessAppointmentSettingsCancellationPolicy.cs index a88c9cec..ac7e4728 100644 --- a/src/Square/Types/BusinessAppointmentSettingsCancellationPolicy.cs +++ b/src/Square/Types/BusinessAppointmentSettingsCancellationPolicy.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BusinessAppointmentSettingsCancellationPolicy : IStringEnum { public static readonly BusinessAppointmentSettingsCancellationPolicy CancellationTreatedAsNoShow = @@ -63,6 +64,7 @@ public static explicit operator BusinessAppointmentSettingsCancellationPolicy(st /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CancellationTreatedAsNoShow = "CANCELLATION_TREATED_AS_NO_SHOW"; diff --git a/src/Square/Types/BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType.cs b/src/Square/Types/BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType.cs index d0ef5f0e..06ce3628 100644 --- a/src/Square/Types/BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType.cs +++ b/src/Square/Types/BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType.cs @@ -6,6 +6,7 @@ namespace Square; [JsonConverter( typeof(StringEnumSerializer) )] +[Serializable] public readonly record struct BusinessAppointmentSettingsMaxAppointmentsPerDayLimitType : IStringEnum { @@ -67,6 +68,7 @@ string value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string PerTeamMember = "PER_TEAM_MEMBER"; diff --git a/src/Square/Types/BusinessBookingProfile.cs b/src/Square/Types/BusinessBookingProfile.cs index 8efeedb2..3499b7b4 100644 --- a/src/Square/Types/BusinessBookingProfile.cs +++ b/src/Square/Types/BusinessBookingProfile.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A seller's business booking profile, including booking policy, appointment settings, etc. /// -public record BusinessBookingProfile +[Serializable] +public record BusinessBookingProfile : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller, obtainable using the Merchants API. /// @@ -62,15 +67,11 @@ public record BusinessBookingProfile [JsonPropertyName("support_seller_level_writes")] public bool? SupportSellerLevelWrites { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BusinessBookingProfileBookingPolicy.cs b/src/Square/Types/BusinessBookingProfileBookingPolicy.cs index f91075bc..62e82eb2 100644 --- a/src/Square/Types/BusinessBookingProfileBookingPolicy.cs +++ b/src/Square/Types/BusinessBookingProfileBookingPolicy.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BusinessBookingProfileBookingPolicy : IStringEnum { public static readonly BusinessBookingProfileBookingPolicy AcceptAll = new(Values.AcceptAll); @@ -57,6 +58,7 @@ public static explicit operator string(BusinessBookingProfileBookingPolicy value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AcceptAll = "ACCEPT_ALL"; diff --git a/src/Square/Types/BusinessBookingProfileCustomerTimezoneChoice.cs b/src/Square/Types/BusinessBookingProfileCustomerTimezoneChoice.cs index d0638d5d..7bf97f24 100644 --- a/src/Square/Types/BusinessBookingProfileCustomerTimezoneChoice.cs +++ b/src/Square/Types/BusinessBookingProfileCustomerTimezoneChoice.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct BusinessBookingProfileCustomerTimezoneChoice : IStringEnum { public static readonly BusinessBookingProfileCustomerTimezoneChoice BusinessLocationTimezone = @@ -63,6 +64,7 @@ public static explicit operator BusinessBookingProfileCustomerTimezoneChoice(str /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string BusinessLocationTimezone = "BUSINESS_LOCATION_TIMEZONE"; diff --git a/src/Square/Types/BusinessHours.cs b/src/Square/Types/BusinessHours.cs index e72b1f95..d5a78b9c 100644 --- a/src/Square/Types/BusinessHours.cs +++ b/src/Square/Types/BusinessHours.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The hours of operation for a location. /// -public record BusinessHours +[Serializable] +public record BusinessHours : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of time periods during which the business is open. There can be at most 10 periods per day. /// [JsonPropertyName("periods")] public IEnumerable? Periods { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BusinessHoursPeriod.cs b/src/Square/Types/BusinessHoursPeriod.cs index 76ae6dce..26e9cff2 100644 --- a/src/Square/Types/BusinessHoursPeriod.cs +++ b/src/Square/Types/BusinessHoursPeriod.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a period of time during which a business location is open. /// -public record BusinessHoursPeriod +[Serializable] +public record BusinessHoursPeriod : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The day of the week for this time period. /// See [DayOfWeek](#type-dayofweek) for possible values @@ -32,15 +37,11 @@ public record BusinessHoursPeriod [JsonPropertyName("end_local_time")] public string? EndLocalTime { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/BuyNowPayLaterDetails.cs b/src/Square/Types/BuyNowPayLaterDetails.cs index 5970ddbe..0763e552 100644 --- a/src/Square/Types/BuyNowPayLaterDetails.cs +++ b/src/Square/Types/BuyNowPayLaterDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Additional details about a Buy Now Pay Later payment type. /// -public record BuyNowPayLaterDetails +[Serializable] +public record BuyNowPayLaterDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The brand used for the Buy Now Pay Later payment. /// The brand can be `AFTERPAY`, `CLEARPAY` or `UNKNOWN`. @@ -30,15 +35,11 @@ public record BuyNowPayLaterDetails [JsonPropertyName("clearpay_details")] public ClearpayDetails? ClearpayDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CalculateLoyaltyPointsResponse.cs b/src/Square/Types/CalculateLoyaltyPointsResponse.cs index 05643269..bb3fc289 100644 --- a/src/Square/Types/CalculateLoyaltyPointsResponse.cs +++ b/src/Square/Types/CalculateLoyaltyPointsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a [CalculateLoyaltyPoints](api-endpoint:Loyalty-CalculateLoyaltyPoints) response. /// -public record CalculateLoyaltyPointsResponse +[Serializable] +public record CalculateLoyaltyPointsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -29,15 +34,11 @@ public record CalculateLoyaltyPointsResponse [JsonPropertyName("promotion_points")] public int? PromotionPoints { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CalculateOrderResponse.cs b/src/Square/Types/CalculateOrderResponse.cs index 4110f7d1..bde34f3a 100644 --- a/src/Square/Types/CalculateOrderResponse.cs +++ b/src/Square/Types/CalculateOrderResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CalculateOrderResponse +[Serializable] +public record CalculateOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The calculated version of the order provided in the request. /// @@ -18,15 +23,11 @@ public record CalculateOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelBookingResponse.cs b/src/Square/Types/CancelBookingResponse.cs index 2964ff3c..db80d407 100644 --- a/src/Square/Types/CancelBookingResponse.cs +++ b/src/Square/Types/CancelBookingResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CancelBookingResponse +[Serializable] +public record CancelBookingResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The booking that was cancelled. /// @@ -18,15 +23,11 @@ public record CancelBookingResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelInvoiceResponse.cs b/src/Square/Types/CancelInvoiceResponse.cs index 4be92602..278b175c 100644 --- a/src/Square/Types/CancelInvoiceResponse.cs +++ b/src/Square/Types/CancelInvoiceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response returned by the `CancelInvoice` request. /// -public record CancelInvoiceResponse +[Serializable] +public record CancelInvoiceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The canceled invoice. /// @@ -21,15 +26,11 @@ public record CancelInvoiceResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelLoyaltyPromotionResponse.cs b/src/Square/Types/CancelLoyaltyPromotionResponse.cs index 0e861b54..0b14547a 100644 --- a/src/Square/Types/CancelLoyaltyPromotionResponse.cs +++ b/src/Square/Types/CancelLoyaltyPromotionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CancelLoyaltyPromotion](api-endpoint:Loyalty-CancelLoyaltyPromotion) response. /// Either `loyalty_promotion` or `errors` is present in the response. /// -public record CancelLoyaltyPromotionResponse +[Serializable] +public record CancelLoyaltyPromotionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record CancelLoyaltyPromotionResponse [JsonPropertyName("loyalty_promotion")] public LoyaltyPromotion? LoyaltyPromotion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelPaymentByIdempotencyKeyResponse.cs b/src/Square/Types/CancelPaymentByIdempotencyKeyResponse.cs index c2bebe47..656eee3b 100644 --- a/src/Square/Types/CancelPaymentByIdempotencyKeyResponse.cs +++ b/src/Square/Types/CancelPaymentByIdempotencyKeyResponse.cs @@ -9,23 +9,24 @@ namespace Square; /// [CancelPaymentByIdempotencyKey](api-endpoint:Payments-CancelPaymentByIdempotencyKey). /// On success, `errors` is empty. /// -public record CancelPaymentByIdempotencyKeyResponse +[Serializable] +public record CancelPaymentByIdempotencyKeyResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelPaymentResponse.cs b/src/Square/Types/CancelPaymentResponse.cs index fc4f9f49..b74dc580 100644 --- a/src/Square/Types/CancelPaymentResponse.cs +++ b/src/Square/Types/CancelPaymentResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the response returned by [CancelPayment](api-endpoint:Payments-CancelPayment). /// -public record CancelPaymentResponse +[Serializable] +public record CancelPaymentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record CancelPaymentResponse [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelSubscriptionResponse.cs b/src/Square/Types/CancelSubscriptionResponse.cs index 71e498f6..b7f4680c 100644 --- a/src/Square/Types/CancelSubscriptionResponse.cs +++ b/src/Square/Types/CancelSubscriptionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [CancelSubscription](api-endpoint:Subscriptions-CancelSubscription) endpoint. /// -public record CancelSubscriptionResponse +[Serializable] +public record CancelSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -28,15 +33,11 @@ public record CancelSubscriptionResponse [JsonPropertyName("actions")] public IEnumerable? Actions { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelTerminalActionResponse.cs b/src/Square/Types/CancelTerminalActionResponse.cs index ac9a2f73..49427055 100644 --- a/src/Square/Types/CancelTerminalActionResponse.cs +++ b/src/Square/Types/CancelTerminalActionResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CancelTerminalActionResponse +[Serializable] +public record CancelTerminalActionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -18,15 +23,11 @@ public record CancelTerminalActionResponse [JsonPropertyName("action")] public TerminalAction? Action { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelTerminalCheckoutResponse.cs b/src/Square/Types/CancelTerminalCheckoutResponse.cs index 4449d102..f4b58be7 100644 --- a/src/Square/Types/CancelTerminalCheckoutResponse.cs +++ b/src/Square/Types/CancelTerminalCheckoutResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CancelTerminalCheckoutResponse +[Serializable] +public record CancelTerminalCheckoutResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record CancelTerminalCheckoutResponse [JsonPropertyName("checkout")] public TerminalCheckout? Checkout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelTerminalRefundResponse.cs b/src/Square/Types/CancelTerminalRefundResponse.cs index 29cdfb91..1f97660b 100644 --- a/src/Square/Types/CancelTerminalRefundResponse.cs +++ b/src/Square/Types/CancelTerminalRefundResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CancelTerminalRefundResponse +[Serializable] +public record CancelTerminalRefundResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record CancelTerminalRefundResponse [JsonPropertyName("refund")] public TerminalRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CancelTransferOrderResponse.cs b/src/Square/Types/CancelTransferOrderResponse.cs index c221312d..9551cdd9 100644 --- a/src/Square/Types/CancelTransferOrderResponse.cs +++ b/src/Square/Types/CancelTransferOrderResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response for canceling a transfer order /// -public record CancelTransferOrderResponse +[Serializable] +public record CancelTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated transfer order with status changed to CANCELED /// @@ -21,15 +26,11 @@ public record CancelTransferOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CaptureTransactionResponse.cs b/src/Square/Types/CaptureTransactionResponse.cs index 9dbc6bb4..ec54fdc4 100644 --- a/src/Square/Types/CaptureTransactionResponse.cs +++ b/src/Square/Types/CaptureTransactionResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [CaptureTransaction](api-endpoint:Transactions-CaptureTransaction) endpoint. /// -public record CaptureTransactionResponse +[Serializable] +public record CaptureTransactionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Card.cs b/src/Square/Types/Card.cs index a6c4a7e6..80c139a6 100644 --- a/src/Square/Types/Card.cs +++ b/src/Square/Types/Card.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the payment details of a card to be used for payments. These /// details are determined by the payment token generated by Web Payments SDK. /// -public record Card +[Serializable] +public record Card : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique ID for this card. Generated by Square. /// @@ -162,15 +167,11 @@ public record Card [JsonPropertyName("hsa_fsa")] public bool? HsaFsa { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardAutomaticallyUpdatedEvent.cs b/src/Square/Types/CardAutomaticallyUpdatedEvent.cs index a21234c4..1a9b7ac3 100644 --- a/src/Square/Types/CardAutomaticallyUpdatedEvent.cs +++ b/src/Square/Types/CardAutomaticallyUpdatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when Square automatically updates the expiration date or /// primary account number (PAN) of a [card](entity:Card) or adds or removes an issuer alert. /// -public record CardAutomaticallyUpdatedEvent +[Serializable] +public record CardAutomaticallyUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -41,15 +46,11 @@ public record CardAutomaticallyUpdatedEvent [JsonPropertyName("data")] public CardAutomaticallyUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardAutomaticallyUpdatedEventData.cs b/src/Square/Types/CardAutomaticallyUpdatedEventData.cs index 063eff06..431a8edf 100644 --- a/src/Square/Types/CardAutomaticallyUpdatedEventData.cs +++ b/src/Square/Types/CardAutomaticallyUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CardAutomaticallyUpdatedEventData +[Serializable] +public record CardAutomaticallyUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"card"`. /// @@ -24,15 +29,11 @@ public record CardAutomaticallyUpdatedEventData [JsonPropertyName("object")] public CardAutomaticallyUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardAutomaticallyUpdatedEventObject.cs b/src/Square/Types/CardAutomaticallyUpdatedEventObject.cs index 93cd9571..12f9942c 100644 --- a/src/Square/Types/CardAutomaticallyUpdatedEventObject.cs +++ b/src/Square/Types/CardAutomaticallyUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CardAutomaticallyUpdatedEventObject +[Serializable] +public record CardAutomaticallyUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The automatically updated card. /// [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardBrand.cs b/src/Square/Types/CardBrand.cs index 53aa2154..8a2754bd 100644 --- a/src/Square/Types/CardBrand.cs +++ b/src/Square/Types/CardBrand.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CardBrand : IStringEnum { public static readonly CardBrand OtherBrand = new(Values.OtherBrand); @@ -76,6 +77,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OtherBrand = "OTHER_BRAND"; diff --git a/src/Square/Types/CardCoBrand.cs b/src/Square/Types/CardCoBrand.cs index 0f9de42e..76f068e8 100644 --- a/src/Square/Types/CardCoBrand.cs +++ b/src/Square/Types/CardCoBrand.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CardCoBrand : IStringEnum { public static readonly CardCoBrand Unknown = new(Values.Unknown); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Unknown = "UNKNOWN"; diff --git a/src/Square/Types/CardCreatedEvent.cs b/src/Square/Types/CardCreatedEvent.cs index 8dd98b10..a0a30ee4 100644 --- a/src/Square/Types/CardCreatedEvent.cs +++ b/src/Square/Types/CardCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [card](entity:Card) is created or imported. /// -public record CardCreatedEvent +[Serializable] +public record CardCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record CardCreatedEvent [JsonPropertyName("data")] public CardCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardCreatedEventData.cs b/src/Square/Types/CardCreatedEventData.cs index 872be9ef..02a311b4 100644 --- a/src/Square/Types/CardCreatedEventData.cs +++ b/src/Square/Types/CardCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CardCreatedEventData +[Serializable] +public record CardCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"card"`. /// @@ -24,15 +29,11 @@ public record CardCreatedEventData [JsonPropertyName("object")] public CardCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardCreatedEventObject.cs b/src/Square/Types/CardCreatedEventObject.cs index 4a4bf080..93ce0543 100644 --- a/src/Square/Types/CardCreatedEventObject.cs +++ b/src/Square/Types/CardCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CardCreatedEventObject +[Serializable] +public record CardCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created card. /// [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardDisabledEvent.cs b/src/Square/Types/CardDisabledEvent.cs index 8804b718..be023063 100644 --- a/src/Square/Types/CardDisabledEvent.cs +++ b/src/Square/Types/CardDisabledEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [card](entity:Card) is disabled. /// -public record CardDisabledEvent +[Serializable] +public record CardDisabledEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record CardDisabledEvent [JsonPropertyName("data")] public CardDisabledEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardDisabledEventData.cs b/src/Square/Types/CardDisabledEventData.cs index f750218e..af563bda 100644 --- a/src/Square/Types/CardDisabledEventData.cs +++ b/src/Square/Types/CardDisabledEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CardDisabledEventData +[Serializable] +public record CardDisabledEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"card"`. /// @@ -24,15 +29,11 @@ public record CardDisabledEventData [JsonPropertyName("object")] public CardDisabledEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardDisabledEventObject.cs b/src/Square/Types/CardDisabledEventObject.cs index 2f0e5e30..632e24ab 100644 --- a/src/Square/Types/CardDisabledEventObject.cs +++ b/src/Square/Types/CardDisabledEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CardDisabledEventObject +[Serializable] +public record CardDisabledEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The disabled card. /// [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardForgottenEvent.cs b/src/Square/Types/CardForgottenEvent.cs index 7e9b1733..54a079d2 100644 --- a/src/Square/Types/CardForgottenEvent.cs +++ b/src/Square/Types/CardForgottenEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [card](entity:Card) is GDPR forgotten or vaulted. /// -public record CardForgottenEvent +[Serializable] +public record CardForgottenEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record CardForgottenEvent [JsonPropertyName("data")] public CardForgottenEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardForgottenEventCard.cs b/src/Square/Types/CardForgottenEventCard.cs index 2c5250d5..fbb503a1 100644 --- a/src/Square/Types/CardForgottenEventCard.cs +++ b/src/Square/Types/CardForgottenEventCard.cs @@ -4,8 +4,13 @@ namespace Square; -public record CardForgottenEventCard +[Serializable] +public record CardForgottenEventCard : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique ID for this card. Generated by Square. /// @@ -47,15 +52,11 @@ public record CardForgottenEventCard [JsonPropertyName("merchant_id")] public string? MerchantId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardForgottenEventData.cs b/src/Square/Types/CardForgottenEventData.cs index c9ef51d4..2bd1e666 100644 --- a/src/Square/Types/CardForgottenEventData.cs +++ b/src/Square/Types/CardForgottenEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CardForgottenEventData +[Serializable] +public record CardForgottenEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"card"`. /// @@ -24,15 +29,11 @@ public record CardForgottenEventData [JsonPropertyName("object")] public CardForgottenEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardForgottenEventObject.cs b/src/Square/Types/CardForgottenEventObject.cs index cfcca4d7..0360d3a3 100644 --- a/src/Square/Types/CardForgottenEventObject.cs +++ b/src/Square/Types/CardForgottenEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CardForgottenEventObject +[Serializable] +public record CardForgottenEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The forgotten card. /// [JsonPropertyName("card")] public CardForgottenEventCard? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardPaymentDetails.cs b/src/Square/Types/CardPaymentDetails.cs index f0fa7b55..010daa3a 100644 --- a/src/Square/Types/CardPaymentDetails.cs +++ b/src/Square/Types/CardPaymentDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Reflects the current status of a card payment. Contains only non-confidential information. /// -public record CardPaymentDetails +[Serializable] +public record CardPaymentDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The card payment's current state. The state can be AUTHORIZED, CAPTURED, VOIDED, or /// FAILED. @@ -131,15 +136,11 @@ public record CardPaymentDetails [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardPaymentTimeline.cs b/src/Square/Types/CardPaymentTimeline.cs index 5e11a5cb..70c0e7b4 100644 --- a/src/Square/Types/CardPaymentTimeline.cs +++ b/src/Square/Types/CardPaymentTimeline.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The timeline for card payments. /// -public record CardPaymentTimeline +[Serializable] +public record CardPaymentTimeline : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The timestamp when the payment was authorized, in RFC 3339 format. /// @@ -27,15 +32,11 @@ public record CardPaymentTimeline [JsonPropertyName("voided_at")] public string? VoidedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardPrepaidType.cs b/src/Square/Types/CardPrepaidType.cs index b5372792..fa124578 100644 --- a/src/Square/Types/CardPrepaidType.cs +++ b/src/Square/Types/CardPrepaidType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CardPrepaidType : IStringEnum { public static readonly CardPrepaidType UnknownPrepaidType = new(Values.UnknownPrepaidType); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string UnknownPrepaidType = "UNKNOWN_PREPAID_TYPE"; diff --git a/src/Square/Types/CardType.cs b/src/Square/Types/CardType.cs index b5fece5c..56cbbf5a 100644 --- a/src/Square/Types/CardType.cs +++ b/src/Square/Types/CardType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CardType : IStringEnum { public static readonly CardType UnknownCardType = new(Values.UnknownCardType); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string UnknownCardType = "UNKNOWN_CARD_TYPE"; diff --git a/src/Square/Types/CardUpdatedEvent.cs b/src/Square/Types/CardUpdatedEvent.cs index 68557a42..548cb7f9 100644 --- a/src/Square/Types/CardUpdatedEvent.cs +++ b/src/Square/Types/CardUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [card](entity:Card) is updated by the seller in the Square Dashboard. /// -public record CardUpdatedEvent +[Serializable] +public record CardUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record CardUpdatedEvent [JsonPropertyName("data")] public CardUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardUpdatedEventData.cs b/src/Square/Types/CardUpdatedEventData.cs index 53330dc0..6eb87142 100644 --- a/src/Square/Types/CardUpdatedEventData.cs +++ b/src/Square/Types/CardUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CardUpdatedEventData +[Serializable] +public record CardUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"card"`. /// @@ -24,15 +29,11 @@ public record CardUpdatedEventData [JsonPropertyName("object")] public CardUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CardUpdatedEventObject.cs b/src/Square/Types/CardUpdatedEventObject.cs index 7b3041f7..44513c73 100644 --- a/src/Square/Types/CardUpdatedEventObject.cs +++ b/src/Square/Types/CardUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CardUpdatedEventObject +[Serializable] +public record CardUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated card. /// [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CashAppDetails.cs b/src/Square/Types/CashAppDetails.cs index 164e4bbf..d2f1be0f 100644 --- a/src/Square/Types/CashAppDetails.cs +++ b/src/Square/Types/CashAppDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Additional details about `WALLET` type payments with the `brand` of `CASH_APP`. /// -public record CashAppDetails +[Serializable] +public record CashAppDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the Cash App account holder. /// @@ -30,15 +35,11 @@ public record CashAppDetails [JsonPropertyName("buyer_cashtag")] public string? BuyerCashtag { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CashDrawerDevice.cs b/src/Square/Types/CashDrawerDevice.cs index 75ad1420..fa62f46d 100644 --- a/src/Square/Types/CashDrawerDevice.cs +++ b/src/Square/Types/CashDrawerDevice.cs @@ -4,8 +4,13 @@ namespace Square; -public record CashDrawerDevice +[Serializable] +public record CashDrawerDevice : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The device Square-issued ID /// @@ -18,15 +23,11 @@ public record CashDrawerDevice [JsonPropertyName("name")] public string? Name { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CashDrawerEventType.cs b/src/Square/Types/CashDrawerEventType.cs index 3d59b80e..d66e2a24 100644 --- a/src/Square/Types/CashDrawerEventType.cs +++ b/src/Square/Types/CashDrawerEventType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CashDrawerEventType : IStringEnum { public static readonly CashDrawerEventType NoSale = new(Values.NoSale); @@ -72,6 +73,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string NoSale = "NO_SALE"; diff --git a/src/Square/Types/CashDrawerShift.cs b/src/Square/Types/CashDrawerShift.cs index 074b74bb..ff079ae2 100644 --- a/src/Square/Types/CashDrawerShift.cs +++ b/src/Square/Types/CashDrawerShift.cs @@ -10,8 +10,13 @@ namespace Square; /// and cash_paid_out_money fields are all computed by summing their respective /// event types. /// -public record CashDrawerShift +[Serializable] +public record CashDrawerShift : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The shift unique ID. /// @@ -165,15 +170,11 @@ public record CashDrawerShift [JsonPropertyName("closing_team_member_id")] public string? ClosingTeamMemberId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CashDrawerShiftEvent.cs b/src/Square/Types/CashDrawerShiftEvent.cs index 5856ccf3..0ddaec35 100644 --- a/src/Square/Types/CashDrawerShiftEvent.cs +++ b/src/Square/Types/CashDrawerShiftEvent.cs @@ -4,8 +4,13 @@ namespace Square; -public record CashDrawerShiftEvent +[Serializable] +public record CashDrawerShiftEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique ID of the event. /// @@ -49,15 +54,11 @@ public record CashDrawerShiftEvent [JsonPropertyName("team_member_id")] public string? TeamMemberId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CashDrawerShiftState.cs b/src/Square/Types/CashDrawerShiftState.cs index 7078ac63..a370400c 100644 --- a/src/Square/Types/CashDrawerShiftState.cs +++ b/src/Square/Types/CashDrawerShiftState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CashDrawerShiftState : IStringEnum { public static readonly CashDrawerShiftState Open = new(Values.Open); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Open = "OPEN"; diff --git a/src/Square/Types/CashDrawerShiftSummary.cs b/src/Square/Types/CashDrawerShiftSummary.cs index 56ae23d6..8c15d9e6 100644 --- a/src/Square/Types/CashDrawerShiftSummary.cs +++ b/src/Square/Types/CashDrawerShiftSummary.cs @@ -10,8 +10,13 @@ namespace Square; /// at the end of the shift, and the amount that should be in the drawer at shift /// end based on summing all cash drawer shift events. /// -public record CashDrawerShiftSummary +[Serializable] +public record CashDrawerShiftSummary : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The shift unique ID. /// @@ -94,15 +99,11 @@ public record CashDrawerShiftSummary [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CashPaymentDetails.cs b/src/Square/Types/CashPaymentDetails.cs index e178461f..acfa95fd 100644 --- a/src/Square/Types/CashPaymentDetails.cs +++ b/src/Square/Types/CashPaymentDetails.cs @@ -8,8 +8,13 @@ namespace Square; /// Stores details about a cash payment. Contains only non-confidential information. For more information, see /// [Take Cash Payments](https://developer.squareup.com/docs/payments-api/take-payments/cash-payments). /// -public record CashPaymentDetails +[Serializable] +public record CashPaymentDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount and currency of the money supplied by the buyer. /// @@ -24,15 +29,11 @@ public record CashPaymentDetails [JsonPropertyName("change_back_money")] public Money? ChangeBackMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogAvailabilityPeriod.cs b/src/Square/Types/CatalogAvailabilityPeriod.cs index 105870b9..2b968783 100644 --- a/src/Square/Types/CatalogAvailabilityPeriod.cs +++ b/src/Square/Types/CatalogAvailabilityPeriod.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a time period of availability. /// -public record CatalogAvailabilityPeriod +[Serializable] +public record CatalogAvailabilityPeriod : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The start time of an availability period, specified in local time using partial-time /// RFC 3339 format. For example, `8:30:00` for a period starting at 8:30 in the morning. @@ -32,15 +37,11 @@ public record CatalogAvailabilityPeriod [JsonPropertyName("day_of_week")] public DayOfWeek? DayOfWeek { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCategory.cs b/src/Square/Types/CatalogCategory.cs index b0c39204..49efdd8e 100644 --- a/src/Square/Types/CatalogCategory.cs +++ b/src/Square/Types/CatalogCategory.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A category to which a `CatalogItem` instance belongs. /// -public record CatalogCategory +[Serializable] +public record CatalogCategory : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The category name. This is a searchable attribute for use in applicable query filters, and its value length is of Unicode code points. /// @@ -79,15 +84,11 @@ public record CatalogCategory [JsonPropertyName("path_to_root")] public IEnumerable? PathToRoot { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCategoryType.cs b/src/Square/Types/CatalogCategoryType.cs index c4dbef81..007700bd 100644 --- a/src/Square/Types/CatalogCategoryType.cs +++ b/src/Square/Types/CatalogCategoryType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogCategoryType : IStringEnum { public static readonly CatalogCategoryType RegularCategory = new(Values.RegularCategory); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string RegularCategory = "REGULAR_CATEGORY"; diff --git a/src/Square/Types/CatalogCustomAttributeDefinition.cs b/src/Square/Types/CatalogCustomAttributeDefinition.cs index c3ab30d2..5295742b 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinition.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinition.cs @@ -11,8 +11,13 @@ namespace Square; /// to store any sensitive information (personally identifiable information, card details, etc.). /// [Read more about custom attributes](https://developer.squareup.com/docs/catalog-api/add-custom-attributes) /// -public record CatalogCustomAttributeDefinition +[Serializable] +public record CatalogCustomAttributeDefinition : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of this custom attribute. Cannot be modified after creation. /// Required. @@ -105,15 +110,11 @@ public record CatalogCustomAttributeDefinition [JsonPropertyName("key")] public string? Key { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionAppVisibility.cs b/src/Square/Types/CatalogCustomAttributeDefinitionAppVisibility.cs index ab4ed82d..28c67142 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionAppVisibility.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionAppVisibility.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogCustomAttributeDefinitionAppVisibility : IStringEnum { public static readonly CatalogCustomAttributeDefinitionAppVisibility AppVisibilityHidden = new( @@ -66,6 +67,7 @@ public static explicit operator CatalogCustomAttributeDefinitionAppVisibility(st /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AppVisibilityHidden = "APP_VISIBILITY_HIDDEN"; diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionNumberConfig.cs b/src/Square/Types/CatalogCustomAttributeDefinitionNumberConfig.cs index 8315494a..18ed79be 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionNumberConfig.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionNumberConfig.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogCustomAttributeDefinitionNumberConfig +[Serializable] +public record CatalogCustomAttributeDefinitionNumberConfig : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// An integer between 0 and 5 that represents the maximum number of /// positions allowed after the decimal in number custom attribute values @@ -20,15 +25,11 @@ public record CatalogCustomAttributeDefinitionNumberConfig [JsonPropertyName("precision")] public int? Precision { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfig.cs b/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfig.cs index d396e915..707edf05 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfig.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfig.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Configuration associated with `SELECTION`-type custom attribute definitions. /// -public record CatalogCustomAttributeDefinitionSelectionConfig +[Serializable] +public record CatalogCustomAttributeDefinitionSelectionConfig : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The maximum number of selections that can be set. The maximum value for this /// attribute is 100. The default value is 1. The value can be modified, but changing the value will not @@ -25,15 +30,11 @@ public record CatalogCustomAttributeDefinitionSelectionConfig [JsonPropertyName("allowed_selections")] public IEnumerable? AllowedSelections { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSelection.cs b/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSelection.cs index d16dff1d..cdba1473 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSelection.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSelection.cs @@ -7,8 +7,14 @@ namespace Square; /// /// A named selection for this `SELECTION`-type custom attribute definition. /// +[Serializable] public record CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSelection + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique ID set by Square. /// @@ -21,15 +27,11 @@ public record CatalogCustomAttributeDefinitionSelectionConfigCustomAttributeSele [JsonPropertyName("name")] public required string Name { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionSellerVisibility.cs b/src/Square/Types/CatalogCustomAttributeDefinitionSellerVisibility.cs index 07476dd4..e6b23584 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionSellerVisibility.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionSellerVisibility.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogCustomAttributeDefinitionSellerVisibility : IStringEnum { public static readonly CatalogCustomAttributeDefinitionSellerVisibility SellerVisibilityHidden = @@ -64,6 +65,7 @@ string value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string SellerVisibilityHidden = "SELLER_VISIBILITY_HIDDEN"; diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionStringConfig.cs b/src/Square/Types/CatalogCustomAttributeDefinitionStringConfig.cs index 1a7123ec..4554db3f 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionStringConfig.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionStringConfig.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Configuration associated with Custom Attribute Definitions of type `STRING`. /// -public record CatalogCustomAttributeDefinitionStringConfig +[Serializable] +public record CatalogCustomAttributeDefinitionStringConfig : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// If true, each Custom Attribute instance associated with this Custom Attribute /// Definition must have a unique value within the seller's catalog. For @@ -19,15 +24,11 @@ public record CatalogCustomAttributeDefinitionStringConfig [JsonPropertyName("enforce_uniqueness")] public bool? EnforceUniqueness { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogCustomAttributeDefinitionType.cs b/src/Square/Types/CatalogCustomAttributeDefinitionType.cs index 344e6dab..03b2dc18 100644 --- a/src/Square/Types/CatalogCustomAttributeDefinitionType.cs +++ b/src/Square/Types/CatalogCustomAttributeDefinitionType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogCustomAttributeDefinitionType : IStringEnum { public static readonly CatalogCustomAttributeDefinitionType String = new(Values.String); @@ -60,6 +61,7 @@ public static explicit operator CatalogCustomAttributeDefinitionType(string valu /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string String = "STRING"; diff --git a/src/Square/Types/CatalogCustomAttributeValue.cs b/src/Square/Types/CatalogCustomAttributeValue.cs index 5a91c8d5..03ddefa9 100644 --- a/src/Square/Types/CatalogCustomAttributeValue.cs +++ b/src/Square/Types/CatalogCustomAttributeValue.cs @@ -9,8 +9,13 @@ namespace Square; /// added to `ITEM` and `ITEM_VARIATION` type catalog objects. /// [Read more about custom attributes](https://developer.squareup.com/docs/catalog-api/add-custom-attributes). /// -public record CatalogCustomAttributeValue +[Serializable] +public record CatalogCustomAttributeValue : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the custom attribute. /// @@ -65,15 +70,11 @@ public record CatalogCustomAttributeValue [JsonPropertyName("key")] public string? Key { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogDiscount.cs b/src/Square/Types/CatalogDiscount.cs index 2d80507f..c5d1584a 100644 --- a/src/Square/Types/CatalogDiscount.cs +++ b/src/Square/Types/CatalogDiscount.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A discount applicable to items. /// -public record CatalogDiscount +[Serializable] +public record CatalogDiscount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The discount name. This is a searchable attribute for use in applicable query filters, and its value length is of Unicode code points. /// @@ -77,15 +82,11 @@ public record CatalogDiscount [JsonPropertyName("maximum_amount_money")] public Money? MaximumAmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogDiscountModifyTaxBasis.cs b/src/Square/Types/CatalogDiscountModifyTaxBasis.cs index ab464a33..9b17f42a 100644 --- a/src/Square/Types/CatalogDiscountModifyTaxBasis.cs +++ b/src/Square/Types/CatalogDiscountModifyTaxBasis.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogDiscountModifyTaxBasis : IStringEnum { public static readonly CatalogDiscountModifyTaxBasis ModifyTaxBasis = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ModifyTaxBasis = "MODIFY_TAX_BASIS"; diff --git a/src/Square/Types/CatalogDiscountType.cs b/src/Square/Types/CatalogDiscountType.cs index 8ad7e8e3..91c2226d 100644 --- a/src/Square/Types/CatalogDiscountType.cs +++ b/src/Square/Types/CatalogDiscountType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogDiscountType : IStringEnum { public static readonly CatalogDiscountType FixedPercentage = new(Values.FixedPercentage); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string FixedPercentage = "FIXED_PERCENTAGE"; diff --git a/src/Square/Types/CatalogEcomSeoData.cs b/src/Square/Types/CatalogEcomSeoData.cs index a55d752f..4fdcaedc 100644 --- a/src/Square/Types/CatalogEcomSeoData.cs +++ b/src/Square/Types/CatalogEcomSeoData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// SEO data for for a seller's Square Online store. /// -public record CatalogEcomSeoData +[Serializable] +public record CatalogEcomSeoData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The SEO title used for the Square Online store. /// @@ -27,15 +32,11 @@ public record CatalogEcomSeoData [JsonPropertyName("permalink")] public string? Permalink { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogIdMapping.cs b/src/Square/Types/CatalogIdMapping.cs index 0b8f91e5..050448e9 100644 --- a/src/Square/Types/CatalogIdMapping.cs +++ b/src/Square/Types/CatalogIdMapping.cs @@ -17,8 +17,13 @@ namespace Square; /// After the request is submitted and the object created, a permanent server-generated ID is assigned /// to the new object. The permanent ID is unique across the Square catalog. /// -public record CatalogIdMapping +[Serializable] +public record CatalogIdMapping : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The client-supplied temporary `#`-prefixed ID for a new `CatalogObject`. /// @@ -31,15 +36,11 @@ public record CatalogIdMapping [JsonPropertyName("object_id")] public string? ObjectId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogImage.cs b/src/Square/Types/CatalogImage.cs index e00abfbb..7aa4d4b1 100644 --- a/src/Square/Types/CatalogImage.cs +++ b/src/Square/Types/CatalogImage.cs @@ -12,8 +12,13 @@ namespace Square; /// Images on items and variations are displayed through Square Online Store. /// Images on other object types are for use by 3rd party application developers. /// -public record CatalogImage +[Serializable] +public record CatalogImage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The internal name to identify this image in calls to the Square API. /// This is a searchable attribute for use in applicable query filters @@ -45,15 +50,11 @@ public record CatalogImage [JsonPropertyName("photo_studio_order_id")] public string? PhotoStudioOrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogInfoResponse.cs b/src/Square/Types/CatalogInfoResponse.cs index cc97066a..9b5572de 100644 --- a/src/Square/Types/CatalogInfoResponse.cs +++ b/src/Square/Types/CatalogInfoResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogInfoResponse +[Serializable] +public record CatalogInfoResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record CatalogInfoResponse [JsonPropertyName("standard_unit_description_group")] public StandardUnitDescriptionGroup? StandardUnitDescriptionGroup { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogInfoResponseLimits.cs b/src/Square/Types/CatalogInfoResponseLimits.cs index f4a22ed4..f1e9092b 100644 --- a/src/Square/Types/CatalogInfoResponseLimits.cs +++ b/src/Square/Types/CatalogInfoResponseLimits.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogInfoResponseLimits +[Serializable] +public record CatalogInfoResponseLimits : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The maximum number of objects that may appear within a single batch in a /// `/v2/catalog/batch-upsert` request. @@ -83,15 +88,11 @@ public record CatalogInfoResponseLimits [JsonPropertyName("update_item_modifier_lists_max_modifier_lists_to_disable")] public int? UpdateItemModifierListsMaxModifierListsToDisable { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItem.cs b/src/Square/Types/CatalogItem.cs index fb7cf162..c876a98c 100644 --- a/src/Square/Types/CatalogItem.cs +++ b/src/Square/Types/CatalogItem.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A [CatalogObject](entity:CatalogObject) instance of the `ITEM` type, also referred to as an item, in the catalog. /// -public record CatalogItem +[Serializable] +public record CatalogItem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The item's name. This is a searchable attribute for use in applicable query filters, its value must not be empty, and the length is of Unicode code points. /// @@ -216,15 +221,11 @@ public record CatalogItem [JsonPropertyName("is_alcoholic")] public bool? IsAlcoholic { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemFoodAndBeverageDetails.cs b/src/Square/Types/CatalogItemFoodAndBeverageDetails.cs index 4e8bf383..e3122ffc 100644 --- a/src/Square/Types/CatalogItemFoodAndBeverageDetails.cs +++ b/src/Square/Types/CatalogItemFoodAndBeverageDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The food and beverage-specific details of a `FOOD_AND_BEV` item. /// -public record CatalogItemFoodAndBeverageDetails +[Serializable] +public record CatalogItemFoodAndBeverageDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The calorie count (in the unit of kcal) for the `FOOD_AND_BEV` type of items. /// @@ -27,15 +32,11 @@ public record CatalogItemFoodAndBeverageDetails [JsonPropertyName("ingredients")] public IEnumerable? Ingredients { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreference.cs b/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreference.cs index 70e3417a..56e9f80a 100644 --- a/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreference.cs +++ b/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreference.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Dietary preferences that can be assigned to an `FOOD_AND_BEV` item and its ingredients. /// -public record CatalogItemFoodAndBeverageDetailsDietaryPreference +[Serializable] +public record CatalogItemFoodAndBeverageDetailsDietaryPreference : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dietary preference type. Supported values include `STANDARD` and `CUSTOM` as specified in `FoodAndBeverageDetails.DietaryPreferenceType`. /// See [DietaryPreferenceType](#type-dietarypreferencetype) for possible values @@ -29,15 +34,11 @@ public record CatalogItemFoodAndBeverageDetailsDietaryPreference [JsonPropertyName("custom_name")] public string? CustomName { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceStandardDietaryPreference.cs b/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceStandardDietaryPreference.cs index bb09364f..b1c32908 100644 --- a/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceStandardDietaryPreference.cs +++ b/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceStandardDietaryPreference.cs @@ -6,6 +6,7 @@ namespace Square; [JsonConverter( typeof(StringEnumSerializer) )] +[Serializable] public readonly record struct CatalogItemFoodAndBeverageDetailsDietaryPreferenceStandardDietaryPreference : IStringEnum { @@ -86,6 +87,7 @@ string value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string DairyFree = "DAIRY_FREE"; diff --git a/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceType.cs b/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceType.cs index fa8877c0..40aa1de3 100644 --- a/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceType.cs +++ b/src/Square/Types/CatalogItemFoodAndBeverageDetailsDietaryPreferenceType.cs @@ -6,6 +6,7 @@ namespace Square; [JsonConverter( typeof(StringEnumSerializer) )] +[Serializable] public readonly record struct CatalogItemFoodAndBeverageDetailsDietaryPreferenceType : IStringEnum { public static readonly CatalogItemFoodAndBeverageDetailsDietaryPreferenceType Standard = new( @@ -68,6 +69,7 @@ string value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Standard = "STANDARD"; diff --git a/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredient.cs b/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredient.cs index f806dc25..90ef79ee 100644 --- a/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredient.cs +++ b/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredient.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes the ingredient used in a `FOOD_AND_BEV` item. /// -public record CatalogItemFoodAndBeverageDetailsIngredient +[Serializable] +public record CatalogItemFoodAndBeverageDetailsIngredient : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dietary preference type of the ingredient. Supported values include `STANDARD` and `CUSTOM` as specified in `FoodAndBeverageDetails.DietaryPreferenceType`. /// See [DietaryPreferenceType](#type-dietarypreferencetype) for possible values @@ -29,15 +34,11 @@ public record CatalogItemFoodAndBeverageDetailsIngredient [JsonPropertyName("custom_name")] public string? CustomName { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredientStandardIngredient.cs b/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredientStandardIngredient.cs index 59f44265..595fe78b 100644 --- a/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredientStandardIngredient.cs +++ b/src/Square/Types/CatalogItemFoodAndBeverageDetailsIngredientStandardIngredient.cs @@ -6,6 +6,7 @@ namespace Square; [JsonConverter( typeof(StringEnumSerializer) )] +[Serializable] public readonly record struct CatalogItemFoodAndBeverageDetailsIngredientStandardIngredient : IStringEnum { @@ -109,6 +110,7 @@ string value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Celery = "CELERY"; diff --git a/src/Square/Types/CatalogItemModifierListInfo.cs b/src/Square/Types/CatalogItemModifierListInfo.cs index 43d056f4..bdbff1df 100644 --- a/src/Square/Types/CatalogItemModifierListInfo.cs +++ b/src/Square/Types/CatalogItemModifierListInfo.cs @@ -8,8 +8,13 @@ namespace Square; /// Controls how a modifier list is applied to a specific item. This object allows for item-specific customization of modifier list behavior /// and provides the ability to override global modifier list settings. /// -public record CatalogItemModifierListInfo +[Serializable] +public record CatalogItemModifierListInfo : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `CatalogModifierList` controlled by this `CatalogModifierListInfo`. /// @@ -70,15 +75,11 @@ public record CatalogItemModifierListInfo [JsonPropertyName("hidden_from_customer_override")] public object? HiddenFromCustomerOverride { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemOption.cs b/src/Square/Types/CatalogItemOption.cs index e8081a60..aa57bd41 100644 --- a/src/Square/Types/CatalogItemOption.cs +++ b/src/Square/Types/CatalogItemOption.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A group of variations for a `CatalogItem`. /// -public record CatalogItemOption +[Serializable] +public record CatalogItemOption : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The item option's display name for the seller. Must be unique across /// all item options. This is a searchable attribute for use in applicable query filters. @@ -43,15 +48,11 @@ public record CatalogItemOption [JsonPropertyName("values")] public IEnumerable? Values { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemOptionForItem.cs b/src/Square/Types/CatalogItemOptionForItem.cs index cf73370d..fe480aa5 100644 --- a/src/Square/Types/CatalogItemOptionForItem.cs +++ b/src/Square/Types/CatalogItemOptionForItem.cs @@ -8,23 +8,24 @@ namespace Square; /// An option that can be assigned to an item. /// For example, a t-shirt item may offer a color option or a size option. /// -public record CatalogItemOptionForItem +[Serializable] +public record CatalogItemOptionForItem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique id of the item option, used to form the dimensions of the item option matrix in a specified order. /// [JsonPropertyName("item_option_id")] public string? ItemOptionId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemOptionValue.cs b/src/Square/Types/CatalogItemOptionValue.cs index a2c2c4c9..55088061 100644 --- a/src/Square/Types/CatalogItemOptionValue.cs +++ b/src/Square/Types/CatalogItemOptionValue.cs @@ -9,8 +9,13 @@ namespace Square; /// `CatalogItemVariation` to an item option as one of /// its item option values. /// -public record CatalogItemOptionValue +[Serializable] +public record CatalogItemOptionValue : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique ID of the associated item option. /// @@ -44,15 +49,11 @@ public record CatalogItemOptionValue [JsonPropertyName("ordinal")] public int? Ordinal { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemOptionValueForItemVariation.cs b/src/Square/Types/CatalogItemOptionValueForItemVariation.cs index c7cc6f92..8fead831 100644 --- a/src/Square/Types/CatalogItemOptionValueForItemVariation.cs +++ b/src/Square/Types/CatalogItemOptionValueForItemVariation.cs @@ -10,8 +10,13 @@ namespace Square; /// a size option. An item option value would represent each variation of t-shirt: /// For example, "Color:Red, Size:Small" or "Color:Blue, Size:Medium". /// -public record CatalogItemOptionValueForItemVariation +[Serializable] +public record CatalogItemOptionValueForItemVariation : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique id of an item option. /// @@ -24,15 +29,11 @@ public record CatalogItemOptionValueForItemVariation [JsonPropertyName("item_option_value_id")] public string? ItemOptionValueId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogItemProductType.cs b/src/Square/Types/CatalogItemProductType.cs index 246860af..c504eaaa 100644 --- a/src/Square/Types/CatalogItemProductType.cs +++ b/src/Square/Types/CatalogItemProductType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogItemProductType : IStringEnum { public static readonly CatalogItemProductType Regular = new(Values.Regular); @@ -74,6 +75,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Regular = "REGULAR"; diff --git a/src/Square/Types/CatalogItemVariation.cs b/src/Square/Types/CatalogItemVariation.cs index c7216602..4c475d21 100644 --- a/src/Square/Types/CatalogItemVariation.cs +++ b/src/Square/Types/CatalogItemVariation.cs @@ -16,8 +16,13 @@ namespace Square; /// the `stockable_conversion` property on the variation to specify the conversion. Thus, when two glasses of the wine are sold, the sellable count /// decreases by 2, and the stockable count automatically decreases by 0.4 bottle according to the conversion. /// -public record CatalogItemVariation +[Serializable] +public record CatalogItemVariation : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `CatalogItem` associated with this item variation. /// @@ -180,15 +185,11 @@ public record CatalogItemVariation [JsonPropertyName("stockable_conversion")] public CatalogStockConversion? StockableConversion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogMeasurementUnit.cs b/src/Square/Types/CatalogMeasurementUnit.cs index 96dae105..385ef60f 100644 --- a/src/Square/Types/CatalogMeasurementUnit.cs +++ b/src/Square/Types/CatalogMeasurementUnit.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the unit used to measure a `CatalogItemVariation` and /// specifies the precision for decimal quantities. /// -public record CatalogMeasurementUnit +[Serializable] +public record CatalogMeasurementUnit : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates the unit used to measure the quantity of a catalog item variation. /// @@ -30,15 +35,11 @@ public record CatalogMeasurementUnit [JsonPropertyName("precision")] public int? Precision { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogModifier.cs b/src/Square/Types/CatalogModifier.cs index 83f30756..9dac4b65 100644 --- a/src/Square/Types/CatalogModifier.cs +++ b/src/Square/Types/CatalogModifier.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A modifier that can be applied to items at the time of sale. For example, a cheese modifier for a burger, or a flavor modifier for a serving of ice cream. /// -public record CatalogModifier +[Serializable] +public record CatalogModifier : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The modifier name. This is a searchable attribute for use in applicable query filters, and its value length is of Unicode code points. /// @@ -59,15 +64,11 @@ public record CatalogModifier [JsonPropertyName("hidden_online")] public bool? HiddenOnline { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogModifierList.cs b/src/Square/Types/CatalogModifierList.cs index fb9fef15..8128727d 100644 --- a/src/Square/Types/CatalogModifierList.cs +++ b/src/Square/Types/CatalogModifierList.cs @@ -11,8 +11,13 @@ namespace Square; /// (For example, a list of condiments for a hot dog, or a list of ice cream flavors). /// Each element of the modifier list is a `CatalogObject` instance of the `MODIFIER` type. /// -public record CatalogModifierList +[Serializable] +public record CatalogModifierList : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the `CatalogModifierList` instance. This is a searchable attribute for use in applicable query filters, and its value length is of /// Unicode code points. @@ -138,15 +143,11 @@ public record CatalogModifierList [JsonPropertyName("hidden_from_customer")] public bool? HiddenFromCustomer { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogModifierListModifierType.cs b/src/Square/Types/CatalogModifierListModifierType.cs index 65621ea4..69c60e91 100644 --- a/src/Square/Types/CatalogModifierListModifierType.cs +++ b/src/Square/Types/CatalogModifierListModifierType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogModifierListModifierType : IStringEnum { public static readonly CatalogModifierListModifierType List = new(Values.List); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string List = "LIST"; diff --git a/src/Square/Types/CatalogModifierListSelectionType.cs b/src/Square/Types/CatalogModifierListSelectionType.cs index 007641a9..edcac967 100644 --- a/src/Square/Types/CatalogModifierListSelectionType.cs +++ b/src/Square/Types/CatalogModifierListSelectionType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogModifierListSelectionType : IStringEnum { public static readonly CatalogModifierListSelectionType Single = new(Values.Single); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Single = "SINGLE"; diff --git a/src/Square/Types/CatalogModifierOverride.cs b/src/Square/Types/CatalogModifierOverride.cs index e6b12f65..b6a330e4 100644 --- a/src/Square/Types/CatalogModifierOverride.cs +++ b/src/Square/Types/CatalogModifierOverride.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Options to control how to override the default behavior of the specified modifier. /// -public record CatalogModifierOverride +[Serializable] +public record CatalogModifierOverride : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `CatalogModifier` whose default behavior is being overridden. /// @@ -27,15 +32,11 @@ public record CatalogModifierOverride [JsonPropertyName("on_by_default_override")] public object? OnByDefaultOverride { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObject.cs b/src/Square/Types/CatalogObject.cs index 86530b3b..f8e512d3 100644 --- a/src/Square/Types/CatalogObject.cs +++ b/src/Square/Types/CatalogObject.cs @@ -21,6 +21,7 @@ namespace Square; /// [Design a Catalog](https://developer.squareup.com/docs/catalog-api/design-a-catalog) guide. /// [JsonConverter(typeof(CatalogObject.JsonConverter))] +[Serializable] public record CatalogObject { internal CatalogObject(string type, object? value) @@ -313,7 +314,7 @@ public CatalogObject(CatalogObject.AvailabilityPeriod value) public Square.CatalogObjectItem AsItem() => IsItem ? (Square.CatalogObjectItem)Value! - : throw new Exception("CatalogObject.Type is not 'ITEM'"); + : throw new System.Exception("CatalogObject.Type is not 'ITEM'"); /// /// Returns the value as a if is 'IMAGE', otherwise throws an exception. @@ -322,7 +323,7 @@ public Square.CatalogObjectItem AsItem() => public Square.CatalogObjectImage AsImage() => IsImage ? (Square.CatalogObjectImage)Value! - : throw new Exception("CatalogObject.Type is not 'IMAGE'"); + : throw new System.Exception("CatalogObject.Type is not 'IMAGE'"); /// /// Returns the value as a if is 'CATEGORY', otherwise throws an exception. @@ -331,7 +332,7 @@ public Square.CatalogObjectImage AsImage() => public Square.CatalogObjectCategory AsCategory() => IsCategory ? (Square.CatalogObjectCategory)Value! - : throw new Exception("CatalogObject.Type is not 'CATEGORY'"); + : throw new System.Exception("CatalogObject.Type is not 'CATEGORY'"); /// /// Returns the value as a if is 'ITEM_VARIATION', otherwise throws an exception. @@ -340,7 +341,7 @@ public Square.CatalogObjectCategory AsCategory() => public Square.CatalogObjectItemVariation AsItemVariation() => IsItemVariation ? (Square.CatalogObjectItemVariation)Value! - : throw new Exception("CatalogObject.Type is not 'ITEM_VARIATION'"); + : throw new System.Exception("CatalogObject.Type is not 'ITEM_VARIATION'"); /// /// Returns the value as a if is 'TAX', otherwise throws an exception. @@ -349,7 +350,7 @@ public Square.CatalogObjectItemVariation AsItemVariation() => public Square.CatalogObjectTax AsTax() => IsTax ? (Square.CatalogObjectTax)Value! - : throw new Exception("CatalogObject.Type is not 'TAX'"); + : throw new System.Exception("CatalogObject.Type is not 'TAX'"); /// /// Returns the value as a if is 'DISCOUNT', otherwise throws an exception. @@ -358,7 +359,7 @@ public Square.CatalogObjectTax AsTax() => public Square.CatalogObjectDiscount AsDiscount() => IsDiscount ? (Square.CatalogObjectDiscount)Value! - : throw new Exception("CatalogObject.Type is not 'DISCOUNT'"); + : throw new System.Exception("CatalogObject.Type is not 'DISCOUNT'"); /// /// Returns the value as a if is 'MODIFIER_LIST', otherwise throws an exception. @@ -367,7 +368,7 @@ public Square.CatalogObjectDiscount AsDiscount() => public Square.CatalogObjectModifierList AsModifierList() => IsModifierList ? (Square.CatalogObjectModifierList)Value! - : throw new Exception("CatalogObject.Type is not 'MODIFIER_LIST'"); + : throw new System.Exception("CatalogObject.Type is not 'MODIFIER_LIST'"); /// /// Returns the value as a if is 'MODIFIER', otherwise throws an exception. @@ -376,7 +377,7 @@ public Square.CatalogObjectModifierList AsModifierList() => public Square.CatalogObjectModifier AsModifier() => IsModifier ? (Square.CatalogObjectModifier)Value! - : throw new Exception("CatalogObject.Type is not 'MODIFIER'"); + : throw new System.Exception("CatalogObject.Type is not 'MODIFIER'"); /// /// Returns the value as a if is 'PRICING_RULE', otherwise throws an exception. @@ -385,7 +386,7 @@ public Square.CatalogObjectModifier AsModifier() => public Square.CatalogObjectPricingRule AsPricingRule() => IsPricingRule ? (Square.CatalogObjectPricingRule)Value! - : throw new Exception("CatalogObject.Type is not 'PRICING_RULE'"); + : throw new System.Exception("CatalogObject.Type is not 'PRICING_RULE'"); /// /// Returns the value as a if is 'PRODUCT_SET', otherwise throws an exception. @@ -394,7 +395,7 @@ public Square.CatalogObjectPricingRule AsPricingRule() => public Square.CatalogObjectProductSet AsProductSet() => IsProductSet ? (Square.CatalogObjectProductSet)Value! - : throw new Exception("CatalogObject.Type is not 'PRODUCT_SET'"); + : throw new System.Exception("CatalogObject.Type is not 'PRODUCT_SET'"); /// /// Returns the value as a if is 'TIME_PERIOD', otherwise throws an exception. @@ -403,7 +404,7 @@ public Square.CatalogObjectProductSet AsProductSet() => public Square.CatalogObjectTimePeriod AsTimePeriod() => IsTimePeriod ? (Square.CatalogObjectTimePeriod)Value! - : throw new Exception("CatalogObject.Type is not 'TIME_PERIOD'"); + : throw new System.Exception("CatalogObject.Type is not 'TIME_PERIOD'"); /// /// Returns the value as a if is 'MEASUREMENT_UNIT', otherwise throws an exception. @@ -412,7 +413,7 @@ public Square.CatalogObjectTimePeriod AsTimePeriod() => public Square.CatalogObjectMeasurementUnit AsMeasurementUnit() => IsMeasurementUnit ? (Square.CatalogObjectMeasurementUnit)Value! - : throw new Exception("CatalogObject.Type is not 'MEASUREMENT_UNIT'"); + : throw new System.Exception("CatalogObject.Type is not 'MEASUREMENT_UNIT'"); /// /// Returns the value as a if is 'SUBSCRIPTION_PLAN_VARIATION', otherwise throws an exception. @@ -421,7 +422,7 @@ public Square.CatalogObjectMeasurementUnit AsMeasurementUnit() => public Square.CatalogObjectSubscriptionPlanVariation AsSubscriptionPlanVariation() => IsSubscriptionPlanVariation ? (Square.CatalogObjectSubscriptionPlanVariation)Value! - : throw new Exception("CatalogObject.Type is not 'SUBSCRIPTION_PLAN_VARIATION'"); + : throw new System.Exception("CatalogObject.Type is not 'SUBSCRIPTION_PLAN_VARIATION'"); /// /// Returns the value as a if is 'ITEM_OPTION', otherwise throws an exception. @@ -430,7 +431,7 @@ public Square.CatalogObjectSubscriptionPlanVariation AsSubscriptionPlanVariation public Square.CatalogObjectItemOption AsItemOption() => IsItemOption ? (Square.CatalogObjectItemOption)Value! - : throw new Exception("CatalogObject.Type is not 'ITEM_OPTION'"); + : throw new System.Exception("CatalogObject.Type is not 'ITEM_OPTION'"); /// /// Returns the value as a if is 'ITEM_OPTION_VAL', otherwise throws an exception. @@ -439,7 +440,7 @@ public Square.CatalogObjectItemOption AsItemOption() => public Square.CatalogObjectItemOptionValue AsItemOptionVal() => IsItemOptionVal ? (Square.CatalogObjectItemOptionValue)Value! - : throw new Exception("CatalogObject.Type is not 'ITEM_OPTION_VAL'"); + : throw new System.Exception("CatalogObject.Type is not 'ITEM_OPTION_VAL'"); /// /// Returns the value as a if is 'CUSTOM_ATTRIBUTE_DEFINITION', otherwise throws an exception. @@ -448,7 +449,7 @@ public Square.CatalogObjectItemOptionValue AsItemOptionVal() => public Square.CatalogObjectCustomAttributeDefinition AsCustomAttributeDefinition() => IsCustomAttributeDefinition ? (Square.CatalogObjectCustomAttributeDefinition)Value! - : throw new Exception("CatalogObject.Type is not 'CUSTOM_ATTRIBUTE_DEFINITION'"); + : throw new System.Exception("CatalogObject.Type is not 'CUSTOM_ATTRIBUTE_DEFINITION'"); /// /// Returns the value as a if is 'QUICK_AMOUNTS_SETTINGS', otherwise throws an exception. @@ -457,7 +458,7 @@ public Square.CatalogObjectCustomAttributeDefinition AsCustomAttributeDefinition public Square.CatalogObjectQuickAmountsSettings AsQuickAmountsSettings() => IsQuickAmountsSettings ? (Square.CatalogObjectQuickAmountsSettings)Value! - : throw new Exception("CatalogObject.Type is not 'QUICK_AMOUNTS_SETTINGS'"); + : throw new System.Exception("CatalogObject.Type is not 'QUICK_AMOUNTS_SETTINGS'"); /// /// Returns the value as a if is 'SUBSCRIPTION_PLAN', otherwise throws an exception. @@ -466,7 +467,7 @@ public Square.CatalogObjectQuickAmountsSettings AsQuickAmountsSettings() => public Square.CatalogObjectSubscriptionPlan AsSubscriptionPlan() => IsSubscriptionPlan ? (Square.CatalogObjectSubscriptionPlan)Value! - : throw new Exception("CatalogObject.Type is not 'SUBSCRIPTION_PLAN'"); + : throw new System.Exception("CatalogObject.Type is not 'SUBSCRIPTION_PLAN'"); /// /// Returns the value as a if is 'AVAILABILITY_PERIOD', otherwise throws an exception. @@ -475,7 +476,7 @@ public Square.CatalogObjectSubscriptionPlan AsSubscriptionPlan() => public Square.CatalogObjectAvailabilityPeriod AsAvailabilityPeriod() => IsAvailabilityPeriod ? (Square.CatalogObjectAvailabilityPeriod)Value! - : throw new Exception("CatalogObject.Type is not 'AVAILABILITY_PERIOD'"); + : throw new System.Exception("CatalogObject.Type is not 'AVAILABILITY_PERIOD'"); public T Match( Func onItem, @@ -933,6 +934,7 @@ public static implicit operator CatalogObject(CatalogObject.SubscriptionPlan val public static implicit operator CatalogObject(CatalogObject.AvailabilityPeriod value) => new(value); + [Serializable] internal sealed class JsonConverter : JsonConverter { public override bool CanConvert(global::System.Type typeToConvert) => @@ -967,78 +969,80 @@ JsonSerializerOptions options var value = discriminator switch { - "ITEM" => json.Deserialize(options) + "ITEM" => json.Deserialize(options) ?? throw new JsonException("Failed to deserialize Square.CatalogObjectItem"), - "IMAGE" => json.Deserialize(options) + "IMAGE" => json.Deserialize(options) ?? throw new JsonException("Failed to deserialize Square.CatalogObjectImage"), - "CATEGORY" => json.Deserialize(options) + "CATEGORY" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectCategory" ), - "ITEM_VARIATION" => json.Deserialize(options) + "ITEM_VARIATION" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectItemVariation" ), - "TAX" => json.Deserialize(options) + "TAX" => json.Deserialize(options) ?? throw new JsonException("Failed to deserialize Square.CatalogObjectTax"), - "DISCOUNT" => json.Deserialize(options) + "DISCOUNT" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectDiscount" ), - "MODIFIER_LIST" => json.Deserialize(options) + "MODIFIER_LIST" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectModifierList" ), - "MODIFIER" => json.Deserialize(options) + "MODIFIER" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectModifier" ), - "PRICING_RULE" => json.Deserialize(options) + "PRICING_RULE" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectPricingRule" ), - "PRODUCT_SET" => json.Deserialize(options) + "PRODUCT_SET" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectProductSet" ), - "TIME_PERIOD" => json.Deserialize(options) + "TIME_PERIOD" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectTimePeriod" ), - "MEASUREMENT_UNIT" => json.Deserialize(options) + "MEASUREMENT_UNIT" => json.Deserialize( + options + ) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectMeasurementUnit" ), "SUBSCRIPTION_PLAN_VARIATION" => - json.Deserialize(options) + json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectSubscriptionPlanVariation" ), - "ITEM_OPTION" => json.Deserialize(options) + "ITEM_OPTION" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectItemOption" ), - "ITEM_OPTION_VAL" => json.Deserialize(options) + "ITEM_OPTION_VAL" => json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectItemOptionValue" ), "CUSTOM_ATTRIBUTE_DEFINITION" => - json.Deserialize(options) + json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectCustomAttributeDefinition" ), "QUICK_AMOUNTS_SETTINGS" => - json.Deserialize(options) + json.Deserialize(options) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectQuickAmountsSettings" ), - "SUBSCRIPTION_PLAN" => json.Deserialize( + "SUBSCRIPTION_PLAN" => json.Deserialize( options ) ?? throw new JsonException( "Failed to deserialize Square.CatalogObjectSubscriptionPlan" ), - "AVAILABILITY_PERIOD" => json.Deserialize( + "AVAILABILITY_PERIOD" => json.Deserialize( options ) ?? throw new JsonException( @@ -1096,6 +1100,7 @@ JsonSerializerOptions options /// /// Discriminated union type for ITEM /// + [Serializable] public struct Item { public Item(Square.CatalogObjectItem value) @@ -1105,14 +1110,16 @@ public Item(Square.CatalogObjectItem value) internal Square.CatalogObjectItem Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator Item(Square.CatalogObjectItem value) => new(value); + public static implicit operator CatalogObject.Item(Square.CatalogObjectItem value) => + new(value); } /// /// Discriminated union type for IMAGE /// + [Serializable] public struct Image { public Image(Square.CatalogObjectImage value) @@ -1122,14 +1129,16 @@ public Image(Square.CatalogObjectImage value) internal Square.CatalogObjectImage Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator Image(Square.CatalogObjectImage value) => new(value); + public static implicit operator CatalogObject.Image(Square.CatalogObjectImage value) => + new(value); } /// /// Discriminated union type for CATEGORY /// + [Serializable] public struct Category { public Category(Square.CatalogObjectCategory value) @@ -1139,14 +1148,17 @@ public Category(Square.CatalogObjectCategory value) internal Square.CatalogObjectCategory Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator Category(Square.CatalogObjectCategory value) => new(value); + public static implicit operator CatalogObject.Category( + Square.CatalogObjectCategory value + ) => new(value); } /// /// Discriminated union type for ITEM_VARIATION /// + [Serializable] public struct ItemVariation { public ItemVariation(Square.CatalogObjectItemVariation value) @@ -1156,15 +1168,17 @@ public ItemVariation(Square.CatalogObjectItemVariation value) internal Square.CatalogObjectItemVariation Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator ItemVariation(Square.CatalogObjectItemVariation value) => - new(value); + public static implicit operator CatalogObject.ItemVariation( + Square.CatalogObjectItemVariation value + ) => new(value); } /// /// Discriminated union type for TAX /// + [Serializable] public struct Tax { public Tax(Square.CatalogObjectTax value) @@ -1174,14 +1188,16 @@ public Tax(Square.CatalogObjectTax value) internal Square.CatalogObjectTax Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator Tax(Square.CatalogObjectTax value) => new(value); + public static implicit operator CatalogObject.Tax(Square.CatalogObjectTax value) => + new(value); } /// /// Discriminated union type for DISCOUNT /// + [Serializable] public struct Discount { public Discount(Square.CatalogObjectDiscount value) @@ -1191,14 +1207,17 @@ public Discount(Square.CatalogObjectDiscount value) internal Square.CatalogObjectDiscount Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator Discount(Square.CatalogObjectDiscount value) => new(value); + public static implicit operator CatalogObject.Discount( + Square.CatalogObjectDiscount value + ) => new(value); } /// /// Discriminated union type for MODIFIER_LIST /// + [Serializable] public struct ModifierList { public ModifierList(Square.CatalogObjectModifierList value) @@ -1208,15 +1227,17 @@ public ModifierList(Square.CatalogObjectModifierList value) internal Square.CatalogObjectModifierList Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator ModifierList(Square.CatalogObjectModifierList value) => - new(value); + public static implicit operator CatalogObject.ModifierList( + Square.CatalogObjectModifierList value + ) => new(value); } /// /// Discriminated union type for MODIFIER /// + [Serializable] public struct Modifier { public Modifier(Square.CatalogObjectModifier value) @@ -1226,14 +1247,17 @@ public Modifier(Square.CatalogObjectModifier value) internal Square.CatalogObjectModifier Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator Modifier(Square.CatalogObjectModifier value) => new(value); + public static implicit operator CatalogObject.Modifier( + Square.CatalogObjectModifier value + ) => new(value); } /// /// Discriminated union type for PRICING_RULE /// + [Serializable] public struct PricingRule { public PricingRule(Square.CatalogObjectPricingRule value) @@ -1243,15 +1267,17 @@ public PricingRule(Square.CatalogObjectPricingRule value) internal Square.CatalogObjectPricingRule Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator PricingRule(Square.CatalogObjectPricingRule value) => - new(value); + public static implicit operator CatalogObject.PricingRule( + Square.CatalogObjectPricingRule value + ) => new(value); } /// /// Discriminated union type for PRODUCT_SET /// + [Serializable] public struct ProductSet { public ProductSet(Square.CatalogObjectProductSet value) @@ -1261,15 +1287,17 @@ public ProductSet(Square.CatalogObjectProductSet value) internal Square.CatalogObjectProductSet Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator ProductSet(Square.CatalogObjectProductSet value) => - new(value); + public static implicit operator CatalogObject.ProductSet( + Square.CatalogObjectProductSet value + ) => new(value); } /// /// Discriminated union type for TIME_PERIOD /// + [Serializable] public struct TimePeriod { public TimePeriod(Square.CatalogObjectTimePeriod value) @@ -1279,15 +1307,17 @@ public TimePeriod(Square.CatalogObjectTimePeriod value) internal Square.CatalogObjectTimePeriod Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator TimePeriod(Square.CatalogObjectTimePeriod value) => - new(value); + public static implicit operator CatalogObject.TimePeriod( + Square.CatalogObjectTimePeriod value + ) => new(value); } /// /// Discriminated union type for MEASUREMENT_UNIT /// + [Serializable] public struct MeasurementUnit { public MeasurementUnit(Square.CatalogObjectMeasurementUnit value) @@ -1297,9 +1327,9 @@ public MeasurementUnit(Square.CatalogObjectMeasurementUnit value) internal Square.CatalogObjectMeasurementUnit Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator MeasurementUnit( + public static implicit operator CatalogObject.MeasurementUnit( Square.CatalogObjectMeasurementUnit value ) => new(value); } @@ -1307,6 +1337,7 @@ Square.CatalogObjectMeasurementUnit value /// /// Discriminated union type for SUBSCRIPTION_PLAN_VARIATION /// + [Serializable] public struct SubscriptionPlanVariation { public SubscriptionPlanVariation(Square.CatalogObjectSubscriptionPlanVariation value) @@ -1316,9 +1347,9 @@ public SubscriptionPlanVariation(Square.CatalogObjectSubscriptionPlanVariation v internal Square.CatalogObjectSubscriptionPlanVariation Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator SubscriptionPlanVariation( + public static implicit operator CatalogObject.SubscriptionPlanVariation( Square.CatalogObjectSubscriptionPlanVariation value ) => new(value); } @@ -1326,6 +1357,7 @@ Square.CatalogObjectSubscriptionPlanVariation value /// /// Discriminated union type for ITEM_OPTION /// + [Serializable] public struct ItemOption { public ItemOption(Square.CatalogObjectItemOption value) @@ -1335,15 +1367,17 @@ public ItemOption(Square.CatalogObjectItemOption value) internal Square.CatalogObjectItemOption Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator ItemOption(Square.CatalogObjectItemOption value) => - new(value); + public static implicit operator CatalogObject.ItemOption( + Square.CatalogObjectItemOption value + ) => new(value); } /// /// Discriminated union type for ITEM_OPTION_VAL /// + [Serializable] public struct ItemOptionVal { public ItemOptionVal(Square.CatalogObjectItemOptionValue value) @@ -1353,15 +1387,17 @@ public ItemOptionVal(Square.CatalogObjectItemOptionValue value) internal Square.CatalogObjectItemOptionValue Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator ItemOptionVal(Square.CatalogObjectItemOptionValue value) => - new(value); + public static implicit operator CatalogObject.ItemOptionVal( + Square.CatalogObjectItemOptionValue value + ) => new(value); } /// /// Discriminated union type for CUSTOM_ATTRIBUTE_DEFINITION /// + [Serializable] public struct CustomAttributeDefinition { public CustomAttributeDefinition(Square.CatalogObjectCustomAttributeDefinition value) @@ -1371,9 +1407,9 @@ public CustomAttributeDefinition(Square.CatalogObjectCustomAttributeDefinition v internal Square.CatalogObjectCustomAttributeDefinition Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator CustomAttributeDefinition( + public static implicit operator CatalogObject.CustomAttributeDefinition( Square.CatalogObjectCustomAttributeDefinition value ) => new(value); } @@ -1381,6 +1417,7 @@ Square.CatalogObjectCustomAttributeDefinition value /// /// Discriminated union type for QUICK_AMOUNTS_SETTINGS /// + [Serializable] public struct QuickAmountsSettings { public QuickAmountsSettings(Square.CatalogObjectQuickAmountsSettings value) @@ -1390,9 +1427,9 @@ public QuickAmountsSettings(Square.CatalogObjectQuickAmountsSettings value) internal Square.CatalogObjectQuickAmountsSettings Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator QuickAmountsSettings( + public static implicit operator CatalogObject.QuickAmountsSettings( Square.CatalogObjectQuickAmountsSettings value ) => new(value); } @@ -1400,6 +1437,7 @@ Square.CatalogObjectQuickAmountsSettings value /// /// Discriminated union type for SUBSCRIPTION_PLAN /// + [Serializable] public struct SubscriptionPlan { public SubscriptionPlan(Square.CatalogObjectSubscriptionPlan value) @@ -1409,9 +1447,9 @@ public SubscriptionPlan(Square.CatalogObjectSubscriptionPlan value) internal Square.CatalogObjectSubscriptionPlan Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator SubscriptionPlan( + public static implicit operator CatalogObject.SubscriptionPlan( Square.CatalogObjectSubscriptionPlan value ) => new(value); } @@ -1419,6 +1457,7 @@ Square.CatalogObjectSubscriptionPlan value /// /// Discriminated union type for AVAILABILITY_PERIOD /// + [Serializable] public struct AvailabilityPeriod { public AvailabilityPeriod(Square.CatalogObjectAvailabilityPeriod value) @@ -1428,9 +1467,9 @@ public AvailabilityPeriod(Square.CatalogObjectAvailabilityPeriod value) internal Square.CatalogObjectAvailabilityPeriod Value { get; set; } - public override string ToString() => Value.ToString(); + public override string ToString() => Value.ToString() ?? "null"; - public static implicit operator AvailabilityPeriod( + public static implicit operator CatalogObject.AvailabilityPeriod( Square.CatalogObjectAvailabilityPeriod value ) => new(value); } diff --git a/src/Square/Types/CatalogObjectAvailabilityPeriod.cs b/src/Square/Types/CatalogObjectAvailabilityPeriod.cs index 2acf2455..61310860 100644 --- a/src/Square/Types/CatalogObjectAvailabilityPeriod.cs +++ b/src/Square/Types/CatalogObjectAvailabilityPeriod.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectAvailabilityPeriod +[Serializable] +public record CatalogObjectAvailabilityPeriod : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogAvailabilityPeriod`, set for CatalogObjects of type `AVAILABILITY_PERIOD`. /// @@ -103,15 +108,11 @@ public record CatalogObjectAvailabilityPeriod [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectBase.cs b/src/Square/Types/CatalogObjectBase.cs index e382ab42..b9051c9a 100644 --- a/src/Square/Types/CatalogObjectBase.cs +++ b/src/Square/Types/CatalogObjectBase.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectBase +[Serializable] +public record CatalogObjectBase : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// An identifier to reference this object in the catalog. When a new `CatalogObject` /// is inserted, the client should set the id to a temporary identifier starting with @@ -97,15 +102,11 @@ public record CatalogObjectBase [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectBatch.cs b/src/Square/Types/CatalogObjectBatch.cs index eb3917a8..57bb3873 100644 --- a/src/Square/Types/CatalogObjectBatch.cs +++ b/src/Square/Types/CatalogObjectBatch.cs @@ -7,23 +7,24 @@ namespace Square; /// /// A batch of catalog objects. /// -public record CatalogObjectBatch +[Serializable] +public record CatalogObjectBatch : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of CatalogObjects belonging to this batch. /// [JsonPropertyName("objects")] public IEnumerable Objects { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectCategory.cs b/src/Square/Types/CatalogObjectCategory.cs index f8938a5c..f95c1209 100644 --- a/src/Square/Types/CatalogObjectCategory.cs +++ b/src/Square/Types/CatalogObjectCategory.cs @@ -9,8 +9,13 @@ namespace Square; /// to another category. For example, a clothing category can be assigned to a t-shirt item or /// be made as the parent category to the pants category. /// -public record CatalogObjectCategory +[Serializable] +public record CatalogObjectCategory : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the object's category. /// @@ -107,15 +112,11 @@ public record CatalogObjectCategory [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectCustomAttributeDefinition.cs b/src/Square/Types/CatalogObjectCustomAttributeDefinition.cs index b1907029..289e4713 100644 --- a/src/Square/Types/CatalogObjectCustomAttributeDefinition.cs +++ b/src/Square/Types/CatalogObjectCustomAttributeDefinition.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectCustomAttributeDefinition +[Serializable] +public record CatalogObjectCustomAttributeDefinition : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogCustomAttributeDefinition`, set for CatalogObjects of type `CUSTOM_ATTRIBUTE_DEFINITION`. /// @@ -103,15 +108,11 @@ public record CatalogObjectCustomAttributeDefinition [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectDiscount.cs b/src/Square/Types/CatalogObjectDiscount.cs index 62db4e42..d9d0fcae 100644 --- a/src/Square/Types/CatalogObjectDiscount.cs +++ b/src/Square/Types/CatalogObjectDiscount.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectDiscount +[Serializable] +public record CatalogObjectDiscount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogDiscount`, set for CatalogObjects of type `DISCOUNT`. /// @@ -103,15 +108,11 @@ public record CatalogObjectDiscount [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectImage.cs b/src/Square/Types/CatalogObjectImage.cs index 5b997a40..864cd745 100644 --- a/src/Square/Types/CatalogObjectImage.cs +++ b/src/Square/Types/CatalogObjectImage.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectImage +[Serializable] +public record CatalogObjectImage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogImage`, set for CatalogObjects of type `IMAGE`. /// @@ -103,15 +108,11 @@ public record CatalogObjectImage [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectItem.cs b/src/Square/Types/CatalogObjectItem.cs index 80ffeff3..c6e4d426 100644 --- a/src/Square/Types/CatalogObjectItem.cs +++ b/src/Square/Types/CatalogObjectItem.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectItem +[Serializable] +public record CatalogObjectItem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogItem`, set for CatalogObjects of type `ITEM`. /// @@ -103,15 +108,11 @@ public record CatalogObjectItem [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectItemOption.cs b/src/Square/Types/CatalogObjectItemOption.cs index 7bc748a5..311d05c2 100644 --- a/src/Square/Types/CatalogObjectItemOption.cs +++ b/src/Square/Types/CatalogObjectItemOption.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectItemOption +[Serializable] +public record CatalogObjectItemOption : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogItemOption`, set for CatalogObjects of type `ITEM_OPTION`. /// @@ -103,15 +108,11 @@ public record CatalogObjectItemOption [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectItemOptionValue.cs b/src/Square/Types/CatalogObjectItemOptionValue.cs index 939cba9e..b79e4fe6 100644 --- a/src/Square/Types/CatalogObjectItemOptionValue.cs +++ b/src/Square/Types/CatalogObjectItemOptionValue.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectItemOptionValue +[Serializable] +public record CatalogObjectItemOptionValue : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogItemOptionValue`, set for CatalogObjects of type `ITEM_OPTION_VAL`. /// @@ -103,15 +108,11 @@ public record CatalogObjectItemOptionValue [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectItemVariation.cs b/src/Square/Types/CatalogObjectItemVariation.cs index 643bb679..140fa2d4 100644 --- a/src/Square/Types/CatalogObjectItemVariation.cs +++ b/src/Square/Types/CatalogObjectItemVariation.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectItemVariation +[Serializable] +public record CatalogObjectItemVariation : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogItemVariation`, set for CatalogObjects of type `ITEM_VARIATION`. /// @@ -103,15 +108,11 @@ public record CatalogObjectItemVariation [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectMeasurementUnit.cs b/src/Square/Types/CatalogObjectMeasurementUnit.cs index 38118eb1..d873314d 100644 --- a/src/Square/Types/CatalogObjectMeasurementUnit.cs +++ b/src/Square/Types/CatalogObjectMeasurementUnit.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectMeasurementUnit +[Serializable] +public record CatalogObjectMeasurementUnit : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogMeasurementUnit`, set for CatalogObjects of type `MEASUREMENT_UNIT`. /// @@ -103,15 +108,11 @@ public record CatalogObjectMeasurementUnit [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectModifier.cs b/src/Square/Types/CatalogObjectModifier.cs index 982aaa46..7d64ae2e 100644 --- a/src/Square/Types/CatalogObjectModifier.cs +++ b/src/Square/Types/CatalogObjectModifier.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectModifier +[Serializable] +public record CatalogObjectModifier : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogModifier`, set for CatalogObjects of type `MODIFIER`. /// @@ -103,15 +108,11 @@ public record CatalogObjectModifier [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectModifierList.cs b/src/Square/Types/CatalogObjectModifierList.cs index 939bfaf2..7343b4b3 100644 --- a/src/Square/Types/CatalogObjectModifierList.cs +++ b/src/Square/Types/CatalogObjectModifierList.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectModifierList +[Serializable] +public record CatalogObjectModifierList : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogModifierList`, set for CatalogObjects of type `MODIFIER_LIST`. /// @@ -103,15 +108,11 @@ public record CatalogObjectModifierList [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectPricingRule.cs b/src/Square/Types/CatalogObjectPricingRule.cs index 007e48ea..bfe4e058 100644 --- a/src/Square/Types/CatalogObjectPricingRule.cs +++ b/src/Square/Types/CatalogObjectPricingRule.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectPricingRule +[Serializable] +public record CatalogObjectPricingRule : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogPricingRule`, set for CatalogObjects of type `PRICING_RULE`. /// A `CatalogPricingRule` object often works with a `CatalogProductSet` object or a `CatalogTimePeriod` object. @@ -104,15 +109,11 @@ public record CatalogObjectPricingRule [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectProductSet.cs b/src/Square/Types/CatalogObjectProductSet.cs index 104562f9..f1db037a 100644 --- a/src/Square/Types/CatalogObjectProductSet.cs +++ b/src/Square/Types/CatalogObjectProductSet.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectProductSet +[Serializable] +public record CatalogObjectProductSet : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogProductSet`, set for CatalogObjects of type `PRODUCT_SET`. /// @@ -103,15 +108,11 @@ public record CatalogObjectProductSet [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectQuickAmountsSettings.cs b/src/Square/Types/CatalogObjectQuickAmountsSettings.cs index d6b44406..9fbae0a3 100644 --- a/src/Square/Types/CatalogObjectQuickAmountsSettings.cs +++ b/src/Square/Types/CatalogObjectQuickAmountsSettings.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectQuickAmountsSettings +[Serializable] +public record CatalogObjectQuickAmountsSettings : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogQuickAmountsSettings`, set for CatalogObjects of type `QUICK_AMOUNTS_SETTINGS`. /// @@ -103,15 +108,11 @@ public record CatalogObjectQuickAmountsSettings [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectReference.cs b/src/Square/Types/CatalogObjectReference.cs index 004b7cad..e6c5c852 100644 --- a/src/Square/Types/CatalogObjectReference.cs +++ b/src/Square/Types/CatalogObjectReference.cs @@ -9,8 +9,13 @@ namespace Square; /// used as an entry point into a graph of catalog objects, where the objects exist /// at a specific version. /// -public record CatalogObjectReference +[Serializable] +public record CatalogObjectReference : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the referenced object. /// @@ -23,15 +28,11 @@ public record CatalogObjectReference [JsonPropertyName("catalog_version")] public long? CatalogVersion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectSubscriptionPlan.cs b/src/Square/Types/CatalogObjectSubscriptionPlan.cs index f83a18db..b7122bed 100644 --- a/src/Square/Types/CatalogObjectSubscriptionPlan.cs +++ b/src/Square/Types/CatalogObjectSubscriptionPlan.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectSubscriptionPlan +[Serializable] +public record CatalogObjectSubscriptionPlan : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogSubscriptionPlan`, set for CatalogObjects of type `SUBSCRIPTION_PLAN`. /// @@ -103,15 +108,11 @@ public record CatalogObjectSubscriptionPlan [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectSubscriptionPlanVariation.cs b/src/Square/Types/CatalogObjectSubscriptionPlanVariation.cs index d74892f4..b906bdd2 100644 --- a/src/Square/Types/CatalogObjectSubscriptionPlanVariation.cs +++ b/src/Square/Types/CatalogObjectSubscriptionPlanVariation.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectSubscriptionPlanVariation +[Serializable] +public record CatalogObjectSubscriptionPlanVariation : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogSubscriptionPlanVariation`, set for CatalogObjects of type `SUBSCRIPTION_PLAN_VARIATION`. /// @@ -103,15 +108,11 @@ public record CatalogObjectSubscriptionPlanVariation [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectTax.cs b/src/Square/Types/CatalogObjectTax.cs index 657af228..8ffa8d96 100644 --- a/src/Square/Types/CatalogObjectTax.cs +++ b/src/Square/Types/CatalogObjectTax.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectTax +[Serializable] +public record CatalogObjectTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogTax`, set for CatalogObjects of type `TAX`. /// @@ -103,15 +108,11 @@ public record CatalogObjectTax [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectTimePeriod.cs b/src/Square/Types/CatalogObjectTimePeriod.cs index 3b8772ef..0bb3124a 100644 --- a/src/Square/Types/CatalogObjectTimePeriod.cs +++ b/src/Square/Types/CatalogObjectTimePeriod.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogObjectTimePeriod +[Serializable] +public record CatalogObjectTimePeriod : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Structured data for a `CatalogTimePeriod`, set for CatalogObjects of type `TIME_PERIOD`. /// @@ -103,15 +108,11 @@ public record CatalogObjectTimePeriod [JsonPropertyName("image_id")] public string? ImageId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogObjectType.cs b/src/Square/Types/CatalogObjectType.cs index 9d5375a3..d3b23582 100644 --- a/src/Square/Types/CatalogObjectType.cs +++ b/src/Square/Types/CatalogObjectType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogObjectType : IStringEnum { public static readonly CatalogObjectType Item = new(Values.Item); @@ -94,6 +95,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Item = "ITEM"; diff --git a/src/Square/Types/CatalogPricingRule.cs b/src/Square/Types/CatalogPricingRule.cs index 3b33f53b..01d13ab6 100644 --- a/src/Square/Types/CatalogPricingRule.cs +++ b/src/Square/Types/CatalogPricingRule.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines how discounts are automatically applied to a set of items that match the pricing rule /// during the active time period. /// -public record CatalogPricingRule +[Serializable] +public record CatalogPricingRule : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// User-defined name for the pricing rule. For example, "Buy one get one /// free" or "10% off". @@ -116,15 +121,11 @@ public record CatalogPricingRule [JsonPropertyName("customer_group_ids_any")] public IEnumerable? CustomerGroupIdsAny { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogPricingType.cs b/src/Square/Types/CatalogPricingType.cs index 5786a550..df6e597c 100644 --- a/src/Square/Types/CatalogPricingType.cs +++ b/src/Square/Types/CatalogPricingType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogPricingType : IStringEnum { public static readonly CatalogPricingType FixedPricing = new(Values.FixedPricing); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string FixedPricing = "FIXED_PRICING"; diff --git a/src/Square/Types/CatalogProductSet.cs b/src/Square/Types/CatalogProductSet.cs index eb791fa2..f0de1eb6 100644 --- a/src/Square/Types/CatalogProductSet.cs +++ b/src/Square/Types/CatalogProductSet.cs @@ -11,8 +11,13 @@ namespace Square; /// items and associated item variations in the product set. Including an item in /// a product set will also include its item variations. /// -public record CatalogProductSet +[Serializable] +public record CatalogProductSet : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// User-defined name for the product set. For example, "Clearance Items" /// or "Winter Sale Items". @@ -77,15 +82,11 @@ public record CatalogProductSet [JsonPropertyName("all_products")] public bool? AllProducts { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQuery.cs b/src/Square/Types/CatalogQuery.cs index 3378f2a2..69c09cbf 100644 --- a/src/Square/Types/CatalogQuery.cs +++ b/src/Square/Types/CatalogQuery.cs @@ -32,8 +32,13 @@ namespace Square; /// For example, to search for [CatalogItem](entity:CatalogItem) objects by searchable attributes, you can use /// the `"name"`, `"description"`, or `"abbreviation"` attribute in an applicable query filter. /// -public record CatalogQuery +[Serializable] +public record CatalogQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A query expression to sort returned query result by the given attribute. /// @@ -103,15 +108,11 @@ public record CatalogQuery [JsonPropertyName("item_variations_for_item_option_values_query")] public CatalogQueryItemVariationsForItemOptionValues? ItemVariationsForItemOptionValuesQuery { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryExact.cs b/src/Square/Types/CatalogQueryExact.cs index 0edbb09d..d9c8b21d 100644 --- a/src/Square/Types/CatalogQueryExact.cs +++ b/src/Square/Types/CatalogQueryExact.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The query filter to return the search result by exact match of the specified attribute name and value. /// -public record CatalogQueryExact +[Serializable] +public record CatalogQueryExact : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the attribute to be searched. Matching of the attribute name is exact. /// @@ -22,15 +27,11 @@ public record CatalogQueryExact [JsonPropertyName("attribute_value")] public required string AttributeValue { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryItemVariationsForItemOptionValues.cs b/src/Square/Types/CatalogQueryItemVariationsForItemOptionValues.cs index 9d269f80..3cd7416a 100644 --- a/src/Square/Types/CatalogQueryItemVariationsForItemOptionValues.cs +++ b/src/Square/Types/CatalogQueryItemVariationsForItemOptionValues.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The query filter to return the item variations containing the specified item option value IDs. /// -public record CatalogQueryItemVariationsForItemOptionValues +[Serializable] +public record CatalogQueryItemVariationsForItemOptionValues : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A set of `CatalogItemOptionValue` IDs to be used to find associated /// `CatalogItemVariation`s. All ItemVariations that contain all of the given @@ -17,15 +22,11 @@ public record CatalogQueryItemVariationsForItemOptionValues [JsonPropertyName("item_option_value_ids")] public IEnumerable? ItemOptionValueIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryItemsForItemOptions.cs b/src/Square/Types/CatalogQueryItemsForItemOptions.cs index 3ab5af7a..237c79b6 100644 --- a/src/Square/Types/CatalogQueryItemsForItemOptions.cs +++ b/src/Square/Types/CatalogQueryItemsForItemOptions.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The query filter to return the items containing the specified item option IDs. /// -public record CatalogQueryItemsForItemOptions +[Serializable] +public record CatalogQueryItemsForItemOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A set of `CatalogItemOption` IDs to be used to find associated /// `CatalogItem`s. All Items that contain all of the given Item Options (in any order) @@ -17,15 +22,11 @@ public record CatalogQueryItemsForItemOptions [JsonPropertyName("item_option_ids")] public IEnumerable? ItemOptionIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryItemsForModifierList.cs b/src/Square/Types/CatalogQueryItemsForModifierList.cs index 807d9d92..82cc2622 100644 --- a/src/Square/Types/CatalogQueryItemsForModifierList.cs +++ b/src/Square/Types/CatalogQueryItemsForModifierList.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The query filter to return the items containing the specified modifier list IDs. /// -public record CatalogQueryItemsForModifierList +[Serializable] +public record CatalogQueryItemsForModifierList : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A set of `CatalogModifierList` IDs to be used to find associated `CatalogItem`s. /// [JsonPropertyName("modifier_list_ids")] public IEnumerable ModifierListIds { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryItemsForTax.cs b/src/Square/Types/CatalogQueryItemsForTax.cs index 0704c9fd..63ab685d 100644 --- a/src/Square/Types/CatalogQueryItemsForTax.cs +++ b/src/Square/Types/CatalogQueryItemsForTax.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The query filter to return the items containing the specified tax IDs. /// -public record CatalogQueryItemsForTax +[Serializable] +public record CatalogQueryItemsForTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A set of `CatalogTax` IDs to be used to find associated `CatalogItem`s. /// [JsonPropertyName("tax_ids")] public IEnumerable TaxIds { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryPrefix.cs b/src/Square/Types/CatalogQueryPrefix.cs index 7874c642..2c31bc79 100644 --- a/src/Square/Types/CatalogQueryPrefix.cs +++ b/src/Square/Types/CatalogQueryPrefix.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The query filter to return the search result whose named attribute values are prefixed by the specified attribute value. /// -public record CatalogQueryPrefix +[Serializable] +public record CatalogQueryPrefix : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the attribute to be searched. /// @@ -21,15 +26,11 @@ public record CatalogQueryPrefix [JsonPropertyName("attribute_prefix")] public required string AttributePrefix { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryRange.cs b/src/Square/Types/CatalogQueryRange.cs index bc0447f4..0dc00c37 100644 --- a/src/Square/Types/CatalogQueryRange.cs +++ b/src/Square/Types/CatalogQueryRange.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The query filter to return the search result whose named attribute values fall between the specified range. /// -public record CatalogQueryRange +[Serializable] +public record CatalogQueryRange : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the attribute to be searched. /// @@ -27,15 +32,11 @@ public record CatalogQueryRange [JsonPropertyName("attribute_max_value")] public long? AttributeMaxValue { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQuerySet.cs b/src/Square/Types/CatalogQuerySet.cs index edc1ab48..19112915 100644 --- a/src/Square/Types/CatalogQuerySet.cs +++ b/src/Square/Types/CatalogQuerySet.cs @@ -8,8 +8,13 @@ namespace Square; /// The query filter to return the search result(s) by exact match of the specified `attribute_name` and any of /// the `attribute_values`. /// -public record CatalogQuerySet +[Serializable] +public record CatalogQuerySet : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the attribute to be searched. Matching of the attribute name is exact. /// @@ -23,15 +28,11 @@ public record CatalogQuerySet [JsonPropertyName("attribute_values")] public IEnumerable AttributeValues { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQuerySortedAttribute.cs b/src/Square/Types/CatalogQuerySortedAttribute.cs index 1b99bd61..b55390d8 100644 --- a/src/Square/Types/CatalogQuerySortedAttribute.cs +++ b/src/Square/Types/CatalogQuerySortedAttribute.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The query expression to specify the key to sort search results. /// -public record CatalogQuerySortedAttribute +[Serializable] +public record CatalogQuerySortedAttribute : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The attribute whose value is used as the sort key. /// @@ -30,15 +35,11 @@ public record CatalogQuerySortedAttribute [JsonPropertyName("sort_order")] public SortOrder? SortOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQueryText.cs b/src/Square/Types/CatalogQueryText.cs index 77d5f2f2..9576849a 100644 --- a/src/Square/Types/CatalogQueryText.cs +++ b/src/Square/Types/CatalogQueryText.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The query filter to return the search result whose searchable attribute values contain all of the specified keywords or tokens, independent of the token order or case. /// -public record CatalogQueryText +[Serializable] +public record CatalogQueryText : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of 1, 2, or 3 search keywords. Keywords with fewer than 3 alphanumeric characters are ignored. /// [JsonPropertyName("keywords")] public IEnumerable Keywords { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQuickAmount.cs b/src/Square/Types/CatalogQuickAmount.cs index 22ab4ccf..f4fcb075 100644 --- a/src/Square/Types/CatalogQuickAmount.cs +++ b/src/Square/Types/CatalogQuickAmount.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a Quick Amount in the Catalog. /// -public record CatalogQuickAmount +[Serializable] +public record CatalogQuickAmount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Represents the type of the Quick Amount. /// See [CatalogQuickAmountType](#type-catalogquickamounttype) for possible values @@ -35,15 +40,11 @@ public record CatalogQuickAmount [JsonPropertyName("ordinal")] public long? Ordinal { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQuickAmountType.cs b/src/Square/Types/CatalogQuickAmountType.cs index 003c6810..0d158f5a 100644 --- a/src/Square/Types/CatalogQuickAmountType.cs +++ b/src/Square/Types/CatalogQuickAmountType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogQuickAmountType : IStringEnum { public static readonly CatalogQuickAmountType QuickAmountTypeManual = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string QuickAmountTypeManual = "QUICK_AMOUNT_TYPE_MANUAL"; diff --git a/src/Square/Types/CatalogQuickAmountsSettings.cs b/src/Square/Types/CatalogQuickAmountsSettings.cs index 75ecdd1c..e4f04e78 100644 --- a/src/Square/Types/CatalogQuickAmountsSettings.cs +++ b/src/Square/Types/CatalogQuickAmountsSettings.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A parent Catalog Object model represents a set of Quick Amounts and the settings control the amounts. /// -public record CatalogQuickAmountsSettings +[Serializable] +public record CatalogQuickAmountsSettings : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Represents the option seller currently uses on Quick Amounts. /// See [CatalogQuickAmountsSettingsOption](#type-catalogquickamountssettingsoption) for possible values @@ -29,15 +34,11 @@ public record CatalogQuickAmountsSettings [JsonPropertyName("amounts")] public IEnumerable? Amounts { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogQuickAmountsSettingsOption.cs b/src/Square/Types/CatalogQuickAmountsSettingsOption.cs index 997457f6..bb571599 100644 --- a/src/Square/Types/CatalogQuickAmountsSettingsOption.cs +++ b/src/Square/Types/CatalogQuickAmountsSettingsOption.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CatalogQuickAmountsSettingsOption : IStringEnum { public static readonly CatalogQuickAmountsSettingsOption Disabled = new(Values.Disabled); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Disabled = "DISABLED"; diff --git a/src/Square/Types/CatalogStockConversion.cs b/src/Square/Types/CatalogStockConversion.cs index 7aa4f224..51277564 100644 --- a/src/Square/Types/CatalogStockConversion.cs +++ b/src/Square/Types/CatalogStockConversion.cs @@ -9,8 +9,13 @@ namespace Square; /// and a non-stockable sell-by or receive-by `CatalogItemVariation` that /// share the same underlying stock. /// -public record CatalogStockConversion +[Serializable] +public record CatalogStockConversion : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// References to the stockable [CatalogItemVariation](entity:CatalogItemVariation) /// for this stock conversion. Selling, receiving or recounting the non-stockable `CatalogItemVariation` @@ -40,15 +45,11 @@ public record CatalogStockConversion [JsonPropertyName("nonstockable_quantity")] public required string NonstockableQuantity { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogSubscriptionPlan.cs b/src/Square/Types/CatalogSubscriptionPlan.cs index 8a8ecb66..2ba61fe0 100644 --- a/src/Square/Types/CatalogSubscriptionPlan.cs +++ b/src/Square/Types/CatalogSubscriptionPlan.cs @@ -8,8 +8,13 @@ namespace Square; /// Describes a subscription plan. A subscription plan represents what you want to sell in a subscription model, and includes references to each of the associated subscription plan variations. /// For more information, see [Subscription Plans and Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). /// -public record CatalogSubscriptionPlan +[Serializable] +public record CatalogSubscriptionPlan : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the plan. /// @@ -47,15 +52,11 @@ public record CatalogSubscriptionPlan [JsonPropertyName("all_items")] public bool? AllItems { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogSubscriptionPlanVariation.cs b/src/Square/Types/CatalogSubscriptionPlanVariation.cs index 7e698601..9b667b38 100644 --- a/src/Square/Types/CatalogSubscriptionPlanVariation.cs +++ b/src/Square/Types/CatalogSubscriptionPlanVariation.cs @@ -8,8 +8,13 @@ namespace Square; /// Describes a subscription plan variation. A subscription plan variation represents how the subscription for a product or service is sold. /// For more information, see [Subscription Plans and Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). /// -public record CatalogSubscriptionPlanVariation +[Serializable] +public record CatalogSubscriptionPlanVariation : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the plan variation. /// @@ -48,15 +53,11 @@ public record CatalogSubscriptionPlanVariation [JsonPropertyName("successor_plan_variation_id")] public string? SuccessorPlanVariationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogTax.cs b/src/Square/Types/CatalogTax.cs index cba00669..f51c268a 100644 --- a/src/Square/Types/CatalogTax.cs +++ b/src/Square/Types/CatalogTax.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A tax applicable to an item. /// -public record CatalogTax +[Serializable] +public record CatalogTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The tax's name. This is a searchable attribute for use in applicable query filters, and its value length is of Unicode code points. /// @@ -55,15 +60,11 @@ public record CatalogTax [JsonPropertyName("applies_to_product_set_id")] public string? AppliesToProductSetId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogTimePeriod.cs b/src/Square/Types/CatalogTimePeriod.cs index 1f04fab2..daf1c469 100644 --- a/src/Square/Types/CatalogTimePeriod.cs +++ b/src/Square/Types/CatalogTimePeriod.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a time period - either a single period or a repeating period. /// -public record CatalogTimePeriod +[Serializable] +public record CatalogTimePeriod : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// An iCalendar (RFC 5545) [event](https://tools.ietf.org/html/rfc5545#section-3.6.1), which /// specifies the name, timing, duration and recurrence of this time period. @@ -29,15 +34,11 @@ public record CatalogTimePeriod [JsonPropertyName("event")] public string? Event { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogV1Id.cs b/src/Square/Types/CatalogV1Id.cs index 6504dda8..164ef0bd 100644 --- a/src/Square/Types/CatalogV1Id.cs +++ b/src/Square/Types/CatalogV1Id.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A Square API V1 identifier of an item, including the object ID and its associated location ID. /// -public record CatalogV1Id +[Serializable] +public record CatalogV1Id : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID for an object used in the Square API V1, if the object ID differs from the Square API V2 object ID. /// @@ -21,15 +26,11 @@ public record CatalogV1Id [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogVersionUpdatedEvent.cs b/src/Square/Types/CatalogVersionUpdatedEvent.cs index 1d6e177d..b6619439 100644 --- a/src/Square/Types/CatalogVersionUpdatedEvent.cs +++ b/src/Square/Types/CatalogVersionUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when the catalog is updated. /// -public record CatalogVersionUpdatedEvent +[Serializable] +public record CatalogVersionUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record CatalogVersionUpdatedEvent [JsonPropertyName("data")] public CatalogVersionUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogVersionUpdatedEventCatalogVersion.cs b/src/Square/Types/CatalogVersionUpdatedEventCatalogVersion.cs index 42108b45..a25a27e3 100644 --- a/src/Square/Types/CatalogVersionUpdatedEventCatalogVersion.cs +++ b/src/Square/Types/CatalogVersionUpdatedEventCatalogVersion.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogVersionUpdatedEventCatalogVersion +[Serializable] +public record CatalogVersionUpdatedEventCatalogVersion : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Last modification timestamp in RFC 3339 format. /// @@ -13,15 +18,11 @@ public record CatalogVersionUpdatedEventCatalogVersion [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogVersionUpdatedEventData.cs b/src/Square/Types/CatalogVersionUpdatedEventData.cs index 124e2a94..5884029b 100644 --- a/src/Square/Types/CatalogVersionUpdatedEventData.cs +++ b/src/Square/Types/CatalogVersionUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CatalogVersionUpdatedEventData +[Serializable] +public record CatalogVersionUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type. /// @@ -18,15 +23,11 @@ public record CatalogVersionUpdatedEventData [JsonPropertyName("object")] public CatalogVersionUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CatalogVersionUpdatedEventObject.cs b/src/Square/Types/CatalogVersionUpdatedEventObject.cs index 84aa9d71..fb7c5cce 100644 --- a/src/Square/Types/CatalogVersionUpdatedEventObject.cs +++ b/src/Square/Types/CatalogVersionUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CatalogVersionUpdatedEventObject +[Serializable] +public record CatalogVersionUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The version of the object. /// [JsonPropertyName("catalog_version")] public CatalogVersionUpdatedEventCatalogVersion? CatalogVersion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CategoryPathToRootNode.cs b/src/Square/Types/CategoryPathToRootNode.cs index b21d29e1..5bbf20b9 100644 --- a/src/Square/Types/CategoryPathToRootNode.cs +++ b/src/Square/Types/CategoryPathToRootNode.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A node in the path from a retrieved category to its root node. /// -public record CategoryPathToRootNode +[Serializable] +public record CategoryPathToRootNode : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The category's ID. /// @@ -21,15 +26,11 @@ public record CategoryPathToRootNode [JsonPropertyName("category_name")] public string? CategoryName { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ChangeBillingAnchorDateResponse.cs b/src/Square/Types/ChangeBillingAnchorDateResponse.cs index ba51793b..b9fedb45 100644 --- a/src/Square/Types/ChangeBillingAnchorDateResponse.cs +++ b/src/Square/Types/ChangeBillingAnchorDateResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a request to the /// [ChangeBillingAnchorDate](api-endpoint:Subscriptions-ChangeBillingAnchorDate) endpoint. /// -public record ChangeBillingAnchorDateResponse +[Serializable] +public record ChangeBillingAnchorDateResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -28,15 +33,11 @@ public record ChangeBillingAnchorDateResponse [JsonPropertyName("actions")] public IEnumerable? Actions { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ChangeTiming.cs b/src/Square/Types/ChangeTiming.cs index 7c703a30..2d2354bc 100644 --- a/src/Square/Types/ChangeTiming.cs +++ b/src/Square/Types/ChangeTiming.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ChangeTiming : IStringEnum { public static readonly ChangeTiming Immediate = new(Values.Immediate); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Immediate = "IMMEDIATE"; diff --git a/src/Square/Types/Channel.cs b/src/Square/Types/Channel.cs index 37be30ae..c52fd320 100644 --- a/src/Square/Types/Channel.cs +++ b/src/Square/Types/Channel.cs @@ -4,8 +4,13 @@ namespace Square; -public record Channel +[Serializable] +public record Channel : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The channel's unique ID. /// @@ -62,15 +67,11 @@ public record Channel [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ChannelStatus.cs b/src/Square/Types/ChannelStatus.cs index 631b1185..4e4c6939 100644 --- a/src/Square/Types/ChannelStatus.cs +++ b/src/Square/Types/ChannelStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ChannelStatus : IStringEnum { public static readonly ChannelStatus Active = new(Values.Active); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/ChargeRequestAdditionalRecipient.cs b/src/Square/Types/ChargeRequestAdditionalRecipient.cs index d90e36fe..47568716 100644 --- a/src/Square/Types/ChargeRequestAdditionalRecipient.cs +++ b/src/Square/Types/ChargeRequestAdditionalRecipient.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an additional recipient (other than the merchant) entitled to a portion of the tender. /// Support is currently limited to USD, CAD and GBP currencies /// -public record ChargeRequestAdditionalRecipient +[Serializable] +public record ChargeRequestAdditionalRecipient : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The location ID for a recipient (other than the merchant) receiving a portion of the tender. /// @@ -28,15 +33,11 @@ public record ChargeRequestAdditionalRecipient [JsonPropertyName("amount_money")] public required Money AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutLocationSettings.cs b/src/Square/Types/CheckoutLocationSettings.cs index 8f9bfc10..200cec99 100644 --- a/src/Square/Types/CheckoutLocationSettings.cs +++ b/src/Square/Types/CheckoutLocationSettings.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutLocationSettings +[Serializable] +public record CheckoutLocationSettings : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the location that these settings apply to. /// @@ -53,15 +58,11 @@ public record CheckoutLocationSettings [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutLocationSettingsBranding.cs b/src/Square/Types/CheckoutLocationSettingsBranding.cs index 9104d874..4842c326 100644 --- a/src/Square/Types/CheckoutLocationSettingsBranding.cs +++ b/src/Square/Types/CheckoutLocationSettingsBranding.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutLocationSettingsBranding +[Serializable] +public record CheckoutLocationSettingsBranding : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Show the location logo on the checkout page. /// See [HeaderType](#type-headertype) for possible values @@ -26,15 +31,11 @@ public record CheckoutLocationSettingsBranding [JsonPropertyName("button_shape")] public CheckoutLocationSettingsBrandingButtonShape? ButtonShape { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutLocationSettingsBrandingButtonShape.cs b/src/Square/Types/CheckoutLocationSettingsBrandingButtonShape.cs index c5f67106..b0548b29 100644 --- a/src/Square/Types/CheckoutLocationSettingsBrandingButtonShape.cs +++ b/src/Square/Types/CheckoutLocationSettingsBrandingButtonShape.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CheckoutLocationSettingsBrandingButtonShape : IStringEnum { public static readonly CheckoutLocationSettingsBrandingButtonShape Squared = new( @@ -66,6 +67,7 @@ public static explicit operator CheckoutLocationSettingsBrandingButtonShape(stri /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Squared = "SQUARED"; diff --git a/src/Square/Types/CheckoutLocationSettingsBrandingHeaderType.cs b/src/Square/Types/CheckoutLocationSettingsBrandingHeaderType.cs index 53fb81e0..8826e2ba 100644 --- a/src/Square/Types/CheckoutLocationSettingsBrandingHeaderType.cs +++ b/src/Square/Types/CheckoutLocationSettingsBrandingHeaderType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CheckoutLocationSettingsBrandingHeaderType : IStringEnum { public static readonly CheckoutLocationSettingsBrandingHeaderType BusinessName = new( @@ -68,6 +69,7 @@ public static explicit operator CheckoutLocationSettingsBrandingHeaderType(strin /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string BusinessName = "BUSINESS_NAME"; diff --git a/src/Square/Types/CheckoutLocationSettingsCoupons.cs b/src/Square/Types/CheckoutLocationSettingsCoupons.cs index 918a673f..cc51439d 100644 --- a/src/Square/Types/CheckoutLocationSettingsCoupons.cs +++ b/src/Square/Types/CheckoutLocationSettingsCoupons.cs @@ -4,23 +4,24 @@ namespace Square; -public record CheckoutLocationSettingsCoupons +[Serializable] +public record CheckoutLocationSettingsCoupons : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether coupons are enabled for this location. /// [JsonPropertyName("enabled")] public bool? Enabled { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutLocationSettingsPolicy.cs b/src/Square/Types/CheckoutLocationSettingsPolicy.cs index 28fb90f3..4ceecfba 100644 --- a/src/Square/Types/CheckoutLocationSettingsPolicy.cs +++ b/src/Square/Types/CheckoutLocationSettingsPolicy.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutLocationSettingsPolicy +[Serializable] +public record CheckoutLocationSettingsPolicy : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID to identify the policy when making changes. You must set the UID for policy updates, but it’s optional when setting new policies. /// @@ -24,15 +29,11 @@ public record CheckoutLocationSettingsPolicy [JsonPropertyName("description")] public string? Description { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutLocationSettingsTipping.cs b/src/Square/Types/CheckoutLocationSettingsTipping.cs index 8de7f643..9b371c49 100644 --- a/src/Square/Types/CheckoutLocationSettingsTipping.cs +++ b/src/Square/Types/CheckoutLocationSettingsTipping.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutLocationSettingsTipping +[Serializable] +public record CheckoutLocationSettingsTipping : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Set three custom percentage amounts that buyers can select at checkout. If Smart Tip is enabled, this only applies to transactions totaling $10 or more. /// @@ -39,15 +44,11 @@ public record CheckoutLocationSettingsTipping [JsonPropertyName("default_smart_tip")] public Money? DefaultSmartTip { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutMerchantSettings.cs b/src/Square/Types/CheckoutMerchantSettings.cs index d180aa55..a4440fb4 100644 --- a/src/Square/Types/CheckoutMerchantSettings.cs +++ b/src/Square/Types/CheckoutMerchantSettings.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutMerchantSettings +[Serializable] +public record CheckoutMerchantSettings : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The set of payment methods accepted for the merchant's account. /// @@ -22,15 +27,11 @@ public record CheckoutMerchantSettings [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutMerchantSettingsPaymentMethods.cs b/src/Square/Types/CheckoutMerchantSettingsPaymentMethods.cs index 49037bd6..1a475830 100644 --- a/src/Square/Types/CheckoutMerchantSettingsPaymentMethods.cs +++ b/src/Square/Types/CheckoutMerchantSettingsPaymentMethods.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutMerchantSettingsPaymentMethods +[Serializable] +public record CheckoutMerchantSettingsPaymentMethods : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + [JsonPropertyName("apple_pay")] public CheckoutMerchantSettingsPaymentMethodsPaymentMethod? ApplePay { get; set; } @@ -18,15 +23,11 @@ public record CheckoutMerchantSettingsPaymentMethods [JsonPropertyName("afterpay_clearpay")] public CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay? AfterpayClearpay { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay.cs b/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay.cs index 03e7e030..8b6732b3 100644 --- a/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay.cs +++ b/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The settings allowed for AfterpayClearpay. /// -public record CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay +[Serializable] +public record CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Afterpay is shown as an option for order totals falling within the configured range. /// @@ -28,15 +33,11 @@ public record CheckoutMerchantSettingsPaymentMethodsAfterpayClearpay [JsonPropertyName("enabled")] public bool? Enabled { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpayEligibilityRange.cs b/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpayEligibilityRange.cs index 95b62563..4b861db6 100644 --- a/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpayEligibilityRange.cs +++ b/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsAfterpayClearpayEligibilityRange.cs @@ -7,23 +7,25 @@ namespace Square; /// /// A range of purchase price that qualifies. /// +[Serializable] public record CheckoutMerchantSettingsPaymentMethodsAfterpayClearpayEligibilityRange + : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + [JsonPropertyName("min")] public required Money Min { get; set; } [JsonPropertyName("max")] public required Money Max { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsPaymentMethod.cs b/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsPaymentMethod.cs index 2c486ad6..2d654e67 100644 --- a/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsPaymentMethod.cs +++ b/src/Square/Types/CheckoutMerchantSettingsPaymentMethodsPaymentMethod.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The settings allowed for a payment method. /// -public record CheckoutMerchantSettingsPaymentMethodsPaymentMethod +[Serializable] +public record CheckoutMerchantSettingsPaymentMethodsPaymentMethod : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether the payment method is enabled for the account. /// [JsonPropertyName("enabled")] public bool? Enabled { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutOptions.cs b/src/Square/Types/CheckoutOptions.cs index b7730993..5abceb56 100644 --- a/src/Square/Types/CheckoutOptions.cs +++ b/src/Square/Types/CheckoutOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record CheckoutOptions +[Serializable] +public record CheckoutOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether the payment allows tipping. /// @@ -81,15 +86,11 @@ public record CheckoutOptions [JsonPropertyName("enable_loyalty")] public bool? EnableLoyalty { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CheckoutOptionsPaymentType.cs b/src/Square/Types/CheckoutOptionsPaymentType.cs index 79d73b81..14196707 100644 --- a/src/Square/Types/CheckoutOptionsPaymentType.cs +++ b/src/Square/Types/CheckoutOptionsPaymentType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CheckoutOptionsPaymentType : IStringEnum { public static readonly CheckoutOptionsPaymentType CardPresent = new(Values.CardPresent); @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CardPresent = "CARD_PRESENT"; diff --git a/src/Square/Types/ClearpayDetails.cs b/src/Square/Types/ClearpayDetails.cs index 1943e1f9..4ee31cd2 100644 --- a/src/Square/Types/ClearpayDetails.cs +++ b/src/Square/Types/ClearpayDetails.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Additional details about Clearpay payments. /// -public record ClearpayDetails +[Serializable] +public record ClearpayDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Email address on the buyer's Clearpay account. /// [JsonPropertyName("email_address")] public string? EmailAddress { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CloneOrderResponse.cs b/src/Square/Types/CloneOrderResponse.cs index 480b3752..09bd09d2 100644 --- a/src/Square/Types/CloneOrderResponse.cs +++ b/src/Square/Types/CloneOrderResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [CloneOrder](api-endpoint:Orders-CloneOrder) endpoint. /// -public record CloneOrderResponse +[Serializable] +public record CloneOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The cloned order. /// @@ -22,15 +27,11 @@ public record CloneOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CollectedData.cs b/src/Square/Types/CollectedData.cs index d31b8e36..486fa61b 100644 --- a/src/Square/Types/CollectedData.cs +++ b/src/Square/Types/CollectedData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CollectedData +[Serializable] +public record CollectedData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The buyer's input text. /// @@ -13,15 +18,11 @@ public record CollectedData [JsonPropertyName("input_text")] public string? InputText { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CompletePaymentResponse.cs b/src/Square/Types/CompletePaymentResponse.cs index b32fce50..21fa168c 100644 --- a/src/Square/Types/CompletePaymentResponse.cs +++ b/src/Square/Types/CompletePaymentResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the response returned by[CompletePayment](api-endpoint:Payments-CompletePayment). /// -public record CompletePaymentResponse +[Serializable] +public record CompletePaymentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record CompletePaymentResponse [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Component.cs b/src/Square/Types/Component.cs index c0d84ad0..4290d07d 100644 --- a/src/Square/Types/Component.cs +++ b/src/Square/Types/Component.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The wrapper object for the component entries of a given component type. /// -public record Component +[Serializable] +public record Component : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of this component. Each component type has expected properties expressed /// in a structured format within its corresponding `*_details` field. @@ -47,15 +52,11 @@ public record Component [JsonPropertyName("ethernet_details")] public DeviceComponentDetailsEthernetDetails? EthernetDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ComponentComponentType.cs b/src/Square/Types/ComponentComponentType.cs index 90ae0208..96472558 100644 --- a/src/Square/Types/ComponentComponentType.cs +++ b/src/Square/Types/ComponentComponentType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ComponentComponentType : IStringEnum { public static readonly ComponentComponentType Application = new(Values.Application); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Application = "APPLICATION"; diff --git a/src/Square/Types/ConfirmationDecision.cs b/src/Square/Types/ConfirmationDecision.cs index 74d6edc8..f2906df1 100644 --- a/src/Square/Types/ConfirmationDecision.cs +++ b/src/Square/Types/ConfirmationDecision.cs @@ -4,8 +4,13 @@ namespace Square; -public record ConfirmationDecision +[Serializable] +public record ConfirmationDecision : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The buyer's decision to the displayed terms. /// @@ -13,15 +18,11 @@ public record ConfirmationDecision [JsonPropertyName("has_agreed")] public bool? HasAgreed { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ConfirmationOptions.cs b/src/Square/Types/ConfirmationOptions.cs index 5fe7b56a..d7f8ca48 100644 --- a/src/Square/Types/ConfirmationOptions.cs +++ b/src/Square/Types/ConfirmationOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record ConfirmationOptions +[Serializable] +public record ConfirmationOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title text to display in the confirmation screen flow on the Terminal. /// @@ -36,15 +41,11 @@ public record ConfirmationOptions [JsonPropertyName("decision")] public ConfirmationDecision? Decision { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Coordinates.cs b/src/Square/Types/Coordinates.cs index 3416894d..815a6870 100644 --- a/src/Square/Types/Coordinates.cs +++ b/src/Square/Types/Coordinates.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Latitude and longitude coordinates. /// -public record Coordinates +[Serializable] +public record Coordinates : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The latitude of the coordinate expressed in degrees. /// @@ -21,15 +26,11 @@ public record Coordinates [JsonPropertyName("longitude")] public double? Longitude { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Country.cs b/src/Square/Types/Country.cs index e0be6582..9259fdde 100644 --- a/src/Square/Types/Country.cs +++ b/src/Square/Types/Country.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct Country : IStringEnum { public static readonly Country Zz = new(Values.Zz); @@ -548,6 +549,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Zz = "ZZ"; diff --git a/src/Square/Types/CreateBookingCustomAttributeDefinitionResponse.cs b/src/Square/Types/CreateBookingCustomAttributeDefinitionResponse.cs index 12d05854..f4361b7d 100644 --- a/src/Square/Types/CreateBookingCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/CreateBookingCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-CreateBookingCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record CreateBookingCustomAttributeDefinitionResponse +[Serializable] +public record CreateBookingCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The newly created custom attribute definition. /// @@ -22,15 +27,11 @@ public record CreateBookingCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateBookingResponse.cs b/src/Square/Types/CreateBookingResponse.cs index f4c84e37..66601f22 100644 --- a/src/Square/Types/CreateBookingResponse.cs +++ b/src/Square/Types/CreateBookingResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateBookingResponse +[Serializable] +public record CreateBookingResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The booking that was created. /// @@ -18,15 +23,11 @@ public record CreateBookingResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateBreakTypeResponse.cs b/src/Square/Types/CreateBreakTypeResponse.cs index e616863b..d578301e 100644 --- a/src/Square/Types/CreateBreakTypeResponse.cs +++ b/src/Square/Types/CreateBreakTypeResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the created `BreakType` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record CreateBreakTypeResponse +[Serializable] +public record CreateBreakTypeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The `BreakType` that was created by the request. /// @@ -23,15 +28,11 @@ public record CreateBreakTypeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCardResponse.cs b/src/Square/Types/CreateCardResponse.cs index c19e066b..3f25514e 100644 --- a/src/Square/Types/CreateCardResponse.cs +++ b/src/Square/Types/CreateCardResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the card field will not be /// present. /// -public record CreateCardResponse +[Serializable] +public record CreateCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors resulting from the request. /// @@ -25,15 +30,11 @@ public record CreateCardResponse [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCatalogImageRequest.cs b/src/Square/Types/CreateCatalogImageRequest.cs index 1a94b76a..b0031865 100644 --- a/src/Square/Types/CreateCatalogImageRequest.cs +++ b/src/Square/Types/CreateCatalogImageRequest.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateCatalogImageRequest +[Serializable] +public record CreateCatalogImageRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique string that identifies this CreateCatalogImage request. /// Keys can be any valid string but must be unique for every CreateCatalogImage request. @@ -39,15 +44,11 @@ public record CreateCatalogImageRequest [JsonPropertyName("is_primary")] public bool? IsPrimary { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCatalogImageResponse.cs b/src/Square/Types/CreateCatalogImageResponse.cs index 5ad20447..da637885 100644 --- a/src/Square/Types/CreateCatalogImageResponse.cs +++ b/src/Square/Types/CreateCatalogImageResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateCatalogImageResponse +[Serializable] +public record CreateCatalogImageResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -19,15 +24,11 @@ public record CreateCatalogImageResponse [JsonPropertyName("image")] public CatalogObject? Image { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCheckoutResponse.cs b/src/Square/Types/CreateCheckoutResponse.cs index 5c76d0fe..f4de3e79 100644 --- a/src/Square/Types/CreateCheckoutResponse.cs +++ b/src/Square/Types/CreateCheckoutResponse.cs @@ -8,13 +8,18 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the `CreateCheckout` endpoint. /// -public record CreateCheckoutResponse +[Serializable] +public record CreateCheckoutResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The newly created `checkout` object associated with the provided idempotency key. /// [JsonPropertyName("checkout")] - public Checkout.Checkout? Checkout { get; set; } + public Square.Checkout.Checkout? Checkout { get; set; } /// /// Any errors that occurred during the request. @@ -22,15 +27,11 @@ public record CreateCheckoutResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCustomerCardResponse.cs b/src/Square/Types/CreateCustomerCardResponse.cs index fd60fe9d..dd38d1ec 100644 --- a/src/Square/Types/CreateCustomerCardResponse.cs +++ b/src/Square/Types/CreateCustomerCardResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `card` is present in a given response (never both). /// -public record CreateCustomerCardResponse +[Serializable] +public record CreateCustomerCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record CreateCustomerCardResponse [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCustomerCustomAttributeDefinitionResponse.cs b/src/Square/Types/CreateCustomerCustomAttributeDefinitionResponse.cs index fb5c05c0..ba7c4776 100644 --- a/src/Square/Types/CreateCustomerCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/CreateCustomerCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-CreateCustomerCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record CreateCustomerCustomAttributeDefinitionResponse +[Serializable] +public record CreateCustomerCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new custom attribute definition. /// @@ -22,15 +27,11 @@ public record CreateCustomerCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCustomerGroupResponse.cs b/src/Square/Types/CreateCustomerGroupResponse.cs index 6b9ff1d7..d1bbb653 100644 --- a/src/Square/Types/CreateCustomerGroupResponse.cs +++ b/src/Square/Types/CreateCustomerGroupResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `group` is present in a given response (never both). /// -public record CreateCustomerGroupResponse +[Serializable] +public record CreateCustomerGroupResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record CreateCustomerGroupResponse [JsonPropertyName("group")] public CustomerGroup? Group { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateCustomerResponse.cs b/src/Square/Types/CreateCustomerResponse.cs index 02c820a6..5861ec71 100644 --- a/src/Square/Types/CreateCustomerResponse.cs +++ b/src/Square/Types/CreateCustomerResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// /// Either `errors` or `customer` is present in a given response (never both). /// -public record CreateCustomerResponse +[Serializable] +public record CreateCustomerResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -25,15 +30,11 @@ public record CreateCustomerResponse [JsonPropertyName("customer")] public Customer? Customer { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateDeviceCodeResponse.cs b/src/Square/Types/CreateDeviceCodeResponse.cs index 8b72c127..d1f8e344 100644 --- a/src/Square/Types/CreateDeviceCodeResponse.cs +++ b/src/Square/Types/CreateDeviceCodeResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateDeviceCodeResponse +[Serializable] +public record CreateDeviceCodeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record CreateDeviceCodeResponse [JsonPropertyName("device_code")] public DeviceCode? DeviceCode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateDisputeEvidenceFileRequest.cs b/src/Square/Types/CreateDisputeEvidenceFileRequest.cs index 64cb5bc8..7fb69686 100644 --- a/src/Square/Types/CreateDisputeEvidenceFileRequest.cs +++ b/src/Square/Types/CreateDisputeEvidenceFileRequest.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the parameters for a `CreateDisputeEvidenceFile` request. /// -public record CreateDisputeEvidenceFileRequest +[Serializable] +public record CreateDisputeEvidenceFileRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique key identifying the request. For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency). /// @@ -29,15 +34,11 @@ public record CreateDisputeEvidenceFileRequest [JsonPropertyName("content_type")] public string? ContentType { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateDisputeEvidenceFileResponse.cs b/src/Square/Types/CreateDisputeEvidenceFileResponse.cs index 3b8cb277..d0a6fabf 100644 --- a/src/Square/Types/CreateDisputeEvidenceFileResponse.cs +++ b/src/Square/Types/CreateDisputeEvidenceFileResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the fields in a `CreateDisputeEvidenceFile` response. /// -public record CreateDisputeEvidenceFileResponse +[Serializable] +public record CreateDisputeEvidenceFileResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record CreateDisputeEvidenceFileResponse [JsonPropertyName("evidence")] public DisputeEvidence? Evidence { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateDisputeEvidenceTextResponse.cs b/src/Square/Types/CreateDisputeEvidenceTextResponse.cs index 7721b79c..2fccf28b 100644 --- a/src/Square/Types/CreateDisputeEvidenceTextResponse.cs +++ b/src/Square/Types/CreateDisputeEvidenceTextResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the fields in a `CreateDisputeEvidenceText` response. /// -public record CreateDisputeEvidenceTextResponse +[Serializable] +public record CreateDisputeEvidenceTextResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record CreateDisputeEvidenceTextResponse [JsonPropertyName("evidence")] public DisputeEvidence? Evidence { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateGiftCardActivityResponse.cs b/src/Square/Types/CreateGiftCardActivityResponse.cs index fbfbcbbc..50cf3f28 100644 --- a/src/Square/Types/CreateGiftCardActivityResponse.cs +++ b/src/Square/Types/CreateGiftCardActivityResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a `GiftCardActivity` that was created. /// The response might contain a set of `Error` objects if the request resulted in errors. /// -public record CreateGiftCardActivityResponse +[Serializable] +public record CreateGiftCardActivityResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record CreateGiftCardActivityResponse [JsonPropertyName("gift_card_activity")] public GiftCardActivity? GiftCardActivity { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateGiftCardResponse.cs b/src/Square/Types/CreateGiftCardResponse.cs index 37803a64..920710c7 100644 --- a/src/Square/Types/CreateGiftCardResponse.cs +++ b/src/Square/Types/CreateGiftCardResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a `GiftCard`. The response might contain a set of `Error` objects if the request /// resulted in errors. /// -public record CreateGiftCardResponse +[Serializable] +public record CreateGiftCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record CreateGiftCardResponse [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateInvoiceAttachmentRequestData.cs b/src/Square/Types/CreateInvoiceAttachmentRequestData.cs index 2c8c6071..6851e020 100644 --- a/src/Square/Types/CreateInvoiceAttachmentRequestData.cs +++ b/src/Square/Types/CreateInvoiceAttachmentRequestData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) request. /// -public record CreateInvoiceAttachmentRequestData +[Serializable] +public record CreateInvoiceAttachmentRequestData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique string that identifies the `CreateInvoiceAttachment` request. /// For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). @@ -22,15 +27,11 @@ public record CreateInvoiceAttachmentRequestData [JsonPropertyName("description")] public string? Description { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateInvoiceAttachmentResponse.cs b/src/Square/Types/CreateInvoiceAttachmentResponse.cs index 95eea21e..88604d2c 100644 --- a/src/Square/Types/CreateInvoiceAttachmentResponse.cs +++ b/src/Square/Types/CreateInvoiceAttachmentResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a [CreateInvoiceAttachment](api-endpoint:Invoices-CreateInvoiceAttachment) response. /// -public record CreateInvoiceAttachmentResponse +[Serializable] +public record CreateInvoiceAttachmentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Metadata about the attachment that was added to the invoice. /// @@ -21,15 +26,11 @@ public record CreateInvoiceAttachmentResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateInvoiceResponse.cs b/src/Square/Types/CreateInvoiceResponse.cs index 72877015..f88e0c75 100644 --- a/src/Square/Types/CreateInvoiceResponse.cs +++ b/src/Square/Types/CreateInvoiceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response returned by the `CreateInvoice` request. /// -public record CreateInvoiceResponse +[Serializable] +public record CreateInvoiceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The newly created invoice. /// @@ -21,15 +26,11 @@ public record CreateInvoiceResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateJobResponse.cs b/src/Square/Types/CreateJobResponse.cs index 7d0404da..ae4e2627 100644 --- a/src/Square/Types/CreateJobResponse.cs +++ b/src/Square/Types/CreateJobResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateJob](api-endpoint:Team-CreateJob) response. Either `job` or `errors` /// is present in the response. /// -public record CreateJobResponse +[Serializable] +public record CreateJobResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new job. /// @@ -22,15 +27,11 @@ public record CreateJobResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateLocationCustomAttributeDefinitionResponse.cs b/src/Square/Types/CreateLocationCustomAttributeDefinitionResponse.cs index d8bfc565..ed73b38f 100644 --- a/src/Square/Types/CreateLocationCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/CreateLocationCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-CreateLocationCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record CreateLocationCustomAttributeDefinitionResponse +[Serializable] +public record CreateLocationCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new custom attribute definition. /// @@ -22,15 +27,11 @@ public record CreateLocationCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateLocationResponse.cs b/src/Square/Types/CreateLocationResponse.cs index b01d6fd8..5a15e50d 100644 --- a/src/Square/Types/CreateLocationResponse.cs +++ b/src/Square/Types/CreateLocationResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response object returned by the [CreateLocation](api-endpoint:Locations-CreateLocation) endpoint. /// -public record CreateLocationResponse +[Serializable] +public record CreateLocationResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about [errors](https://developer.squareup.com/docs/build-basics/handling-errors) encountered during the request. /// @@ -21,15 +26,11 @@ public record CreateLocationResponse [JsonPropertyName("location")] public Location? Location { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateLoyaltyAccountResponse.cs b/src/Square/Types/CreateLoyaltyAccountResponse.cs index 10d4e143..0a57e826 100644 --- a/src/Square/Types/CreateLoyaltyAccountResponse.cs +++ b/src/Square/Types/CreateLoyaltyAccountResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes loyalty account created. /// -public record CreateLoyaltyAccountResponse +[Serializable] +public record CreateLoyaltyAccountResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record CreateLoyaltyAccountResponse [JsonPropertyName("loyalty_account")] public LoyaltyAccount? LoyaltyAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateLoyaltyPromotionResponse.cs b/src/Square/Types/CreateLoyaltyPromotionResponse.cs index bd78052d..5c0bf513 100644 --- a/src/Square/Types/CreateLoyaltyPromotionResponse.cs +++ b/src/Square/Types/CreateLoyaltyPromotionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateLoyaltyPromotion](api-endpoint:Loyalty-CreateLoyaltyPromotion) response. /// Either `loyalty_promotion` or `errors` is present in the response. /// -public record CreateLoyaltyPromotionResponse +[Serializable] +public record CreateLoyaltyPromotionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record CreateLoyaltyPromotionResponse [JsonPropertyName("loyalty_promotion")] public LoyaltyPromotion? LoyaltyPromotion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateLoyaltyRewardResponse.cs b/src/Square/Types/CreateLoyaltyRewardResponse.cs index 8e2e3666..1fd96d48 100644 --- a/src/Square/Types/CreateLoyaltyRewardResponse.cs +++ b/src/Square/Types/CreateLoyaltyRewardResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes the loyalty reward created. /// -public record CreateLoyaltyRewardResponse +[Serializable] +public record CreateLoyaltyRewardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record CreateLoyaltyRewardResponse [JsonPropertyName("reward")] public LoyaltyReward? Reward { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateMerchantCustomAttributeDefinitionResponse.cs b/src/Square/Types/CreateMerchantCustomAttributeDefinitionResponse.cs index 816ab6e7..d7265cc9 100644 --- a/src/Square/Types/CreateMerchantCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/CreateMerchantCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record CreateMerchantCustomAttributeDefinitionResponse +[Serializable] +public record CreateMerchantCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new custom attribute definition. /// @@ -22,15 +27,11 @@ public record CreateMerchantCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateMobileAuthorizationCodeResponse.cs b/src/Square/Types/CreateMobileAuthorizationCodeResponse.cs index c15bbc62..dc7b5794 100644 --- a/src/Square/Types/CreateMobileAuthorizationCodeResponse.cs +++ b/src/Square/Types/CreateMobileAuthorizationCodeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the `CreateMobileAuthorizationCode` endpoint. /// -public record CreateMobileAuthorizationCodeResponse +[Serializable] +public record CreateMobileAuthorizationCodeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The generated authorization code that connects a mobile application instance /// to a Square account. @@ -30,15 +35,11 @@ public record CreateMobileAuthorizationCodeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateOrderCustomAttributeDefinitionResponse.cs b/src/Square/Types/CreateOrderCustomAttributeDefinitionResponse.cs index 63523f22..1fc8f465 100644 --- a/src/Square/Types/CreateOrderCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/CreateOrderCustomAttributeDefinitionResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from creating an order custom attribute definition. /// -public record CreateOrderCustomAttributeDefinitionResponse +[Serializable] +public record CreateOrderCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new custom attribute definition. /// @@ -21,15 +26,11 @@ public record CreateOrderCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateOrderRequest.cs b/src/Square/Types/CreateOrderRequest.cs index 4ec9eb47..e32411a4 100644 --- a/src/Square/Types/CreateOrderRequest.cs +++ b/src/Square/Types/CreateOrderRequest.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateOrderRequest +[Serializable] +public record CreateOrderRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order to create. If this field is set, the only other top-level field that can be /// set is the `idempotency_key`. @@ -26,15 +31,11 @@ public record CreateOrderRequest [JsonPropertyName("idempotency_key")] public string? IdempotencyKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateOrderResponse.cs b/src/Square/Types/CreateOrderResponse.cs index e22f1595..2d985b08 100644 --- a/src/Square/Types/CreateOrderResponse.cs +++ b/src/Square/Types/CreateOrderResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `order` is present in a given response, but never both. /// -public record CreateOrderResponse +[Serializable] +public record CreateOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The newly created order. /// @@ -24,15 +29,11 @@ public record CreateOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreatePaymentLinkResponse.cs b/src/Square/Types/CreatePaymentLinkResponse.cs index d0aac551..6fb88361 100644 --- a/src/Square/Types/CreatePaymentLinkResponse.cs +++ b/src/Square/Types/CreatePaymentLinkResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreatePaymentLinkResponse +[Serializable] +public record CreatePaymentLinkResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record CreatePaymentLinkResponse [JsonPropertyName("related_resources")] public PaymentLinkRelatedResources? RelatedResources { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreatePaymentResponse.cs b/src/Square/Types/CreatePaymentResponse.cs index 213b90eb..cbd04e78 100644 --- a/src/Square/Types/CreatePaymentResponse.cs +++ b/src/Square/Types/CreatePaymentResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// If there are errors processing the request, the `payment` field might not be /// present, or it might be present with a status of `FAILED`. /// -public record CreatePaymentResponse +[Serializable] +public record CreatePaymentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -24,15 +29,11 @@ public record CreatePaymentResponse [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateScheduledShiftResponse.cs b/src/Square/Types/CreateScheduledShiftResponse.cs index ea4128ab..5caccb9c 100644 --- a/src/Square/Types/CreateScheduledShiftResponse.cs +++ b/src/Square/Types/CreateScheduledShiftResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [CreateScheduledShift](api-endpoint:Labor-CreateScheduledShift) response. /// Either `scheduled_shift` or `errors` is present in the response. /// -public record CreateScheduledShiftResponse +[Serializable] +public record CreateScheduledShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new scheduled shift. To make the shift public, call /// [PublishScheduledShift](api-endpoint:Labor-PublishScheduledShift) or @@ -24,15 +29,11 @@ public record CreateScheduledShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateShiftResponse.cs b/src/Square/Types/CreateShiftResponse.cs index 7bbae3e1..f81528a3 100644 --- a/src/Square/Types/CreateShiftResponse.cs +++ b/src/Square/Types/CreateShiftResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the created `Shift` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record CreateShiftResponse +[Serializable] +public record CreateShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The `Shift` that was created on the request. /// @@ -23,15 +28,11 @@ public record CreateShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateSubscriptionResponse.cs b/src/Square/Types/CreateSubscriptionResponse.cs index 3cabacb0..c85b6cd5 100644 --- a/src/Square/Types/CreateSubscriptionResponse.cs +++ b/src/Square/Types/CreateSubscriptionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [CreateSubscription](api-endpoint:Subscriptions-CreateSubscription) endpoint. /// -public record CreateSubscriptionResponse +[Serializable] +public record CreateSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -25,15 +30,11 @@ public record CreateSubscriptionResponse [JsonPropertyName("subscription")] public Subscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTeamMemberRequest.cs b/src/Square/Types/CreateTeamMemberRequest.cs index 6810c4e5..8fac57d2 100644 --- a/src/Square/Types/CreateTeamMemberRequest.cs +++ b/src/Square/Types/CreateTeamMemberRequest.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a create request for a `TeamMember` object. /// -public record CreateTeamMemberRequest +[Serializable] +public record CreateTeamMemberRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique string that identifies this `CreateTeamMember` request. /// Keys can be any valid string, but must be unique for every request. @@ -26,15 +31,11 @@ public record CreateTeamMemberRequest [JsonPropertyName("team_member")] public TeamMember? TeamMember { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTeamMemberResponse.cs b/src/Square/Types/CreateTeamMemberResponse.cs index 310ac02b..ea95bb58 100644 --- a/src/Square/Types/CreateTeamMemberResponse.cs +++ b/src/Square/Types/CreateTeamMemberResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a create request containing the created `TeamMember` object or error messages. /// -public record CreateTeamMemberResponse +[Serializable] +public record CreateTeamMemberResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully created `TeamMember` object. /// @@ -21,15 +26,11 @@ public record CreateTeamMemberResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTerminalActionResponse.cs b/src/Square/Types/CreateTerminalActionResponse.cs index b52b7fe4..dc5c9cb4 100644 --- a/src/Square/Types/CreateTerminalActionResponse.cs +++ b/src/Square/Types/CreateTerminalActionResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateTerminalActionResponse +[Serializable] +public record CreateTerminalActionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -18,15 +23,11 @@ public record CreateTerminalActionResponse [JsonPropertyName("action")] public TerminalAction? Action { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTerminalCheckoutResponse.cs b/src/Square/Types/CreateTerminalCheckoutResponse.cs index cf44672d..25bd055f 100644 --- a/src/Square/Types/CreateTerminalCheckoutResponse.cs +++ b/src/Square/Types/CreateTerminalCheckoutResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateTerminalCheckoutResponse +[Serializable] +public record CreateTerminalCheckoutResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record CreateTerminalCheckoutResponse [JsonPropertyName("checkout")] public TerminalCheckout? Checkout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTerminalRefundResponse.cs b/src/Square/Types/CreateTerminalRefundResponse.cs index f58d44ea..29f4fe3d 100644 --- a/src/Square/Types/CreateTerminalRefundResponse.cs +++ b/src/Square/Types/CreateTerminalRefundResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record CreateTerminalRefundResponse +[Serializable] +public record CreateTerminalRefundResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record CreateTerminalRefundResponse [JsonPropertyName("refund")] public TerminalRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTimecardResponse.cs b/src/Square/Types/CreateTimecardResponse.cs index 1ff40c73..98db7b6e 100644 --- a/src/Square/Types/CreateTimecardResponse.cs +++ b/src/Square/Types/CreateTimecardResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the created `Timecard` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record CreateTimecardResponse +[Serializable] +public record CreateTimecardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The `Timecard` that was created on the request. /// @@ -23,15 +28,11 @@ public record CreateTimecardResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTransferOrderData.cs b/src/Square/Types/CreateTransferOrderData.cs index 8c0e4020..69829704 100644 --- a/src/Square/Types/CreateTransferOrderData.cs +++ b/src/Square/Types/CreateTransferOrderData.cs @@ -9,8 +9,13 @@ namespace Square; /// between [Location](entity:Location)s. Used with the [CreateTransferOrder](api-endpoint:TransferOrders-CreateTransferOrder) /// endpoint. /// -public record CreateTransferOrderData +[Serializable] +public record CreateTransferOrderData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The source [Location](entity:Location) that will send the items. Must be an active location /// in your Square account with sufficient inventory of the requested items. @@ -56,15 +61,11 @@ public record CreateTransferOrderData [JsonPropertyName("line_items")] public IEnumerable? LineItems { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTransferOrderLineData.cs b/src/Square/Types/CreateTransferOrderLineData.cs index 4879c8ff..89f55d52 100644 --- a/src/Square/Types/CreateTransferOrderLineData.cs +++ b/src/Square/Types/CreateTransferOrderLineData.cs @@ -8,8 +8,13 @@ namespace Square; /// Data for creating a new transfer order line item. Each line item specifies a /// [CatalogItemVariation](entity:CatalogItemVariation) and quantity to transfer. /// -public record CreateTransferOrderLineData +[Serializable] +public record CreateTransferOrderLineData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// ID of the [CatalogItemVariation](entity:CatalogItemVariation) to transfer. Must reference a valid /// item variation in the [Catalog](api:Catalog). The item variation must be: @@ -26,15 +31,11 @@ public record CreateTransferOrderLineData [JsonPropertyName("quantity_ordered")] public required string QuantityOrdered { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateTransferOrderResponse.cs b/src/Square/Types/CreateTransferOrderResponse.cs index f16a295c..97293a45 100644 --- a/src/Square/Types/CreateTransferOrderResponse.cs +++ b/src/Square/Types/CreateTransferOrderResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response for creating a transfer order. /// -public record CreateTransferOrderResponse +[Serializable] +public record CreateTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created transfer order /// @@ -21,15 +26,11 @@ public record CreateTransferOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateVendorResponse.cs b/src/Square/Types/CreateVendorResponse.cs index 4c8acdf0..cb8792be 100644 --- a/src/Square/Types/CreateVendorResponse.cs +++ b/src/Square/Types/CreateVendorResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [CreateVendor](api-endpoint:Vendors-CreateVendor). /// -public record CreateVendorResponse +[Serializable] +public record CreateVendorResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered when the request fails. /// @@ -21,15 +26,11 @@ public record CreateVendorResponse [JsonPropertyName("vendor")] public Vendor? Vendor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CreateWebhookSubscriptionResponse.cs b/src/Square/Types/CreateWebhookSubscriptionResponse.cs index 19782593..03158a18 100644 --- a/src/Square/Types/CreateWebhookSubscriptionResponse.cs +++ b/src/Square/Types/CreateWebhookSubscriptionResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the [Subscription](entity:WebhookSubscription) will not be /// present. /// -public record CreateWebhookSubscriptionResponse +[Serializable] +public record CreateWebhookSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -25,15 +30,11 @@ public record CreateWebhookSubscriptionResponse [JsonPropertyName("subscription")] public WebhookSubscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Currency.cs b/src/Square/Types/Currency.cs index ab76284c..a1f68552 100644 --- a/src/Square/Types/Currency.cs +++ b/src/Square/Types/Currency.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct Currency : IStringEnum { public static readonly Currency UnknownCurrency = new(Values.UnknownCurrency); @@ -414,6 +415,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string UnknownCurrency = "UNKNOWN_CURRENCY"; diff --git a/src/Square/Types/CustomAttribute.cs b/src/Square/Types/CustomAttribute.cs index 839edf72..4ddc7817 100644 --- a/src/Square/Types/CustomAttribute.cs +++ b/src/Square/Types/CustomAttribute.cs @@ -8,8 +8,13 @@ namespace Square; /// A custom attribute value. Each custom attribute value has a corresponding /// `CustomAttributeDefinition` object. /// -public record CustomAttribute +[Serializable] +public record CustomAttribute : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The identifier /// of the custom attribute definition and its corresponding custom attributes. This value @@ -75,15 +80,11 @@ public record CustomAttribute [JsonPropertyName("created_at")] public string? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomAttributeDefinition.cs b/src/Square/Types/CustomAttributeDefinition.cs index 01c0e043..81ff0c8a 100644 --- a/src/Square/Types/CustomAttributeDefinition.cs +++ b/src/Square/Types/CustomAttributeDefinition.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a definition for custom attribute values. A custom attribute definition /// specifies the key, visibility, schema, and other properties for a custom attribute. /// -public record CustomAttributeDefinition +[Serializable] +public record CustomAttributeDefinition : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The identifier /// of the custom attribute definition and its corresponding custom attributes. This value @@ -35,7 +40,7 @@ public record CustomAttributeDefinition /// see [Custom Attributes Overview](https://developer.squareup.com/docs/devtools/customattributes/overview). This field is required when creating a definition. /// [JsonPropertyName("schema")] - public object? Schema { get; set; } + public Dictionary? Schema { get; set; } /// /// The name of the custom attribute definition for API and seller-facing UI purposes. The name must @@ -91,15 +96,11 @@ public record CustomAttributeDefinition [JsonPropertyName("created_at")] public string? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomAttributeDefinitionEventData.cs b/src/Square/Types/CustomAttributeDefinitionEventData.cs index a11f1c61..ffc8022a 100644 --- a/src/Square/Types/CustomAttributeDefinitionEventData.cs +++ b/src/Square/Types/CustomAttributeDefinitionEventData.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an object in the CustomAttributeDefinition event notification /// payload that contains the affected custom attribute definition. /// -public record CustomAttributeDefinitionEventData +[Serializable] +public record CustomAttributeDefinitionEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"custom_attribute_definition"`. /// @@ -28,15 +33,11 @@ public record CustomAttributeDefinitionEventData [JsonPropertyName("object")] public CustomAttributeDefinitionEventDataObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomAttributeDefinitionEventDataObject.cs b/src/Square/Types/CustomAttributeDefinitionEventDataObject.cs index 7a7a7e4a..4d8505b5 100644 --- a/src/Square/Types/CustomAttributeDefinitionEventDataObject.cs +++ b/src/Square/Types/CustomAttributeDefinitionEventDataObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CustomAttributeDefinitionEventDataObject +[Serializable] +public record CustomAttributeDefinitionEventDataObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The custom attribute definition. /// [JsonPropertyName("custom_attribute_definition")] public CustomAttributeDefinition? CustomAttributeDefinition { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomAttributeDefinitionVisibility.cs b/src/Square/Types/CustomAttributeDefinitionVisibility.cs index 03eab5fa..0ad8163a 100644 --- a/src/Square/Types/CustomAttributeDefinitionVisibility.cs +++ b/src/Square/Types/CustomAttributeDefinitionVisibility.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CustomAttributeDefinitionVisibility : IStringEnum { public static readonly CustomAttributeDefinitionVisibility VisibilityHidden = new( @@ -63,6 +64,7 @@ public static explicit operator string(CustomAttributeDefinitionVisibility value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string VisibilityHidden = "VISIBILITY_HIDDEN"; diff --git a/src/Square/Types/CustomAttributeEventData.cs b/src/Square/Types/CustomAttributeEventData.cs index 51ba5869..4a79f138 100644 --- a/src/Square/Types/CustomAttributeEventData.cs +++ b/src/Square/Types/CustomAttributeEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record CustomAttributeEventData +[Serializable] +public record CustomAttributeEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"custom_attribute"`. /// @@ -24,15 +29,11 @@ public record CustomAttributeEventData [JsonPropertyName("object")] public CustomAttributeEventDataObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomAttributeEventDataObject.cs b/src/Square/Types/CustomAttributeEventDataObject.cs index dbb4bc4e..addd8c56 100644 --- a/src/Square/Types/CustomAttributeEventDataObject.cs +++ b/src/Square/Types/CustomAttributeEventDataObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record CustomAttributeEventDataObject +[Serializable] +public record CustomAttributeEventDataObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The custom attribute. /// [JsonPropertyName("custom_attribute")] public CustomAttribute? CustomAttribute { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomAttributeFilter.cs b/src/Square/Types/CustomAttributeFilter.cs index 0a34ce0d..bbb08923 100644 --- a/src/Square/Types/CustomAttributeFilter.cs +++ b/src/Square/Types/CustomAttributeFilter.cs @@ -9,8 +9,13 @@ namespace Square; /// [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) /// endpoint to search for items or item variations. /// -public record CustomAttributeFilter +[Serializable] +public record CustomAttributeFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A query expression to filter items or item variations by matching their custom attributes' /// `custom_attribute_definition_id` property value against the the specified id. @@ -59,15 +64,11 @@ public record CustomAttributeFilter [JsonPropertyName("bool_filter")] public bool? BoolFilter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomField.cs b/src/Square/Types/CustomField.cs index 9458a377..5b2e2b3e 100644 --- a/src/Square/Types/CustomField.cs +++ b/src/Square/Types/CustomField.cs @@ -9,23 +9,24 @@ namespace Square; /// For more information, /// see [Specify checkout options](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations#specify-checkout-options-1). /// -public record CustomField +[Serializable] +public record CustomField : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title of the custom field. /// [JsonPropertyName("title")] public required string Title { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Customer.cs b/src/Square/Types/Customer.cs index 40cf3bc2..268bd5e6 100644 --- a/src/Square/Types/Customer.cs +++ b/src/Square/Types/Customer.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a Square customer profile in the Customer Directory of a Square seller. /// -public record Customer +[Serializable] +public record Customer : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique Square-assigned ID for the customer profile. /// @@ -132,15 +137,11 @@ public record Customer [JsonPropertyName("tax_ids")] public CustomerTaxIds? TaxIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerAddressFilter.cs b/src/Square/Types/CustomerAddressFilter.cs index 78247814..99d31bea 100644 --- a/src/Square/Types/CustomerAddressFilter.cs +++ b/src/Square/Types/CustomerAddressFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// The customer address filter. This filter is used in a [CustomerCustomAttributeFilterValue](entity:CustomerCustomAttributeFilterValue) filter when /// searching by an `Address`-type custom attribute. /// -public record CustomerAddressFilter +[Serializable] +public record CustomerAddressFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The postal code to search for. Only an `exact` match is supported. /// @@ -23,15 +28,11 @@ public record CustomerAddressFilter [JsonPropertyName("country")] public Country? Country { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCreatedEvent.cs b/src/Square/Types/CustomerCreatedEvent.cs index e753b11b..29a8cb69 100644 --- a/src/Square/Types/CustomerCreatedEvent.cs +++ b/src/Square/Types/CustomerCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// /// The `customer` object in the event notification does not include the `segment_ids` field. /// -public record CustomerCreatedEvent +[Serializable] +public record CustomerCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event. /// @@ -43,15 +48,11 @@ public record CustomerCreatedEvent [JsonPropertyName("data")] public CustomerCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCreatedEventData.cs b/src/Square/Types/CustomerCreatedEventData.cs index cfa8ec5b..0270a89f 100644 --- a/src/Square/Types/CustomerCreatedEventData.cs +++ b/src/Square/Types/CustomerCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with the event. /// -public record CustomerCreatedEventData +[Serializable] +public record CustomerCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `customer`. /// @@ -27,15 +32,11 @@ public record CustomerCreatedEventData [JsonPropertyName("object")] public CustomerCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCreatedEventEventContext.cs b/src/Square/Types/CustomerCreatedEventEventContext.cs index 22d6b607..dde1e442 100644 --- a/src/Square/Types/CustomerCreatedEventEventContext.cs +++ b/src/Square/Types/CustomerCreatedEventEventContext.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Information about the change that triggered the event. /// -public record CustomerCreatedEventEventContext +[Serializable] +public record CustomerCreatedEventEventContext : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the merge operation associated with the event. /// [JsonPropertyName("merge")] public CustomerCreatedEventEventContextMerge? Merge { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCreatedEventEventContextMerge.cs b/src/Square/Types/CustomerCreatedEventEventContextMerge.cs index 8bca5541..d9d6859d 100644 --- a/src/Square/Types/CustomerCreatedEventEventContextMerge.cs +++ b/src/Square/Types/CustomerCreatedEventEventContextMerge.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Information about a merge operation, which creates a new customer using aggregated properties from two or more existing customers. /// -public record CustomerCreatedEventEventContextMerge +[Serializable] +public record CustomerCreatedEventEventContextMerge : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The IDs of the existing customers that were merged and then deleted. /// @@ -21,15 +26,11 @@ public record CustomerCreatedEventEventContextMerge [JsonPropertyName("to_customer_id")] public string? ToCustomerId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCreatedEventObject.cs b/src/Square/Types/CustomerCreatedEventObject.cs index b26e06fd..506ac00a 100644 --- a/src/Square/Types/CustomerCreatedEventObject.cs +++ b/src/Square/Types/CustomerCreatedEventObject.cs @@ -7,8 +7,13 @@ namespace Square; /// /// An object that contains the customer associated with the event. /// -public record CustomerCreatedEventObject +[Serializable] +public record CustomerCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new customer. /// @@ -21,15 +26,11 @@ public record CustomerCreatedEventObject [JsonPropertyName("event_context")] public CustomerCreatedEventEventContext? EventContext { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCreationSource.cs b/src/Square/Types/CustomerCreationSource.cs index ceff62db..3dcd9678 100644 --- a/src/Square/Types/CustomerCreationSource.cs +++ b/src/Square/Types/CustomerCreationSource.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CustomerCreationSource : IStringEnum { public static readonly CustomerCreationSource Other = new(Values.Other); @@ -88,6 +89,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Other = "OTHER"; diff --git a/src/Square/Types/CustomerCreationSourceFilter.cs b/src/Square/Types/CustomerCreationSourceFilter.cs index 00c7ca0b..6a37f3dd 100644 --- a/src/Square/Types/CustomerCreationSourceFilter.cs +++ b/src/Square/Types/CustomerCreationSourceFilter.cs @@ -10,8 +10,13 @@ namespace Square; /// If one or more creation sources are set, customer profiles are included in, /// or excluded from, the result if they match at least one of the filter criteria. /// -public record CustomerCreationSourceFilter +[Serializable] +public record CustomerCreationSourceFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of creation sources used as filtering criteria. /// See [CustomerCreationSource](#type-customercreationsource) for possible values @@ -29,15 +34,11 @@ public record CustomerCreationSourceFilter [JsonPropertyName("rule")] public CustomerInclusionExclusion? Rule { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionCreatedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionCreatedEvent.cs index c5244d39..fee5f133 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionCreatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionCreatedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// This event is replaced by /// [customer.custom_attribute_definition.owned.created](webhook:customer.custom_attribute_definition.owned.created). /// -public record CustomerCustomAttributeDefinitionCreatedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -44,15 +49,11 @@ public record CustomerCustomAttributeDefinitionCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionCreatedPublicEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionCreatedPublicEvent.cs index ba3cb83d..c4b743ac 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionCreatedPublicEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionCreatedPublicEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// [customer.custom_attribute_definition.visible.created](webhook:customer.custom_attribute_definition.visible.created), /// which applies to custom attribute definitions that are visible to the subscribing application. /// -public record CustomerCustomAttributeDefinitionCreatedPublicEvent +[Serializable] +public record CustomerCustomAttributeDefinitionCreatedPublicEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeDefinitionCreatedPublicEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionDeletedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionDeletedEvent.cs index 267bfa80..b494c53b 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionDeletedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionDeletedEvent.cs @@ -12,8 +12,13 @@ namespace Square; /// This event is replaced by /// [customer.custom_attribute_definition.owned.deleted](webhook:customer.custom_attribute_definition.owned.deleted). /// -public record CustomerCustomAttributeDefinitionDeletedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -45,15 +50,11 @@ public record CustomerCustomAttributeDefinitionDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionDeletedPublicEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionDeletedPublicEvent.cs index 46eb33b9..d847abbd 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionDeletedPublicEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionDeletedPublicEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// [customer.custom_attribute_definition.visible.deleted](webhook:customer.custom_attribute_definition.visible.deleted), /// which applies to custom attribute definitions that are visible to the subscribing application. /// -public record CustomerCustomAttributeDefinitionDeletedPublicEvent +[Serializable] +public record CustomerCustomAttributeDefinitionDeletedPublicEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeDefinitionDeletedPublicEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionOwnedCreatedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionOwnedCreatedEvent.cs index 4e576c09..41919216 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionOwnedCreatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionOwnedCreatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a customer [custom attribute definition](entity:CustomAttributeDefinition) /// is created by the subscribing application. /// -public record CustomerCustomAttributeDefinitionOwnedCreatedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionOwnedCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -41,15 +46,11 @@ public record CustomerCustomAttributeDefinitionOwnedCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionOwnedDeletedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionOwnedDeletedEvent.cs index 3ffbf25d..766b55eb 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionOwnedDeletedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionOwnedDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// created by the subscribing application is deleted. A custom attribute definition can only be deleted by /// the application that created it. /// -public record CustomerCustomAttributeDefinitionOwnedDeletedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record CustomerCustomAttributeDefinitionOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionOwnedUpdatedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionOwnedUpdatedEvent.cs index 5afcfddc..554ab45c 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionOwnedUpdatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionOwnedUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// created by the subscribing application is updated. A custom attribute definition can only be updated by /// the application that created it. /// -public record CustomerCustomAttributeDefinitionOwnedUpdatedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record CustomerCustomAttributeDefinitionOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedEvent.cs index b8e51047..a3f4c385 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedEvent.cs @@ -12,8 +12,13 @@ namespace Square; /// This event is replaced by /// [customer.custom_attribute_definition.owned.updated](webhook:customer.custom_attribute_definition.owned.updated). /// -public record CustomerCustomAttributeDefinitionUpdatedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -45,15 +50,11 @@ public record CustomerCustomAttributeDefinitionUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedPublicEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedPublicEvent.cs index d4cf18be..08106977 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedPublicEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionUpdatedPublicEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// [customer.custom_attribute_definition.visible.updated](webhook:customer.custom_attribute_definition.visible.updated), /// which applies to custom attribute definitions that are visible to the subscribing application. /// -public record CustomerCustomAttributeDefinitionUpdatedPublicEvent +[Serializable] +public record CustomerCustomAttributeDefinitionUpdatedPublicEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeDefinitionUpdatedPublicEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionVisibleCreatedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionVisibleCreatedEvent.cs index ea872790..a376d720 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionVisibleCreatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionVisibleCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// creates a custom attribute definition or another application creates a custom attribute definition whose /// `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record CustomerCustomAttributeDefinitionVisibleCreatedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionVisibleCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record CustomerCustomAttributeDefinitionVisibleCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionVisibleDeletedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionVisibleDeletedEvent.cs index 18f974fc..d45459ed 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionVisibleDeletedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionVisibleDeletedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// definition or when another application deletes a custom attribute definition whose `visibility` is /// `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record CustomerCustomAttributeDefinitionVisibleDeletedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -44,15 +49,11 @@ public record CustomerCustomAttributeDefinitionVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDefinitionVisibleUpdatedEvent.cs b/src/Square/Types/CustomerCustomAttributeDefinitionVisibleUpdatedEvent.cs index 7c87a6c2..316a6db1 100644 --- a/src/Square/Types/CustomerCustomAttributeDefinitionVisibleUpdatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDefinitionVisibleUpdatedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// attribute definition or when another application updates a custom attribute definition whose `visibility` is /// `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record CustomerCustomAttributeDefinitionVisibleUpdatedEvent +[Serializable] +public record CustomerCustomAttributeDefinitionVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -44,15 +49,11 @@ public record CustomerCustomAttributeDefinitionVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDeletedEvent.cs b/src/Square/Types/CustomerCustomAttributeDeletedEvent.cs index 3b53da8f..4652cea9 100644 --- a/src/Square/Types/CustomerCustomAttributeDeletedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDeletedEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// This event is replaced by /// [customer.custom_attribute.owned.deleted](webhook:customer.custom_attribute.owned.deleted). /// -public record CustomerCustomAttributeDeletedEvent +[Serializable] +public record CustomerCustomAttributeDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeDeletedPublicEvent.cs b/src/Square/Types/CustomerCustomAttributeDeletedPublicEvent.cs index e2a1d314..32cdf369 100644 --- a/src/Square/Types/CustomerCustomAttributeDeletedPublicEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeDeletedPublicEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// [customer.custom_attribute.visible.deleted](webhook:customer.custom_attribute.visible.deleted), /// which applies to custom attributes that are visible to the subscribing application. /// -public record CustomerCustomAttributeDeletedPublicEvent +[Serializable] +public record CustomerCustomAttributeDeletedPublicEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeDeletedPublicEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeFilter.cs b/src/Square/Types/CustomerCustomAttributeFilter.cs index 12ac99ec..89267b05 100644 --- a/src/Square/Types/CustomerCustomAttributeFilter.cs +++ b/src/Square/Types/CustomerCustomAttributeFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// The custom attribute filter. Use this filter in a set of [custom attribute filters](entity:CustomerCustomAttributeFilters) to search /// based on the value or last updated date of a customer-related [custom attribute](entity:CustomAttribute). /// -public record CustomerCustomAttributeFilter +[Serializable] +public record CustomerCustomAttributeFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The `key` of the [custom attribute](entity:CustomAttribute) to filter by. The key is the identifier of the custom attribute /// (and the corresponding custom attribute definition) and can be retrieved using the [Customer Custom Attributes API](api:CustomerCustomAttributes). @@ -36,15 +41,11 @@ public record CustomerCustomAttributeFilter [JsonPropertyName("updated_at")] public TimeRange? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeFilterValue.cs b/src/Square/Types/CustomerCustomAttributeFilterValue.cs index 8078b73c..3fb32b43 100644 --- a/src/Square/Types/CustomerCustomAttributeFilterValue.cs +++ b/src/Square/Types/CustomerCustomAttributeFilterValue.cs @@ -8,8 +8,13 @@ namespace Square; /// A type-specific filter used in a [custom attribute filter](entity:CustomerCustomAttributeFilter) to search based on the value /// of a customer-related [custom attribute](entity:CustomAttribute). /// -public record CustomerCustomAttributeFilterValue +[Serializable] +public record CustomerCustomAttributeFilterValue : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A filter for a query based on the value of an `Email`-type custom attribute. This filter is case-insensitive and can /// include `exact` or `fuzzy`, but not both. @@ -99,15 +104,11 @@ public record CustomerCustomAttributeFilterValue [JsonPropertyName("address")] public CustomerAddressFilter? Address { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeFilters.cs b/src/Square/Types/CustomerCustomAttributeFilters.cs index 7da587f5..cc468c03 100644 --- a/src/Square/Types/CustomerCustomAttributeFilters.cs +++ b/src/Square/Types/CustomerCustomAttributeFilters.cs @@ -9,8 +9,13 @@ namespace Square; /// to search based on [custom attributes](entity:CustomAttribute) that are assigned to customer profiles. For more information, see /// [Search by custom attribute](https://developer.squareup.com/docs/customers-api/use-the-api/search-customers#search-by-custom-attribute). /// -public record CustomerCustomAttributeFilters +[Serializable] +public record CustomerCustomAttributeFilters : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The custom attribute filters. Each filter must specify `key` and include the `filter` field with a type-specific filter, /// the `updated_at` field, or both. The provided keys must be unique within the list of custom attribute filters. @@ -18,15 +23,11 @@ public record CustomerCustomAttributeFilters [JsonPropertyName("filters")] public IEnumerable? Filters { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeOwnedDeletedEvent.cs b/src/Square/Types/CustomerCustomAttributeOwnedDeletedEvent.cs index bca44cb3..06001c29 100644 --- a/src/Square/Types/CustomerCustomAttributeOwnedDeletedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeOwnedDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// corresponding [custom attribute definition](entity:CustomAttributeDefinition). Custom attributes whose /// `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be deleted by any application. /// -public record CustomerCustomAttributeOwnedDeletedEvent +[Serializable] +public record CustomerCustomAttributeOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record CustomerCustomAttributeOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeOwnedUpdatedEvent.cs b/src/Square/Types/CustomerCustomAttributeOwnedUpdatedEvent.cs index 4854c595..492a6183 100644 --- a/src/Square/Types/CustomerCustomAttributeOwnedUpdatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeOwnedUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// the corresponding [custom attribute definition](entity:CustomAttributeDefinition). Custom attributes whose /// `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be created or updated by any application. /// -public record CustomerCustomAttributeOwnedUpdatedEvent +[Serializable] +public record CustomerCustomAttributeOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record CustomerCustomAttributeOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeUpdatedEvent.cs b/src/Square/Types/CustomerCustomAttributeUpdatedEvent.cs index 047169bc..6315eb98 100644 --- a/src/Square/Types/CustomerCustomAttributeUpdatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeUpdatedEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// This event is replaced by /// [customer.custom_attribute.owned.updated](webhook:customer.custom_attribute.owned.updated). /// -public record CustomerCustomAttributeUpdatedEvent +[Serializable] +public record CustomerCustomAttributeUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeUpdatedPublicEvent.cs b/src/Square/Types/CustomerCustomAttributeUpdatedPublicEvent.cs index 1dcaea28..e35ad125 100644 --- a/src/Square/Types/CustomerCustomAttributeUpdatedPublicEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeUpdatedPublicEvent.cs @@ -13,8 +13,13 @@ namespace Square; /// [customer.custom_attribute.visible.updated](webhook:customer.custom_attribute.visible.updated), /// which applies to custom attributes that are visible to the subscribing application. /// -public record CustomerCustomAttributeUpdatedPublicEvent +[Serializable] +public record CustomerCustomAttributeUpdatedPublicEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -46,15 +51,11 @@ public record CustomerCustomAttributeUpdatedPublicEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeVisibleDeletedEvent.cs b/src/Square/Types/CustomerCustomAttributeVisibleDeletedEvent.cs index 4c4c718b..5cdca63b 100644 --- a/src/Square/Types/CustomerCustomAttributeVisibleDeletedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeVisibleDeletedEvent.cs @@ -15,8 +15,13 @@ namespace Square; /// `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be deleted by the owner. Custom attributes are owned /// by the application that created the corresponding [custom attribute definition](entity:CustomAttributeDefinition). /// -public record CustomerCustomAttributeVisibleDeletedEvent +[Serializable] +public record CustomerCustomAttributeVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -48,15 +53,11 @@ public record CustomerCustomAttributeVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerCustomAttributeVisibleUpdatedEvent.cs b/src/Square/Types/CustomerCustomAttributeVisibleUpdatedEvent.cs index 2f88c0f0..8fbf62a6 100644 --- a/src/Square/Types/CustomerCustomAttributeVisibleUpdatedEvent.cs +++ b/src/Square/Types/CustomerCustomAttributeVisibleUpdatedEvent.cs @@ -15,8 +15,13 @@ namespace Square; /// `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be created or updated by the owner. Custom attributes are owned /// by the application that created the corresponding [custom attribute definition](entity:CustomAttributeDefinition). /// -public record CustomerCustomAttributeVisibleUpdatedEvent +[Serializable] +public record CustomerCustomAttributeVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -48,15 +53,11 @@ public record CustomerCustomAttributeVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerDeletedEvent.cs b/src/Square/Types/CustomerDeletedEvent.cs index c66087f3..203bb141 100644 --- a/src/Square/Types/CustomerDeletedEvent.cs +++ b/src/Square/Types/CustomerDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// /// The `customer` object in the event notification does not include the following fields: `group_ids` and `segment_ids`. /// -public record CustomerDeletedEvent +[Serializable] +public record CustomerDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event. /// @@ -42,15 +47,11 @@ public record CustomerDeletedEvent [JsonPropertyName("data")] public CustomerDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerDeletedEventData.cs b/src/Square/Types/CustomerDeletedEventData.cs index 3ac22c50..10534947 100644 --- a/src/Square/Types/CustomerDeletedEventData.cs +++ b/src/Square/Types/CustomerDeletedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with the event. /// -public record CustomerDeletedEventData +[Serializable] +public record CustomerDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `customer`. /// @@ -27,15 +32,11 @@ public record CustomerDeletedEventData [JsonPropertyName("object")] public CustomerDeletedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerDeletedEventEventContext.cs b/src/Square/Types/CustomerDeletedEventEventContext.cs index b330177a..298aa492 100644 --- a/src/Square/Types/CustomerDeletedEventEventContext.cs +++ b/src/Square/Types/CustomerDeletedEventEventContext.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Information about the change that triggered the event. /// -public record CustomerDeletedEventEventContext +[Serializable] +public record CustomerDeletedEventEventContext : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the merge operation associated with the event. /// [JsonPropertyName("merge")] public CustomerDeletedEventEventContextMerge? Merge { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerDeletedEventEventContextMerge.cs b/src/Square/Types/CustomerDeletedEventEventContextMerge.cs index ef12cd20..f481f50b 100644 --- a/src/Square/Types/CustomerDeletedEventEventContextMerge.cs +++ b/src/Square/Types/CustomerDeletedEventEventContextMerge.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Information about a merge operation, which creates a new customer using aggregated properties from two or more existing customers. /// -public record CustomerDeletedEventEventContextMerge +[Serializable] +public record CustomerDeletedEventEventContextMerge : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The IDs of the existing customers that were merged and then deleted. /// @@ -21,15 +26,11 @@ public record CustomerDeletedEventEventContextMerge [JsonPropertyName("to_customer_id")] public string? ToCustomerId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerDeletedEventObject.cs b/src/Square/Types/CustomerDeletedEventObject.cs index d8897235..3eae2286 100644 --- a/src/Square/Types/CustomerDeletedEventObject.cs +++ b/src/Square/Types/CustomerDeletedEventObject.cs @@ -7,8 +7,13 @@ namespace Square; /// /// An object that contains the customer associated with the event. /// -public record CustomerDeletedEventObject +[Serializable] +public record CustomerDeletedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The deleted customer. /// @@ -21,15 +26,11 @@ public record CustomerDeletedEventObject [JsonPropertyName("event_context")] public CustomerDeletedEventEventContext? EventContext { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerDetails.cs b/src/Square/Types/CustomerDetails.cs index ada4f5fa..308ae509 100644 --- a/src/Square/Types/CustomerDetails.cs +++ b/src/Square/Types/CustomerDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Details about the customer making the payment. /// -public record CustomerDetails +[Serializable] +public record CustomerDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether the customer initiated the payment. /// @@ -22,15 +27,11 @@ public record CustomerDetails [JsonPropertyName("seller_keyed_in")] public bool? SellerKeyedIn { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerFilter.cs b/src/Square/Types/CustomerFilter.cs index fd0877e5..10eebada 100644 --- a/src/Square/Types/CustomerFilter.cs +++ b/src/Square/Types/CustomerFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the filtering criteria in a [search query](entity:CustomerQuery) that defines how to filter /// customer profiles returned in [SearchCustomers](api-endpoint:Customers-SearchCustomers) results. /// -public record CustomerFilter +[Serializable] +public record CustomerFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A filter to select customers based on their creation source. /// @@ -148,15 +153,11 @@ public record CustomerFilter [JsonPropertyName("segment_ids")] public FilterValue? SegmentIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerGroup.cs b/src/Square/Types/CustomerGroup.cs index b398289b..eb9c246f 100644 --- a/src/Square/Types/CustomerGroup.cs +++ b/src/Square/Types/CustomerGroup.cs @@ -10,8 +10,13 @@ namespace Square; /// Customer groups can be created, be modified, and have their membership defined using /// the Customers API or within the Customer Directory in the Square Seller Dashboard or Point of Sale. /// -public record CustomerGroup +[Serializable] +public record CustomerGroup : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique Square-generated ID for the customer group. /// @@ -39,15 +44,11 @@ public record CustomerGroup [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerInclusionExclusion.cs b/src/Square/Types/CustomerInclusionExclusion.cs index 124c88eb..29eb791d 100644 --- a/src/Square/Types/CustomerInclusionExclusion.cs +++ b/src/Square/Types/CustomerInclusionExclusion.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CustomerInclusionExclusion : IStringEnum { public static readonly CustomerInclusionExclusion Include = new(Values.Include); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Include = "INCLUDE"; diff --git a/src/Square/Types/CustomerPreferences.cs b/src/Square/Types/CustomerPreferences.cs index 0016389c..f614e632 100644 --- a/src/Square/Types/CustomerPreferences.cs +++ b/src/Square/Types/CustomerPreferences.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents communication preferences for the customer profile. /// -public record CustomerPreferences +[Serializable] +public record CustomerPreferences : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether the customer has unsubscribed from marketing campaign emails. A value of `true` means that the customer chose to opt out of email marketing from the current Square seller or from all Square sellers. This value is read-only from the Customers API. /// [JsonPropertyName("email_unsubscribed")] public bool? EmailUnsubscribed { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerQuery.cs b/src/Square/Types/CustomerQuery.cs index 63adc82c..5746f640 100644 --- a/src/Square/Types/CustomerQuery.cs +++ b/src/Square/Types/CustomerQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents filtering and sorting criteria for a [SearchCustomers](api-endpoint:Customers-SearchCustomers) request. /// -public record CustomerQuery +[Serializable] +public record CustomerQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The filtering criteria for the search query. A query can contain multiple filters in any combination. /// Multiple filters are combined as `AND` statements. @@ -26,15 +31,11 @@ public record CustomerQuery [JsonPropertyName("sort")] public CustomerSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerSegment.cs b/src/Square/Types/CustomerSegment.cs index c907cdc5..30e7e542 100644 --- a/src/Square/Types/CustomerSegment.cs +++ b/src/Square/Types/CustomerSegment.cs @@ -10,8 +10,13 @@ namespace Square; /// Segments (also known as Smart Groups) are defined and created within the Customer Directory in the /// Square Seller Dashboard or Point of Sale. /// -public record CustomerSegment +[Serializable] +public record CustomerSegment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique Square-generated ID for the segment. /// @@ -40,15 +45,11 @@ public record CustomerSegment [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerSort.cs b/src/Square/Types/CustomerSort.cs index b80cbe23..23fa6ad2 100644 --- a/src/Square/Types/CustomerSort.cs +++ b/src/Square/Types/CustomerSort.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the sorting criteria in a [search query](entity:CustomerQuery) that defines how to sort /// customer profiles returned in [SearchCustomers](api-endpoint:Customers-SearchCustomers) results. /// -public record CustomerSort +[Serializable] +public record CustomerSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates the fields to use as the sort key, which is either the default set of fields or `created_at`. /// @@ -30,15 +35,11 @@ public record CustomerSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerSortField.cs b/src/Square/Types/CustomerSortField.cs index 1a03b7c5..73bd1918 100644 --- a/src/Square/Types/CustomerSortField.cs +++ b/src/Square/Types/CustomerSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct CustomerSortField : IStringEnum { public static readonly CustomerSortField Default = new(Values.Default); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Default = "DEFAULT"; diff --git a/src/Square/Types/CustomerTaxIds.cs b/src/Square/Types/CustomerTaxIds.cs index 62a0e7bf..06f184c4 100644 --- a/src/Square/Types/CustomerTaxIds.cs +++ b/src/Square/Types/CustomerTaxIds.cs @@ -8,23 +8,24 @@ namespace Square; /// Represents the tax ID associated with a [customer profile](entity:Customer). The corresponding `tax_ids` field is available 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). /// -public record CustomerTaxIds +[Serializable] +public record CustomerTaxIds : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The EU VAT identification number for the customer. For example, `IE3426675K`. The ID can contain alphanumeric characters only. /// [JsonPropertyName("eu_vat")] public string? EuVat { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerTextFilter.cs b/src/Square/Types/CustomerTextFilter.cs index c2461c67..71923f63 100644 --- a/src/Square/Types/CustomerTextFilter.cs +++ b/src/Square/Types/CustomerTextFilter.cs @@ -9,8 +9,13 @@ namespace Square; /// customer attributes against a specified query. Depending on the customer attributes, /// the filter can be case-sensitive. This filter can be exact or fuzzy, but it cannot be both. /// -public record CustomerTextFilter +[Serializable] +public record CustomerTextFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Use the exact filter to select customers whose attributes match exactly the specified query. /// @@ -26,15 +31,11 @@ public record CustomerTextFilter [JsonPropertyName("fuzzy")] public string? Fuzzy { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerUpdatedEvent.cs b/src/Square/Types/CustomerUpdatedEvent.cs index 3cdf3ac6..88ba6d79 100644 --- a/src/Square/Types/CustomerUpdatedEvent.cs +++ b/src/Square/Types/CustomerUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Updates to the 'segment_ids' customer field does not invoke a `customer.updated` event. In addition, the `customer` object in the event notification does not include this field. /// -public record CustomerUpdatedEvent +[Serializable] +public record CustomerUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event. /// @@ -42,15 +47,11 @@ public record CustomerUpdatedEvent [JsonPropertyName("data")] public CustomerUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerUpdatedEventData.cs b/src/Square/Types/CustomerUpdatedEventData.cs index 5a0b7d95..82226f47 100644 --- a/src/Square/Types/CustomerUpdatedEventData.cs +++ b/src/Square/Types/CustomerUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with the event. /// -public record CustomerUpdatedEventData +[Serializable] +public record CustomerUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `customer`. /// @@ -27,15 +32,11 @@ public record CustomerUpdatedEventData [JsonPropertyName("object")] public CustomerUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/CustomerUpdatedEventObject.cs b/src/Square/Types/CustomerUpdatedEventObject.cs index a37d1ead..0f4052cd 100644 --- a/src/Square/Types/CustomerUpdatedEventObject.cs +++ b/src/Square/Types/CustomerUpdatedEventObject.cs @@ -7,23 +7,24 @@ namespace Square; /// /// An object that contains the customer associated with the event. /// -public record CustomerUpdatedEventObject +[Serializable] +public record CustomerUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated customer. /// [JsonPropertyName("customer")] public Customer? Customer { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DataCollectionOptions.cs b/src/Square/Types/DataCollectionOptions.cs index fc9aba09..ba2d6a3e 100644 --- a/src/Square/Types/DataCollectionOptions.cs +++ b/src/Square/Types/DataCollectionOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record DataCollectionOptions +[Serializable] +public record DataCollectionOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title text to display in the data collection flow on the Terminal. /// @@ -32,15 +37,11 @@ public record DataCollectionOptions [JsonPropertyName("collected_data")] public CollectedData? CollectedData { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DataCollectionOptionsInputType.cs b/src/Square/Types/DataCollectionOptionsInputType.cs index 82ffbfbc..1efa10e4 100644 --- a/src/Square/Types/DataCollectionOptionsInputType.cs +++ b/src/Square/Types/DataCollectionOptionsInputType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DataCollectionOptionsInputType : IStringEnum { public static readonly DataCollectionOptionsInputType Email = new(Values.Email); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Email = "EMAIL"; diff --git a/src/Square/Types/DateRange.cs b/src/Square/Types/DateRange.cs index 532b36e9..991c7c2a 100644 --- a/src/Square/Types/DateRange.cs +++ b/src/Square/Types/DateRange.cs @@ -8,8 +8,13 @@ namespace Square; /// A range defined by two dates. Used for filtering a query for Connect v2 /// objects that have date properties. /// -public record DateRange +[Serializable] +public record DateRange : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A string in `YYYY-MM-DD` format, such as `2017-10-31`, per the ISO 8601 /// extended format for calendar dates. @@ -26,15 +31,11 @@ public record DateRange [JsonPropertyName("end_date")] public string? EndDate { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DayOfWeek.cs b/src/Square/Types/DayOfWeek.cs index d3ac8611..e40d48ca 100644 --- a/src/Square/Types/DayOfWeek.cs +++ b/src/Square/Types/DayOfWeek.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DayOfWeek : IStringEnum { public static readonly DayOfWeek Sun = new(Values.Sun); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Sun = "SUN"; diff --git a/src/Square/Types/DeleteBookingCustomAttributeDefinitionResponse.cs b/src/Square/Types/DeleteBookingCustomAttributeDefinitionResponse.cs index 6a398c37..ee74c0ea 100644 --- a/src/Square/Types/DeleteBookingCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/DeleteBookingCustomAttributeDefinitionResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Represents a [DeleteBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-DeleteBookingCustomAttributeDefinition) response /// containing error messages when errors occurred during the request. The successful response does not contain any payload. /// -public record DeleteBookingCustomAttributeDefinitionResponse +[Serializable] +public record DeleteBookingCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteBookingCustomAttributeResponse.cs b/src/Square/Types/DeleteBookingCustomAttributeResponse.cs index 8c7b347f..8a3dc926 100644 --- a/src/Square/Types/DeleteBookingCustomAttributeResponse.cs +++ b/src/Square/Types/DeleteBookingCustomAttributeResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Represents a [DeleteBookingCustomAttribute](api-endpoint:BookingCustomAttributes-DeleteBookingCustomAttribute) response. /// Either an empty object `{}` (for a successful deletion) or `errors` is present in the response. /// -public record DeleteBookingCustomAttributeResponse +[Serializable] +public record DeleteBookingCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteBreakTypeResponse.cs b/src/Square/Types/DeleteBreakTypeResponse.cs index 1639b2e7..0aebc9f2 100644 --- a/src/Square/Types/DeleteBreakTypeResponse.cs +++ b/src/Square/Types/DeleteBreakTypeResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// The response to a request to delete a `BreakType`. The response might contain a set /// of `Error` objects if the request resulted in errors. /// -public record DeleteBreakTypeResponse +[Serializable] +public record DeleteBreakTypeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteCatalogObjectResponse.cs b/src/Square/Types/DeleteCatalogObjectResponse.cs index 7e4b80fa..bf11ad88 100644 --- a/src/Square/Types/DeleteCatalogObjectResponse.cs +++ b/src/Square/Types/DeleteCatalogObjectResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeleteCatalogObjectResponse +[Serializable] +public record DeleteCatalogObjectResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -28,15 +33,11 @@ public record DeleteCatalogObjectResponse [JsonPropertyName("deleted_at")] public string? DeletedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteCustomerCardResponse.cs b/src/Square/Types/DeleteCustomerCardResponse.cs index 33872727..ba6aa103 100644 --- a/src/Square/Types/DeleteCustomerCardResponse.cs +++ b/src/Square/Types/DeleteCustomerCardResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the `DeleteCustomerCard` endpoint. /// -public record DeleteCustomerCardResponse +[Serializable] +public record DeleteCustomerCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteCustomerCustomAttributeDefinitionResponse.cs b/src/Square/Types/DeleteCustomerCustomAttributeDefinitionResponse.cs index b8b27ab6..09dc5698 100644 --- a/src/Square/Types/DeleteCustomerCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/DeleteCustomerCustomAttributeDefinitionResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a response from a delete request containing error messages if there are any. /// -public record DeleteCustomerCustomAttributeDefinitionResponse +[Serializable] +public record DeleteCustomerCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteCustomerCustomAttributeResponse.cs b/src/Square/Types/DeleteCustomerCustomAttributeResponse.cs index 3c60324d..041a073a 100644 --- a/src/Square/Types/DeleteCustomerCustomAttributeResponse.cs +++ b/src/Square/Types/DeleteCustomerCustomAttributeResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Represents a [DeleteCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-DeleteCustomerCustomAttribute) response. /// Either an empty object `{}` (for a successful deletion) or `errors` is present in the response. /// -public record DeleteCustomerCustomAttributeResponse +[Serializable] +public record DeleteCustomerCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteCustomerGroupResponse.cs b/src/Square/Types/DeleteCustomerGroupResponse.cs index 36d72b4e..d55472a7 100644 --- a/src/Square/Types/DeleteCustomerGroupResponse.cs +++ b/src/Square/Types/DeleteCustomerGroupResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [DeleteCustomerGroup](api-endpoint:CustomerGroups-DeleteCustomerGroup) endpoint. /// -public record DeleteCustomerGroupResponse +[Serializable] +public record DeleteCustomerGroupResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteCustomerResponse.cs b/src/Square/Types/DeleteCustomerResponse.cs index e91a36fd..65afc479 100644 --- a/src/Square/Types/DeleteCustomerResponse.cs +++ b/src/Square/Types/DeleteCustomerResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the `DeleteCustomer` endpoint. /// -public record DeleteCustomerResponse +[Serializable] +public record DeleteCustomerResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteDisputeEvidenceResponse.cs b/src/Square/Types/DeleteDisputeEvidenceResponse.cs index d9cbea61..b68043b2 100644 --- a/src/Square/Types/DeleteDisputeEvidenceResponse.cs +++ b/src/Square/Types/DeleteDisputeEvidenceResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Defines the fields in a `DeleteDisputeEvidence` response. /// -public record DeleteDisputeEvidenceResponse +[Serializable] +public record DeleteDisputeEvidenceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteInvoiceAttachmentResponse.cs b/src/Square/Types/DeleteInvoiceAttachmentResponse.cs index 7595923e..65322274 100644 --- a/src/Square/Types/DeleteInvoiceAttachmentResponse.cs +++ b/src/Square/Types/DeleteInvoiceAttachmentResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a [DeleteInvoiceAttachment](api-endpoint:Invoices-DeleteInvoiceAttachment) response. /// -public record DeleteInvoiceAttachmentResponse +[Serializable] +public record DeleteInvoiceAttachmentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteInvoiceResponse.cs b/src/Square/Types/DeleteInvoiceResponse.cs index b78b2e51..51235613 100644 --- a/src/Square/Types/DeleteInvoiceResponse.cs +++ b/src/Square/Types/DeleteInvoiceResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Describes a `DeleteInvoice` response. /// -public record DeleteInvoiceResponse +[Serializable] +public record DeleteInvoiceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteLocationCustomAttributeDefinitionResponse.cs b/src/Square/Types/DeleteLocationCustomAttributeDefinitionResponse.cs index 077d6124..8598d8a5 100644 --- a/src/Square/Types/DeleteLocationCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/DeleteLocationCustomAttributeDefinitionResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a response from a delete request containing error messages if there are any. /// -public record DeleteLocationCustomAttributeDefinitionResponse +[Serializable] +public record DeleteLocationCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteLocationCustomAttributeResponse.cs b/src/Square/Types/DeleteLocationCustomAttributeResponse.cs index 905c6e93..59fe0b0d 100644 --- a/src/Square/Types/DeleteLocationCustomAttributeResponse.cs +++ b/src/Square/Types/DeleteLocationCustomAttributeResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Represents a [DeleteLocationCustomAttribute](api-endpoint:LocationCustomAttributes-DeleteLocationCustomAttribute) response. /// Either an empty object `{}` (for a successful deletion) or `errors` is present in the response. /// -public record DeleteLocationCustomAttributeResponse +[Serializable] +public record DeleteLocationCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteLoyaltyRewardResponse.cs b/src/Square/Types/DeleteLoyaltyRewardResponse.cs index 8f54ea21..18a42ac2 100644 --- a/src/Square/Types/DeleteLoyaltyRewardResponse.cs +++ b/src/Square/Types/DeleteLoyaltyRewardResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// A response returned by the API call. /// -public record DeleteLoyaltyRewardResponse +[Serializable] +public record DeleteLoyaltyRewardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteMerchantCustomAttributeDefinitionResponse.cs b/src/Square/Types/DeleteMerchantCustomAttributeDefinitionResponse.cs index 3ed79ba0..d764355e 100644 --- a/src/Square/Types/DeleteMerchantCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/DeleteMerchantCustomAttributeDefinitionResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a response from a delete request containing error messages if there are any. /// -public record DeleteMerchantCustomAttributeDefinitionResponse +[Serializable] +public record DeleteMerchantCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteMerchantCustomAttributeResponse.cs b/src/Square/Types/DeleteMerchantCustomAttributeResponse.cs index 8f80a191..fe6f768c 100644 --- a/src/Square/Types/DeleteMerchantCustomAttributeResponse.cs +++ b/src/Square/Types/DeleteMerchantCustomAttributeResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Represents a [DeleteMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-DeleteMerchantCustomAttribute) response. /// Either an empty object `{}` (for a successful deletion) or `errors` is present in the response. /// -public record DeleteMerchantCustomAttributeResponse +[Serializable] +public record DeleteMerchantCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteOrderCustomAttributeDefinitionResponse.cs b/src/Square/Types/DeleteOrderCustomAttributeDefinitionResponse.cs index 365d15d7..e967ee75 100644 --- a/src/Square/Types/DeleteOrderCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/DeleteOrderCustomAttributeDefinitionResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a response from deleting an order custom attribute definition. /// -public record DeleteOrderCustomAttributeDefinitionResponse +[Serializable] +public record DeleteOrderCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteOrderCustomAttributeResponse.cs b/src/Square/Types/DeleteOrderCustomAttributeResponse.cs index 0d3b178e..a5c571c7 100644 --- a/src/Square/Types/DeleteOrderCustomAttributeResponse.cs +++ b/src/Square/Types/DeleteOrderCustomAttributeResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a response from deleting an order custom attribute. /// -public record DeleteOrderCustomAttributeResponse +[Serializable] +public record DeleteOrderCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeletePaymentLinkResponse.cs b/src/Square/Types/DeletePaymentLinkResponse.cs index b443ea0e..5b56b677 100644 --- a/src/Square/Types/DeletePaymentLinkResponse.cs +++ b/src/Square/Types/DeletePaymentLinkResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeletePaymentLinkResponse +[Serializable] +public record DeletePaymentLinkResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } @@ -22,15 +27,11 @@ public record DeletePaymentLinkResponse [JsonPropertyName("cancelled_order_id")] public string? CancelledOrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteShiftResponse.cs b/src/Square/Types/DeleteShiftResponse.cs index 823a1eac..2e21467f 100644 --- a/src/Square/Types/DeleteShiftResponse.cs +++ b/src/Square/Types/DeleteShiftResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// The response to a request to delete a `Shift`. The response might contain a set of /// `Error` objects if the request resulted in errors. /// -public record DeleteShiftResponse +[Serializable] +public record DeleteShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteSnippetResponse.cs b/src/Square/Types/DeleteSnippetResponse.cs index a5254d2a..4906b491 100644 --- a/src/Square/Types/DeleteSnippetResponse.cs +++ b/src/Square/Types/DeleteSnippetResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a `DeleteSnippet` response. /// -public record DeleteSnippetResponse +[Serializable] +public record DeleteSnippetResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteSubscriptionActionResponse.cs b/src/Square/Types/DeleteSubscriptionActionResponse.cs index c605c3c6..12c60ad4 100644 --- a/src/Square/Types/DeleteSubscriptionActionResponse.cs +++ b/src/Square/Types/DeleteSubscriptionActionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response of the [DeleteSubscriptionAction](api-endpoint:Subscriptions-DeleteSubscriptionAction) /// endpoint. /// -public record DeleteSubscriptionActionResponse +[Serializable] +public record DeleteSubscriptionActionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -22,15 +27,11 @@ public record DeleteSubscriptionActionResponse [JsonPropertyName("subscription")] public Subscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteTimecardResponse.cs b/src/Square/Types/DeleteTimecardResponse.cs index 25a26ef3..9f78e4b2 100644 --- a/src/Square/Types/DeleteTimecardResponse.cs +++ b/src/Square/Types/DeleteTimecardResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// The response to a request to delete a `Timecard`. The response might contain a set of /// `Error` objects if the request resulted in errors. /// -public record DeleteTimecardResponse +[Serializable] +public record DeleteTimecardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteTransferOrderResponse.cs b/src/Square/Types/DeleteTransferOrderResponse.cs index 42431807..56726241 100644 --- a/src/Square/Types/DeleteTransferOrderResponse.cs +++ b/src/Square/Types/DeleteTransferOrderResponse.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Response for deleting a transfer order /// -public record DeleteTransferOrderResponse +[Serializable] +public record DeleteTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeleteWebhookSubscriptionResponse.cs b/src/Square/Types/DeleteWebhookSubscriptionResponse.cs index 8db30ef5..ccbe55cd 100644 --- a/src/Square/Types/DeleteWebhookSubscriptionResponse.cs +++ b/src/Square/Types/DeleteWebhookSubscriptionResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [DeleteWebhookSubscription](api-endpoint:WebhookSubscriptions-DeleteWebhookSubscription) endpoint. /// -public record DeleteWebhookSubscriptionResponse +[Serializable] +public record DeleteWebhookSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Destination.cs b/src/Square/Types/Destination.cs index 26b8f45e..e2083820 100644 --- a/src/Square/Types/Destination.cs +++ b/src/Square/Types/Destination.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Information about the destination against which the payout was made. /// -public record Destination +[Serializable] +public record Destination : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Type of the destination such as a bank account or debit card. /// See [DestinationType](#type-destinationtype) for possible values @@ -22,15 +27,11 @@ public record Destination [JsonPropertyName("id")] public string? Id { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DestinationDetails.cs b/src/Square/Types/DestinationDetails.cs index f97367fe..22ec3af2 100644 --- a/src/Square/Types/DestinationDetails.cs +++ b/src/Square/Types/DestinationDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Details about a refund's destination. /// -public record DestinationDetails +[Serializable] +public record DestinationDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Details about a card refund. Only populated if the destination_type is `CARD`. /// @@ -27,15 +32,11 @@ public record DestinationDetails [JsonPropertyName("external_details")] public DestinationDetailsExternalRefundDetails? ExternalDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DestinationDetailsCardRefundDetails.cs b/src/Square/Types/DestinationDetailsCardRefundDetails.cs index c55decdc..0b73e234 100644 --- a/src/Square/Types/DestinationDetailsCardRefundDetails.cs +++ b/src/Square/Types/DestinationDetailsCardRefundDetails.cs @@ -4,8 +4,13 @@ namespace Square; -public record DestinationDetailsCardRefundDetails +[Serializable] +public record DestinationDetailsCardRefundDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The card's non-confidential details. /// @@ -25,15 +30,11 @@ public record DestinationDetailsCardRefundDetails [JsonPropertyName("auth_result_code")] public string? AuthResultCode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DestinationDetailsCashRefundDetails.cs b/src/Square/Types/DestinationDetailsCashRefundDetails.cs index 54ca05c5..eb35dc05 100644 --- a/src/Square/Types/DestinationDetailsCashRefundDetails.cs +++ b/src/Square/Types/DestinationDetailsCashRefundDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Stores details about a cash refund. Contains only non-confidential information. /// -public record DestinationDetailsCashRefundDetails +[Serializable] +public record DestinationDetailsCashRefundDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount and currency of the money supplied by the seller. /// @@ -23,15 +28,11 @@ public record DestinationDetailsCashRefundDetails [JsonPropertyName("change_back_money")] public Money? ChangeBackMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DestinationDetailsExternalRefundDetails.cs b/src/Square/Types/DestinationDetailsExternalRefundDetails.cs index b736bea0..a6244864 100644 --- a/src/Square/Types/DestinationDetailsExternalRefundDetails.cs +++ b/src/Square/Types/DestinationDetailsExternalRefundDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Stores details about an external refund. Contains only non-confidential information. /// -public record DestinationDetailsExternalRefundDetails +[Serializable] +public record DestinationDetailsExternalRefundDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of external refund the seller paid to the buyer. It can be one of the /// following: @@ -41,15 +46,11 @@ public record DestinationDetailsExternalRefundDetails [JsonPropertyName("source_id")] public string? SourceId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DestinationType.cs b/src/Square/Types/DestinationType.cs index 8a8bee0d..cdebe505 100644 --- a/src/Square/Types/DestinationType.cs +++ b/src/Square/Types/DestinationType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DestinationType : IStringEnum { public static readonly DestinationType BankAccount = new(Values.BankAccount); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string BankAccount = "BANK_ACCOUNT"; diff --git a/src/Square/Types/Device.cs b/src/Square/Types/Device.cs index 8479ebc3..8ee51c5e 100644 --- a/src/Square/Types/Device.cs +++ b/src/Square/Types/Device.cs @@ -4,8 +4,13 @@ namespace Square; -public record Device +[Serializable] +public record Device : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A synthetic identifier for the device. The identifier includes a standardized prefix and /// is otherwise an opaque id generated from key device fields. @@ -32,15 +37,11 @@ public record Device [JsonPropertyName("status")] public DeviceStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceAttributes.cs b/src/Square/Types/DeviceAttributes.cs index 1cc7e8e5..c7d51350 100644 --- a/src/Square/Types/DeviceAttributes.cs +++ b/src/Square/Types/DeviceAttributes.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceAttributes +[Serializable] +public record DeviceAttributes : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The device type. /// See [DeviceType](#type-devicetype) for possible values @@ -58,15 +63,11 @@ public record DeviceAttributes [JsonPropertyName("merchant_token")] public string? MerchantToken { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceAttributesDeviceType.cs b/src/Square/Types/DeviceAttributesDeviceType.cs index d7da6d53..01c6c9e7 100644 --- a/src/Square/Types/DeviceAttributesDeviceType.cs +++ b/src/Square/Types/DeviceAttributesDeviceType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DeviceAttributesDeviceType : IStringEnum { public static readonly DeviceAttributesDeviceType Terminal = new(Values.Terminal); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Terminal = "TERMINAL"; diff --git a/src/Square/Types/DeviceCheckoutOptions.cs b/src/Square/Types/DeviceCheckoutOptions.cs index 6a23ae4a..ffed62d3 100644 --- a/src/Square/Types/DeviceCheckoutOptions.cs +++ b/src/Square/Types/DeviceCheckoutOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceCheckoutOptions +[Serializable] +public record DeviceCheckoutOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique ID of the device intended for this `TerminalCheckout`. /// A list of `DeviceCode` objects can be retrieved from the /v2/devices/codes endpoint. @@ -39,15 +44,11 @@ public record DeviceCheckoutOptions [JsonPropertyName("show_itemized_cart")] public bool? ShowItemizedCart { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCode.cs b/src/Square/Types/DeviceCode.cs index 8e2b85bb..0a22c2ca 100644 --- a/src/Square/Types/DeviceCode.cs +++ b/src/Square/Types/DeviceCode.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceCode +[Serializable] +public record DeviceCode : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique id for this device code. /// @@ -80,15 +85,11 @@ public record DeviceCode [JsonPropertyName("paired_at")] public string? PairedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCodePairedEvent.cs b/src/Square/Types/DeviceCodePairedEvent.cs index 861d0b70..0f231e57 100644 --- a/src/Square/Types/DeviceCodePairedEvent.cs +++ b/src/Square/Types/DeviceCodePairedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// Terminal API client and the device_id of the paired Square Terminal is /// available. /// -public record DeviceCodePairedEvent +[Serializable] +public record DeviceCodePairedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DeviceCodePairedEvent [JsonPropertyName("data")] public DeviceCodePairedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCodePairedEventData.cs b/src/Square/Types/DeviceCodePairedEventData.cs index db10cf37..3ab164b0 100644 --- a/src/Square/Types/DeviceCodePairedEventData.cs +++ b/src/Square/Types/DeviceCodePairedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceCodePairedEventData +[Serializable] +public record DeviceCodePairedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the paired object’s type, `"device_code"`. /// @@ -24,15 +29,11 @@ public record DeviceCodePairedEventData [JsonPropertyName("object")] public DeviceCodePairedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCodePairedEventObject.cs b/src/Square/Types/DeviceCodePairedEventObject.cs index bc236e47..b225c85e 100644 --- a/src/Square/Types/DeviceCodePairedEventObject.cs +++ b/src/Square/Types/DeviceCodePairedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DeviceCodePairedEventObject +[Serializable] +public record DeviceCodePairedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created terminal checkout /// [JsonPropertyName("device_code")] public DeviceCode? DeviceCode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCodeStatus.cs b/src/Square/Types/DeviceCodeStatus.cs index 185f3bb7..2f0c7a55 100644 --- a/src/Square/Types/DeviceCodeStatus.cs +++ b/src/Square/Types/DeviceCodeStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DeviceCodeStatus : IStringEnum { public static readonly DeviceCodeStatus Unknown = new(Values.Unknown); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Unknown = "UNKNOWN"; diff --git a/src/Square/Types/DeviceComponentDetailsApplicationDetails.cs b/src/Square/Types/DeviceComponentDetailsApplicationDetails.cs index 5a0044f3..7ef77909 100644 --- a/src/Square/Types/DeviceComponentDetailsApplicationDetails.cs +++ b/src/Square/Types/DeviceComponentDetailsApplicationDetails.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceComponentDetailsApplicationDetails +[Serializable] +public record DeviceComponentDetailsApplicationDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of application. /// See [ApplicationType](#type-applicationtype) for possible values @@ -31,15 +36,11 @@ public record DeviceComponentDetailsApplicationDetails [JsonPropertyName("device_code_id")] public string? DeviceCodeId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceComponentDetailsBatteryDetails.cs b/src/Square/Types/DeviceComponentDetailsBatteryDetails.cs index 921eceab..d62507d0 100644 --- a/src/Square/Types/DeviceComponentDetailsBatteryDetails.cs +++ b/src/Square/Types/DeviceComponentDetailsBatteryDetails.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceComponentDetailsBatteryDetails +[Serializable] +public record DeviceComponentDetailsBatteryDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The battery charge percentage as displayed on the device. /// @@ -19,15 +24,11 @@ public record DeviceComponentDetailsBatteryDetails [JsonPropertyName("external_power")] public DeviceComponentDetailsExternalPower? ExternalPower { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceComponentDetailsCardReaderDetails.cs b/src/Square/Types/DeviceComponentDetailsCardReaderDetails.cs index e805fab9..8aa53434 100644 --- a/src/Square/Types/DeviceComponentDetailsCardReaderDetails.cs +++ b/src/Square/Types/DeviceComponentDetailsCardReaderDetails.cs @@ -4,23 +4,24 @@ namespace Square; -public record DeviceComponentDetailsCardReaderDetails +[Serializable] +public record DeviceComponentDetailsCardReaderDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The version of the card reader. /// [JsonPropertyName("version")] public string? Version { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceComponentDetailsEthernetDetails.cs b/src/Square/Types/DeviceComponentDetailsEthernetDetails.cs index e14029cd..0bd8e2ed 100644 --- a/src/Square/Types/DeviceComponentDetailsEthernetDetails.cs +++ b/src/Square/Types/DeviceComponentDetailsEthernetDetails.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceComponentDetailsEthernetDetails +[Serializable] +public record DeviceComponentDetailsEthernetDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A boolean to represent whether the Ethernet interface is currently active. /// @@ -24,15 +29,11 @@ public record DeviceComponentDetailsEthernetDetails [JsonPropertyName("mac_address")] public string? MacAddress { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceComponentDetailsExternalPower.cs b/src/Square/Types/DeviceComponentDetailsExternalPower.cs index b8f90927..022d741a 100644 --- a/src/Square/Types/DeviceComponentDetailsExternalPower.cs +++ b/src/Square/Types/DeviceComponentDetailsExternalPower.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DeviceComponentDetailsExternalPower : IStringEnum { public static readonly DeviceComponentDetailsExternalPower AvailableCharging = new( @@ -67,6 +68,7 @@ public static explicit operator string(DeviceComponentDetailsExternalPower value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AvailableCharging = "AVAILABLE_CHARGING"; diff --git a/src/Square/Types/DeviceComponentDetailsMeasurement.cs b/src/Square/Types/DeviceComponentDetailsMeasurement.cs index feea0846..d7257d9a 100644 --- a/src/Square/Types/DeviceComponentDetailsMeasurement.cs +++ b/src/Square/Types/DeviceComponentDetailsMeasurement.cs @@ -7,23 +7,24 @@ namespace Square; /// /// A value qualified by unit of measure. /// -public record DeviceComponentDetailsMeasurement +[Serializable] +public record DeviceComponentDetailsMeasurement : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Value of measure. /// [JsonPropertyName("value")] public int? Value { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceComponentDetailsWiFiDetails.cs b/src/Square/Types/DeviceComponentDetailsWiFiDetails.cs index 117911e7..23930d4a 100644 --- a/src/Square/Types/DeviceComponentDetailsWiFiDetails.cs +++ b/src/Square/Types/DeviceComponentDetailsWiFiDetails.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceComponentDetailsWiFiDetails +[Serializable] +public record DeviceComponentDetailsWiFiDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A boolean to represent whether the WiFI interface is currently active. /// @@ -43,15 +48,11 @@ public record DeviceComponentDetailsWiFiDetails [JsonPropertyName("mac_address")] public string? MacAddress { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCreatedEvent.cs b/src/Square/Types/DeviceCreatedEvent.cs index d794bc9b..dd1852d3 100644 --- a/src/Square/Types/DeviceCreatedEvent.cs +++ b/src/Square/Types/DeviceCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Device is created. /// -public record DeviceCreatedEvent +[Serializable] +public record DeviceCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The merchant the newly created device belongs to. /// @@ -40,15 +45,11 @@ public record DeviceCreatedEvent [JsonPropertyName("data")] public DeviceCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCreatedEventData.cs b/src/Square/Types/DeviceCreatedEventData.cs index 12e9ca6e..bb1d19c5 100644 --- a/src/Square/Types/DeviceCreatedEventData.cs +++ b/src/Square/Types/DeviceCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceCreatedEventData +[Serializable] +public record DeviceCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `"device"`. /// @@ -24,15 +29,11 @@ public record DeviceCreatedEventData [JsonPropertyName("object")] public DeviceCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceCreatedEventObject.cs b/src/Square/Types/DeviceCreatedEventObject.cs index fe51bb77..ddf0c36a 100644 --- a/src/Square/Types/DeviceCreatedEventObject.cs +++ b/src/Square/Types/DeviceCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DeviceCreatedEventObject +[Serializable] +public record DeviceCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created device. /// [JsonPropertyName("device")] public Device? Device { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceDetails.cs b/src/Square/Types/DeviceDetails.cs index be9dfa5b..0c7ae2ca 100644 --- a/src/Square/Types/DeviceDetails.cs +++ b/src/Square/Types/DeviceDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Details about the device that took the payment. /// -public record DeviceDetails +[Serializable] +public record DeviceDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-issued ID of the device. /// @@ -27,15 +32,11 @@ public record DeviceDetails [JsonPropertyName("device_name")] public string? DeviceName { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceMetadata.cs b/src/Square/Types/DeviceMetadata.cs index 4893c519..b9a4b9ec 100644 --- a/src/Square/Types/DeviceMetadata.cs +++ b/src/Square/Types/DeviceMetadata.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceMetadata +[Serializable] +public record DeviceMetadata : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Terminal’s remaining battery percentage, between 1-100. /// @@ -82,15 +87,11 @@ public record DeviceMetadata [JsonPropertyName("ip_address")] public string? IpAddress { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceStatus.cs b/src/Square/Types/DeviceStatus.cs index afb952cc..45e27574 100644 --- a/src/Square/Types/DeviceStatus.cs +++ b/src/Square/Types/DeviceStatus.cs @@ -4,8 +4,13 @@ namespace Square; -public record DeviceStatus +[Serializable] +public record DeviceStatus : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Category of the device status. /// See [Category](#type-category) for possible values @@ -13,15 +18,11 @@ public record DeviceStatus [JsonPropertyName("category")] public DeviceStatusCategory? Category { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DeviceStatusCategory.cs b/src/Square/Types/DeviceStatusCategory.cs index cb94e342..027598b1 100644 --- a/src/Square/Types/DeviceStatusCategory.cs +++ b/src/Square/Types/DeviceStatusCategory.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DeviceStatusCategory : IStringEnum { public static readonly DeviceStatusCategory Available = new(Values.Available); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Available = "AVAILABLE"; diff --git a/src/Square/Types/DigitalWalletDetails.cs b/src/Square/Types/DigitalWalletDetails.cs index c3e1001f..12fce677 100644 --- a/src/Square/Types/DigitalWalletDetails.cs +++ b/src/Square/Types/DigitalWalletDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Additional details about `WALLET` type payments. Contains only non-confidential information. /// -public record DigitalWalletDetails +[Serializable] +public record DigitalWalletDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The status of the `WALLET` payment. The status can be `AUTHORIZED`, `CAPTURED`, `VOIDED`, or /// `FAILED`. @@ -29,15 +34,11 @@ public record DigitalWalletDetails [JsonPropertyName("cash_app_details")] public CashAppDetails? CashAppDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisableCardResponse.cs b/src/Square/Types/DisableCardResponse.cs index 36482669..b43bf4f7 100644 --- a/src/Square/Types/DisableCardResponse.cs +++ b/src/Square/Types/DisableCardResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the card field will not be /// present. /// -public record DisableCardResponse +[Serializable] +public record DisableCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -25,15 +30,11 @@ public record DisableCardResponse [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisableEventsResponse.cs b/src/Square/Types/DisableEventsResponse.cs index 8b2d64f7..b2d1b2d1 100644 --- a/src/Square/Types/DisableEventsResponse.cs +++ b/src/Square/Types/DisableEventsResponse.cs @@ -11,23 +11,24 @@ namespace Square; /// Note: if there are errors processing the request, the events field will not be /// present. /// -public record DisableEventsResponse +[Serializable] +public record DisableEventsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DismissTerminalActionResponse.cs b/src/Square/Types/DismissTerminalActionResponse.cs index 64e41c9d..6aaf1fdc 100644 --- a/src/Square/Types/DismissTerminalActionResponse.cs +++ b/src/Square/Types/DismissTerminalActionResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record DismissTerminalActionResponse +[Serializable] +public record DismissTerminalActionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -18,15 +23,11 @@ public record DismissTerminalActionResponse [JsonPropertyName("action")] public TerminalAction? Action { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DismissTerminalCheckoutResponse.cs b/src/Square/Types/DismissTerminalCheckoutResponse.cs index 82a7160d..cd01277c 100644 --- a/src/Square/Types/DismissTerminalCheckoutResponse.cs +++ b/src/Square/Types/DismissTerminalCheckoutResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record DismissTerminalCheckoutResponse +[Serializable] +public record DismissTerminalCheckoutResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -18,15 +23,11 @@ public record DismissTerminalCheckoutResponse [JsonPropertyName("checkout")] public TerminalCheckout? Checkout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DismissTerminalRefundResponse.cs b/src/Square/Types/DismissTerminalRefundResponse.cs index abf0daf5..50e51f36 100644 --- a/src/Square/Types/DismissTerminalRefundResponse.cs +++ b/src/Square/Types/DismissTerminalRefundResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record DismissTerminalRefundResponse +[Serializable] +public record DismissTerminalRefundResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -18,15 +23,11 @@ public record DismissTerminalRefundResponse [JsonPropertyName("refund")] public TerminalRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Dispute.cs b/src/Square/Types/Dispute.cs index 767a0d2b..2756703b 100644 --- a/src/Square/Types/Dispute.cs +++ b/src/Square/Types/Dispute.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a [dispute](https://developer.squareup.com/docs/disputes-api/overview) a cardholder initiated with their bank. /// -public record Dispute +[Serializable] +public record Dispute : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique ID for this `Dispute`, generated by Square. /// @@ -111,15 +116,11 @@ public record Dispute [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeCreatedEvent.cs b/src/Square/Types/DisputeCreatedEvent.cs index f197edff..ce6c4697 100644 --- a/src/Square/Types/DisputeCreatedEvent.cs +++ b/src/Square/Types/DisputeCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Dispute](entity:Dispute) is created. /// -public record DisputeCreatedEvent +[Serializable] +public record DisputeCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -46,15 +51,11 @@ public record DisputeCreatedEvent [JsonPropertyName("data")] public DisputeCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeCreatedEventData.cs b/src/Square/Types/DisputeCreatedEventData.cs index ed8c3d3f..ef338ab5 100644 --- a/src/Square/Types/DisputeCreatedEventData.cs +++ b/src/Square/Types/DisputeCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeCreatedEventData +[Serializable] +public record DisputeCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeCreatedEventData [JsonPropertyName("object")] public DisputeCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeCreatedEventObject.cs b/src/Square/Types/DisputeCreatedEventObject.cs index ad0296ec..c6f4d954 100644 --- a/src/Square/Types/DisputeCreatedEventObject.cs +++ b/src/Square/Types/DisputeCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeCreatedEventObject +[Serializable] +public record DisputeCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidence.cs b/src/Square/Types/DisputeEvidence.cs index e4c6d143..6bdbf98e 100644 --- a/src/Square/Types/DisputeEvidence.cs +++ b/src/Square/Types/DisputeEvidence.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeEvidence +[Serializable] +public record DisputeEvidence : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-generated ID of the evidence. /// @@ -49,15 +54,11 @@ public record DisputeEvidence [JsonPropertyName("evidence_type")] public DisputeEvidenceType? EvidenceType { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceAddedEvent.cs b/src/Square/Types/DisputeEvidenceAddedEvent.cs index 020ea16c..2650208e 100644 --- a/src/Square/Types/DisputeEvidenceAddedEvent.cs +++ b/src/Square/Types/DisputeEvidenceAddedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// from the Disputes Dashboard in the Seller Dashboard, the Square Point of Sale app, /// or by calling either [CreateDisputeEvidenceFile](api-endpoint:Disputes-CreateDisputeEvidenceFile) or [CreateDisputeEvidenceText](api-endpoint:Disputes-CreateDisputeEvidenceText). /// -public record DisputeEvidenceAddedEvent +[Serializable] +public record DisputeEvidenceAddedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DisputeEvidenceAddedEvent [JsonPropertyName("data")] public DisputeEvidenceAddedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceAddedEventData.cs b/src/Square/Types/DisputeEvidenceAddedEventData.cs index 7357ffa7..390ed4cf 100644 --- a/src/Square/Types/DisputeEvidenceAddedEventData.cs +++ b/src/Square/Types/DisputeEvidenceAddedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeEvidenceAddedEventData +[Serializable] +public record DisputeEvidenceAddedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeEvidenceAddedEventData [JsonPropertyName("object")] public DisputeEvidenceAddedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceAddedEventObject.cs b/src/Square/Types/DisputeEvidenceAddedEventObject.cs index 599c3402..86391c46 100644 --- a/src/Square/Types/DisputeEvidenceAddedEventObject.cs +++ b/src/Square/Types/DisputeEvidenceAddedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeEvidenceAddedEventObject +[Serializable] +public record DisputeEvidenceAddedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceCreatedEvent.cs b/src/Square/Types/DisputeEvidenceCreatedEvent.cs index 23c64720..10f3315e 100644 --- a/src/Square/Types/DisputeEvidenceCreatedEvent.cs +++ b/src/Square/Types/DisputeEvidenceCreatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// from the Disputes Dashboard in the Seller Dashboard, the Square Point of Sale app, /// or by calling either [CreateDisputeEvidenceFile](api-endpoint:Disputes-CreateDisputeEvidenceFile) or [CreateDisputeEvidenceText](api-endpoint:Disputes-CreateDisputeEvidenceText). /// -public record DisputeEvidenceCreatedEvent +[Serializable] +public record DisputeEvidenceCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DisputeEvidenceCreatedEvent [JsonPropertyName("data")] public DisputeEvidenceCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceCreatedEventData.cs b/src/Square/Types/DisputeEvidenceCreatedEventData.cs index 171e87e4..765e6289 100644 --- a/src/Square/Types/DisputeEvidenceCreatedEventData.cs +++ b/src/Square/Types/DisputeEvidenceCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeEvidenceCreatedEventData +[Serializable] +public record DisputeEvidenceCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeEvidenceCreatedEventData [JsonPropertyName("object")] public DisputeEvidenceCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceCreatedEventObject.cs b/src/Square/Types/DisputeEvidenceCreatedEventObject.cs index 08e46a82..f118d4e5 100644 --- a/src/Square/Types/DisputeEvidenceCreatedEventObject.cs +++ b/src/Square/Types/DisputeEvidenceCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeEvidenceCreatedEventObject +[Serializable] +public record DisputeEvidenceCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceDeletedEvent.cs b/src/Square/Types/DisputeEvidenceDeletedEvent.cs index 942c9bcb..ed3a6f6e 100644 --- a/src/Square/Types/DisputeEvidenceDeletedEvent.cs +++ b/src/Square/Types/DisputeEvidenceDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// from the Disputes Dashboard in the Seller Dashboard, the Square Point of Sale app, /// or by calling [DeleteDisputeEvidence](api-endpoint:Disputes-DeleteDisputeEvidence). /// -public record DisputeEvidenceDeletedEvent +[Serializable] +public record DisputeEvidenceDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DisputeEvidenceDeletedEvent [JsonPropertyName("data")] public DisputeEvidenceDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceDeletedEventData.cs b/src/Square/Types/DisputeEvidenceDeletedEventData.cs index 045aedee..7e359034 100644 --- a/src/Square/Types/DisputeEvidenceDeletedEventData.cs +++ b/src/Square/Types/DisputeEvidenceDeletedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeEvidenceDeletedEventData +[Serializable] +public record DisputeEvidenceDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeEvidenceDeletedEventData [JsonPropertyName("object")] public DisputeEvidenceDeletedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceDeletedEventObject.cs b/src/Square/Types/DisputeEvidenceDeletedEventObject.cs index 3e1dfe0c..509fcbb5 100644 --- a/src/Square/Types/DisputeEvidenceDeletedEventObject.cs +++ b/src/Square/Types/DisputeEvidenceDeletedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeEvidenceDeletedEventObject +[Serializable] +public record DisputeEvidenceDeletedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceFile.cs b/src/Square/Types/DisputeEvidenceFile.cs index a734574f..634d0206 100644 --- a/src/Square/Types/DisputeEvidenceFile.cs +++ b/src/Square/Types/DisputeEvidenceFile.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A file to be uploaded as dispute evidence. /// -public record DisputeEvidenceFile +[Serializable] +public record DisputeEvidenceFile : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The file name including the file extension. For example: "receipt.tiff". /// @@ -21,15 +26,11 @@ public record DisputeEvidenceFile [JsonPropertyName("filetype")] public string? Filetype { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceRemovedEvent.cs b/src/Square/Types/DisputeEvidenceRemovedEvent.cs index 767e90d4..3431e49b 100644 --- a/src/Square/Types/DisputeEvidenceRemovedEvent.cs +++ b/src/Square/Types/DisputeEvidenceRemovedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// from the Disputes Dashboard in the Seller Dashboard, the Square Point of Sale app, /// or by calling [DeleteDisputeEvidence](api-endpoint:Disputes-DeleteDisputeEvidence). /// -public record DisputeEvidenceRemovedEvent +[Serializable] +public record DisputeEvidenceRemovedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DisputeEvidenceRemovedEvent [JsonPropertyName("data")] public DisputeEvidenceRemovedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceRemovedEventData.cs b/src/Square/Types/DisputeEvidenceRemovedEventData.cs index 1ffc4292..333c1a7b 100644 --- a/src/Square/Types/DisputeEvidenceRemovedEventData.cs +++ b/src/Square/Types/DisputeEvidenceRemovedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeEvidenceRemovedEventData +[Serializable] +public record DisputeEvidenceRemovedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeEvidenceRemovedEventData [JsonPropertyName("object")] public DisputeEvidenceRemovedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceRemovedEventObject.cs b/src/Square/Types/DisputeEvidenceRemovedEventObject.cs index 5313bf73..a6bc800d 100644 --- a/src/Square/Types/DisputeEvidenceRemovedEventObject.cs +++ b/src/Square/Types/DisputeEvidenceRemovedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeEvidenceRemovedEventObject +[Serializable] +public record DisputeEvidenceRemovedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeEvidenceType.cs b/src/Square/Types/DisputeEvidenceType.cs index 41326e7e..75bb2fb9 100644 --- a/src/Square/Types/DisputeEvidenceType.cs +++ b/src/Square/Types/DisputeEvidenceType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DisputeEvidenceType : IStringEnum { public static readonly DisputeEvidenceType GenericEvidence = new(Values.GenericEvidence); @@ -104,6 +105,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string GenericEvidence = "GENERIC_EVIDENCE"; diff --git a/src/Square/Types/DisputeReason.cs b/src/Square/Types/DisputeReason.cs index 2c93be81..abb3dbac 100644 --- a/src/Square/Types/DisputeReason.cs +++ b/src/Square/Types/DisputeReason.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DisputeReason : IStringEnum { public static readonly DisputeReason AmountDiffers = new(Values.AmountDiffers); @@ -70,6 +71,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AmountDiffers = "AMOUNT_DIFFERS"; diff --git a/src/Square/Types/DisputeState.cs b/src/Square/Types/DisputeState.cs index 908fb95e..659659f7 100644 --- a/src/Square/Types/DisputeState.cs +++ b/src/Square/Types/DisputeState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct DisputeState : IStringEnum { public static readonly DisputeState InquiryEvidenceRequired = new( @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string InquiryEvidenceRequired = "INQUIRY_EVIDENCE_REQUIRED"; diff --git a/src/Square/Types/DisputeStateChangedEvent.cs b/src/Square/Types/DisputeStateChangedEvent.cs index 0dcd5942..66f60ba4 100644 --- a/src/Square/Types/DisputeStateChangedEvent.cs +++ b/src/Square/Types/DisputeStateChangedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// This includes the dispute resolution (WON, LOST) reported by the bank. The event /// data includes details of what changed. /// -public record DisputeStateChangedEvent +[Serializable] +public record DisputeStateChangedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DisputeStateChangedEvent [JsonPropertyName("data")] public DisputeStateChangedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeStateChangedEventData.cs b/src/Square/Types/DisputeStateChangedEventData.cs index 74710a2d..d4f272c0 100644 --- a/src/Square/Types/DisputeStateChangedEventData.cs +++ b/src/Square/Types/DisputeStateChangedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeStateChangedEventData +[Serializable] +public record DisputeStateChangedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeStateChangedEventData [JsonPropertyName("object")] public DisputeStateChangedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeStateChangedEventObject.cs b/src/Square/Types/DisputeStateChangedEventObject.cs index 7130c386..fc4ac03b 100644 --- a/src/Square/Types/DisputeStateChangedEventObject.cs +++ b/src/Square/Types/DisputeStateChangedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeStateChangedEventObject +[Serializable] +public record DisputeStateChangedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeStateUpdatedEvent.cs b/src/Square/Types/DisputeStateUpdatedEvent.cs index 44ba26ea..c0581c3d 100644 --- a/src/Square/Types/DisputeStateUpdatedEvent.cs +++ b/src/Square/Types/DisputeStateUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// This includes the dispute resolution (WON, LOST) reported by the bank. The event /// data includes details of what changed. /// -public record DisputeStateUpdatedEvent +[Serializable] +public record DisputeStateUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -48,15 +53,11 @@ public record DisputeStateUpdatedEvent [JsonPropertyName("data")] public DisputeStateUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeStateUpdatedEventData.cs b/src/Square/Types/DisputeStateUpdatedEventData.cs index 2f95f767..ac527648 100644 --- a/src/Square/Types/DisputeStateUpdatedEventData.cs +++ b/src/Square/Types/DisputeStateUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record DisputeStateUpdatedEventData +[Serializable] +public record DisputeStateUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected dispute's type. /// @@ -24,15 +29,11 @@ public record DisputeStateUpdatedEventData [JsonPropertyName("object")] public DisputeStateUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputeStateUpdatedEventObject.cs b/src/Square/Types/DisputeStateUpdatedEventObject.cs index b745ffd6..41108e6e 100644 --- a/src/Square/Types/DisputeStateUpdatedEventObject.cs +++ b/src/Square/Types/DisputeStateUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record DisputeStateUpdatedEventObject +[Serializable] +public record DisputeStateUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The dispute object. /// [JsonPropertyName("object")] public Dispute? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/DisputedPayment.cs b/src/Square/Types/DisputedPayment.cs index e6025b15..9186eafa 100644 --- a/src/Square/Types/DisputedPayment.cs +++ b/src/Square/Types/DisputedPayment.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The payment the cardholder disputed. /// -public record DisputedPayment +[Serializable] +public record DisputedPayment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Square-generated unique ID of the payment being disputed. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/EcomVisibility.cs b/src/Square/Types/EcomVisibility.cs index 0672ac65..806a4c32 100644 --- a/src/Square/Types/EcomVisibility.cs +++ b/src/Square/Types/EcomVisibility.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct EcomVisibility : IStringEnum { public static readonly EcomVisibility Unindexed = new(Values.Unindexed); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Unindexed = "UNINDEXED"; diff --git a/src/Square/Types/Employee.cs b/src/Square/Types/Employee.cs index 7c2f7cdf..3a884592 100644 --- a/src/Square/Types/Employee.cs +++ b/src/Square/Types/Employee.cs @@ -9,8 +9,13 @@ namespace Square; /// /// DEPRECATED at version 2020-08-26. Replaced by [TeamMember](entity:TeamMember). /// -public record Employee +[Serializable] +public record Employee : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// UUID for this object. /// @@ -76,15 +81,11 @@ public record Employee [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/EmployeeStatus.cs b/src/Square/Types/EmployeeStatus.cs index 4e8bc75c..0f621626 100644 --- a/src/Square/Types/EmployeeStatus.cs +++ b/src/Square/Types/EmployeeStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct EmployeeStatus : IStringEnum { public static readonly EmployeeStatus Active = new(Values.Active); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/EmployeeWage.cs b/src/Square/Types/EmployeeWage.cs index c9b0d259..eec58f86 100644 --- a/src/Square/Types/EmployeeWage.cs +++ b/src/Square/Types/EmployeeWage.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The hourly wage rate that an employee earns on a `Shift` for doing the job specified by the `title` property of this object. Deprecated at version 2020-08-26. Use [TeamMemberWage](entity:TeamMemberWage). /// -public record EmployeeWage +[Serializable] +public record EmployeeWage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The UUID for this object. /// @@ -34,15 +39,11 @@ public record EmployeeWage [JsonPropertyName("hourly_rate")] public Money? HourlyRate { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/EnableEventsResponse.cs b/src/Square/Types/EnableEventsResponse.cs index bfaae557..361568da 100644 --- a/src/Square/Types/EnableEventsResponse.cs +++ b/src/Square/Types/EnableEventsResponse.cs @@ -11,23 +11,24 @@ namespace Square; /// Note: if there are errors processing the request, the events field will not be /// present. /// -public record EnableEventsResponse +[Serializable] +public record EnableEventsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Error.cs b/src/Square/Types/Error.cs index 39d6cee5..9d124d01 100644 --- a/src/Square/Types/Error.cs +++ b/src/Square/Types/Error.cs @@ -9,8 +9,13 @@ namespace Square; /// /// See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information. /// -public record Error +[Serializable] +public record Error : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The high-level category for the error. /// See [ErrorCategory](#type-errorcategory) for possible values @@ -38,15 +43,11 @@ public record Error [JsonPropertyName("field")] public string? Field { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ErrorCategory.cs b/src/Square/Types/ErrorCategory.cs index 6496835b..d5725ece 100644 --- a/src/Square/Types/ErrorCategory.cs +++ b/src/Square/Types/ErrorCategory.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ErrorCategory : IStringEnum { public static readonly ErrorCategory ApiError = new(Values.ApiError); @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ApiError = "API_ERROR"; diff --git a/src/Square/Types/ErrorCode.cs b/src/Square/Types/ErrorCode.cs index e81d2764..700926ff 100644 --- a/src/Square/Types/ErrorCode.cs +++ b/src/Square/Types/ErrorCode.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ErrorCode : IStringEnum { public static readonly ErrorCode InternalServerError = new(Values.InternalServerError); @@ -398,6 +399,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string InternalServerError = "INTERNAL_SERVER_ERROR"; diff --git a/src/Square/Types/Event.cs b/src/Square/Types/Event.cs index 8c4b4aef..6998df95 100644 --- a/src/Square/Types/Event.cs +++ b/src/Square/Types/Event.cs @@ -4,8 +4,13 @@ namespace Square; -public record Event +[Serializable] +public record Event : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -43,15 +48,11 @@ public record Event [JsonPropertyName("data")] public EventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/EventData.cs b/src/Square/Types/EventData.cs index aa9a8eb5..5ed1d2b1 100644 --- a/src/Square/Types/EventData.cs +++ b/src/Square/Types/EventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record EventData +[Serializable] +public record EventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the affected object’s type. /// @@ -28,17 +33,13 @@ public record EventData /// An object containing fields and values relevant to the event. It is absent if the affected object has been deleted. /// [JsonPropertyName("object")] - public object? Object { get; set; } + public Dictionary? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/EventMetadata.cs b/src/Square/Types/EventMetadata.cs index 72da08c3..1a1e5ad9 100644 --- a/src/Square/Types/EventMetadata.cs +++ b/src/Square/Types/EventMetadata.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains metadata about a particular [Event](entity:Event). /// -public record EventMetadata +[Serializable] +public record EventMetadata : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for the event. /// @@ -21,15 +26,11 @@ public record EventMetadata [JsonPropertyName("api_version")] public string? ApiVersion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/EventTypeMetadata.cs b/src/Square/Types/EventTypeMetadata.cs index 90ef9f38..542e8ad5 100644 --- a/src/Square/Types/EventTypeMetadata.cs +++ b/src/Square/Types/EventTypeMetadata.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains the metadata of a webhook event type. /// -public record EventTypeMetadata +[Serializable] +public record EventTypeMetadata : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The event type. /// @@ -30,15 +35,11 @@ public record EventTypeMetadata [JsonPropertyName("release_status")] public string? ReleaseStatus { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ExcludeStrategy.cs b/src/Square/Types/ExcludeStrategy.cs index 242d2925..f0af61e9 100644 --- a/src/Square/Types/ExcludeStrategy.cs +++ b/src/Square/Types/ExcludeStrategy.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ExcludeStrategy : IStringEnum { public static readonly ExcludeStrategy LeastExpensive = new(Values.LeastExpensive); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string LeastExpensive = "LEAST_EXPENSIVE"; diff --git a/src/Square/Types/ExternalPaymentDetails.cs b/src/Square/Types/ExternalPaymentDetails.cs index f58b79fc..b527822e 100644 --- a/src/Square/Types/ExternalPaymentDetails.cs +++ b/src/Square/Types/ExternalPaymentDetails.cs @@ -9,8 +9,13 @@ namespace Square; /// For more information, see /// [Take External Payments](https://developer.squareup.com/docs/payments-api/take-payments/external-payments). /// -public record ExternalPaymentDetails +[Serializable] +public record ExternalPaymentDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of external payment the seller received. It can be one of the following: /// - CHECK - Paid using a physical check. @@ -49,15 +54,11 @@ public record ExternalPaymentDetails [JsonPropertyName("source_fee_money")] public Money? SourceFeeMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FilterValue.cs b/src/Square/Types/FilterValue.cs index 63a38854..6548ca66 100644 --- a/src/Square/Types/FilterValue.cs +++ b/src/Square/Types/FilterValue.cs @@ -11,8 +11,13 @@ namespace Square; /// /// Refer to the documentation of the field. /// -public record FilterValue +[Serializable] +public record FilterValue : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of terms that must be present on the field of the resource. /// @@ -32,15 +37,11 @@ public record FilterValue [JsonPropertyName("none")] public IEnumerable? None { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FloatNumberRange.cs b/src/Square/Types/FloatNumberRange.cs index b6db62f0..680ffd0b 100644 --- a/src/Square/Types/FloatNumberRange.cs +++ b/src/Square/Types/FloatNumberRange.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Specifies a decimal number range. /// -public record FloatNumberRange +[Serializable] +public record FloatNumberRange : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A decimal value indicating where the range starts. /// @@ -21,15 +26,11 @@ public record FloatNumberRange [JsonPropertyName("end_at")] public string? EndAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Fulfillment.cs b/src/Square/Types/Fulfillment.cs index 939da926..b0f8d1a3 100644 --- a/src/Square/Types/Fulfillment.cs +++ b/src/Square/Types/Fulfillment.cs @@ -9,8 +9,13 @@ namespace Square; /// Orders can only be created with at most one fulfillment using the API. /// However, orders returned by the Orders API might contain multiple fulfillments because sellers can create multiple fulfillments using Square products such as Square Online. /// -public record Fulfillment +[Serializable] +public record Fulfillment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the fulfillment only within this order. /// @@ -107,15 +112,11 @@ public record Fulfillment [JsonPropertyName("delivery_details")] public FulfillmentDeliveryDetails? DeliveryDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentDeliveryDetails.cs b/src/Square/Types/FulfillmentDeliveryDetails.cs index e125c8f6..1926f85a 100644 --- a/src/Square/Types/FulfillmentDeliveryDetails.cs +++ b/src/Square/Types/FulfillmentDeliveryDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes delivery details of an order fulfillment. /// -public record FulfillmentDeliveryDetails +[Serializable] +public record FulfillmentDeliveryDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The contact information for the person to receive the fulfillment. /// @@ -198,15 +203,11 @@ public record FulfillmentDeliveryDetails [JsonPropertyName("managed_delivery")] public bool? ManagedDelivery { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType.cs b/src/Square/Types/FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType.cs index d1310887..4d16e9a9 100644 --- a/src/Square/Types/FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType.cs +++ b/src/Square/Types/FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType.cs @@ -6,6 +6,7 @@ namespace Square; [JsonConverter( typeof(StringEnumSerializer) )] +[Serializable] public readonly record struct FulfillmentDeliveryDetailsOrderFulfillmentDeliveryDetailsScheduleType : IStringEnum { @@ -69,6 +70,7 @@ string value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Scheduled = "SCHEDULED"; diff --git a/src/Square/Types/FulfillmentFulfillmentEntry.cs b/src/Square/Types/FulfillmentFulfillmentEntry.cs index 3f006a31..1f251bec 100644 --- a/src/Square/Types/FulfillmentFulfillmentEntry.cs +++ b/src/Square/Types/FulfillmentFulfillmentEntry.cs @@ -9,8 +9,13 @@ namespace Square; /// a valid `uid` for an order line item in the `line_item_uid` field, as well as a `quantity` to /// fulfill. /// -public record FulfillmentFulfillmentEntry +[Serializable] +public record FulfillmentFulfillmentEntry : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the fulfillment entry only within this order. /// @@ -56,15 +61,11 @@ public record FulfillmentFulfillmentEntry [JsonPropertyName("metadata")] public Dictionary? Metadata { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentFulfillmentLineItemApplication.cs b/src/Square/Types/FulfillmentFulfillmentLineItemApplication.cs index 1d00b26c..549a1724 100644 --- a/src/Square/Types/FulfillmentFulfillmentLineItemApplication.cs +++ b/src/Square/Types/FulfillmentFulfillmentLineItemApplication.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct FulfillmentFulfillmentLineItemApplication : IStringEnum { public static readonly FulfillmentFulfillmentLineItemApplication All = new(Values.All); @@ -62,6 +63,7 @@ public static explicit operator FulfillmentFulfillmentLineItemApplication(string /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string All = "ALL"; diff --git a/src/Square/Types/FulfillmentPickupDetails.cs b/src/Square/Types/FulfillmentPickupDetails.cs index 968d1192..2d4fdcac 100644 --- a/src/Square/Types/FulfillmentPickupDetails.cs +++ b/src/Square/Types/FulfillmentPickupDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains details necessary to fulfill a pickup order. /// -public record FulfillmentPickupDetails +[Serializable] +public record FulfillmentPickupDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the person to pick up this fulfillment from a physical /// location. @@ -156,15 +161,11 @@ public record FulfillmentPickupDetails [JsonPropertyName("curbside_pickup_details")] public FulfillmentPickupDetailsCurbsidePickupDetails? CurbsidePickupDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentPickupDetailsCurbsidePickupDetails.cs b/src/Square/Types/FulfillmentPickupDetailsCurbsidePickupDetails.cs index 7287b899..cf100f7f 100644 --- a/src/Square/Types/FulfillmentPickupDetailsCurbsidePickupDetails.cs +++ b/src/Square/Types/FulfillmentPickupDetailsCurbsidePickupDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Specific details for curbside pickup. /// -public record FulfillmentPickupDetailsCurbsidePickupDetails +[Serializable] +public record FulfillmentPickupDetailsCurbsidePickupDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Specific details for curbside pickup, such as parking number and vehicle model. /// @@ -23,15 +28,11 @@ public record FulfillmentPickupDetailsCurbsidePickupDetails [JsonPropertyName("buyer_arrived_at")] public string? BuyerArrivedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentPickupDetailsScheduleType.cs b/src/Square/Types/FulfillmentPickupDetailsScheduleType.cs index 9f54461e..ca2bfa1a 100644 --- a/src/Square/Types/FulfillmentPickupDetailsScheduleType.cs +++ b/src/Square/Types/FulfillmentPickupDetailsScheduleType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct FulfillmentPickupDetailsScheduleType : IStringEnum { public static readonly FulfillmentPickupDetailsScheduleType Scheduled = new(Values.Scheduled); @@ -56,6 +57,7 @@ public static explicit operator FulfillmentPickupDetailsScheduleType(string valu /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Scheduled = "SCHEDULED"; diff --git a/src/Square/Types/FulfillmentRecipient.cs b/src/Square/Types/FulfillmentRecipient.cs index b12955b7..415c6c97 100644 --- a/src/Square/Types/FulfillmentRecipient.cs +++ b/src/Square/Types/FulfillmentRecipient.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Information about the fulfillment recipient. /// -public record FulfillmentRecipient +[Serializable] +public record FulfillmentRecipient : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the customer associated with the fulfillment. /// @@ -58,15 +63,11 @@ public record FulfillmentRecipient [JsonPropertyName("address")] public Address? Address { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentShipmentDetails.cs b/src/Square/Types/FulfillmentShipmentDetails.cs index 87e171f0..efd02108 100644 --- a/src/Square/Types/FulfillmentShipmentDetails.cs +++ b/src/Square/Types/FulfillmentShipmentDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains the details necessary to fulfill a shipment order. /// -public record FulfillmentShipmentDetails +[Serializable] +public record FulfillmentShipmentDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the person to receive this shipment fulfillment. /// @@ -120,15 +125,11 @@ public record FulfillmentShipmentDetails [JsonPropertyName("failure_reason")] public string? FailureReason { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/FulfillmentState.cs b/src/Square/Types/FulfillmentState.cs index ba1966f7..d326af58 100644 --- a/src/Square/Types/FulfillmentState.cs +++ b/src/Square/Types/FulfillmentState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct FulfillmentState : IStringEnum { public static readonly FulfillmentState Proposed = new(Values.Proposed); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Proposed = "PROPOSED"; diff --git a/src/Square/Types/FulfillmentType.cs b/src/Square/Types/FulfillmentType.cs index 98e16f3f..ae50cb0c 100644 --- a/src/Square/Types/FulfillmentType.cs +++ b/src/Square/Types/FulfillmentType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct FulfillmentType : IStringEnum { public static readonly FulfillmentType Pickup = new(Values.Pickup); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pickup = "PICKUP"; diff --git a/src/Square/Types/GetBankAccountByV1IdResponse.cs b/src/Square/Types/GetBankAccountByV1IdResponse.cs index f71ff50d..f5b06ef9 100644 --- a/src/Square/Types/GetBankAccountByV1IdResponse.cs +++ b/src/Square/Types/GetBankAccountByV1IdResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response object returned by GetBankAccountByV1Id. /// -public record GetBankAccountByV1IdResponse +[Serializable] +public record GetBankAccountByV1IdResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -21,15 +26,11 @@ public record GetBankAccountByV1IdResponse [JsonPropertyName("bank_account")] public BankAccount? BankAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetBankAccountResponse.cs b/src/Square/Types/GetBankAccountResponse.cs index 6b9ec979..c0365437 100644 --- a/src/Square/Types/GetBankAccountResponse.cs +++ b/src/Square/Types/GetBankAccountResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response object returned by `GetBankAccount`. /// -public record GetBankAccountResponse +[Serializable] +public record GetBankAccountResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -21,15 +26,11 @@ public record GetBankAccountResponse [JsonPropertyName("bank_account")] public BankAccount? BankAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetBookingResponse.cs b/src/Square/Types/GetBookingResponse.cs index 56cff3b6..f1d8f823 100644 --- a/src/Square/Types/GetBookingResponse.cs +++ b/src/Square/Types/GetBookingResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetBookingResponse +[Serializable] +public record GetBookingResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The booking that was requested. /// @@ -18,15 +23,11 @@ public record GetBookingResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetBreakTypeResponse.cs b/src/Square/Types/GetBreakTypeResponse.cs index 9c0f3792..1a00ca6b 100644 --- a/src/Square/Types/GetBreakTypeResponse.cs +++ b/src/Square/Types/GetBreakTypeResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `BreakType` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record GetBreakTypeResponse +[Serializable] +public record GetBreakTypeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The response object. /// @@ -23,15 +28,11 @@ public record GetBreakTypeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetBusinessBookingProfileResponse.cs b/src/Square/Types/GetBusinessBookingProfileResponse.cs index e841dc8a..6c6d2c55 100644 --- a/src/Square/Types/GetBusinessBookingProfileResponse.cs +++ b/src/Square/Types/GetBusinessBookingProfileResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetBusinessBookingProfileResponse +[Serializable] +public record GetBusinessBookingProfileResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The seller's booking profile. /// @@ -18,15 +23,11 @@ public record GetBusinessBookingProfileResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCardResponse.cs b/src/Square/Types/GetCardResponse.cs index 25395a18..e362cd0e 100644 --- a/src/Square/Types/GetCardResponse.cs +++ b/src/Square/Types/GetCardResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the card field will not be /// present. /// -public record GetCardResponse +[Serializable] +public record GetCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -25,15 +30,11 @@ public record GetCardResponse [JsonPropertyName("card")] public Card? Card { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCashDrawerShiftResponse.cs b/src/Square/Types/GetCashDrawerShiftResponse.cs index 7d640755..66110ad2 100644 --- a/src/Square/Types/GetCashDrawerShiftResponse.cs +++ b/src/Square/Types/GetCashDrawerShiftResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetCashDrawerShiftResponse +[Serializable] +public record GetCashDrawerShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The cash drawer shift queried for. /// @@ -18,15 +23,11 @@ public record GetCashDrawerShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCatalogObjectResponse.cs b/src/Square/Types/GetCatalogObjectResponse.cs index a49eb8fc..09f55611 100644 --- a/src/Square/Types/GetCatalogObjectResponse.cs +++ b/src/Square/Types/GetCatalogObjectResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetCatalogObjectResponse +[Serializable] +public record GetCatalogObjectResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record GetCatalogObjectResponse [JsonPropertyName("related_objects")] public IEnumerable? RelatedObjects { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCustomerCustomAttributeDefinitionResponse.cs b/src/Square/Types/GetCustomerCustomAttributeDefinitionResponse.cs index 90eb4ea6..9518662b 100644 --- a/src/Square/Types/GetCustomerCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/GetCustomerCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-RetrieveCustomerCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record GetCustomerCustomAttributeDefinitionResponse +[Serializable] +public record GetCustomerCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definition. /// @@ -22,15 +27,11 @@ public record GetCustomerCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCustomerCustomAttributeResponse.cs b/src/Square/Types/GetCustomerCustomAttributeResponse.cs index 9747b964..4f624ad9 100644 --- a/src/Square/Types/GetCustomerCustomAttributeResponse.cs +++ b/src/Square/Types/GetCustomerCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-RetrieveCustomerCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record GetCustomerCustomAttributeResponse +[Serializable] +public record GetCustomerCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute. If `with_definition` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field. @@ -23,15 +28,11 @@ public record GetCustomerCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCustomerGroupResponse.cs b/src/Square/Types/GetCustomerGroupResponse.cs index 5281bb41..1179d365 100644 --- a/src/Square/Types/GetCustomerGroupResponse.cs +++ b/src/Square/Types/GetCustomerGroupResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `group` is present in a given response (never both). /// -public record GetCustomerGroupResponse +[Serializable] +public record GetCustomerGroupResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record GetCustomerGroupResponse [JsonPropertyName("group")] public CustomerGroup? Group { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCustomerResponse.cs b/src/Square/Types/GetCustomerResponse.cs index 9cf8980b..9f2030a7 100644 --- a/src/Square/Types/GetCustomerResponse.cs +++ b/src/Square/Types/GetCustomerResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `customer` is present in a given response (never both). /// -public record GetCustomerResponse +[Serializable] +public record GetCustomerResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record GetCustomerResponse [JsonPropertyName("customer")] public Customer? Customer { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetCustomerSegmentResponse.cs b/src/Square/Types/GetCustomerSegmentResponse.cs index 7de1e391..b93c2311 100644 --- a/src/Square/Types/GetCustomerSegmentResponse.cs +++ b/src/Square/Types/GetCustomerSegmentResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Either `errors` or `segment` is present in a given response (never both). /// -public record GetCustomerSegmentResponse +[Serializable] +public record GetCustomerSegmentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -23,15 +28,11 @@ public record GetCustomerSegmentResponse [JsonPropertyName("segment")] public CustomerSegment? Segment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetDeviceCodeResponse.cs b/src/Square/Types/GetDeviceCodeResponse.cs index 26d1168d..5e221818 100644 --- a/src/Square/Types/GetDeviceCodeResponse.cs +++ b/src/Square/Types/GetDeviceCodeResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetDeviceCodeResponse +[Serializable] +public record GetDeviceCodeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record GetDeviceCodeResponse [JsonPropertyName("device_code")] public DeviceCode? DeviceCode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetDeviceResponse.cs b/src/Square/Types/GetDeviceResponse.cs index 0ced1eaf..91cdcb6e 100644 --- a/src/Square/Types/GetDeviceResponse.cs +++ b/src/Square/Types/GetDeviceResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetDeviceResponse +[Serializable] +public record GetDeviceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record GetDeviceResponse [JsonPropertyName("device")] public Device? Device { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetDisputeEvidenceResponse.cs b/src/Square/Types/GetDisputeEvidenceResponse.cs index 663bab61..9f5a4c83 100644 --- a/src/Square/Types/GetDisputeEvidenceResponse.cs +++ b/src/Square/Types/GetDisputeEvidenceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the fields in a `RetrieveDisputeEvidence` response. /// -public record GetDisputeEvidenceResponse +[Serializable] +public record GetDisputeEvidenceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record GetDisputeEvidenceResponse [JsonPropertyName("evidence")] public DisputeEvidence? Evidence { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetDisputeResponse.cs b/src/Square/Types/GetDisputeResponse.cs index a1a58e74..5dd5f1ca 100644 --- a/src/Square/Types/GetDisputeResponse.cs +++ b/src/Square/Types/GetDisputeResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines fields in a `RetrieveDispute` response. /// -public record GetDisputeResponse +[Serializable] +public record GetDisputeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record GetDisputeResponse [JsonPropertyName("dispute")] public Dispute? Dispute { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetEmployeeResponse.cs b/src/Square/Types/GetEmployeeResponse.cs index 572d7a6a..c6c29bd9 100644 --- a/src/Square/Types/GetEmployeeResponse.cs +++ b/src/Square/Types/GetEmployeeResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetEmployeeResponse +[Serializable] +public record GetEmployeeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + [JsonPropertyName("employee")] public Employee? Employee { get; set; } @@ -15,15 +20,11 @@ public record GetEmployeeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetEmployeeWageResponse.cs b/src/Square/Types/GetEmployeeWageResponse.cs index f65c740f..b3852963 100644 --- a/src/Square/Types/GetEmployeeWageResponse.cs +++ b/src/Square/Types/GetEmployeeWageResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `EmployeeWage` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record GetEmployeeWageResponse +[Serializable] +public record GetEmployeeWageResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested `EmployeeWage` object. /// @@ -23,15 +28,11 @@ public record GetEmployeeWageResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetGiftCardFromGanResponse.cs b/src/Square/Types/GetGiftCardFromGanResponse.cs index 78bdfd43..d3a1b431 100644 --- a/src/Square/Types/GetGiftCardFromGanResponse.cs +++ b/src/Square/Types/GetGiftCardFromGanResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a `GiftCard`. This response might contain a set of `Error` objects /// if the request resulted in errors. /// -public record GetGiftCardFromGanResponse +[Serializable] +public record GetGiftCardFromGanResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record GetGiftCardFromGanResponse [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetGiftCardFromNonceResponse.cs b/src/Square/Types/GetGiftCardFromNonceResponse.cs index d77f0e03..c587953f 100644 --- a/src/Square/Types/GetGiftCardFromNonceResponse.cs +++ b/src/Square/Types/GetGiftCardFromNonceResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a `GiftCard` object. If the request resulted in errors, /// the response contains a set of `Error` objects. /// -public record GetGiftCardFromNonceResponse +[Serializable] +public record GetGiftCardFromNonceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record GetGiftCardFromNonceResponse [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetGiftCardResponse.cs b/src/Square/Types/GetGiftCardResponse.cs index 5725eff6..0572dacb 100644 --- a/src/Square/Types/GetGiftCardResponse.cs +++ b/src/Square/Types/GetGiftCardResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a `GiftCard`. The response might contain a set of `Error` objects /// if the request resulted in errors. /// -public record GetGiftCardResponse +[Serializable] +public record GetGiftCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record GetGiftCardResponse [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetInventoryAdjustmentResponse.cs b/src/Square/Types/GetInventoryAdjustmentResponse.cs index f8fb38fa..95034a62 100644 --- a/src/Square/Types/GetInventoryAdjustmentResponse.cs +++ b/src/Square/Types/GetInventoryAdjustmentResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetInventoryAdjustmentResponse +[Serializable] +public record GetInventoryAdjustmentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record GetInventoryAdjustmentResponse [JsonPropertyName("adjustment")] public InventoryAdjustment? Adjustment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetInventoryChangesResponse.cs b/src/Square/Types/GetInventoryChangesResponse.cs index eecfd5fc..6dd283e4 100644 --- a/src/Square/Types/GetInventoryChangesResponse.cs +++ b/src/Square/Types/GetInventoryChangesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetInventoryChangesResponse +[Serializable] +public record GetInventoryChangesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -27,15 +32,11 @@ public record GetInventoryChangesResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetInventoryCountResponse.cs b/src/Square/Types/GetInventoryCountResponse.cs index d1fa1334..f54f38ee 100644 --- a/src/Square/Types/GetInventoryCountResponse.cs +++ b/src/Square/Types/GetInventoryCountResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetInventoryCountResponse +[Serializable] +public record GetInventoryCountResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -28,15 +33,11 @@ public record GetInventoryCountResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetInventoryPhysicalCountResponse.cs b/src/Square/Types/GetInventoryPhysicalCountResponse.cs index e603a95a..8e3ca309 100644 --- a/src/Square/Types/GetInventoryPhysicalCountResponse.cs +++ b/src/Square/Types/GetInventoryPhysicalCountResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetInventoryPhysicalCountResponse +[Serializable] +public record GetInventoryPhysicalCountResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record GetInventoryPhysicalCountResponse [JsonPropertyName("count")] public InventoryPhysicalCount? Count { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetInventoryTransferResponse.cs b/src/Square/Types/GetInventoryTransferResponse.cs index ac953b3f..f049a3cc 100644 --- a/src/Square/Types/GetInventoryTransferResponse.cs +++ b/src/Square/Types/GetInventoryTransferResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetInventoryTransferResponse +[Serializable] +public record GetInventoryTransferResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record GetInventoryTransferResponse [JsonPropertyName("transfer")] public InventoryTransfer? Transfer { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetInvoiceResponse.cs b/src/Square/Types/GetInvoiceResponse.cs index e3bb2944..70dd39df 100644 --- a/src/Square/Types/GetInvoiceResponse.cs +++ b/src/Square/Types/GetInvoiceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes a `GetInvoice` response. /// -public record GetInvoiceResponse +[Serializable] +public record GetInvoiceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The invoice requested. /// @@ -21,15 +26,11 @@ public record GetInvoiceResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetLocationResponse.cs b/src/Square/Types/GetLocationResponse.cs index 716dbab8..1f21c652 100644 --- a/src/Square/Types/GetLocationResponse.cs +++ b/src/Square/Types/GetLocationResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that the [RetrieveLocation](api-endpoint:Locations-RetrieveLocation) /// endpoint returns in a response. /// -public record GetLocationResponse +[Serializable] +public record GetLocationResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -22,15 +27,11 @@ public record GetLocationResponse [JsonPropertyName("location")] public Location? Location { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetLoyaltyAccountResponse.cs b/src/Square/Types/GetLoyaltyAccountResponse.cs index 1c34879b..0c55f58e 100644 --- a/src/Square/Types/GetLoyaltyAccountResponse.cs +++ b/src/Square/Types/GetLoyaltyAccountResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes the loyalty account. /// -public record GetLoyaltyAccountResponse +[Serializable] +public record GetLoyaltyAccountResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record GetLoyaltyAccountResponse [JsonPropertyName("loyalty_account")] public LoyaltyAccount? LoyaltyAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetLoyaltyProgramResponse.cs b/src/Square/Types/GetLoyaltyProgramResponse.cs index 611886a9..5fa2b08f 100644 --- a/src/Square/Types/GetLoyaltyProgramResponse.cs +++ b/src/Square/Types/GetLoyaltyProgramResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that contains the loyalty program. /// -public record GetLoyaltyProgramResponse +[Serializable] +public record GetLoyaltyProgramResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record GetLoyaltyProgramResponse [JsonPropertyName("program")] public LoyaltyProgram? Program { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetLoyaltyPromotionResponse.cs b/src/Square/Types/GetLoyaltyPromotionResponse.cs index 3dc494f4..dae0720a 100644 --- a/src/Square/Types/GetLoyaltyPromotionResponse.cs +++ b/src/Square/Types/GetLoyaltyPromotionResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a [RetrieveLoyaltyPromotionPromotions](api-endpoint:Loyalty-RetrieveLoyaltyPromotion) response. /// -public record GetLoyaltyPromotionResponse +[Serializable] +public record GetLoyaltyPromotionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record GetLoyaltyPromotionResponse [JsonPropertyName("loyalty_promotion")] public LoyaltyPromotion? LoyaltyPromotion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetLoyaltyRewardResponse.cs b/src/Square/Types/GetLoyaltyRewardResponse.cs index 27ab2377..b8a994bd 100644 --- a/src/Square/Types/GetLoyaltyRewardResponse.cs +++ b/src/Square/Types/GetLoyaltyRewardResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes the loyalty reward. /// -public record GetLoyaltyRewardResponse +[Serializable] +public record GetLoyaltyRewardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record GetLoyaltyRewardResponse [JsonPropertyName("reward")] public LoyaltyReward? Reward { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetMerchantResponse.cs b/src/Square/Types/GetMerchantResponse.cs index 1d8f81e7..feb40305 100644 --- a/src/Square/Types/GetMerchantResponse.cs +++ b/src/Square/Types/GetMerchantResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response object returned by the [RetrieveMerchant](api-endpoint:Merchants-RetrieveMerchant) endpoint. /// -public record GetMerchantResponse +[Serializable] +public record GetMerchantResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -21,15 +26,11 @@ public record GetMerchantResponse [JsonPropertyName("merchant")] public Merchant? Merchant { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetOrderResponse.cs b/src/Square/Types/GetOrderResponse.cs index 5aceed29..6d8a2372 100644 --- a/src/Square/Types/GetOrderResponse.cs +++ b/src/Square/Types/GetOrderResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetOrderResponse +[Serializable] +public record GetOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested order. /// @@ -18,15 +23,11 @@ public record GetOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetPaymentLinkResponse.cs b/src/Square/Types/GetPaymentLinkResponse.cs index 96b29f06..57138bbb 100644 --- a/src/Square/Types/GetPaymentLinkResponse.cs +++ b/src/Square/Types/GetPaymentLinkResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetPaymentLinkResponse +[Serializable] +public record GetPaymentLinkResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record GetPaymentLinkResponse [JsonPropertyName("payment_link")] public PaymentLink? PaymentLink { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetPaymentRefundResponse.cs b/src/Square/Types/GetPaymentRefundResponse.cs index 580bdf11..8557c6c5 100644 --- a/src/Square/Types/GetPaymentRefundResponse.cs +++ b/src/Square/Types/GetPaymentRefundResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// Note: If there are errors processing the request, the refund field might not be /// present or it might be present in a FAILED state. /// -public record GetPaymentRefundResponse +[Serializable] +public record GetPaymentRefundResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -24,15 +29,11 @@ public record GetPaymentRefundResponse [JsonPropertyName("refund")] public PaymentRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetPaymentResponse.cs b/src/Square/Types/GetPaymentResponse.cs index 82944536..6de234b1 100644 --- a/src/Square/Types/GetPaymentResponse.cs +++ b/src/Square/Types/GetPaymentResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the response returned by [GetPayment](api-endpoint:Payments-GetPayment). /// -public record GetPaymentResponse +[Serializable] +public record GetPaymentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record GetPaymentResponse [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetPayoutResponse.cs b/src/Square/Types/GetPayoutResponse.cs index e1d92a98..e84fd7b3 100644 --- a/src/Square/Types/GetPayoutResponse.cs +++ b/src/Square/Types/GetPayoutResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetPayoutResponse +[Serializable] +public record GetPayoutResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested payout. /// @@ -18,15 +23,11 @@ public record GetPayoutResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetShiftResponse.cs b/src/Square/Types/GetShiftResponse.cs index 7f98385c..5f30c389 100644 --- a/src/Square/Types/GetShiftResponse.cs +++ b/src/Square/Types/GetShiftResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `Shift` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record GetShiftResponse +[Serializable] +public record GetShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested `Shift`. /// @@ -23,15 +28,11 @@ public record GetShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetSnippetResponse.cs b/src/Square/Types/GetSnippetResponse.cs index c5c3bc0c..ab429329 100644 --- a/src/Square/Types/GetSnippetResponse.cs +++ b/src/Square/Types/GetSnippetResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a `RetrieveSnippet` response. The response can include either `snippet` or `errors`. /// -public record GetSnippetResponse +[Serializable] +public record GetSnippetResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record GetSnippetResponse [JsonPropertyName("snippet")] public Snippet? Snippet { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetSubscriptionResponse.cs b/src/Square/Types/GetSubscriptionResponse.cs index 8eb9dd9e..c49c77fc 100644 --- a/src/Square/Types/GetSubscriptionResponse.cs +++ b/src/Square/Types/GetSubscriptionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [RetrieveSubscription](api-endpoint:Subscriptions-RetrieveSubscription) endpoint. /// -public record GetSubscriptionResponse +[Serializable] +public record GetSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -22,15 +27,11 @@ public record GetSubscriptionResponse [JsonPropertyName("subscription")] public Subscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTeamMemberBookingProfileResponse.cs b/src/Square/Types/GetTeamMemberBookingProfileResponse.cs index e3dedec3..63724f63 100644 --- a/src/Square/Types/GetTeamMemberBookingProfileResponse.cs +++ b/src/Square/Types/GetTeamMemberBookingProfileResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetTeamMemberBookingProfileResponse +[Serializable] +public record GetTeamMemberBookingProfileResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The returned team member booking profile. /// @@ -18,15 +23,11 @@ public record GetTeamMemberBookingProfileResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTeamMemberResponse.cs b/src/Square/Types/GetTeamMemberResponse.cs index 68f187be..766671ca 100644 --- a/src/Square/Types/GetTeamMemberResponse.cs +++ b/src/Square/Types/GetTeamMemberResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a retrieve request containing a `TeamMember` object or error messages. /// -public record GetTeamMemberResponse +[Serializable] +public record GetTeamMemberResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully retrieved `TeamMember` object. /// @@ -21,15 +26,11 @@ public record GetTeamMemberResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTeamMemberWageResponse.cs b/src/Square/Types/GetTeamMemberWageResponse.cs index 8b173c19..28518116 100644 --- a/src/Square/Types/GetTeamMemberWageResponse.cs +++ b/src/Square/Types/GetTeamMemberWageResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `TeamMemberWage` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record GetTeamMemberWageResponse +[Serializable] +public record GetTeamMemberWageResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested `TeamMemberWage` object. /// @@ -23,15 +28,11 @@ public record GetTeamMemberWageResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTerminalActionResponse.cs b/src/Square/Types/GetTerminalActionResponse.cs index 8f4645a7..8fd1260d 100644 --- a/src/Square/Types/GetTerminalActionResponse.cs +++ b/src/Square/Types/GetTerminalActionResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetTerminalActionResponse +[Serializable] +public record GetTerminalActionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -18,15 +23,11 @@ public record GetTerminalActionResponse [JsonPropertyName("action")] public TerminalAction? Action { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTerminalCheckoutResponse.cs b/src/Square/Types/GetTerminalCheckoutResponse.cs index ad860891..94bd7a1b 100644 --- a/src/Square/Types/GetTerminalCheckoutResponse.cs +++ b/src/Square/Types/GetTerminalCheckoutResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetTerminalCheckoutResponse +[Serializable] +public record GetTerminalCheckoutResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record GetTerminalCheckoutResponse [JsonPropertyName("checkout")] public TerminalCheckout? Checkout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTerminalRefundResponse.cs b/src/Square/Types/GetTerminalRefundResponse.cs index 793afd82..7c06703e 100644 --- a/src/Square/Types/GetTerminalRefundResponse.cs +++ b/src/Square/Types/GetTerminalRefundResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record GetTerminalRefundResponse +[Serializable] +public record GetTerminalRefundResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record GetTerminalRefundResponse [JsonPropertyName("refund")] public TerminalRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetTransactionResponse.cs b/src/Square/Types/GetTransactionResponse.cs index 24d86327..60b197dd 100644 --- a/src/Square/Types/GetTransactionResponse.cs +++ b/src/Square/Types/GetTransactionResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// One of `errors` or `transaction` is present in a given response (never both). /// -public record GetTransactionResponse +[Serializable] +public record GetTransactionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record GetTransactionResponse [JsonPropertyName("transaction")] public Transaction? Transaction { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetVendorResponse.cs b/src/Square/Types/GetVendorResponse.cs index 2c772e00..b730530c 100644 --- a/src/Square/Types/GetVendorResponse.cs +++ b/src/Square/Types/GetVendorResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [RetrieveVendor](api-endpoint:Vendors-RetrieveVendor). /// -public record GetVendorResponse +[Serializable] +public record GetVendorResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered when the request fails. /// @@ -21,15 +26,11 @@ public record GetVendorResponse [JsonPropertyName("vendor")] public Vendor? Vendor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetWageSettingResponse.cs b/src/Square/Types/GetWageSettingResponse.cs index 15a7851f..c0cd74e6 100644 --- a/src/Square/Types/GetWageSettingResponse.cs +++ b/src/Square/Types/GetWageSettingResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a retrieve request containing the specified `WageSetting` object or error messages. /// -public record GetWageSettingResponse +[Serializable] +public record GetWageSettingResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully retrieved `WageSetting` object. /// @@ -21,15 +26,11 @@ public record GetWageSettingResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GetWebhookSubscriptionResponse.cs b/src/Square/Types/GetWebhookSubscriptionResponse.cs index 06174bc3..ebc9864e 100644 --- a/src/Square/Types/GetWebhookSubscriptionResponse.cs +++ b/src/Square/Types/GetWebhookSubscriptionResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the [Subscription](entity:WebhookSubscription) will not be /// present. /// -public record GetWebhookSubscriptionResponse +[Serializable] +public record GetWebhookSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -25,15 +30,11 @@ public record GetWebhookSubscriptionResponse [JsonPropertyName("subscription")] public WebhookSubscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCard.cs b/src/Square/Types/GiftCard.cs index 0bfdaa13..a748bc64 100644 --- a/src/Square/Types/GiftCard.cs +++ b/src/Square/Types/GiftCard.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a Square gift card. /// -public record GiftCard +[Serializable] +public record GiftCard : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the gift card. /// @@ -68,15 +73,11 @@ public record GiftCard [JsonPropertyName("customer_ids")] public IEnumerable? CustomerIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivity.cs b/src/Square/Types/GiftCardActivity.cs index 22c49236..2560e0e5 100644 --- a/src/Square/Types/GiftCardActivity.cs +++ b/src/Square/Types/GiftCardActivity.cs @@ -9,8 +9,13 @@ namespace Square; /// A gift card activity contains information about a specific activity type. For example, a `REDEEM` activity /// includes a `redeem_activity_details` field that contains information about the redemption. /// -public record GiftCardActivity +[Serializable] +public record GiftCardActivity : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the gift card activity. /// @@ -168,15 +173,11 @@ public record GiftCardActivity [JsonPropertyName("transfer_balance_from_activity_details")] public GiftCardActivityTransferBalanceFrom? TransferBalanceFromActivityDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityActivate.cs b/src/Square/Types/GiftCardActivityActivate.cs index d747a589..8cd38d61 100644 --- a/src/Square/Types/GiftCardActivityActivate.cs +++ b/src/Square/Types/GiftCardActivityActivate.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about an `ACTIVATE` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityActivate +[Serializable] +public record GiftCardActivityActivate : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount added to the gift card. This value is a positive integer. /// @@ -61,15 +66,11 @@ public record GiftCardActivityActivate [JsonPropertyName("buyer_payment_instrument_ids")] public IEnumerable? BuyerPaymentInstrumentIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityAdjustDecrement.cs b/src/Square/Types/GiftCardActivityAdjustDecrement.cs index 671ab2cd..c2a4ae6f 100644 --- a/src/Square/Types/GiftCardActivityAdjustDecrement.cs +++ b/src/Square/Types/GiftCardActivityAdjustDecrement.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about an `ADJUST_DECREMENT` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityAdjustDecrement +[Serializable] +public record GiftCardActivityAdjustDecrement : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount deducted from the gift card balance. This value is a positive integer. /// @@ -22,15 +27,11 @@ public record GiftCardActivityAdjustDecrement [JsonPropertyName("reason")] public required GiftCardActivityAdjustDecrementReason Reason { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityAdjustDecrementReason.cs b/src/Square/Types/GiftCardActivityAdjustDecrementReason.cs index dd9c4241..33b3bcc0 100644 --- a/src/Square/Types/GiftCardActivityAdjustDecrementReason.cs +++ b/src/Square/Types/GiftCardActivityAdjustDecrementReason.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardActivityAdjustDecrementReason : IStringEnum { public static readonly GiftCardActivityAdjustDecrementReason SuspiciousActivity = new( @@ -68,6 +69,7 @@ public static explicit operator GiftCardActivityAdjustDecrementReason(string val /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string SuspiciousActivity = "SUSPICIOUS_ACTIVITY"; diff --git a/src/Square/Types/GiftCardActivityAdjustIncrement.cs b/src/Square/Types/GiftCardActivityAdjustIncrement.cs index ba25ec06..6ed57480 100644 --- a/src/Square/Types/GiftCardActivityAdjustIncrement.cs +++ b/src/Square/Types/GiftCardActivityAdjustIncrement.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about an `ADJUST_INCREMENT` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityAdjustIncrement +[Serializable] +public record GiftCardActivityAdjustIncrement : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount added to the gift card balance. This value is a positive integer. /// @@ -22,15 +27,11 @@ public record GiftCardActivityAdjustIncrement [JsonPropertyName("reason")] public required GiftCardActivityAdjustIncrementReason Reason { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityAdjustIncrementReason.cs b/src/Square/Types/GiftCardActivityAdjustIncrementReason.cs index a44237f3..f9d4991e 100644 --- a/src/Square/Types/GiftCardActivityAdjustIncrementReason.cs +++ b/src/Square/Types/GiftCardActivityAdjustIncrementReason.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardActivityAdjustIncrementReason : IStringEnum { public static readonly GiftCardActivityAdjustIncrementReason Complimentary = new( @@ -64,6 +65,7 @@ public static explicit operator GiftCardActivityAdjustIncrementReason(string val /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Complimentary = "COMPLIMENTARY"; diff --git a/src/Square/Types/GiftCardActivityBlock.cs b/src/Square/Types/GiftCardActivityBlock.cs index 3a2a0512..04d6de85 100644 --- a/src/Square/Types/GiftCardActivityBlock.cs +++ b/src/Square/Types/GiftCardActivityBlock.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `BLOCK` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityBlock +[Serializable] +public record GiftCardActivityBlock : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The reason the gift card was blocked. /// See [Reason](#type-reason) for possible values @@ -16,15 +21,11 @@ public record GiftCardActivityBlock [JsonPropertyName("reason")] public string Reason { get; set; } = "CHARGEBACK_BLOCK"; - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityClearBalance.cs b/src/Square/Types/GiftCardActivityClearBalance.cs index 93a3ae44..519a9d1c 100644 --- a/src/Square/Types/GiftCardActivityClearBalance.cs +++ b/src/Square/Types/GiftCardActivityClearBalance.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `CLEAR_BALANCE` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityClearBalance +[Serializable] +public record GiftCardActivityClearBalance : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The reason the gift card balance was cleared. /// See [Reason](#type-reason) for possible values @@ -16,15 +21,11 @@ public record GiftCardActivityClearBalance [JsonPropertyName("reason")] public required GiftCardActivityClearBalanceReason Reason { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityClearBalanceReason.cs b/src/Square/Types/GiftCardActivityClearBalanceReason.cs index 52f0374b..1c7d1645 100644 --- a/src/Square/Types/GiftCardActivityClearBalanceReason.cs +++ b/src/Square/Types/GiftCardActivityClearBalanceReason.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardActivityClearBalanceReason : IStringEnum { public static readonly GiftCardActivityClearBalanceReason SuspiciousActivity = new( @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string SuspiciousActivity = "SUSPICIOUS_ACTIVITY"; diff --git a/src/Square/Types/GiftCardActivityCreatedEvent.cs b/src/Square/Types/GiftCardActivityCreatedEvent.cs index 4c7c61b2..c2cbae51 100644 --- a/src/Square/Types/GiftCardActivityCreatedEvent.cs +++ b/src/Square/Types/GiftCardActivityCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [gift card activity](entity:GiftCardActivity) is created. /// -public record GiftCardActivityCreatedEvent +[Serializable] +public record GiftCardActivityCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record GiftCardActivityCreatedEvent [JsonPropertyName("data")] public GiftCardActivityCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityCreatedEventData.cs b/src/Square/Types/GiftCardActivityCreatedEventData.cs index e31ad966..c8fdd422 100644 --- a/src/Square/Types/GiftCardActivityCreatedEventData.cs +++ b/src/Square/Types/GiftCardActivityCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the data associated with a `gift_card.activity.created` event. /// -public record GiftCardActivityCreatedEventData +[Serializable] +public record GiftCardActivityCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `gift_card_activity`. /// @@ -27,15 +32,11 @@ public record GiftCardActivityCreatedEventData [JsonPropertyName("object")] public GiftCardActivityCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityCreatedEventObject.cs b/src/Square/Types/GiftCardActivityCreatedEventObject.cs index 8b67749a..3909d4e1 100644 --- a/src/Square/Types/GiftCardActivityCreatedEventObject.cs +++ b/src/Square/Types/GiftCardActivityCreatedEventObject.cs @@ -8,23 +8,24 @@ namespace Square; /// An object that contains the gift card activity associated with a /// `gift_card.activity.created` event. /// -public record GiftCardActivityCreatedEventObject +[Serializable] +public record GiftCardActivityCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new gift card activity. /// [JsonPropertyName("gift_card_activity")] public GiftCardActivity? GiftCardActivity { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityDeactivate.cs b/src/Square/Types/GiftCardActivityDeactivate.cs index b2a7435d..0f028c8a 100644 --- a/src/Square/Types/GiftCardActivityDeactivate.cs +++ b/src/Square/Types/GiftCardActivityDeactivate.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `DEACTIVATE` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityDeactivate +[Serializable] +public record GiftCardActivityDeactivate : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The reason the gift card was deactivated. /// See [Reason](#type-reason) for possible values @@ -16,15 +21,11 @@ public record GiftCardActivityDeactivate [JsonPropertyName("reason")] public required GiftCardActivityDeactivateReason Reason { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityDeactivateReason.cs b/src/Square/Types/GiftCardActivityDeactivateReason.cs index 8dad0175..845eeb35 100644 --- a/src/Square/Types/GiftCardActivityDeactivateReason.cs +++ b/src/Square/Types/GiftCardActivityDeactivateReason.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardActivityDeactivateReason : IStringEnum { public static readonly GiftCardActivityDeactivateReason SuspiciousActivity = new( @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string SuspiciousActivity = "SUSPICIOUS_ACTIVITY"; diff --git a/src/Square/Types/GiftCardActivityImport.cs b/src/Square/Types/GiftCardActivityImport.cs index ae0c9a37..97c42352 100644 --- a/src/Square/Types/GiftCardActivityImport.cs +++ b/src/Square/Types/GiftCardActivityImport.cs @@ -9,23 +9,24 @@ namespace Square; /// This activity type is used when Square imports a third-party gift card, in which case the /// `gan_source` of the gift card is set to `OTHER`. /// -public record GiftCardActivityImport +[Serializable] +public record GiftCardActivityImport : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The balance amount on the imported gift card. /// [JsonPropertyName("amount_money")] public required Money AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityImportReversal.cs b/src/Square/Types/GiftCardActivityImportReversal.cs index 913e5424..b5191f43 100644 --- a/src/Square/Types/GiftCardActivityImportReversal.cs +++ b/src/Square/Types/GiftCardActivityImportReversal.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about an `IMPORT_REVERSAL` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityImportReversal +[Serializable] +public record GiftCardActivityImportReversal : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount of money cleared from the third-party gift card when /// the import was reversed. @@ -16,15 +21,11 @@ public record GiftCardActivityImportReversal [JsonPropertyName("amount_money")] public required Money AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityLoad.cs b/src/Square/Types/GiftCardActivityLoad.cs index cf722b22..94e27973 100644 --- a/src/Square/Types/GiftCardActivityLoad.cs +++ b/src/Square/Types/GiftCardActivityLoad.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `LOAD` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityLoad +[Serializable] +public record GiftCardActivityLoad : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount added to the gift card. This value is a positive integer. /// @@ -61,15 +66,11 @@ public record GiftCardActivityLoad [JsonPropertyName("buyer_payment_instrument_ids")] public IEnumerable? BuyerPaymentInstrumentIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityRedeem.cs b/src/Square/Types/GiftCardActivityRedeem.cs index 67e2a755..7057dd1d 100644 --- a/src/Square/Types/GiftCardActivityRedeem.cs +++ b/src/Square/Types/GiftCardActivityRedeem.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `REDEEM` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityRedeem +[Serializable] +public record GiftCardActivityRedeem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount deducted from the gift card for the redemption. This value is a positive integer. /// @@ -45,15 +50,11 @@ public record GiftCardActivityRedeem [JsonPropertyName("status")] public GiftCardActivityRedeemStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityRedeemStatus.cs b/src/Square/Types/GiftCardActivityRedeemStatus.cs index 66f0c926..2f845812 100644 --- a/src/Square/Types/GiftCardActivityRedeemStatus.cs +++ b/src/Square/Types/GiftCardActivityRedeemStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardActivityRedeemStatus : IStringEnum { public static readonly GiftCardActivityRedeemStatus Pending = new(Values.Pending); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/GiftCardActivityRefund.cs b/src/Square/Types/GiftCardActivityRefund.cs index fe24f525..c10a9646 100644 --- a/src/Square/Types/GiftCardActivityRefund.cs +++ b/src/Square/Types/GiftCardActivityRefund.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `REFUND` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityRefund +[Serializable] +public record GiftCardActivityRefund : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the refunded `REDEEM` gift card activity. Square populates this field if the /// `payment_id` in the corresponding [RefundPayment](api-endpoint:Refunds-RefundPayment) request @@ -43,15 +48,11 @@ public record GiftCardActivityRefund [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityTransferBalanceFrom.cs b/src/Square/Types/GiftCardActivityTransferBalanceFrom.cs index 8f78c378..68ea1912 100644 --- a/src/Square/Types/GiftCardActivityTransferBalanceFrom.cs +++ b/src/Square/Types/GiftCardActivityTransferBalanceFrom.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `TRANSFER_BALANCE_FROM` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityTransferBalanceFrom +[Serializable] +public record GiftCardActivityTransferBalanceFrom : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the gift card to which the specified amount was transferred. /// @@ -21,15 +26,11 @@ public record GiftCardActivityTransferBalanceFrom [JsonPropertyName("amount_money")] public required Money AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityTransferBalanceTo.cs b/src/Square/Types/GiftCardActivityTransferBalanceTo.cs index 71c7e343..a7c5d4a3 100644 --- a/src/Square/Types/GiftCardActivityTransferBalanceTo.cs +++ b/src/Square/Types/GiftCardActivityTransferBalanceTo.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about a `TRANSFER_BALANCE_TO` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityTransferBalanceTo +[Serializable] +public record GiftCardActivityTransferBalanceTo : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the gift card from which the specified amount was transferred. /// @@ -21,15 +26,11 @@ public record GiftCardActivityTransferBalanceTo [JsonPropertyName("amount_money")] public required Money AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityType.cs b/src/Square/Types/GiftCardActivityType.cs index 1ab97e94..b0e27f92 100644 --- a/src/Square/Types/GiftCardActivityType.cs +++ b/src/Square/Types/GiftCardActivityType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardActivityType : IStringEnum { public static readonly GiftCardActivityType Activate = new(Values.Activate); @@ -84,6 +85,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Activate = "ACTIVATE"; diff --git a/src/Square/Types/GiftCardActivityUnblock.cs b/src/Square/Types/GiftCardActivityUnblock.cs index 9b371e20..e31da83d 100644 --- a/src/Square/Types/GiftCardActivityUnblock.cs +++ b/src/Square/Types/GiftCardActivityUnblock.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about an `UNBLOCK` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityUnblock +[Serializable] +public record GiftCardActivityUnblock : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The reason the gift card was unblocked. /// See [Reason](#type-reason) for possible values @@ -16,15 +21,11 @@ public record GiftCardActivityUnblock [JsonPropertyName("reason")] public string Reason { get; set; } = "CHARGEBACK_UNBLOCK"; - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityUnlinkedActivityRefund.cs b/src/Square/Types/GiftCardActivityUnlinkedActivityRefund.cs index c39573a7..a0cf025c 100644 --- a/src/Square/Types/GiftCardActivityUnlinkedActivityRefund.cs +++ b/src/Square/Types/GiftCardActivityUnlinkedActivityRefund.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents details about an `UNLINKED_ACTIVITY_REFUND` [gift card activity type](entity:GiftCardActivityType). /// -public record GiftCardActivityUnlinkedActivityRefund +[Serializable] +public record GiftCardActivityUnlinkedActivityRefund : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount added to the gift card for the refund. This value is a positive integer. /// @@ -28,15 +33,11 @@ public record GiftCardActivityUnlinkedActivityRefund [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityUpdatedEvent.cs b/src/Square/Types/GiftCardActivityUpdatedEvent.cs index 7f42aed5..1296b354 100644 --- a/src/Square/Types/GiftCardActivityUpdatedEvent.cs +++ b/src/Square/Types/GiftCardActivityUpdatedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// These redemptions are initially assigned a `PENDING` state, but then change to a `COMPLETED` or `CANCELED` state. /// - An update to the `IMPORT` activity for an imported gift card when the balance is later adjusted by Square. /// -public record GiftCardActivityUpdatedEvent +[Serializable] +public record GiftCardActivityUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -45,15 +50,11 @@ public record GiftCardActivityUpdatedEvent [JsonPropertyName("data")] public GiftCardActivityUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityUpdatedEventData.cs b/src/Square/Types/GiftCardActivityUpdatedEventData.cs index aa5554e6..cf5123ee 100644 --- a/src/Square/Types/GiftCardActivityUpdatedEventData.cs +++ b/src/Square/Types/GiftCardActivityUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `gift_card.activity.updated` event. /// -public record GiftCardActivityUpdatedEventData +[Serializable] +public record GiftCardActivityUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `gift_card_activity`. /// @@ -27,15 +32,11 @@ public record GiftCardActivityUpdatedEventData [JsonPropertyName("object")] public GiftCardActivityUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardActivityUpdatedEventObject.cs b/src/Square/Types/GiftCardActivityUpdatedEventObject.cs index 05384ea7..03f27de8 100644 --- a/src/Square/Types/GiftCardActivityUpdatedEventObject.cs +++ b/src/Square/Types/GiftCardActivityUpdatedEventObject.cs @@ -8,23 +8,24 @@ namespace Square; /// An object that contains the gift card activity associated with a /// `gift_card.activity.updated` event. /// -public record GiftCardActivityUpdatedEventObject +[Serializable] +public record GiftCardActivityUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated gift card activity. /// [JsonPropertyName("gift_card_activity")] public GiftCardActivity? GiftCardActivity { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCreatedEvent.cs b/src/Square/Types/GiftCardCreatedEvent.cs index d562c132..94af165e 100644 --- a/src/Square/Types/GiftCardCreatedEvent.cs +++ b/src/Square/Types/GiftCardCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [gift card](entity:GiftCard) is created. /// -public record GiftCardCreatedEvent +[Serializable] +public record GiftCardCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record GiftCardCreatedEvent [JsonPropertyName("data")] public GiftCardCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCreatedEventData.cs b/src/Square/Types/GiftCardCreatedEventData.cs index 61e50ecf..8e7756a8 100644 --- a/src/Square/Types/GiftCardCreatedEventData.cs +++ b/src/Square/Types/GiftCardCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `gift_card.created` event. /// -public record GiftCardCreatedEventData +[Serializable] +public record GiftCardCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `gift_card`. /// @@ -27,15 +32,11 @@ public record GiftCardCreatedEventData [JsonPropertyName("object")] public GiftCardCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCreatedEventObject.cs b/src/Square/Types/GiftCardCreatedEventObject.cs index eaf87970..c40d413a 100644 --- a/src/Square/Types/GiftCardCreatedEventObject.cs +++ b/src/Square/Types/GiftCardCreatedEventObject.cs @@ -7,23 +7,24 @@ namespace Square; /// /// An object that contains the gift card associated with a `gift_card.created` event. /// -public record GiftCardCreatedEventObject +[Serializable] +public record GiftCardCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new gift card. /// [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCustomerLinkedEvent.cs b/src/Square/Types/GiftCardCustomerLinkedEvent.cs index 2682ba93..468ca0a9 100644 --- a/src/Square/Types/GiftCardCustomerLinkedEvent.cs +++ b/src/Square/Types/GiftCardCustomerLinkedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [customer](entity:Customer) is linked to a [gift card](entity:GiftCard). /// -public record GiftCardCustomerLinkedEvent +[Serializable] +public record GiftCardCustomerLinkedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record GiftCardCustomerLinkedEvent [JsonPropertyName("data")] public GiftCardCustomerLinkedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCustomerLinkedEventData.cs b/src/Square/Types/GiftCardCustomerLinkedEventData.cs index 3e0f6f71..4c604c7d 100644 --- a/src/Square/Types/GiftCardCustomerLinkedEventData.cs +++ b/src/Square/Types/GiftCardCustomerLinkedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `gift_card.customer_linked` event. /// -public record GiftCardCustomerLinkedEventData +[Serializable] +public record GiftCardCustomerLinkedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `gift_card`. /// @@ -27,15 +32,11 @@ public record GiftCardCustomerLinkedEventData [JsonPropertyName("object")] public GiftCardCustomerLinkedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCustomerLinkedEventObject.cs b/src/Square/Types/GiftCardCustomerLinkedEventObject.cs index 09c0aecb..cb3488c1 100644 --- a/src/Square/Types/GiftCardCustomerLinkedEventObject.cs +++ b/src/Square/Types/GiftCardCustomerLinkedEventObject.cs @@ -8,8 +8,13 @@ namespace Square; /// An object that contains the gift card and customer ID associated with a /// `gift_card.customer_linked` event. /// -public record GiftCardCustomerLinkedEventObject +[Serializable] +public record GiftCardCustomerLinkedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The gift card with the updated `customer_ids` field. /// @@ -22,15 +27,11 @@ public record GiftCardCustomerLinkedEventObject [JsonPropertyName("linked_customer_id")] public string? LinkedCustomerId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCustomerUnlinkedEvent.cs b/src/Square/Types/GiftCardCustomerUnlinkedEvent.cs index ca41d82c..340943a5 100644 --- a/src/Square/Types/GiftCardCustomerUnlinkedEvent.cs +++ b/src/Square/Types/GiftCardCustomerUnlinkedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [customer](entity:Customer) is unlinked from a [gift card](entity:GiftCard). /// -public record GiftCardCustomerUnlinkedEvent +[Serializable] +public record GiftCardCustomerUnlinkedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record GiftCardCustomerUnlinkedEvent [JsonPropertyName("data")] public GiftCardCustomerUnlinkedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCustomerUnlinkedEventData.cs b/src/Square/Types/GiftCardCustomerUnlinkedEventData.cs index cb74332b..7c677134 100644 --- a/src/Square/Types/GiftCardCustomerUnlinkedEventData.cs +++ b/src/Square/Types/GiftCardCustomerUnlinkedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `gift_card.customer_unlinked` event. /// -public record GiftCardCustomerUnlinkedEventData +[Serializable] +public record GiftCardCustomerUnlinkedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `gift_card`. /// @@ -27,15 +32,11 @@ public record GiftCardCustomerUnlinkedEventData [JsonPropertyName("object")] public GiftCardCustomerUnlinkedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardCustomerUnlinkedEventObject.cs b/src/Square/Types/GiftCardCustomerUnlinkedEventObject.cs index 93a9beee..406a84a0 100644 --- a/src/Square/Types/GiftCardCustomerUnlinkedEventObject.cs +++ b/src/Square/Types/GiftCardCustomerUnlinkedEventObject.cs @@ -8,8 +8,13 @@ namespace Square; /// An object that contains the gift card and the customer ID associated with a /// `gift_card.customer_linked` event. /// -public record GiftCardCustomerUnlinkedEventObject +[Serializable] +public record GiftCardCustomerUnlinkedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The gift card with the updated `customer_ids` field. /// The field is removed if the gift card is not linked to any customers. @@ -23,15 +28,11 @@ public record GiftCardCustomerUnlinkedEventObject [JsonPropertyName("unlinked_customer_id")] public string? UnlinkedCustomerId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardGanSource.cs b/src/Square/Types/GiftCardGanSource.cs index fd6fb16e..636f9311 100644 --- a/src/Square/Types/GiftCardGanSource.cs +++ b/src/Square/Types/GiftCardGanSource.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardGanSource : IStringEnum { public static readonly GiftCardGanSource Square = new(Values.Square); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Square = "SQUARE"; diff --git a/src/Square/Types/GiftCardStatus.cs b/src/Square/Types/GiftCardStatus.cs index 9e44e3cf..afaec101 100644 --- a/src/Square/Types/GiftCardStatus.cs +++ b/src/Square/Types/GiftCardStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardStatus : IStringEnum { public static readonly GiftCardStatus Active = new(Values.Active); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/GiftCardType.cs b/src/Square/Types/GiftCardType.cs index 76859902..162c36f6 100644 --- a/src/Square/Types/GiftCardType.cs +++ b/src/Square/Types/GiftCardType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct GiftCardType : IStringEnum { public static readonly GiftCardType Physical = new(Values.Physical); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Physical = "PHYSICAL"; diff --git a/src/Square/Types/GiftCardUpdatedEvent.cs b/src/Square/Types/GiftCardUpdatedEvent.cs index 2d83b9ed..64153b64 100644 --- a/src/Square/Types/GiftCardUpdatedEvent.cs +++ b/src/Square/Types/GiftCardUpdatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a [gift card](entity:GiftCard) is updated. This includes /// changes to the state, balance, and customer association. /// -public record GiftCardUpdatedEvent +[Serializable] +public record GiftCardUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -42,15 +47,11 @@ public record GiftCardUpdatedEvent [JsonPropertyName("data")] public GiftCardUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardUpdatedEventData.cs b/src/Square/Types/GiftCardUpdatedEventData.cs index 89b2fb54..4e93e43f 100644 --- a/src/Square/Types/GiftCardUpdatedEventData.cs +++ b/src/Square/Types/GiftCardUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `gift_card.updated` event. /// -public record GiftCardUpdatedEventData +[Serializable] +public record GiftCardUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `gift_card`. /// @@ -27,15 +32,11 @@ public record GiftCardUpdatedEventData [JsonPropertyName("object")] public GiftCardUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/GiftCardUpdatedEventObject.cs b/src/Square/Types/GiftCardUpdatedEventObject.cs index 54d120ae..543f6f27 100644 --- a/src/Square/Types/GiftCardUpdatedEventObject.cs +++ b/src/Square/Types/GiftCardUpdatedEventObject.cs @@ -7,8 +7,13 @@ namespace Square; /// /// An object that contains the gift card associated with a `gift_card.updated` event. /// -public record GiftCardUpdatedEventObject +[Serializable] +public record GiftCardUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The gift card with the updated `balance_money`, `state`, or `customer_ids` field. /// Some events can affect both `balance_money` and `state`. @@ -16,15 +21,11 @@ public record GiftCardUpdatedEventObject [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryAdjustment.cs b/src/Square/Types/InventoryAdjustment.cs index 4d2e1929..95219985 100644 --- a/src/Square/Types/InventoryAdjustment.cs +++ b/src/Square/Types/InventoryAdjustment.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a change in state or quantity of product inventory at a /// particular time and location. /// -public record InventoryAdjustment +[Serializable] +public record InventoryAdjustment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID generated by Square for the /// `InventoryAdjustment`. @@ -158,15 +163,11 @@ public record InventoryAdjustment [JsonPropertyName("adjustment_group")] public InventoryAdjustmentGroup? AdjustmentGroup { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryAdjustmentGroup.cs b/src/Square/Types/InventoryAdjustmentGroup.cs index d6cb8a10..071935b7 100644 --- a/src/Square/Types/InventoryAdjustmentGroup.cs +++ b/src/Square/Types/InventoryAdjustmentGroup.cs @@ -4,8 +4,13 @@ namespace Square; -public record InventoryAdjustmentGroup +[Serializable] +public record InventoryAdjustmentGroup : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID generated by Square for the /// `InventoryAdjustmentGroup`. @@ -39,15 +44,11 @@ public record InventoryAdjustmentGroup [JsonPropertyName("to_state")] public InventoryState? ToState { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryAlertType.cs b/src/Square/Types/InventoryAlertType.cs index 348ce2bb..8ac9fe41 100644 --- a/src/Square/Types/InventoryAlertType.cs +++ b/src/Square/Types/InventoryAlertType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InventoryAlertType : IStringEnum { public static readonly InventoryAlertType None = new(Values.None); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string None = "NONE"; diff --git a/src/Square/Types/InventoryChange.cs b/src/Square/Types/InventoryChange.cs index 87c56c24..676e8965 100644 --- a/src/Square/Types/InventoryChange.cs +++ b/src/Square/Types/InventoryChange.cs @@ -9,8 +9,13 @@ namespace Square; /// that is part of the history of inventory changes for a particular /// [CatalogObject](entity:CatalogObject) instance. /// -public record InventoryChange +[Serializable] +public record InventoryChange : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates how the inventory change is applied. See /// [InventoryChangeType](entity:InventoryChangeType) for all possible values. @@ -56,15 +61,11 @@ public record InventoryChange [JsonPropertyName("measurement_unit_id")] public string? MeasurementUnitId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryChangeType.cs b/src/Square/Types/InventoryChangeType.cs index 11510ac8..0abf0524 100644 --- a/src/Square/Types/InventoryChangeType.cs +++ b/src/Square/Types/InventoryChangeType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InventoryChangeType : IStringEnum { public static readonly InventoryChangeType PhysicalCount = new(Values.PhysicalCount); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string PhysicalCount = "PHYSICAL_COUNT"; diff --git a/src/Square/Types/InventoryCount.cs b/src/Square/Types/InventoryCount.cs index b9ccaf3d..145b782c 100644 --- a/src/Square/Types/InventoryCount.cs +++ b/src/Square/Types/InventoryCount.cs @@ -9,8 +9,13 @@ namespace Square; /// particular seller location based on the known history of physical counts and /// inventory adjustments. /// -public record InventoryCount +[Serializable] +public record InventoryCount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-generated ID of the /// [CatalogObject](entity:CatalogObject) being tracked. @@ -68,15 +73,11 @@ public record InventoryCount [JsonPropertyName("is_estimated")] public bool? IsEstimated { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryCountUpdatedEvent.cs b/src/Square/Types/InventoryCountUpdatedEvent.cs index 22685f04..97611b36 100644 --- a/src/Square/Types/InventoryCountUpdatedEvent.cs +++ b/src/Square/Types/InventoryCountUpdatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when the quantity is updated for a /// [CatalogItemVariation](entity:CatalogItemVariation). /// -public record InventoryCountUpdatedEvent +[Serializable] +public record InventoryCountUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -41,15 +46,11 @@ public record InventoryCountUpdatedEvent [JsonPropertyName("data")] public InventoryCountUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryCountUpdatedEventData.cs b/src/Square/Types/InventoryCountUpdatedEventData.cs index 1f2fc90d..8dca1fb9 100644 --- a/src/Square/Types/InventoryCountUpdatedEventData.cs +++ b/src/Square/Types/InventoryCountUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InventoryCountUpdatedEventData +[Serializable] +public record InventoryCountUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type. For this event, the value is `inventory_counts`. /// @@ -24,15 +29,11 @@ public record InventoryCountUpdatedEventData [JsonPropertyName("object")] public InventoryCountUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryCountUpdatedEventObject.cs b/src/Square/Types/InventoryCountUpdatedEventObject.cs index 9e072843..52f5270f 100644 --- a/src/Square/Types/InventoryCountUpdatedEventObject.cs +++ b/src/Square/Types/InventoryCountUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InventoryCountUpdatedEventObject +[Serializable] +public record InventoryCountUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The inventory counts. /// [JsonPropertyName("inventory_counts")] public IEnumerable? InventoryCounts { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryPhysicalCount.cs b/src/Square/Types/InventoryPhysicalCount.cs index 707dc1b4..ba180166 100644 --- a/src/Square/Types/InventoryPhysicalCount.cs +++ b/src/Square/Types/InventoryPhysicalCount.cs @@ -10,8 +10,13 @@ namespace Square; /// a physical count might come from an employee counting the item variations on /// hand or from syncing with an external system. /// -public record InventoryPhysicalCount +[Serializable] +public record InventoryPhysicalCount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique Square-generated ID for the /// [InventoryPhysicalCount](entity:InventoryPhysicalCount). @@ -102,15 +107,11 @@ public record InventoryPhysicalCount [JsonPropertyName("created_at")] public string? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InventoryState.cs b/src/Square/Types/InventoryState.cs index 248fef4f..eca6a383 100644 --- a/src/Square/Types/InventoryState.cs +++ b/src/Square/Types/InventoryState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InventoryState : IStringEnum { public static readonly InventoryState Custom = new(Values.Custom); @@ -84,6 +85,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Custom = "CUSTOM"; diff --git a/src/Square/Types/InventoryTransfer.cs b/src/Square/Types/InventoryTransfer.cs index 25a34994..bc8231b7 100644 --- a/src/Square/Types/InventoryTransfer.cs +++ b/src/Square/Types/InventoryTransfer.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the transfer of a quantity of product inventory at a /// particular time from one location to another. /// -public record InventoryTransfer +[Serializable] +public record InventoryTransfer : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID generated by Square for the /// `InventoryTransfer`. @@ -107,15 +112,11 @@ public record InventoryTransfer [JsonPropertyName("team_member_id")] public string? TeamMemberId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Invoice.cs b/src/Square/Types/Invoice.cs index 989ecb37..0c313b3b 100644 --- a/src/Square/Types/Invoice.cs +++ b/src/Square/Types/Invoice.cs @@ -8,8 +8,13 @@ namespace Square; /// Stores information about an invoice. You use the Invoices API to create and manage /// invoices. For more information, see [Invoices API Overview](https://developer.squareup.com/docs/invoices-api/overview). /// -public record Invoice +[Serializable] +public record Invoice : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the invoice. /// @@ -238,15 +243,11 @@ public record Invoice [JsonPropertyName("creator_team_member_id")] public string? CreatorTeamMemberId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceAcceptedPaymentMethods.cs b/src/Square/Types/InvoiceAcceptedPaymentMethods.cs index 36a64b01..11548ff1 100644 --- a/src/Square/Types/InvoiceAcceptedPaymentMethods.cs +++ b/src/Square/Types/InvoiceAcceptedPaymentMethods.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The payment methods that customers can use to pay an [invoice](entity:Invoice) on the Square-hosted invoice payment page. /// -public record InvoiceAcceptedPaymentMethods +[Serializable] +public record InvoiceAcceptedPaymentMethods : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether credit card or debit card payments are accepted. The default value is `false`. /// @@ -47,15 +52,11 @@ public record InvoiceAcceptedPaymentMethods [JsonPropertyName("cash_app_pay")] public bool? CashAppPay { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceAttachment.cs b/src/Square/Types/InvoiceAttachment.cs index 1cc40506..291a1d3a 100644 --- a/src/Square/Types/InvoiceAttachment.cs +++ b/src/Square/Types/InvoiceAttachment.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a file attached to an [invoice](entity:Invoice). /// -public record InvoiceAttachment +[Serializable] +public record InvoiceAttachment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the attachment. /// @@ -61,15 +66,11 @@ public record InvoiceAttachment [JsonPropertyName("uploaded_at")] public string? UploadedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceAutomaticPaymentSource.cs b/src/Square/Types/InvoiceAutomaticPaymentSource.cs index 960db802..bafed9f5 100644 --- a/src/Square/Types/InvoiceAutomaticPaymentSource.cs +++ b/src/Square/Types/InvoiceAutomaticPaymentSource.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoiceAutomaticPaymentSource : IStringEnum { public static readonly InvoiceAutomaticPaymentSource None = new(Values.None); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string None = "NONE"; diff --git a/src/Square/Types/InvoiceCanceledEvent.cs b/src/Square/Types/InvoiceCanceledEvent.cs index 988f3f04..152cef52 100644 --- a/src/Square/Types/InvoiceCanceledEvent.cs +++ b/src/Square/Types/InvoiceCanceledEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an [Invoice](entity:Invoice) is canceled. /// -public record InvoiceCanceledEvent +[Serializable] +public record InvoiceCanceledEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record InvoiceCanceledEvent [JsonPropertyName("data")] public InvoiceCanceledEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCanceledEventData.cs b/src/Square/Types/InvoiceCanceledEventData.cs index 47ad69af..ecf1c1a2 100644 --- a/src/Square/Types/InvoiceCanceledEventData.cs +++ b/src/Square/Types/InvoiceCanceledEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoiceCanceledEventData +[Serializable] +public record InvoiceCanceledEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoiceCanceledEventData [JsonPropertyName("object")] public InvoiceCanceledEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCanceledEventObject.cs b/src/Square/Types/InvoiceCanceledEventObject.cs index e71a9e11..5c4f38fa 100644 --- a/src/Square/Types/InvoiceCanceledEventObject.cs +++ b/src/Square/Types/InvoiceCanceledEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoiceCanceledEventObject +[Serializable] +public record InvoiceCanceledEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCreatedEvent.cs b/src/Square/Types/InvoiceCreatedEvent.cs index 4e41ec9c..23af9ea5 100644 --- a/src/Square/Types/InvoiceCreatedEvent.cs +++ b/src/Square/Types/InvoiceCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an [Invoice](entity:Invoice) is created. /// -public record InvoiceCreatedEvent +[Serializable] +public record InvoiceCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record InvoiceCreatedEvent [JsonPropertyName("data")] public InvoiceCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCreatedEventData.cs b/src/Square/Types/InvoiceCreatedEventData.cs index 492b7acf..93cf018e 100644 --- a/src/Square/Types/InvoiceCreatedEventData.cs +++ b/src/Square/Types/InvoiceCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoiceCreatedEventData +[Serializable] +public record InvoiceCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoiceCreatedEventData [JsonPropertyName("object")] public InvoiceCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCreatedEventObject.cs b/src/Square/Types/InvoiceCreatedEventObject.cs index 30c2dce7..de3856a4 100644 --- a/src/Square/Types/InvoiceCreatedEventObject.cs +++ b/src/Square/Types/InvoiceCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoiceCreatedEventObject +[Serializable] +public record InvoiceCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCustomField.cs b/src/Square/Types/InvoiceCustomField.cs index 7f8e7c77..571bcff0 100644 --- a/src/Square/Types/InvoiceCustomField.cs +++ b/src/Square/Types/InvoiceCustomField.cs @@ -11,8 +11,13 @@ namespace Square; /// Adding custom fields to an invoice requires an /// [Invoices Plus subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription). /// -public record InvoiceCustomField +[Serializable] +public record InvoiceCustomField : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The label or title of the custom field. This field is required for a custom field. /// @@ -32,15 +37,11 @@ public record InvoiceCustomField [JsonPropertyName("placement")] public InvoiceCustomFieldPlacement? Placement { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceCustomFieldPlacement.cs b/src/Square/Types/InvoiceCustomFieldPlacement.cs index 5a61b80b..7c430289 100644 --- a/src/Square/Types/InvoiceCustomFieldPlacement.cs +++ b/src/Square/Types/InvoiceCustomFieldPlacement.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoiceCustomFieldPlacement : IStringEnum { public static readonly InvoiceCustomFieldPlacement AboveLineItems = new(Values.AboveLineItems); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AboveLineItems = "ABOVE_LINE_ITEMS"; diff --git a/src/Square/Types/InvoiceDeletedEvent.cs b/src/Square/Types/InvoiceDeletedEvent.cs index 2b639b2c..1c65475b 100644 --- a/src/Square/Types/InvoiceDeletedEvent.cs +++ b/src/Square/Types/InvoiceDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a draft [Invoice](entity:Invoice) is deleted. /// -public record InvoiceDeletedEvent +[Serializable] +public record InvoiceDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record InvoiceDeletedEvent [JsonPropertyName("data")] public InvoiceDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceDeletedEventData.cs b/src/Square/Types/InvoiceDeletedEventData.cs index 8213fc74..6defb432 100644 --- a/src/Square/Types/InvoiceDeletedEventData.cs +++ b/src/Square/Types/InvoiceDeletedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoiceDeletedEventData +[Serializable] +public record InvoiceDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoiceDeletedEventData [JsonPropertyName("deleted")] public bool? Deleted { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceDeliveryMethod.cs b/src/Square/Types/InvoiceDeliveryMethod.cs index c46b9adb..e6325cd8 100644 --- a/src/Square/Types/InvoiceDeliveryMethod.cs +++ b/src/Square/Types/InvoiceDeliveryMethod.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoiceDeliveryMethod : IStringEnum { public static readonly InvoiceDeliveryMethod Email = new(Values.Email); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Email = "EMAIL"; diff --git a/src/Square/Types/InvoiceFilter.cs b/src/Square/Types/InvoiceFilter.cs index 8ce49e05..550d7205 100644 --- a/src/Square/Types/InvoiceFilter.cs +++ b/src/Square/Types/InvoiceFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes query filters to apply. /// -public record InvoiceFilter +[Serializable] +public record InvoiceFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Limits the search to the specified locations. A location is required. /// In the current implementation, only one location can be specified. @@ -24,15 +29,11 @@ public record InvoiceFilter [JsonPropertyName("customer_ids")] public IEnumerable? CustomerIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePaymentMadeEvent.cs b/src/Square/Types/InvoicePaymentMadeEvent.cs index 2689a990..f0e2a8c5 100644 --- a/src/Square/Types/InvoicePaymentMadeEvent.cs +++ b/src/Square/Types/InvoicePaymentMadeEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a payment that is associated with an [invoice](entity:Invoice) is completed. /// For more information about invoice payments, see [Pay an invoice](https://developer.squareup.com/docs/invoices-api/pay-refund-invoices#pay-invoice). /// -public record InvoicePaymentMadeEvent +[Serializable] +public record InvoicePaymentMadeEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -41,15 +46,11 @@ public record InvoicePaymentMadeEvent [JsonPropertyName("data")] public InvoicePaymentMadeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePaymentMadeEventData.cs b/src/Square/Types/InvoicePaymentMadeEventData.cs index e147e463..4907b33a 100644 --- a/src/Square/Types/InvoicePaymentMadeEventData.cs +++ b/src/Square/Types/InvoicePaymentMadeEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoicePaymentMadeEventData +[Serializable] +public record InvoicePaymentMadeEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoicePaymentMadeEventData [JsonPropertyName("object")] public InvoicePaymentMadeEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePaymentMadeEventObject.cs b/src/Square/Types/InvoicePaymentMadeEventObject.cs index 8f0a69ec..91ca443b 100644 --- a/src/Square/Types/InvoicePaymentMadeEventObject.cs +++ b/src/Square/Types/InvoicePaymentMadeEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoicePaymentMadeEventObject +[Serializable] +public record InvoicePaymentMadeEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePaymentReminder.cs b/src/Square/Types/InvoicePaymentReminder.cs index 4fe2a14c..57ca8d99 100644 --- a/src/Square/Types/InvoicePaymentReminder.cs +++ b/src/Square/Types/InvoicePaymentReminder.cs @@ -9,8 +9,13 @@ namespace Square; /// to the customer. You configure a reminder relative to the payment request /// `due_date`. /// -public record InvoicePaymentReminder +[Serializable] +public record InvoicePaymentReminder : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A Square-assigned ID that uniquely identifies the reminder within the /// `InvoicePaymentRequest`. @@ -47,15 +52,11 @@ public record InvoicePaymentReminder [JsonPropertyName("sent_at")] public string? SentAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePaymentReminderStatus.cs b/src/Square/Types/InvoicePaymentReminderStatus.cs index 0a37979f..508e57b4 100644 --- a/src/Square/Types/InvoicePaymentReminderStatus.cs +++ b/src/Square/Types/InvoicePaymentReminderStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoicePaymentReminderStatus : IStringEnum { public static readonly InvoicePaymentReminderStatus Pending = new(Values.Pending); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/InvoicePaymentRequest.cs b/src/Square/Types/InvoicePaymentRequest.cs index 1ec59be0..ace828ea 100644 --- a/src/Square/Types/InvoicePaymentRequest.cs +++ b/src/Square/Types/InvoicePaymentRequest.cs @@ -12,8 +12,13 @@ namespace Square; /// Adding `INSTALLMENT` payment requests to an invoice requires an /// [Invoices Plus subscription](https://developer.squareup.com/docs/invoices-api/overview#invoices-plus-subscription). /// -public record InvoicePaymentRequest +[Serializable] +public record InvoicePaymentRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-generated ID of the payment request in an [invoice](entity:Invoice). /// @@ -133,15 +138,11 @@ public record InvoicePaymentRequest [JsonPropertyName("rounding_adjustment_included_money")] public Money? RoundingAdjustmentIncludedMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePublishedEvent.cs b/src/Square/Types/InvoicePublishedEvent.cs index de86f007..68028be8 100644 --- a/src/Square/Types/InvoicePublishedEvent.cs +++ b/src/Square/Types/InvoicePublishedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an [Invoice](entity:Invoice) transitions from a draft to a non-draft status. /// -public record InvoicePublishedEvent +[Serializable] +public record InvoicePublishedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record InvoicePublishedEvent [JsonPropertyName("data")] public InvoicePublishedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePublishedEventData.cs b/src/Square/Types/InvoicePublishedEventData.cs index 1a1c7469..20b96304 100644 --- a/src/Square/Types/InvoicePublishedEventData.cs +++ b/src/Square/Types/InvoicePublishedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoicePublishedEventData +[Serializable] +public record InvoicePublishedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoicePublishedEventData [JsonPropertyName("object")] public InvoicePublishedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoicePublishedEventObject.cs b/src/Square/Types/InvoicePublishedEventObject.cs index 6acaaab4..d0509c3a 100644 --- a/src/Square/Types/InvoicePublishedEventObject.cs +++ b/src/Square/Types/InvoicePublishedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoicePublishedEventObject +[Serializable] +public record InvoicePublishedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceQuery.cs b/src/Square/Types/InvoiceQuery.cs index 588a954f..98ff3e1e 100644 --- a/src/Square/Types/InvoiceQuery.cs +++ b/src/Square/Types/InvoiceQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes query criteria for searching invoices. /// -public record InvoiceQuery +[Serializable] +public record InvoiceQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Query filters to apply in searching invoices. /// For more information, see [Search for invoices](https://developer.squareup.com/docs/invoices-api/retrieve-list-search-invoices#search-invoices). @@ -22,15 +27,11 @@ public record InvoiceQuery [JsonPropertyName("sort")] public InvoiceSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceRecipient.cs b/src/Square/Types/InvoiceRecipient.cs index bbe4c1e7..69992507 100644 --- a/src/Square/Types/InvoiceRecipient.cs +++ b/src/Square/Types/InvoiceRecipient.cs @@ -12,8 +12,13 @@ namespace Square; /// the remaining `InvoiceRecipient` fields. You cannot update these fields after the invoice is published. /// Square updates the customer ID in response to a merge operation, but does not update other fields. /// -public record InvoiceRecipient +[Serializable] +public record InvoiceRecipient : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the customer. This is the customer profile ID that /// you provide when creating a draft invoice. @@ -69,15 +74,11 @@ public record InvoiceRecipient [JsonPropertyName("tax_ids")] public InvoiceRecipientTaxIds? TaxIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceRecipientTaxIds.cs b/src/Square/Types/InvoiceRecipientTaxIds.cs index 049078a2..256b177c 100644 --- a/src/Square/Types/InvoiceRecipientTaxIds.cs +++ b/src/Square/Types/InvoiceRecipientTaxIds.cs @@ -9,8 +9,13 @@ namespace Square; /// whether the corresponding `tax_ids` field is available for the customer. For more information, /// see [Invoice recipient tax IDs](https://developer.squareup.com/docs/invoices-api/overview#recipient-tax-ids). /// -public record InvoiceRecipientTaxIds +[Serializable] +public record InvoiceRecipientTaxIds : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The EU VAT identification number for the invoice recipient. For example, `IE3426675K`. /// @@ -18,15 +23,11 @@ public record InvoiceRecipientTaxIds [JsonPropertyName("eu_vat")] public string? EuVat { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceRefundedEvent.cs b/src/Square/Types/InvoiceRefundedEvent.cs index 9de1d087..2e38c9b5 100644 --- a/src/Square/Types/InvoiceRefundedEvent.cs +++ b/src/Square/Types/InvoiceRefundedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a refund is applied toward a payment of an [invoice](entity:Invoice). /// For more information about invoice refunds, see [Refund an invoice](https://developer.squareup.com/docs/invoices-api/pay-refund-invoices#refund-invoice). /// -public record InvoiceRefundedEvent +[Serializable] +public record InvoiceRefundedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -41,15 +46,11 @@ public record InvoiceRefundedEvent [JsonPropertyName("data")] public InvoiceRefundedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceRefundedEventData.cs b/src/Square/Types/InvoiceRefundedEventData.cs index a53a9a2a..567d47e8 100644 --- a/src/Square/Types/InvoiceRefundedEventData.cs +++ b/src/Square/Types/InvoiceRefundedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoiceRefundedEventData +[Serializable] +public record InvoiceRefundedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoiceRefundedEventData [JsonPropertyName("object")] public InvoiceRefundedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceRefundedEventObject.cs b/src/Square/Types/InvoiceRefundedEventObject.cs index f8510234..df403b69 100644 --- a/src/Square/Types/InvoiceRefundedEventObject.cs +++ b/src/Square/Types/InvoiceRefundedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoiceRefundedEventObject +[Serializable] +public record InvoiceRefundedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceRequestMethod.cs b/src/Square/Types/InvoiceRequestMethod.cs index f6a3132a..f19725b4 100644 --- a/src/Square/Types/InvoiceRequestMethod.cs +++ b/src/Square/Types/InvoiceRequestMethod.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoiceRequestMethod : IStringEnum { public static readonly InvoiceRequestMethod Email = new(Values.Email); @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Email = "EMAIL"; diff --git a/src/Square/Types/InvoiceRequestType.cs b/src/Square/Types/InvoiceRequestType.cs index 44344d66..6e595309 100644 --- a/src/Square/Types/InvoiceRequestType.cs +++ b/src/Square/Types/InvoiceRequestType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoiceRequestType : IStringEnum { public static readonly InvoiceRequestType Balance = new(Values.Balance); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Balance = "BALANCE"; diff --git a/src/Square/Types/InvoiceScheduledChargeFailedEvent.cs b/src/Square/Types/InvoiceScheduledChargeFailedEvent.cs index 811c16c3..45f071ad 100644 --- a/src/Square/Types/InvoiceScheduledChargeFailedEvent.cs +++ b/src/Square/Types/InvoiceScheduledChargeFailedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an automatic scheduled payment for an [Invoice](entity:Invoice) has failed. /// -public record InvoiceScheduledChargeFailedEvent +[Serializable] +public record InvoiceScheduledChargeFailedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record InvoiceScheduledChargeFailedEvent [JsonPropertyName("data")] public InvoiceScheduledChargeFailedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceScheduledChargeFailedEventData.cs b/src/Square/Types/InvoiceScheduledChargeFailedEventData.cs index 6a47b128..f0463505 100644 --- a/src/Square/Types/InvoiceScheduledChargeFailedEventData.cs +++ b/src/Square/Types/InvoiceScheduledChargeFailedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoiceScheduledChargeFailedEventData +[Serializable] +public record InvoiceScheduledChargeFailedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoiceScheduledChargeFailedEventData [JsonPropertyName("object")] public InvoiceScheduledChargeFailedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceScheduledChargeFailedEventObject.cs b/src/Square/Types/InvoiceScheduledChargeFailedEventObject.cs index 9e1120af..507ae782 100644 --- a/src/Square/Types/InvoiceScheduledChargeFailedEventObject.cs +++ b/src/Square/Types/InvoiceScheduledChargeFailedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoiceScheduledChargeFailedEventObject +[Serializable] +public record InvoiceScheduledChargeFailedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceSort.cs b/src/Square/Types/InvoiceSort.cs index 33a7c31c..a3685753 100644 --- a/src/Square/Types/InvoiceSort.cs +++ b/src/Square/Types/InvoiceSort.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Identifies the sort field and sort order. /// -public record InvoiceSort +[Serializable] +public record InvoiceSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The field to use for sorting. /// See [InvoiceSortField](#type-invoicesortfield) for possible values @@ -23,15 +28,11 @@ public record InvoiceSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceStatus.cs b/src/Square/Types/InvoiceStatus.cs index f8a87e9c..9bba448b 100644 --- a/src/Square/Types/InvoiceStatus.cs +++ b/src/Square/Types/InvoiceStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct InvoiceStatus : IStringEnum { public static readonly InvoiceStatus Draft = new(Values.Draft); @@ -70,6 +71,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Draft = "DRAFT"; diff --git a/src/Square/Types/InvoiceUpdatedEvent.cs b/src/Square/Types/InvoiceUpdatedEvent.cs index 367f1ccd..152a4ef4 100644 --- a/src/Square/Types/InvoiceUpdatedEvent.cs +++ b/src/Square/Types/InvoiceUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an [Invoice](entity:Invoice) is updated. /// -public record InvoiceUpdatedEvent +[Serializable] +public record InvoiceUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record InvoiceUpdatedEvent [JsonPropertyName("data")] public InvoiceUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceUpdatedEventData.cs b/src/Square/Types/InvoiceUpdatedEventData.cs index a17813af..bd8de488 100644 --- a/src/Square/Types/InvoiceUpdatedEventData.cs +++ b/src/Square/Types/InvoiceUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record InvoiceUpdatedEventData +[Serializable] +public record InvoiceUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"invoice"`. /// @@ -24,15 +29,11 @@ public record InvoiceUpdatedEventData [JsonPropertyName("object")] public InvoiceUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/InvoiceUpdatedEventObject.cs b/src/Square/Types/InvoiceUpdatedEventObject.cs index 7b1db7c4..5052a775 100644 --- a/src/Square/Types/InvoiceUpdatedEventObject.cs +++ b/src/Square/Types/InvoiceUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record InvoiceUpdatedEventObject +[Serializable] +public record InvoiceUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The related invoice. /// [JsonPropertyName("invoice")] public Invoice? Invoice { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ItemVariationLocationOverrides.cs b/src/Square/Types/ItemVariationLocationOverrides.cs index bb3a0659..ee3a2cb4 100644 --- a/src/Square/Types/ItemVariationLocationOverrides.cs +++ b/src/Square/Types/ItemVariationLocationOverrides.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Price and inventory alerting overrides for a `CatalogItemVariation` at a specific `Location`. /// -public record ItemVariationLocationOverrides +[Serializable] +public record ItemVariationLocationOverrides : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `Location`. This can include locations that are deactivated. /// @@ -73,15 +78,11 @@ public record ItemVariationLocationOverrides [JsonPropertyName("sold_out_valid_until")] public string? SoldOutValidUntil { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Job.cs b/src/Square/Types/Job.cs index 22268b36..b2537958 100644 --- a/src/Square/Types/Job.cs +++ b/src/Square/Types/Job.cs @@ -9,8 +9,13 @@ namespace Square; /// job's title and tip eligibility. Compensation is defined in a [job assignment](entity:JobAssignment) /// in a team member's wage setting. /// -public record Job +[Serializable] +public record Job : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// **Read only** The unique Square-assigned ID of the job. If you need a job ID for an API request, /// call [ListJobs](api-endpoint:Team-ListJobs) or use the ID returned when you created the job. @@ -54,15 +59,11 @@ public record Job [JsonPropertyName("version")] public int? Version { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobAssignment.cs b/src/Square/Types/JobAssignment.cs index d5c43c93..b2b96e36 100644 --- a/src/Square/Types/JobAssignment.cs +++ b/src/Square/Types/JobAssignment.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a job assigned to a [team member](entity:TeamMember), including the compensation the team /// member earns for the job. Job assignments are listed in the team member's [wage setting](entity:WageSetting). /// -public record JobAssignment +[Serializable] +public record JobAssignment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title of the job. /// @@ -49,15 +54,11 @@ public record JobAssignment [JsonPropertyName("job_id")] public string? JobId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobAssignmentPayType.cs b/src/Square/Types/JobAssignmentPayType.cs index 226d8d68..2fe1225b 100644 --- a/src/Square/Types/JobAssignmentPayType.cs +++ b/src/Square/Types/JobAssignmentPayType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct JobAssignmentPayType : IStringEnum { public static readonly JobAssignmentPayType None = new(Values.None); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string None = "NONE"; diff --git a/src/Square/Types/JobCreatedEvent.cs b/src/Square/Types/JobCreatedEvent.cs index e61b1d84..92072c0d 100644 --- a/src/Square/Types/JobCreatedEvent.cs +++ b/src/Square/Types/JobCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Job is created. /// -public record JobCreatedEvent +[Serializable] +public record JobCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record JobCreatedEvent [JsonPropertyName("data")] public JobCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobCreatedEventData.cs b/src/Square/Types/JobCreatedEventData.cs index dd19a96c..a716ebe7 100644 --- a/src/Square/Types/JobCreatedEventData.cs +++ b/src/Square/Types/JobCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record JobCreatedEventData +[Serializable] +public record JobCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"job"`. /// @@ -24,15 +29,11 @@ public record JobCreatedEventData [JsonPropertyName("object")] public JobCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobCreatedEventObject.cs b/src/Square/Types/JobCreatedEventObject.cs index c39769aa..efe6c15a 100644 --- a/src/Square/Types/JobCreatedEventObject.cs +++ b/src/Square/Types/JobCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record JobCreatedEventObject +[Serializable] +public record JobCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created job. /// [JsonPropertyName("job")] public Job? Job { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobUpdatedEvent.cs b/src/Square/Types/JobUpdatedEvent.cs index f44af72e..2d8b8a70 100644 --- a/src/Square/Types/JobUpdatedEvent.cs +++ b/src/Square/Types/JobUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Job is updated. /// -public record JobUpdatedEvent +[Serializable] +public record JobUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record JobUpdatedEvent [JsonPropertyName("data")] public JobUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobUpdatedEventData.cs b/src/Square/Types/JobUpdatedEventData.cs index 08d54e19..caa3931b 100644 --- a/src/Square/Types/JobUpdatedEventData.cs +++ b/src/Square/Types/JobUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record JobUpdatedEventData +[Serializable] +public record JobUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"job"`. /// @@ -24,15 +29,11 @@ public record JobUpdatedEventData [JsonPropertyName("object")] public JobUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/JobUpdatedEventObject.cs b/src/Square/Types/JobUpdatedEventObject.cs index a16d3031..1cbd659d 100644 --- a/src/Square/Types/JobUpdatedEventObject.cs +++ b/src/Square/Types/JobUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record JobUpdatedEventObject +[Serializable] +public record JobUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated job. /// [JsonPropertyName("job")] public Job? Job { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftCreatedEvent.cs b/src/Square/Types/LaborScheduledShiftCreatedEvent.cs index 4347a8d6..3bed5dcb 100644 --- a/src/Square/Types/LaborScheduledShiftCreatedEvent.cs +++ b/src/Square/Types/LaborScheduledShiftCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [ScheduledShift](entity:ScheduledShift) is created. /// -public record LaborScheduledShiftCreatedEvent +[Serializable] +public record LaborScheduledShiftCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -46,15 +51,11 @@ public record LaborScheduledShiftCreatedEvent [JsonPropertyName("data")] public LaborScheduledShiftCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftCreatedEventData.cs b/src/Square/Types/LaborScheduledShiftCreatedEventData.cs index 3adcdc22..a073fe28 100644 --- a/src/Square/Types/LaborScheduledShiftCreatedEventData.cs +++ b/src/Square/Types/LaborScheduledShiftCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborScheduledShiftCreatedEventData +[Serializable] +public record LaborScheduledShiftCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `scheduled_shift`. /// @@ -24,15 +29,11 @@ public record LaborScheduledShiftCreatedEventData [JsonPropertyName("object")] public LaborScheduledShiftCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftCreatedEventObject.cs b/src/Square/Types/LaborScheduledShiftCreatedEventObject.cs index 9083cd15..d79f80ad 100644 --- a/src/Square/Types/LaborScheduledShiftCreatedEventObject.cs +++ b/src/Square/Types/LaborScheduledShiftCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborScheduledShiftCreatedEventObject +[Serializable] +public record LaborScheduledShiftCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new `ScheduledShift`. /// [JsonPropertyName("ScheduledShift")] public ScheduledShift? ScheduledShift { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftDeletedEvent.cs b/src/Square/Types/LaborScheduledShiftDeletedEvent.cs index 93a1ba74..0e39d421 100644 --- a/src/Square/Types/LaborScheduledShiftDeletedEvent.cs +++ b/src/Square/Types/LaborScheduledShiftDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [ScheduledShift](entity:ScheduledShift) is deleted. /// -public record LaborScheduledShiftDeletedEvent +[Serializable] +public record LaborScheduledShiftDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -46,15 +51,11 @@ public record LaborScheduledShiftDeletedEvent [JsonPropertyName("data")] public LaborScheduledShiftDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftDeletedEventData.cs b/src/Square/Types/LaborScheduledShiftDeletedEventData.cs index 89c8b0d3..0cad5c88 100644 --- a/src/Square/Types/LaborScheduledShiftDeletedEventData.cs +++ b/src/Square/Types/LaborScheduledShiftDeletedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborScheduledShiftDeletedEventData +[Serializable] +public record LaborScheduledShiftDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `scheduled_shift`. /// @@ -24,15 +29,11 @@ public record LaborScheduledShiftDeletedEventData [JsonPropertyName("deleted")] public bool? Deleted { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftPublishedEvent.cs b/src/Square/Types/LaborScheduledShiftPublishedEvent.cs index 1a46d705..6b88f1c9 100644 --- a/src/Square/Types/LaborScheduledShiftPublishedEvent.cs +++ b/src/Square/Types/LaborScheduledShiftPublishedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [ScheduledShift](entity:ScheduledShift) is published. /// -public record LaborScheduledShiftPublishedEvent +[Serializable] +public record LaborScheduledShiftPublishedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -46,15 +51,11 @@ public record LaborScheduledShiftPublishedEvent [JsonPropertyName("data")] public LaborScheduledShiftPublishedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftPublishedEventData.cs b/src/Square/Types/LaborScheduledShiftPublishedEventData.cs index c8fca0c0..8448737a 100644 --- a/src/Square/Types/LaborScheduledShiftPublishedEventData.cs +++ b/src/Square/Types/LaborScheduledShiftPublishedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborScheduledShiftPublishedEventData +[Serializable] +public record LaborScheduledShiftPublishedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `scheduled_shift`. /// @@ -24,15 +29,11 @@ public record LaborScheduledShiftPublishedEventData [JsonPropertyName("object")] public LaborScheduledShiftPublishedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftPublishedEventObject.cs b/src/Square/Types/LaborScheduledShiftPublishedEventObject.cs index a67b42b5..75727d09 100644 --- a/src/Square/Types/LaborScheduledShiftPublishedEventObject.cs +++ b/src/Square/Types/LaborScheduledShiftPublishedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborScheduledShiftPublishedEventObject +[Serializable] +public record LaborScheduledShiftPublishedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The published `ScheduledShift`. /// [JsonPropertyName("ScheduledShift")] public ScheduledShift? ScheduledShift { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftUpdatedEvent.cs b/src/Square/Types/LaborScheduledShiftUpdatedEvent.cs index 15d9514d..fa62679a 100644 --- a/src/Square/Types/LaborScheduledShiftUpdatedEvent.cs +++ b/src/Square/Types/LaborScheduledShiftUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [ScheduledShift](entity:ScheduledShift) is updated. /// -public record LaborScheduledShiftUpdatedEvent +[Serializable] +public record LaborScheduledShiftUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -46,15 +51,11 @@ public record LaborScheduledShiftUpdatedEvent [JsonPropertyName("data")] public LaborScheduledShiftUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftUpdatedEventData.cs b/src/Square/Types/LaborScheduledShiftUpdatedEventData.cs index c8808215..95fd6b17 100644 --- a/src/Square/Types/LaborScheduledShiftUpdatedEventData.cs +++ b/src/Square/Types/LaborScheduledShiftUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborScheduledShiftUpdatedEventData +[Serializable] +public record LaborScheduledShiftUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `scheduled_shift`. /// @@ -24,15 +29,11 @@ public record LaborScheduledShiftUpdatedEventData [JsonPropertyName("object")] public LaborScheduledShiftUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborScheduledShiftUpdatedEventObject.cs b/src/Square/Types/LaborScheduledShiftUpdatedEventObject.cs index 1170fa2c..da368f52 100644 --- a/src/Square/Types/LaborScheduledShiftUpdatedEventObject.cs +++ b/src/Square/Types/LaborScheduledShiftUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborScheduledShiftUpdatedEventObject +[Serializable] +public record LaborScheduledShiftUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated `ScheduledShift`. /// [JsonPropertyName("ScheduledShift")] public ScheduledShift? ScheduledShift { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftCreatedEvent.cs b/src/Square/Types/LaborShiftCreatedEvent.cs index b5669a10..4362e3f8 100644 --- a/src/Square/Types/LaborShiftCreatedEvent.cs +++ b/src/Square/Types/LaborShiftCreatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. Replaced by `labor.timecard.created`. /// -public record LaborShiftCreatedEvent +[Serializable] +public record LaborShiftCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -42,15 +47,11 @@ public record LaborShiftCreatedEvent [JsonPropertyName("data")] public LaborShiftCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftCreatedEventData.cs b/src/Square/Types/LaborShiftCreatedEventData.cs index 16c64613..bd913f01 100644 --- a/src/Square/Types/LaborShiftCreatedEventData.cs +++ b/src/Square/Types/LaborShiftCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborShiftCreatedEventData +[Serializable] +public record LaborShiftCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `shift`. /// @@ -24,15 +29,11 @@ public record LaborShiftCreatedEventData [JsonPropertyName("object")] public LaborShiftCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftCreatedEventObject.cs b/src/Square/Types/LaborShiftCreatedEventObject.cs index 35931860..4f6f7542 100644 --- a/src/Square/Types/LaborShiftCreatedEventObject.cs +++ b/src/Square/Types/LaborShiftCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborShiftCreatedEventObject +[Serializable] +public record LaborShiftCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new `Shift`. /// [JsonPropertyName("shift")] public Shift? Shift { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftDeletedEvent.cs b/src/Square/Types/LaborShiftDeletedEvent.cs index 1e8f51a0..fc405fb4 100644 --- a/src/Square/Types/LaborShiftDeletedEvent.cs +++ b/src/Square/Types/LaborShiftDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. Replaced by `labor.timecard.deleted`. /// -public record LaborShiftDeletedEvent +[Serializable] +public record LaborShiftDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -42,15 +47,11 @@ public record LaborShiftDeletedEvent [JsonPropertyName("data")] public LaborShiftDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftDeletedEventData.cs b/src/Square/Types/LaborShiftDeletedEventData.cs index 4e6c6dd0..e0fe4d47 100644 --- a/src/Square/Types/LaborShiftDeletedEventData.cs +++ b/src/Square/Types/LaborShiftDeletedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborShiftDeletedEventData +[Serializable] +public record LaborShiftDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `shift`. /// @@ -24,15 +29,11 @@ public record LaborShiftDeletedEventData [JsonPropertyName("deleted")] public bool? Deleted { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftUpdatedEvent.cs b/src/Square/Types/LaborShiftUpdatedEvent.cs index a058849a..3c5f2426 100644 --- a/src/Square/Types/LaborShiftUpdatedEvent.cs +++ b/src/Square/Types/LaborShiftUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. Replaced by `labor.timecard.updated`. /// -public record LaborShiftUpdatedEvent +[Serializable] +public record LaborShiftUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -42,15 +47,11 @@ public record LaborShiftUpdatedEvent [JsonPropertyName("data")] public LaborShiftUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftUpdatedEventData.cs b/src/Square/Types/LaborShiftUpdatedEventData.cs index f9117811..aab234b5 100644 --- a/src/Square/Types/LaborShiftUpdatedEventData.cs +++ b/src/Square/Types/LaborShiftUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborShiftUpdatedEventData +[Serializable] +public record LaborShiftUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `shift`. /// @@ -24,15 +29,11 @@ public record LaborShiftUpdatedEventData [JsonPropertyName("object")] public LaborShiftUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborShiftUpdatedEventObject.cs b/src/Square/Types/LaborShiftUpdatedEventObject.cs index abb017f1..5fd44a55 100644 --- a/src/Square/Types/LaborShiftUpdatedEventObject.cs +++ b/src/Square/Types/LaborShiftUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborShiftUpdatedEventObject +[Serializable] +public record LaborShiftUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated `Shift`. /// [JsonPropertyName("shift")] public Shift? Shift { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardCreatedEvent.cs b/src/Square/Types/LaborTimecardCreatedEvent.cs index c6aed3ed..e52e3ec0 100644 --- a/src/Square/Types/LaborTimecardCreatedEvent.cs +++ b/src/Square/Types/LaborTimecardCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a worker starts a [Timecard](entity:Timecard). /// -public record LaborTimecardCreatedEvent +[Serializable] +public record LaborTimecardCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record LaborTimecardCreatedEvent [JsonPropertyName("data")] public LaborTimecardCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardCreatedEventData.cs b/src/Square/Types/LaborTimecardCreatedEventData.cs index 5e696564..68ff72ec 100644 --- a/src/Square/Types/LaborTimecardCreatedEventData.cs +++ b/src/Square/Types/LaborTimecardCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborTimecardCreatedEventData +[Serializable] +public record LaborTimecardCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `timecard`. /// @@ -24,15 +29,11 @@ public record LaborTimecardCreatedEventData [JsonPropertyName("object")] public LaborTimecardCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardCreatedEventObject.cs b/src/Square/Types/LaborTimecardCreatedEventObject.cs index c80e7201..f6c48776 100644 --- a/src/Square/Types/LaborTimecardCreatedEventObject.cs +++ b/src/Square/Types/LaborTimecardCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborTimecardCreatedEventObject +[Serializable] +public record LaborTimecardCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new `Timecard`. /// [JsonPropertyName("timecard")] public Timecard? Timecard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardDeletedEvent.cs b/src/Square/Types/LaborTimecardDeletedEvent.cs index 828879ac..ac6a8809 100644 --- a/src/Square/Types/LaborTimecardDeletedEvent.cs +++ b/src/Square/Types/LaborTimecardDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Timecard](entity:Timecard) is deleted. /// -public record LaborTimecardDeletedEvent +[Serializable] +public record LaborTimecardDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -40,15 +45,11 @@ public record LaborTimecardDeletedEvent [JsonPropertyName("data")] public LaborTimecardDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardDeletedEventData.cs b/src/Square/Types/LaborTimecardDeletedEventData.cs index 3a468f8f..d0141034 100644 --- a/src/Square/Types/LaborTimecardDeletedEventData.cs +++ b/src/Square/Types/LaborTimecardDeletedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborTimecardDeletedEventData +[Serializable] +public record LaborTimecardDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `timecard`. /// @@ -24,15 +29,11 @@ public record LaborTimecardDeletedEventData [JsonPropertyName("deleted")] public bool? Deleted { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardUpdatedEvent.cs b/src/Square/Types/LaborTimecardUpdatedEvent.cs index 5a48e68e..8a72574f 100644 --- a/src/Square/Types/LaborTimecardUpdatedEvent.cs +++ b/src/Square/Types/LaborTimecardUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Timecard](entity:Timecard) is updated. /// -public record LaborTimecardUpdatedEvent +[Serializable] +public record LaborTimecardUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the merchant associated with the event. /// @@ -40,15 +45,11 @@ public record LaborTimecardUpdatedEvent [JsonPropertyName("data")] public LaborTimecardUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardUpdatedEventData.cs b/src/Square/Types/LaborTimecardUpdatedEventData.cs index 8b99fde7..c1461736 100644 --- a/src/Square/Types/LaborTimecardUpdatedEventData.cs +++ b/src/Square/Types/LaborTimecardUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LaborTimecardUpdatedEventData +[Serializable] +public record LaborTimecardUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `timecard`. /// @@ -24,15 +29,11 @@ public record LaborTimecardUpdatedEventData [JsonPropertyName("object")] public LaborTimecardUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LaborTimecardUpdatedEventObject.cs b/src/Square/Types/LaborTimecardUpdatedEventObject.cs index 43b5bf53..3858937e 100644 --- a/src/Square/Types/LaborTimecardUpdatedEventObject.cs +++ b/src/Square/Types/LaborTimecardUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LaborTimecardUpdatedEventObject +[Serializable] +public record LaborTimecardUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated `Timecard`. /// [JsonPropertyName("timecard")] public Timecard? Timecard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LinkCustomerToGiftCardResponse.cs b/src/Square/Types/LinkCustomerToGiftCardResponse.cs index b4e025b2..504a4554 100644 --- a/src/Square/Types/LinkCustomerToGiftCardResponse.cs +++ b/src/Square/Types/LinkCustomerToGiftCardResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains the linked `GiftCard` object. If the request resulted in errors, /// the response contains a set of `Error` objects. /// -public record LinkCustomerToGiftCardResponse +[Serializable] +public record LinkCustomerToGiftCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record LinkCustomerToGiftCardResponse [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListBankAccountsResponse.cs b/src/Square/Types/ListBankAccountsResponse.cs index a0b8917f..87b1d3d7 100644 --- a/src/Square/Types/ListBankAccountsResponse.cs +++ b/src/Square/Types/ListBankAccountsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response object returned by ListBankAccounts. /// -public record ListBankAccountsResponse +[Serializable] +public record ListBankAccountsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -31,15 +36,11 @@ public record ListBankAccountsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListBookingCustomAttributeDefinitionsResponse.cs b/src/Square/Types/ListBookingCustomAttributeDefinitionsResponse.cs index df20691d..e54889a8 100644 --- a/src/Square/Types/ListBookingCustomAttributeDefinitionsResponse.cs +++ b/src/Square/Types/ListBookingCustomAttributeDefinitionsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attribute_definitions`, an empty object, or `errors` is present in the response. /// If additional results are available, the `cursor` field is also present along with `custom_attribute_definitions`. /// -public record ListBookingCustomAttributeDefinitionsResponse +[Serializable] +public record ListBookingCustomAttributeDefinitionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definitions. If no custom attribute definitions are found, /// Square returns an empty object (`{}`). @@ -32,15 +37,11 @@ public record ListBookingCustomAttributeDefinitionsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListBookingCustomAttributesResponse.cs b/src/Square/Types/ListBookingCustomAttributesResponse.cs index e7fd9a50..02a777cd 100644 --- a/src/Square/Types/ListBookingCustomAttributesResponse.cs +++ b/src/Square/Types/ListBookingCustomAttributesResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attributes`, an empty object, or `errors` is present in the response. If additional /// results are available, the `cursor` field is also present along with `custom_attributes`. /// -public record ListBookingCustomAttributesResponse +[Serializable] +public record ListBookingCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attributes. If `with_definitions` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field of each custom attribute. @@ -34,15 +39,11 @@ public record ListBookingCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListBookingsResponse.cs b/src/Square/Types/ListBookingsResponse.cs index e92bf589..aa3824e3 100644 --- a/src/Square/Types/ListBookingsResponse.cs +++ b/src/Square/Types/ListBookingsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListBookingsResponse +[Serializable] +public record ListBookingsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of targeted bookings. /// @@ -24,15 +29,11 @@ public record ListBookingsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListBreakTypesResponse.cs b/src/Square/Types/ListBreakTypesResponse.cs index dc84f2cb..7396c702 100644 --- a/src/Square/Types/ListBreakTypesResponse.cs +++ b/src/Square/Types/ListBreakTypesResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `BreakType` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record ListBreakTypesResponse +[Serializable] +public record ListBreakTypesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A page of `BreakType` results. /// @@ -30,15 +35,11 @@ public record ListBreakTypesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCardsResponse.cs b/src/Square/Types/ListCardsResponse.cs index 3c367087..9c074c48 100644 --- a/src/Square/Types/ListCardsResponse.cs +++ b/src/Square/Types/ListCardsResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the card field will not be /// present. /// -public record ListCardsResponse +[Serializable] +public record ListCardsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -34,15 +39,11 @@ public record ListCardsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCashDrawerShiftEventsResponse.cs b/src/Square/Types/ListCashDrawerShiftEventsResponse.cs index aa6274b1..ece44d55 100644 --- a/src/Square/Types/ListCashDrawerShiftEventsResponse.cs +++ b/src/Square/Types/ListCashDrawerShiftEventsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListCashDrawerShiftEventsResponse +[Serializable] +public record ListCashDrawerShiftEventsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Opaque cursor for fetching the next page. Cursor is not present in /// the last page of results. @@ -26,15 +31,11 @@ public record ListCashDrawerShiftEventsResponse [JsonPropertyName("cash_drawer_shift_events")] public IEnumerable? CashDrawerShiftEvents { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCashDrawerShiftsResponse.cs b/src/Square/Types/ListCashDrawerShiftsResponse.cs index c4c83c83..aeb94c5f 100644 --- a/src/Square/Types/ListCashDrawerShiftsResponse.cs +++ b/src/Square/Types/ListCashDrawerShiftsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListCashDrawerShiftsResponse +[Serializable] +public record ListCashDrawerShiftsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Opaque cursor for fetching the next page of results. Cursor is not /// present in the last page of results. @@ -26,15 +31,11 @@ public record ListCashDrawerShiftsResponse [JsonPropertyName("cash_drawer_shifts")] public IEnumerable? CashDrawerShifts { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCatalogResponse.cs b/src/Square/Types/ListCatalogResponse.cs index b9bed545..593047f5 100644 --- a/src/Square/Types/ListCatalogResponse.cs +++ b/src/Square/Types/ListCatalogResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListCatalogResponse +[Serializable] +public record ListCatalogResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -25,15 +30,11 @@ public record ListCatalogResponse [JsonPropertyName("objects")] public IEnumerable? Objects { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListChannelsResponse.cs b/src/Square/Types/ListChannelsResponse.cs index e6c0aff2..d9b024ab 100644 --- a/src/Square/Types/ListChannelsResponse.cs +++ b/src/Square/Types/ListChannelsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListChannelsResponse +[Serializable] +public record ListChannelsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -24,15 +29,11 @@ public record ListChannelsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCustomerCustomAttributeDefinitionsResponse.cs b/src/Square/Types/ListCustomerCustomAttributeDefinitionsResponse.cs index e3ce325a..db672183 100644 --- a/src/Square/Types/ListCustomerCustomAttributeDefinitionsResponse.cs +++ b/src/Square/Types/ListCustomerCustomAttributeDefinitionsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attribute_definitions`, an empty object, or `errors` is present in the response. /// If additional results are available, the `cursor` field is also present along with `custom_attribute_definitions`. /// -public record ListCustomerCustomAttributeDefinitionsResponse +[Serializable] +public record ListCustomerCustomAttributeDefinitionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definitions. If no custom attribute definitions are found, /// Square returns an empty object (`{}`). @@ -32,15 +37,11 @@ public record ListCustomerCustomAttributeDefinitionsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCustomerCustomAttributesResponse.cs b/src/Square/Types/ListCustomerCustomAttributesResponse.cs index 47ec74c7..5e6920db 100644 --- a/src/Square/Types/ListCustomerCustomAttributesResponse.cs +++ b/src/Square/Types/ListCustomerCustomAttributesResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attributes`, an empty object, or `errors` is present in the response. If additional /// results are available, the `cursor` field is also present along with `custom_attributes`. /// -public record ListCustomerCustomAttributesResponse +[Serializable] +public record ListCustomerCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attributes. If `with_definitions` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field of each custom attribute. @@ -34,15 +39,11 @@ public record ListCustomerCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCustomerGroupsResponse.cs b/src/Square/Types/ListCustomerGroupsResponse.cs index beee85f3..d661cbc3 100644 --- a/src/Square/Types/ListCustomerGroupsResponse.cs +++ b/src/Square/Types/ListCustomerGroupsResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `groups` is present in a given response (never both). /// -public record ListCustomerGroupsResponse +[Serializable] +public record ListCustomerGroupsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -34,15 +39,11 @@ public record ListCustomerGroupsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCustomerSegmentsResponse.cs b/src/Square/Types/ListCustomerSegmentsResponse.cs index d178dd58..2d330c7e 100644 --- a/src/Square/Types/ListCustomerSegmentsResponse.cs +++ b/src/Square/Types/ListCustomerSegmentsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Either `errors` or `segments` is present in a given response (never both). /// -public record ListCustomerSegmentsResponse +[Serializable] +public record ListCustomerSegmentsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -33,15 +38,11 @@ public record ListCustomerSegmentsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListCustomersResponse.cs b/src/Square/Types/ListCustomersResponse.cs index 7ff1ec55..2d76da7f 100644 --- a/src/Square/Types/ListCustomersResponse.cs +++ b/src/Square/Types/ListCustomersResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `customers` is present in a given response (never both). /// -public record ListCustomersResponse +[Serializable] +public record ListCustomersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -44,15 +49,11 @@ public record ListCustomersResponse [JsonPropertyName("count")] public long? Count { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListDeviceCodesResponse.cs b/src/Square/Types/ListDeviceCodesResponse.cs index 60b68289..7712fba8 100644 --- a/src/Square/Types/ListDeviceCodesResponse.cs +++ b/src/Square/Types/ListDeviceCodesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListDeviceCodesResponse +[Serializable] +public record ListDeviceCodesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -28,15 +33,11 @@ public record ListDeviceCodesResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListDevicesResponse.cs b/src/Square/Types/ListDevicesResponse.cs index b3171a6f..13a8951f 100644 --- a/src/Square/Types/ListDevicesResponse.cs +++ b/src/Square/Types/ListDevicesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListDevicesResponse +[Serializable] +public record ListDevicesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors that occurred during the request. /// @@ -26,15 +31,11 @@ public record ListDevicesResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListDisputeEvidenceResponse.cs b/src/Square/Types/ListDisputeEvidenceResponse.cs index a2b05b15..b7380c19 100644 --- a/src/Square/Types/ListDisputeEvidenceResponse.cs +++ b/src/Square/Types/ListDisputeEvidenceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the fields in a `ListDisputeEvidence` response. /// -public record ListDisputeEvidenceResponse +[Serializable] +public record ListDisputeEvidenceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of evidence previously uploaded to the specified dispute. /// @@ -28,15 +33,11 @@ public record ListDisputeEvidenceResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListDisputesResponse.cs b/src/Square/Types/ListDisputesResponse.cs index c24fb948..b19abcd9 100644 --- a/src/Square/Types/ListDisputesResponse.cs +++ b/src/Square/Types/ListDisputesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines fields in a `ListDisputes` response. /// -public record ListDisputesResponse +[Serializable] +public record ListDisputesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -28,15 +33,11 @@ public record ListDisputesResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListEmployeeWagesResponse.cs b/src/Square/Types/ListEmployeeWagesResponse.cs index 6f2a0122..8570c34d 100644 --- a/src/Square/Types/ListEmployeeWagesResponse.cs +++ b/src/Square/Types/ListEmployeeWagesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// The response to a request for a set of `EmployeeWage` objects. The response contains /// a set of `EmployeeWage` objects. /// -public record ListEmployeeWagesResponse +[Serializable] +public record ListEmployeeWagesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A page of `EmployeeWage` results. /// @@ -29,15 +34,11 @@ public record ListEmployeeWagesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListEmployeesResponse.cs b/src/Square/Types/ListEmployeesResponse.cs index 70fbf746..da2375ae 100644 --- a/src/Square/Types/ListEmployeesResponse.cs +++ b/src/Square/Types/ListEmployeesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListEmployeesResponse +[Serializable] +public record ListEmployeesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + [JsonPropertyName("employees")] public IEnumerable? Employees { get; set; } @@ -21,15 +26,11 @@ public record ListEmployeesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListEventTypesResponse.cs b/src/Square/Types/ListEventTypesResponse.cs index 4dbdd309..fd96a7e8 100644 --- a/src/Square/Types/ListEventTypesResponse.cs +++ b/src/Square/Types/ListEventTypesResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the event types field will not be /// present. /// -public record ListEventTypesResponse +[Serializable] +public record ListEventTypesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -31,15 +36,11 @@ public record ListEventTypesResponse [JsonPropertyName("metadata")] public IEnumerable? Metadata { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListGiftCardActivitiesResponse.cs b/src/Square/Types/ListGiftCardActivitiesResponse.cs index ad4813a6..d7a5c9f9 100644 --- a/src/Square/Types/ListGiftCardActivitiesResponse.cs +++ b/src/Square/Types/ListGiftCardActivitiesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a list of `GiftCardActivity` objects. If the request resulted in errors, /// the response contains a set of `Error` objects. /// -public record ListGiftCardActivitiesResponse +[Serializable] +public record ListGiftCardActivitiesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -31,15 +36,11 @@ public record ListGiftCardActivitiesResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListGiftCardsResponse.cs b/src/Square/Types/ListGiftCardsResponse.cs index 2f0a99af..2d82954a 100644 --- a/src/Square/Types/ListGiftCardsResponse.cs +++ b/src/Square/Types/ListGiftCardsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains a list of `GiftCard` objects. If the request resulted in errors, /// the response contains a set of `Error` objects. /// -public record ListGiftCardsResponse +[Serializable] +public record ListGiftCardsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -31,15 +36,11 @@ public record ListGiftCardsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListInvoicesResponse.cs b/src/Square/Types/ListInvoicesResponse.cs index a05df01e..5e307b48 100644 --- a/src/Square/Types/ListInvoicesResponse.cs +++ b/src/Square/Types/ListInvoicesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes a `ListInvoice` response. /// -public record ListInvoicesResponse +[Serializable] +public record ListInvoicesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The invoices retrieved. /// @@ -30,15 +35,11 @@ public record ListInvoicesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListJobsResponse.cs b/src/Square/Types/ListJobsResponse.cs index 64b9ad8e..19c29f96 100644 --- a/src/Square/Types/ListJobsResponse.cs +++ b/src/Square/Types/ListJobsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [ListJobs](api-endpoint:Team-ListJobs) response. Either `jobs` or `errors` /// is present in the response. If additional results are available, the `cursor` field is also present. /// -public record ListJobsResponse +[Serializable] +public record ListJobsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved jobs. A single paged response contains up to 100 jobs. /// @@ -30,15 +35,11 @@ public record ListJobsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListLocationBookingProfilesResponse.cs b/src/Square/Types/ListLocationBookingProfilesResponse.cs index d8b5cc97..2613ab35 100644 --- a/src/Square/Types/ListLocationBookingProfilesResponse.cs +++ b/src/Square/Types/ListLocationBookingProfilesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListLocationBookingProfilesResponse +[Serializable] +public record ListLocationBookingProfilesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of a seller's location booking profiles. /// @@ -24,15 +29,11 @@ public record ListLocationBookingProfilesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListLocationCustomAttributeDefinitionsResponse.cs b/src/Square/Types/ListLocationCustomAttributeDefinitionsResponse.cs index 0d19bfa5..97809358 100644 --- a/src/Square/Types/ListLocationCustomAttributeDefinitionsResponse.cs +++ b/src/Square/Types/ListLocationCustomAttributeDefinitionsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attribute_definitions`, an empty object, or `errors` is present in the response. /// If additional results are available, the `cursor` field is also present along with `custom_attribute_definitions`. /// -public record ListLocationCustomAttributeDefinitionsResponse +[Serializable] +public record ListLocationCustomAttributeDefinitionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definitions. If no custom attribute definitions are found, /// Square returns an empty object (`{}`). @@ -32,15 +37,11 @@ public record ListLocationCustomAttributeDefinitionsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListLocationCustomAttributesResponse.cs b/src/Square/Types/ListLocationCustomAttributesResponse.cs index 179409ad..a20e804e 100644 --- a/src/Square/Types/ListLocationCustomAttributesResponse.cs +++ b/src/Square/Types/ListLocationCustomAttributesResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attributes`, an empty object, or `errors` is present in the response. If additional /// results are available, the `cursor` field is also present along with `custom_attributes`. /// -public record ListLocationCustomAttributesResponse +[Serializable] +public record ListLocationCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attributes. If `with_definitions` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field of each custom attribute. @@ -33,15 +38,11 @@ public record ListLocationCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListLocationsResponse.cs b/src/Square/Types/ListLocationsResponse.cs index 9da071e0..6189cecc 100644 --- a/src/Square/Types/ListLocationsResponse.cs +++ b/src/Square/Types/ListLocationsResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `locations` is present in a given response (never both). /// -public record ListLocationsResponse +[Serializable] +public record ListLocationsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record ListLocationsResponse [JsonPropertyName("locations")] public IEnumerable? Locations { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListLoyaltyProgramsResponse.cs b/src/Square/Types/ListLoyaltyProgramsResponse.cs index 28e154b7..c514533c 100644 --- a/src/Square/Types/ListLoyaltyProgramsResponse.cs +++ b/src/Square/Types/ListLoyaltyProgramsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that contains all loyalty programs. /// -public record ListLoyaltyProgramsResponse +[Serializable] +public record ListLoyaltyProgramsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record ListLoyaltyProgramsResponse [JsonPropertyName("programs")] public IEnumerable? Programs { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListLoyaltyPromotionsResponse.cs b/src/Square/Types/ListLoyaltyPromotionsResponse.cs index 05dc5c40..75fdf8c1 100644 --- a/src/Square/Types/ListLoyaltyPromotionsResponse.cs +++ b/src/Square/Types/ListLoyaltyPromotionsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// One of `loyalty_promotions`, an empty object, or `errors` is present in the response. /// If additional results are available, the `cursor` field is also present along with `loyalty_promotions`. /// -public record ListLoyaltyPromotionsResponse +[Serializable] +public record ListLoyaltyPromotionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -31,15 +36,11 @@ public record ListLoyaltyPromotionsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListMerchantCustomAttributeDefinitionsResponse.cs b/src/Square/Types/ListMerchantCustomAttributeDefinitionsResponse.cs index 499b569f..69c86d37 100644 --- a/src/Square/Types/ListMerchantCustomAttributeDefinitionsResponse.cs +++ b/src/Square/Types/ListMerchantCustomAttributeDefinitionsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attribute_definitions`, an empty object, or `errors` is present in the response. /// If additional results are available, the `cursor` field is also present along with `custom_attribute_definitions`. /// -public record ListMerchantCustomAttributeDefinitionsResponse +[Serializable] +public record ListMerchantCustomAttributeDefinitionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definitions. If no custom attribute definitions are found, /// Square returns an empty object (`{}`). @@ -32,15 +37,11 @@ public record ListMerchantCustomAttributeDefinitionsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListMerchantCustomAttributesResponse.cs b/src/Square/Types/ListMerchantCustomAttributesResponse.cs index 6794b333..3349fcb3 100644 --- a/src/Square/Types/ListMerchantCustomAttributesResponse.cs +++ b/src/Square/Types/ListMerchantCustomAttributesResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// Either `custom_attributes`, an empty object, or `errors` is present in the response. If additional /// results are available, the `cursor` field is also present along with `custom_attributes`. /// -public record ListMerchantCustomAttributesResponse +[Serializable] +public record ListMerchantCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attributes. If `with_definitions` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field of each custom attribute. @@ -33,15 +38,11 @@ public record ListMerchantCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListMerchantsResponse.cs b/src/Square/Types/ListMerchantsResponse.cs index 0930e8ab..abaf696e 100644 --- a/src/Square/Types/ListMerchantsResponse.cs +++ b/src/Square/Types/ListMerchantsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response object returned by the [ListMerchant](api-endpoint:Merchants-ListMerchants) endpoint. /// -public record ListMerchantsResponse +[Serializable] +public record ListMerchantsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -27,15 +32,11 @@ public record ListMerchantsResponse [JsonPropertyName("cursor")] public int? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListOrderCustomAttributeDefinitionsResponse.cs b/src/Square/Types/ListOrderCustomAttributeDefinitionsResponse.cs index 7b7ad257..c4c36539 100644 --- a/src/Square/Types/ListOrderCustomAttributeDefinitionsResponse.cs +++ b/src/Square/Types/ListOrderCustomAttributeDefinitionsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from listing order custom attribute definitions. /// -public record ListOrderCustomAttributeDefinitionsResponse +[Serializable] +public record ListOrderCustomAttributeDefinitionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definitions. If no custom attribute definitions are found, Square returns an empty object (`{}`). /// @@ -30,15 +35,11 @@ public record ListOrderCustomAttributeDefinitionsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListOrderCustomAttributesResponse.cs b/src/Square/Types/ListOrderCustomAttributesResponse.cs index 391f471b..074a715f 100644 --- a/src/Square/Types/ListOrderCustomAttributesResponse.cs +++ b/src/Square/Types/ListOrderCustomAttributesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from listing order custom attributes. /// -public record ListOrderCustomAttributesResponse +[Serializable] +public record ListOrderCustomAttributesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attributes. If no custom attribute are found, Square returns an empty object (`{}`). /// @@ -29,15 +34,11 @@ public record ListOrderCustomAttributesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListPaymentLinksResponse.cs b/src/Square/Types/ListPaymentLinksResponse.cs index 3e6d0909..77ad39ed 100644 --- a/src/Square/Types/ListPaymentLinksResponse.cs +++ b/src/Square/Types/ListPaymentLinksResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListPaymentLinksResponse +[Serializable] +public record ListPaymentLinksResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors that occurred during the request. /// @@ -26,15 +31,11 @@ public record ListPaymentLinksResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListPaymentRefundsRequestSortField.cs b/src/Square/Types/ListPaymentRefundsRequestSortField.cs index c3bdf57b..b1be15d9 100644 --- a/src/Square/Types/ListPaymentRefundsRequestSortField.cs +++ b/src/Square/Types/ListPaymentRefundsRequestSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ListPaymentRefundsRequestSortField : IStringEnum { public static readonly ListPaymentRefundsRequestSortField CreatedAt = new(Values.CreatedAt); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CreatedAt = "CREATED_AT"; diff --git a/src/Square/Types/ListPaymentRefundsResponse.cs b/src/Square/Types/ListPaymentRefundsResponse.cs index 74fc2b94..012515c3 100644 --- a/src/Square/Types/ListPaymentRefundsResponse.cs +++ b/src/Square/Types/ListPaymentRefundsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Either `errors` or `refunds` is present in a given response (never both). /// -public record ListPaymentRefundsResponse +[Serializable] +public record ListPaymentRefundsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -32,15 +37,11 @@ public record ListPaymentRefundsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListPaymentsRequestSortField.cs b/src/Square/Types/ListPaymentsRequestSortField.cs index 23a7db77..bd4a5580 100644 --- a/src/Square/Types/ListPaymentsRequestSortField.cs +++ b/src/Square/Types/ListPaymentsRequestSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ListPaymentsRequestSortField : IStringEnum { public static readonly ListPaymentsRequestSortField CreatedAt = new(Values.CreatedAt); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CreatedAt = "CREATED_AT"; diff --git a/src/Square/Types/ListPaymentsResponse.cs b/src/Square/Types/ListPaymentsResponse.cs index b09d625c..d53d1788 100644 --- a/src/Square/Types/ListPaymentsResponse.cs +++ b/src/Square/Types/ListPaymentsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the response returned by [ListPayments](api-endpoint:Payments-ListPayments). /// -public record ListPaymentsResponse +[Serializable] +public record ListPaymentsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -30,15 +35,11 @@ public record ListPaymentsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListPayoutEntriesResponse.cs b/src/Square/Types/ListPayoutEntriesResponse.cs index 5f039af9..f2912dc9 100644 --- a/src/Square/Types/ListPayoutEntriesResponse.cs +++ b/src/Square/Types/ListPayoutEntriesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response to retrieve payout records entries. /// -public record ListPayoutEntriesResponse +[Serializable] +public record ListPayoutEntriesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested list of payout entries, ordered with the given or default sort order. /// @@ -28,15 +33,11 @@ public record ListPayoutEntriesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListPayoutsResponse.cs b/src/Square/Types/ListPayoutsResponse.cs index de684d7c..1b1b348f 100644 --- a/src/Square/Types/ListPayoutsResponse.cs +++ b/src/Square/Types/ListPayoutsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response to retrieve payout records entries. /// -public record ListPayoutsResponse +[Serializable] +public record ListPayoutsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested list of payouts. /// @@ -28,15 +33,11 @@ public record ListPayoutsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListSitesResponse.cs b/src/Square/Types/ListSitesResponse.cs index d3eeb654..adbce503 100644 --- a/src/Square/Types/ListSitesResponse.cs +++ b/src/Square/Types/ListSitesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a `ListSites` response. The response can include either `sites` or `errors`. /// -public record ListSitesResponse +[Serializable] +public record ListSitesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record ListSitesResponse [JsonPropertyName("sites")] public IEnumerable? Sites { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListSubscriptionEventsResponse.cs b/src/Square/Types/ListSubscriptionEventsResponse.cs index 16e712cb..ccd259f9 100644 --- a/src/Square/Types/ListSubscriptionEventsResponse.cs +++ b/src/Square/Types/ListSubscriptionEventsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [ListSubscriptionEvents](api-endpoint:Subscriptions-ListSubscriptionEvents). /// -public record ListSubscriptionEventsResponse +[Serializable] +public record ListSubscriptionEventsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -32,15 +37,11 @@ public record ListSubscriptionEventsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListTeamMemberBookingProfilesResponse.cs b/src/Square/Types/ListTeamMemberBookingProfilesResponse.cs index ccafebb4..4a536aad 100644 --- a/src/Square/Types/ListTeamMemberBookingProfilesResponse.cs +++ b/src/Square/Types/ListTeamMemberBookingProfilesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record ListTeamMemberBookingProfilesResponse +[Serializable] +public record ListTeamMemberBookingProfilesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of team member booking profiles. The results are returned in the ascending order of the time /// when the team member booking profiles were last updated. Multiple booking profiles updated at the same time @@ -26,15 +31,11 @@ public record ListTeamMemberBookingProfilesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListTeamMemberWagesResponse.cs b/src/Square/Types/ListTeamMemberWagesResponse.cs index 2c14e7ce..a2ad076a 100644 --- a/src/Square/Types/ListTeamMemberWagesResponse.cs +++ b/src/Square/Types/ListTeamMemberWagesResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// The response to a request for a set of `TeamMemberWage` objects. The response contains /// a set of `TeamMemberWage` objects. /// -public record ListTeamMemberWagesResponse +[Serializable] +public record ListTeamMemberWagesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A page of `TeamMemberWage` results. /// @@ -29,15 +34,11 @@ public record ListTeamMemberWagesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListTransactionsResponse.cs b/src/Square/Types/ListTransactionsResponse.cs index a4c85514..c6fd3f91 100644 --- a/src/Square/Types/ListTransactionsResponse.cs +++ b/src/Square/Types/ListTransactionsResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// One of `errors` or `transactions` is present in a given response (never both). /// -public record ListTransactionsResponse +[Serializable] +public record ListTransactionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -34,15 +39,11 @@ public record ListTransactionsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListWebhookEventTypesResponse.cs b/src/Square/Types/ListWebhookEventTypesResponse.cs index 8dd115a5..6df9dba3 100644 --- a/src/Square/Types/ListWebhookEventTypesResponse.cs +++ b/src/Square/Types/ListWebhookEventTypesResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the event types field will not be /// present. /// -public record ListWebhookEventTypesResponse +[Serializable] +public record ListWebhookEventTypesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -31,15 +36,11 @@ public record ListWebhookEventTypesResponse [JsonPropertyName("metadata")] public IEnumerable? Metadata { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListWebhookSubscriptionsResponse.cs b/src/Square/Types/ListWebhookSubscriptionsResponse.cs index 04d80462..d366718c 100644 --- a/src/Square/Types/ListWebhookSubscriptionsResponse.cs +++ b/src/Square/Types/ListWebhookSubscriptionsResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the subscriptions field will not be /// present. /// -public record ListWebhookSubscriptionsResponse +[Serializable] +public record ListWebhookSubscriptionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -34,15 +39,11 @@ public record ListWebhookSubscriptionsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ListWorkweekConfigsResponse.cs b/src/Square/Types/ListWorkweekConfigsResponse.cs index 28412ab5..af99fda9 100644 --- a/src/Square/Types/ListWorkweekConfigsResponse.cs +++ b/src/Square/Types/ListWorkweekConfigsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `WorkweekConfig` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record ListWorkweekConfigsResponse +[Serializable] +public record ListWorkweekConfigsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A page of `WorkweekConfig` results. /// @@ -30,15 +35,11 @@ public record ListWorkweekConfigsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Location.cs b/src/Square/Types/Location.cs index db0bf016..71b965a4 100644 --- a/src/Square/Types/Location.cs +++ b/src/Square/Types/Location.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents one of a business' [locations](https://developer.squareup.com/docs/locations-api). /// -public record Location +[Serializable] +public record Location : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A short generated string of letters and numbers that uniquely identifies this location instance. /// @@ -200,15 +205,11 @@ public record Location [JsonPropertyName("tax_ids")] public TaxIds? TaxIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationBookingProfile.cs b/src/Square/Types/LocationBookingProfile.cs index d65f92ba..e94db815 100644 --- a/src/Square/Types/LocationBookingProfile.cs +++ b/src/Square/Types/LocationBookingProfile.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The booking profile of a seller's location, including the location's ID and whether the location is enabled for online booking. /// -public record LocationBookingProfile +[Serializable] +public record LocationBookingProfile : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [location](entity:Location). /// @@ -27,15 +32,11 @@ public record LocationBookingProfile [JsonPropertyName("online_booking_enabled")] public bool? OnlineBookingEnabled { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCapability.cs b/src/Square/Types/LocationCapability.cs index 548c6bee..69bb20b2 100644 --- a/src/Square/Types/LocationCapability.cs +++ b/src/Square/Types/LocationCapability.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LocationCapability : IStringEnum { public static readonly LocationCapability CreditCardProcessing = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CreditCardProcessing = "CREDIT_CARD_PROCESSING"; diff --git a/src/Square/Types/LocationCreatedEvent.cs b/src/Square/Types/LocationCreatedEvent.cs index 62e38c96..2cd0dd8e 100644 --- a/src/Square/Types/LocationCreatedEvent.cs +++ b/src/Square/Types/LocationCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Location](entity:Location) is created. /// -public record LocationCreatedEvent +[Serializable] +public record LocationCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -46,15 +51,11 @@ public record LocationCreatedEvent [JsonPropertyName("data")] public LocationCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCreatedEventData.cs b/src/Square/Types/LocationCreatedEventData.cs index 378a551d..a56203e7 100644 --- a/src/Square/Types/LocationCreatedEventData.cs +++ b/src/Square/Types/LocationCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LocationCreatedEventData +[Serializable] +public record LocationCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"location"`. /// @@ -18,15 +23,11 @@ public record LocationCreatedEventData [JsonPropertyName("id")] public string? Id { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeDefinitionOwnedCreatedEvent.cs b/src/Square/Types/LocationCustomAttributeDefinitionOwnedCreatedEvent.cs index 59e1173a..8b7a1a29 100644 --- a/src/Square/Types/LocationCustomAttributeDefinitionOwnedCreatedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeDefinitionOwnedCreatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a location [custom attribute definition](entity:CustomAttributeDefinition) /// is created by the subscribing application. /// -public record LocationCustomAttributeDefinitionOwnedCreatedEvent +[Serializable] +public record LocationCustomAttributeDefinitionOwnedCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -41,15 +46,11 @@ public record LocationCustomAttributeDefinitionOwnedCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeDefinitionOwnedDeletedEvent.cs b/src/Square/Types/LocationCustomAttributeDefinitionOwnedDeletedEvent.cs index b3071302..3f4a5fed 100644 --- a/src/Square/Types/LocationCustomAttributeDefinitionOwnedDeletedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeDefinitionOwnedDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// created by the subscribing application is deleted. A custom attribute definition can only be deleted by /// the application that created it. /// -public record LocationCustomAttributeDefinitionOwnedDeletedEvent +[Serializable] +public record LocationCustomAttributeDefinitionOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record LocationCustomAttributeDefinitionOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeDefinitionOwnedUpdatedEvent.cs b/src/Square/Types/LocationCustomAttributeDefinitionOwnedUpdatedEvent.cs index fe332990..06b62e55 100644 --- a/src/Square/Types/LocationCustomAttributeDefinitionOwnedUpdatedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeDefinitionOwnedUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// created by the subscribing application is updated. A custom attribute definition can only be updated /// by the application that created it. /// -public record LocationCustomAttributeDefinitionOwnedUpdatedEvent +[Serializable] +public record LocationCustomAttributeDefinitionOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record LocationCustomAttributeDefinitionOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeDefinitionVisibleCreatedEvent.cs b/src/Square/Types/LocationCustomAttributeDefinitionVisibleCreatedEvent.cs index 76275114..325bccc2 100644 --- a/src/Square/Types/LocationCustomAttributeDefinitionVisibleCreatedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeDefinitionVisibleCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// creates a custom attribute definition or another application creates a custom attribute definition whose /// `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record LocationCustomAttributeDefinitionVisibleCreatedEvent +[Serializable] +public record LocationCustomAttributeDefinitionVisibleCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record LocationCustomAttributeDefinitionVisibleCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeDefinitionVisibleDeletedEvent.cs b/src/Square/Types/LocationCustomAttributeDefinitionVisibleDeletedEvent.cs index 1d19029f..c0bdacfb 100644 --- a/src/Square/Types/LocationCustomAttributeDefinitionVisibleDeletedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeDefinitionVisibleDeletedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// a custom attribute definition or when another application deletes a custom attribute definition whose /// `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record LocationCustomAttributeDefinitionVisibleDeletedEvent +[Serializable] +public record LocationCustomAttributeDefinitionVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -44,15 +49,11 @@ public record LocationCustomAttributeDefinitionVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeDefinitionVisibleUpdatedEvent.cs b/src/Square/Types/LocationCustomAttributeDefinitionVisibleUpdatedEvent.cs index 9d2ff767..2ea37699 100644 --- a/src/Square/Types/LocationCustomAttributeDefinitionVisibleUpdatedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeDefinitionVisibleUpdatedEvent.cs @@ -11,8 +11,13 @@ namespace Square; /// definition or when another application updates a custom attribute definition whose `visibility` is /// `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record LocationCustomAttributeDefinitionVisibleUpdatedEvent +[Serializable] +public record LocationCustomAttributeDefinitionVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -44,15 +49,11 @@ public record LocationCustomAttributeDefinitionVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeOwnedDeletedEvent.cs b/src/Square/Types/LocationCustomAttributeOwnedDeletedEvent.cs index a092c51c..8e6806a3 100644 --- a/src/Square/Types/LocationCustomAttributeOwnedDeletedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeOwnedDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// application that created the corresponding [custom attribute definition](entity:CustomAttributeDefinition). /// Custom attributes whose `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be deleted by any application. /// -public record LocationCustomAttributeOwnedDeletedEvent +[Serializable] +public record LocationCustomAttributeOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record LocationCustomAttributeOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeOwnedUpdatedEvent.cs b/src/Square/Types/LocationCustomAttributeOwnedUpdatedEvent.cs index d5c57bdf..8855bd6e 100644 --- a/src/Square/Types/LocationCustomAttributeOwnedUpdatedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeOwnedUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// the corresponding [custom attribute definition](entity:CustomAttributeDefinition). Custom attributes whose /// `visibility` is `VISIBILITY_READ_WRITE_VALUES` can be created or updated by any application. /// -public record LocationCustomAttributeOwnedUpdatedEvent +[Serializable] +public record LocationCustomAttributeOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record LocationCustomAttributeOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeVisibleDeletedEvent.cs b/src/Square/Types/LocationCustomAttributeVisibleDeletedEvent.cs index 1047618f..0ad73917 100644 --- a/src/Square/Types/LocationCustomAttributeVisibleDeletedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeVisibleDeletedEvent.cs @@ -15,8 +15,13 @@ namespace Square; /// `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be deleted by the owner. Custom attributes are owned /// by the application that created the corresponding [custom attribute definition](entity:CustomAttributeDefinition). /// -public record LocationCustomAttributeVisibleDeletedEvent +[Serializable] +public record LocationCustomAttributeVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -48,15 +53,11 @@ public record LocationCustomAttributeVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationCustomAttributeVisibleUpdatedEvent.cs b/src/Square/Types/LocationCustomAttributeVisibleUpdatedEvent.cs index 4c02f298..7d395fad 100644 --- a/src/Square/Types/LocationCustomAttributeVisibleUpdatedEvent.cs +++ b/src/Square/Types/LocationCustomAttributeVisibleUpdatedEvent.cs @@ -15,8 +15,13 @@ namespace Square; /// `VISIBILITY_READ_ONLY` or `VISIBILITY_HIDDEN` can only be created or updated by the owner. Custom attributes are owned /// by the application that created the corresponding [custom attribute definition](entity:CustomAttributeDefinition). /// -public record LocationCustomAttributeVisibleUpdatedEvent +[Serializable] +public record LocationCustomAttributeVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -48,15 +53,11 @@ public record LocationCustomAttributeVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationSettingsUpdatedEvent.cs b/src/Square/Types/LocationSettingsUpdatedEvent.cs index b0b25606..cccd6411 100644 --- a/src/Square/Types/LocationSettingsUpdatedEvent.cs +++ b/src/Square/Types/LocationSettingsUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when online checkout location settings are updated /// -public record LocationSettingsUpdatedEvent +[Serializable] +public record LocationSettingsUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record LocationSettingsUpdatedEvent [JsonPropertyName("data")] public LocationSettingsUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationSettingsUpdatedEventData.cs b/src/Square/Types/LocationSettingsUpdatedEventData.cs index 8fed25f7..13d70065 100644 --- a/src/Square/Types/LocationSettingsUpdatedEventData.cs +++ b/src/Square/Types/LocationSettingsUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LocationSettingsUpdatedEventData +[Serializable] +public record LocationSettingsUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the updated object’s type, `"online_checkout.location_settings"`. /// @@ -24,15 +29,11 @@ public record LocationSettingsUpdatedEventData [JsonPropertyName("object")] public LocationSettingsUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationSettingsUpdatedEventObject.cs b/src/Square/Types/LocationSettingsUpdatedEventObject.cs index f58cc9ef..a86d1f55 100644 --- a/src/Square/Types/LocationSettingsUpdatedEventObject.cs +++ b/src/Square/Types/LocationSettingsUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LocationSettingsUpdatedEventObject +[Serializable] +public record LocationSettingsUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated location settings. /// [JsonPropertyName("location_settings")] public CheckoutLocationSettings? LocationSettings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationStatus.cs b/src/Square/Types/LocationStatus.cs index 3a79b7bc..be10e036 100644 --- a/src/Square/Types/LocationStatus.cs +++ b/src/Square/Types/LocationStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LocationStatus : IStringEnum { public static readonly LocationStatus Active = new(Values.Active); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/LocationType.cs b/src/Square/Types/LocationType.cs index 4b836d8b..607eec75 100644 --- a/src/Square/Types/LocationType.cs +++ b/src/Square/Types/LocationType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LocationType : IStringEnum { public static readonly LocationType Physical = new(Values.Physical); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Physical = "PHYSICAL"; diff --git a/src/Square/Types/LocationUpdatedEvent.cs b/src/Square/Types/LocationUpdatedEvent.cs index 073a81e0..08292d24 100644 --- a/src/Square/Types/LocationUpdatedEvent.cs +++ b/src/Square/Types/LocationUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Location](entity:Location) is updated. /// -public record LocationUpdatedEvent +[Serializable] +public record LocationUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -46,15 +51,11 @@ public record LocationUpdatedEvent [JsonPropertyName("data")] public LocationUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LocationUpdatedEventData.cs b/src/Square/Types/LocationUpdatedEventData.cs index e4e673a5..9e93f5ae 100644 --- a/src/Square/Types/LocationUpdatedEventData.cs +++ b/src/Square/Types/LocationUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record LocationUpdatedEventData +[Serializable] +public record LocationUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"location"`. /// @@ -18,15 +23,11 @@ public record LocationUpdatedEventData [JsonPropertyName("id")] public string? Id { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccount.cs b/src/Square/Types/LoyaltyAccount.cs index 8cac06c1..1559a76f 100644 --- a/src/Square/Types/LoyaltyAccount.cs +++ b/src/Square/Types/LoyaltyAccount.cs @@ -8,8 +8,13 @@ namespace Square; /// Describes a loyalty account in a [loyalty program](entity:LoyaltyProgram). For more information, see /// [Create and Retrieve Loyalty Accounts](https://developer.squareup.com/docs/loyalty-api/loyalty-accounts). /// -public record LoyaltyAccount +[Serializable] +public record LoyaltyAccount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the loyalty account. /// @@ -90,15 +95,11 @@ public record LoyaltyAccount [JsonPropertyName("expiring_point_deadlines")] public IEnumerable? ExpiringPointDeadlines { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountCreatedEvent.cs b/src/Square/Types/LoyaltyAccountCreatedEvent.cs index 3bec437e..7864a7ac 100644 --- a/src/Square/Types/LoyaltyAccountCreatedEvent.cs +++ b/src/Square/Types/LoyaltyAccountCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty account](entity:LoyaltyAccount) is created. /// -public record LoyaltyAccountCreatedEvent +[Serializable] +public record LoyaltyAccountCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyAccountCreatedEvent [JsonPropertyName("data")] public LoyaltyAccountCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountCreatedEventData.cs b/src/Square/Types/LoyaltyAccountCreatedEventData.cs index 72b98e66..40331694 100644 --- a/src/Square/Types/LoyaltyAccountCreatedEventData.cs +++ b/src/Square/Types/LoyaltyAccountCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.account.created` event. /// -public record LoyaltyAccountCreatedEventData +[Serializable] +public record LoyaltyAccountCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_account`. /// @@ -27,15 +32,11 @@ public record LoyaltyAccountCreatedEventData [JsonPropertyName("object")] public LoyaltyAccountCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountCreatedEventObject.cs b/src/Square/Types/LoyaltyAccountCreatedEventObject.cs index a480b023..39e41009 100644 --- a/src/Square/Types/LoyaltyAccountCreatedEventObject.cs +++ b/src/Square/Types/LoyaltyAccountCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LoyaltyAccountCreatedEventObject +[Serializable] +public record LoyaltyAccountCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty account that was created. /// [JsonPropertyName("loyalty_account")] public LoyaltyAccount? LoyaltyAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountDeletedEvent.cs b/src/Square/Types/LoyaltyAccountDeletedEvent.cs index ff3c24b9..dd11bedb 100644 --- a/src/Square/Types/LoyaltyAccountDeletedEvent.cs +++ b/src/Square/Types/LoyaltyAccountDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty account](entity:LoyaltyAccount) is deleted. /// -public record LoyaltyAccountDeletedEvent +[Serializable] +public record LoyaltyAccountDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyAccountDeletedEvent [JsonPropertyName("data")] public LoyaltyAccountDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountDeletedEventData.cs b/src/Square/Types/LoyaltyAccountDeletedEventData.cs index 6292702e..001a7c5c 100644 --- a/src/Square/Types/LoyaltyAccountDeletedEventData.cs +++ b/src/Square/Types/LoyaltyAccountDeletedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.account.deleted` event. /// -public record LoyaltyAccountDeletedEventData +[Serializable] +public record LoyaltyAccountDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_account`. /// @@ -27,15 +32,11 @@ public record LoyaltyAccountDeletedEventData [JsonPropertyName("object")] public LoyaltyAccountDeletedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountDeletedEventObject.cs b/src/Square/Types/LoyaltyAccountDeletedEventObject.cs index 2436b715..221a24e5 100644 --- a/src/Square/Types/LoyaltyAccountDeletedEventObject.cs +++ b/src/Square/Types/LoyaltyAccountDeletedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LoyaltyAccountDeletedEventObject +[Serializable] +public record LoyaltyAccountDeletedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty account that was deleted. /// [JsonPropertyName("loyalty_account")] public LoyaltyAccount? LoyaltyAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountExpiringPointDeadline.cs b/src/Square/Types/LoyaltyAccountExpiringPointDeadline.cs index 7e02c564..7c2bfe05 100644 --- a/src/Square/Types/LoyaltyAccountExpiringPointDeadline.cs +++ b/src/Square/Types/LoyaltyAccountExpiringPointDeadline.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a set of points for a loyalty account that are scheduled to expire on a specific date. /// -public record LoyaltyAccountExpiringPointDeadline +[Serializable] +public record LoyaltyAccountExpiringPointDeadline : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The number of points scheduled to expire at the `expires_at` timestamp. /// @@ -21,15 +26,11 @@ public record LoyaltyAccountExpiringPointDeadline [JsonPropertyName("expires_at")] public required string ExpiresAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountMapping.cs b/src/Square/Types/LoyaltyAccountMapping.cs index c4c7bf6f..306cee7e 100644 --- a/src/Square/Types/LoyaltyAccountMapping.cs +++ b/src/Square/Types/LoyaltyAccountMapping.cs @@ -10,8 +10,13 @@ namespace Square; /// Currently, a loyalty account can only be mapped to a buyer by phone number. For more information, see /// [Loyalty Overview](https://developer.squareup.com/docs/loyalty/overview). /// -public record LoyaltyAccountMapping +[Serializable] +public record LoyaltyAccountMapping : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the mapping. /// @@ -32,15 +37,11 @@ public record LoyaltyAccountMapping [JsonPropertyName("phone_number")] public string? PhoneNumber { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountUpdatedEvent.cs b/src/Square/Types/LoyaltyAccountUpdatedEvent.cs index 0f6e09d3..e148b225 100644 --- a/src/Square/Types/LoyaltyAccountUpdatedEvent.cs +++ b/src/Square/Types/LoyaltyAccountUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty account](entity:LoyaltyAccount) is updated. /// -public record LoyaltyAccountUpdatedEvent +[Serializable] +public record LoyaltyAccountUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyAccountUpdatedEvent [JsonPropertyName("data")] public LoyaltyAccountUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountUpdatedEventData.cs b/src/Square/Types/LoyaltyAccountUpdatedEventData.cs index 0af0e66f..6944ba87 100644 --- a/src/Square/Types/LoyaltyAccountUpdatedEventData.cs +++ b/src/Square/Types/LoyaltyAccountUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.account.updated` event. /// -public record LoyaltyAccountUpdatedEventData +[Serializable] +public record LoyaltyAccountUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_account`. /// @@ -27,15 +32,11 @@ public record LoyaltyAccountUpdatedEventData [JsonPropertyName("object")] public LoyaltyAccountUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyAccountUpdatedEventObject.cs b/src/Square/Types/LoyaltyAccountUpdatedEventObject.cs index 3ee7846e..f520ddb2 100644 --- a/src/Square/Types/LoyaltyAccountUpdatedEventObject.cs +++ b/src/Square/Types/LoyaltyAccountUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LoyaltyAccountUpdatedEventObject +[Serializable] +public record LoyaltyAccountUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty account that was updated. /// [JsonPropertyName("loyalty_account")] public LoyaltyAccount? LoyaltyAccount { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEvent.cs b/src/Square/Types/LoyaltyEvent.cs index 6a69edec..440d5630 100644 --- a/src/Square/Types/LoyaltyEvent.cs +++ b/src/Square/Types/LoyaltyEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Provides information about a loyalty event. /// For more information, see [Search for Balance-Changing Loyalty Events](https://developer.squareup.com/docs/loyalty-api/loyalty-events). /// -public record LoyaltyEvent +[Serializable] +public record LoyaltyEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the loyalty event. /// @@ -100,15 +105,11 @@ public record LoyaltyEvent [JsonPropertyName("accumulate_promotion_points")] public LoyaltyEventAccumulatePromotionPoints? AccumulatePromotionPoints { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventAccumulatePoints.cs b/src/Square/Types/LoyaltyEventAccumulatePoints.cs index d10ac09b..d1e9751c 100644 --- a/src/Square/Types/LoyaltyEventAccumulatePoints.cs +++ b/src/Square/Types/LoyaltyEventAccumulatePoints.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `ACCUMULATE_POINTS`. /// -public record LoyaltyEventAccumulatePoints +[Serializable] +public record LoyaltyEventAccumulatePoints : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -29,15 +34,11 @@ public record LoyaltyEventAccumulatePoints [JsonPropertyName("order_id")] public string? OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventAccumulatePromotionPoints.cs b/src/Square/Types/LoyaltyEventAccumulatePromotionPoints.cs index 54c93388..3136ca0f 100644 --- a/src/Square/Types/LoyaltyEventAccumulatePromotionPoints.cs +++ b/src/Square/Types/LoyaltyEventAccumulatePromotionPoints.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `ACCUMULATE_PROMOTION_POINTS`. /// -public record LoyaltyEventAccumulatePromotionPoints +[Serializable] +public record LoyaltyEventAccumulatePromotionPoints : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -38,15 +43,11 @@ public record LoyaltyEventAccumulatePromotionPoints [JsonPropertyName("order_id")] public string? OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventAdjustPoints.cs b/src/Square/Types/LoyaltyEventAdjustPoints.cs index 9d7c6f07..cb0bb670 100644 --- a/src/Square/Types/LoyaltyEventAdjustPoints.cs +++ b/src/Square/Types/LoyaltyEventAdjustPoints.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `ADJUST_POINTS`. /// -public record LoyaltyEventAdjustPoints +[Serializable] +public record LoyaltyEventAdjustPoints : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -28,15 +33,11 @@ public record LoyaltyEventAdjustPoints [JsonPropertyName("reason")] public string? Reason { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventCreateReward.cs b/src/Square/Types/LoyaltyEventCreateReward.cs index 52f5e87d..9ddc851a 100644 --- a/src/Square/Types/LoyaltyEventCreateReward.cs +++ b/src/Square/Types/LoyaltyEventCreateReward.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `CREATE_REWARD`. /// -public record LoyaltyEventCreateReward +[Serializable] +public record LoyaltyEventCreateReward : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -31,15 +36,11 @@ public record LoyaltyEventCreateReward [JsonPropertyName("points")] public int? Points { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventCreatedEvent.cs b/src/Square/Types/LoyaltyEventCreatedEvent.cs index 8a7a406e..850b9d57 100644 --- a/src/Square/Types/LoyaltyEventCreatedEvent.cs +++ b/src/Square/Types/LoyaltyEventCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty event](entity:LoyaltyEvent) is created. /// -public record LoyaltyEventCreatedEvent +[Serializable] +public record LoyaltyEventCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyEventCreatedEvent [JsonPropertyName("data")] public LoyaltyEventCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventCreatedEventData.cs b/src/Square/Types/LoyaltyEventCreatedEventData.cs index 214509ae..9b3f082e 100644 --- a/src/Square/Types/LoyaltyEventCreatedEventData.cs +++ b/src/Square/Types/LoyaltyEventCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.event.created` event. /// -public record LoyaltyEventCreatedEventData +[Serializable] +public record LoyaltyEventCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_event`. /// @@ -27,15 +32,11 @@ public record LoyaltyEventCreatedEventData [JsonPropertyName("object")] public LoyaltyEventCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventCreatedEventObject.cs b/src/Square/Types/LoyaltyEventCreatedEventObject.cs index 8ee8e613..2f1fa9f8 100644 --- a/src/Square/Types/LoyaltyEventCreatedEventObject.cs +++ b/src/Square/Types/LoyaltyEventCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record LoyaltyEventCreatedEventObject +[Serializable] +public record LoyaltyEventCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty event that was created. /// [JsonPropertyName("loyalty_event")] public LoyaltyEvent? LoyaltyEvent { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventDateTimeFilter.cs b/src/Square/Types/LoyaltyEventDateTimeFilter.cs index 3864f57f..80d51cc8 100644 --- a/src/Square/Types/LoyaltyEventDateTimeFilter.cs +++ b/src/Square/Types/LoyaltyEventDateTimeFilter.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Filter events by date time range. /// -public record LoyaltyEventDateTimeFilter +[Serializable] +public record LoyaltyEventDateTimeFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The `created_at` date time range used to filter the result. /// [JsonPropertyName("created_at")] public required TimeRange CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventDeleteReward.cs b/src/Square/Types/LoyaltyEventDeleteReward.cs index 341c301f..b729d16a 100644 --- a/src/Square/Types/LoyaltyEventDeleteReward.cs +++ b/src/Square/Types/LoyaltyEventDeleteReward.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `DELETE_REWARD`. /// -public record LoyaltyEventDeleteReward +[Serializable] +public record LoyaltyEventDeleteReward : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -31,15 +36,11 @@ public record LoyaltyEventDeleteReward [JsonPropertyName("points")] public int? Points { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventExpirePoints.cs b/src/Square/Types/LoyaltyEventExpirePoints.cs index 8a29f716..8a2fe27c 100644 --- a/src/Square/Types/LoyaltyEventExpirePoints.cs +++ b/src/Square/Types/LoyaltyEventExpirePoints.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `EXPIRE_POINTS`. /// -public record LoyaltyEventExpirePoints +[Serializable] +public record LoyaltyEventExpirePoints : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -22,15 +27,11 @@ public record LoyaltyEventExpirePoints [JsonPropertyName("points")] public required int Points { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventFilter.cs b/src/Square/Types/LoyaltyEventFilter.cs index 07293c9a..e9baf89c 100644 --- a/src/Square/Types/LoyaltyEventFilter.cs +++ b/src/Square/Types/LoyaltyEventFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// The filtering criteria. If the request specifies multiple filters, /// the endpoint uses a logical AND to evaluate them. /// -public record LoyaltyEventFilter +[Serializable] +public record LoyaltyEventFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filter events by loyalty account. /// @@ -42,15 +47,11 @@ public record LoyaltyEventFilter [JsonPropertyName("order_filter")] public LoyaltyEventOrderFilter? OrderFilter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventLocationFilter.cs b/src/Square/Types/LoyaltyEventLocationFilter.cs index f0ddf68a..10d80884 100644 --- a/src/Square/Types/LoyaltyEventLocationFilter.cs +++ b/src/Square/Types/LoyaltyEventLocationFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Filter events by location. /// -public record LoyaltyEventLocationFilter +[Serializable] +public record LoyaltyEventLocationFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The [location](entity:Location) IDs for loyalty events to query. /// If multiple values are specified, the endpoint uses @@ -17,15 +22,11 @@ public record LoyaltyEventLocationFilter [JsonPropertyName("location_ids")] public IEnumerable LocationIds { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventLoyaltyAccountFilter.cs b/src/Square/Types/LoyaltyEventLoyaltyAccountFilter.cs index fed74f23..d9d0c8d5 100644 --- a/src/Square/Types/LoyaltyEventLoyaltyAccountFilter.cs +++ b/src/Square/Types/LoyaltyEventLoyaltyAccountFilter.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Filter events by loyalty account. /// -public record LoyaltyEventLoyaltyAccountFilter +[Serializable] +public record LoyaltyEventLoyaltyAccountFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [loyalty account](entity:LoyaltyAccount) associated with loyalty events. /// [JsonPropertyName("loyalty_account_id")] public required string LoyaltyAccountId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventOrderFilter.cs b/src/Square/Types/LoyaltyEventOrderFilter.cs index 9a37bcfa..dd71a32c 100644 --- a/src/Square/Types/LoyaltyEventOrderFilter.cs +++ b/src/Square/Types/LoyaltyEventOrderFilter.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Filter events by the order associated with the event. /// -public record LoyaltyEventOrderFilter +[Serializable] +public record LoyaltyEventOrderFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [order](entity:Order) associated with the event. /// [JsonPropertyName("order_id")] public required string OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventOther.cs b/src/Square/Types/LoyaltyEventOther.cs index 731bf1b1..e11d2e54 100644 --- a/src/Square/Types/LoyaltyEventOther.cs +++ b/src/Square/Types/LoyaltyEventOther.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `OTHER`. /// -public record LoyaltyEventOther +[Serializable] +public record LoyaltyEventOther : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -22,15 +27,11 @@ public record LoyaltyEventOther [JsonPropertyName("points")] public required int Points { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventQuery.cs b/src/Square/Types/LoyaltyEventQuery.cs index 7c14f041..55c50c44 100644 --- a/src/Square/Types/LoyaltyEventQuery.cs +++ b/src/Square/Types/LoyaltyEventQuery.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a query used to search for loyalty events. /// -public record LoyaltyEventQuery +[Serializable] +public record LoyaltyEventQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The query filter criteria. /// [JsonPropertyName("filter")] public LoyaltyEventFilter? Filter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventRedeemReward.cs b/src/Square/Types/LoyaltyEventRedeemReward.cs index 05b80c23..e103f221 100644 --- a/src/Square/Types/LoyaltyEventRedeemReward.cs +++ b/src/Square/Types/LoyaltyEventRedeemReward.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides metadata when the event `type` is `REDEEM_REWARD`. /// -public record LoyaltyEventRedeemReward +[Serializable] +public record LoyaltyEventRedeemReward : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [loyalty program](entity:LoyaltyProgram). /// @@ -32,15 +37,11 @@ public record LoyaltyEventRedeemReward [JsonPropertyName("order_id")] public string? OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyEventSource.cs b/src/Square/Types/LoyaltyEventSource.cs index 4c03f299..b8adadb9 100644 --- a/src/Square/Types/LoyaltyEventSource.cs +++ b/src/Square/Types/LoyaltyEventSource.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyEventSource : IStringEnum { public static readonly LoyaltyEventSource Square = new(Values.Square); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Square = "SQUARE"; diff --git a/src/Square/Types/LoyaltyEventType.cs b/src/Square/Types/LoyaltyEventType.cs index 5530309c..369be680 100644 --- a/src/Square/Types/LoyaltyEventType.cs +++ b/src/Square/Types/LoyaltyEventType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyEventType : IStringEnum { public static readonly LoyaltyEventType AccumulatePoints = new(Values.AccumulatePoints); @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AccumulatePoints = "ACCUMULATE_POINTS"; diff --git a/src/Square/Types/LoyaltyEventTypeFilter.cs b/src/Square/Types/LoyaltyEventTypeFilter.cs index 88cadb01..5e24df71 100644 --- a/src/Square/Types/LoyaltyEventTypeFilter.cs +++ b/src/Square/Types/LoyaltyEventTypeFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Filter events by event type. /// -public record LoyaltyEventTypeFilter +[Serializable] +public record LoyaltyEventTypeFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty event types used to filter the result. /// If multiple values are specified, the endpoint uses a @@ -18,15 +23,11 @@ public record LoyaltyEventTypeFilter [JsonPropertyName("types")] public IEnumerable Types { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgram.cs b/src/Square/Types/LoyaltyProgram.cs index ab5a41cb..e2278a25 100644 --- a/src/Square/Types/LoyaltyProgram.cs +++ b/src/Square/Types/LoyaltyProgram.cs @@ -9,8 +9,13 @@ namespace Square; /// Square sellers can have only one loyalty program, which is created and managed from the Seller Dashboard. /// For more information, see [Loyalty Program Overview](https://developer.squareup.com/docs/loyalty/overview). /// -public record LoyaltyProgram +[Serializable] +public record LoyaltyProgram : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the loyalty program. Updates to /// the loyalty program do not modify the identifier. @@ -72,15 +77,11 @@ public record LoyaltyProgram [JsonPropertyName("accrual_rules")] public IEnumerable? AccrualRules { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramAccrualRule.cs b/src/Square/Types/LoyaltyProgramAccrualRule.cs index 06485cc1..6017105d 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRule.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRule.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an accrual rule, which defines how buyers can earn points from the base [loyalty program](entity:LoyaltyProgram). /// -public record LoyaltyProgramAccrualRule +[Serializable] +public record LoyaltyProgramAccrualRule : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the accrual rule that defines how buyers can earn points. /// See [LoyaltyProgramAccrualRuleType](#type-loyaltyprogramaccrualruletype) for possible values @@ -47,15 +52,11 @@ public record LoyaltyProgramAccrualRule [JsonPropertyName("category_data")] public LoyaltyProgramAccrualRuleCategoryData? CategoryData { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramAccrualRuleCategoryData.cs b/src/Square/Types/LoyaltyProgramAccrualRuleCategoryData.cs index 5018f6f7..65a14473 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRuleCategoryData.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRuleCategoryData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents additional data for rules with the `CATEGORY` accrual type. /// -public record LoyaltyProgramAccrualRuleCategoryData +[Serializable] +public record LoyaltyProgramAccrualRuleCategoryData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `CATEGORY` [catalog object](entity:CatalogObject) that buyers can purchase to earn /// points. @@ -16,15 +21,11 @@ public record LoyaltyProgramAccrualRuleCategoryData [JsonPropertyName("category_id")] public required string CategoryId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramAccrualRuleItemVariationData.cs b/src/Square/Types/LoyaltyProgramAccrualRuleItemVariationData.cs index b8c4cc85..f6f48fb2 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRuleItemVariationData.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRuleItemVariationData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents additional data for rules with the `ITEM_VARIATION` accrual type. /// -public record LoyaltyProgramAccrualRuleItemVariationData +[Serializable] +public record LoyaltyProgramAccrualRuleItemVariationData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `ITEM_VARIATION` [catalog object](entity:CatalogObject) that buyers can purchase to earn /// points. @@ -16,15 +21,11 @@ public record LoyaltyProgramAccrualRuleItemVariationData [JsonPropertyName("item_variation_id")] public required string ItemVariationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramAccrualRuleSpendData.cs b/src/Square/Types/LoyaltyProgramAccrualRuleSpendData.cs index 1c61cbbe..865bd534 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRuleSpendData.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRuleSpendData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents additional data for rules with the `SPEND` accrual type. /// -public record LoyaltyProgramAccrualRuleSpendData +[Serializable] +public record LoyaltyProgramAccrualRuleSpendData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount that buyers must spend to earn points. /// For example, given an "Earn 1 point for every $10 spent" accrual rule, a buyer who spends $105 earns 10 points. @@ -41,15 +46,11 @@ public record LoyaltyProgramAccrualRuleSpendData [JsonPropertyName("tax_mode")] public required LoyaltyProgramAccrualRuleTaxMode TaxMode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramAccrualRuleTaxMode.cs b/src/Square/Types/LoyaltyProgramAccrualRuleTaxMode.cs index 4451024b..a972dfd6 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRuleTaxMode.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRuleTaxMode.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyProgramAccrualRuleTaxMode : IStringEnum { public static readonly LoyaltyProgramAccrualRuleTaxMode BeforeTax = new(Values.BeforeTax); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string BeforeTax = "BEFORE_TAX"; diff --git a/src/Square/Types/LoyaltyProgramAccrualRuleType.cs b/src/Square/Types/LoyaltyProgramAccrualRuleType.cs index d26f19ba..f55e1a37 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRuleType.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRuleType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyProgramAccrualRuleType : IStringEnum { public static readonly LoyaltyProgramAccrualRuleType Visit = new(Values.Visit); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Visit = "VISIT"; diff --git a/src/Square/Types/LoyaltyProgramAccrualRuleVisitData.cs b/src/Square/Types/LoyaltyProgramAccrualRuleVisitData.cs index 4164f0fd..5b961b31 100644 --- a/src/Square/Types/LoyaltyProgramAccrualRuleVisitData.cs +++ b/src/Square/Types/LoyaltyProgramAccrualRuleVisitData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents additional data for rules with the `VISIT` accrual type. /// -public record LoyaltyProgramAccrualRuleVisitData +[Serializable] +public record LoyaltyProgramAccrualRuleVisitData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The minimum purchase required during the visit to quality for points. /// @@ -23,15 +28,11 @@ public record LoyaltyProgramAccrualRuleVisitData [JsonPropertyName("tax_mode")] public required LoyaltyProgramAccrualRuleTaxMode TaxMode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramCreatedEvent.cs b/src/Square/Types/LoyaltyProgramCreatedEvent.cs index 1d6676a9..1de74dd7 100644 --- a/src/Square/Types/LoyaltyProgramCreatedEvent.cs +++ b/src/Square/Types/LoyaltyProgramCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty program](entity:LoyaltyProgram) is created. /// -public record LoyaltyProgramCreatedEvent +[Serializable] +public record LoyaltyProgramCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyProgramCreatedEvent [JsonPropertyName("data")] public LoyaltyProgramCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramCreatedEventData.cs b/src/Square/Types/LoyaltyProgramCreatedEventData.cs index 4add529b..25948639 100644 --- a/src/Square/Types/LoyaltyProgramCreatedEventData.cs +++ b/src/Square/Types/LoyaltyProgramCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.program.created` event. /// -public record LoyaltyProgramCreatedEventData +[Serializable] +public record LoyaltyProgramCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_program`. /// @@ -27,15 +32,11 @@ public record LoyaltyProgramCreatedEventData [JsonPropertyName("object")] public LoyaltyProgramCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramCreatedEventObject.cs b/src/Square/Types/LoyaltyProgramCreatedEventObject.cs index 009d43c2..b309cc51 100644 --- a/src/Square/Types/LoyaltyProgramCreatedEventObject.cs +++ b/src/Square/Types/LoyaltyProgramCreatedEventObject.cs @@ -7,23 +7,24 @@ namespace Square; /// /// An object that contains the loyalty program associated with a `loyalty.program.created` event. /// -public record LoyaltyProgramCreatedEventObject +[Serializable] +public record LoyaltyProgramCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty program that was created. /// [JsonPropertyName("loyalty_program")] public LoyaltyProgram? LoyaltyProgram { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramExpirationPolicy.cs b/src/Square/Types/LoyaltyProgramExpirationPolicy.cs index 88d4d986..eae0dfa0 100644 --- a/src/Square/Types/LoyaltyProgramExpirationPolicy.cs +++ b/src/Square/Types/LoyaltyProgramExpirationPolicy.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes when the loyalty program expires. /// -public record LoyaltyProgramExpirationPolicy +[Serializable] +public record LoyaltyProgramExpirationPolicy : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The number of months before points expire, in `P[n]M` RFC 3339 duration format. For example, a value of `P12M` represents a duration of 12 months. /// Points are valid through the last day of the month in which they are scheduled to expire. For example, with a `P12M` duration, points earned on July 6, 2020 expire on August 1, 2021. @@ -16,15 +21,11 @@ public record LoyaltyProgramExpirationPolicy [JsonPropertyName("expiration_duration")] public required string ExpirationDuration { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramRewardTier.cs b/src/Square/Types/LoyaltyProgramRewardTier.cs index 9aa37294..d626b6cc 100644 --- a/src/Square/Types/LoyaltyProgramRewardTier.cs +++ b/src/Square/Types/LoyaltyProgramRewardTier.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a reward tier in a loyalty program. A reward tier defines how buyers can redeem points for a reward, such as the number of points required and the value and scope of the discount. A loyalty program can offer multiple reward tiers. /// -public record LoyaltyProgramRewardTier +[Serializable] +public record LoyaltyProgramRewardTier : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the reward tier. /// @@ -46,15 +51,11 @@ public record LoyaltyProgramRewardTier [JsonPropertyName("pricing_rule_reference")] public required CatalogObjectReference PricingRuleReference { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramStatus.cs b/src/Square/Types/LoyaltyProgramStatus.cs index 421fe59d..e4d55051 100644 --- a/src/Square/Types/LoyaltyProgramStatus.cs +++ b/src/Square/Types/LoyaltyProgramStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyProgramStatus : IStringEnum { public static readonly LoyaltyProgramStatus Inactive = new(Values.Inactive); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Inactive = "INACTIVE"; diff --git a/src/Square/Types/LoyaltyProgramTerminology.cs b/src/Square/Types/LoyaltyProgramTerminology.cs index 4f494447..3bb809bb 100644 --- a/src/Square/Types/LoyaltyProgramTerminology.cs +++ b/src/Square/Types/LoyaltyProgramTerminology.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the naming used for loyalty points. /// -public record LoyaltyProgramTerminology +[Serializable] +public record LoyaltyProgramTerminology : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A singular unit for a point (for example, 1 point is called 1 star). /// @@ -21,15 +26,11 @@ public record LoyaltyProgramTerminology [JsonPropertyName("other")] public required string Other { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramUpdatedEvent.cs b/src/Square/Types/LoyaltyProgramUpdatedEvent.cs index eb42ebb8..82735553 100644 --- a/src/Square/Types/LoyaltyProgramUpdatedEvent.cs +++ b/src/Square/Types/LoyaltyProgramUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty program](entity:LoyaltyProgram) is updated. /// -public record LoyaltyProgramUpdatedEvent +[Serializable] +public record LoyaltyProgramUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyProgramUpdatedEvent [JsonPropertyName("data")] public LoyaltyProgramUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramUpdatedEventData.cs b/src/Square/Types/LoyaltyProgramUpdatedEventData.cs index 69547416..54ccd328 100644 --- a/src/Square/Types/LoyaltyProgramUpdatedEventData.cs +++ b/src/Square/Types/LoyaltyProgramUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.program.updated` event. /// -public record LoyaltyProgramUpdatedEventData +[Serializable] +public record LoyaltyProgramUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_program`. /// @@ -27,15 +32,11 @@ public record LoyaltyProgramUpdatedEventData [JsonPropertyName("object")] public LoyaltyProgramUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyProgramUpdatedEventObject.cs b/src/Square/Types/LoyaltyProgramUpdatedEventObject.cs index 749bbe50..145b61f2 100644 --- a/src/Square/Types/LoyaltyProgramUpdatedEventObject.cs +++ b/src/Square/Types/LoyaltyProgramUpdatedEventObject.cs @@ -7,23 +7,24 @@ namespace Square; /// /// An object that contains the loyalty program associated with a `loyalty.program.updated` event. /// -public record LoyaltyProgramUpdatedEventObject +[Serializable] +public record LoyaltyProgramUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty program that was updated. /// [JsonPropertyName("loyalty_program")] public LoyaltyProgram? LoyaltyProgram { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotion.cs b/src/Square/Types/LoyaltyPromotion.cs index a0785c7e..99d92621 100644 --- a/src/Square/Types/LoyaltyPromotion.cs +++ b/src/Square/Types/LoyaltyPromotion.cs @@ -10,8 +10,13 @@ namespace Square; /// /// A loyalty program can have a maximum of 10 loyalty promotions with an `ACTIVE` or `SCHEDULED` status. /// -public record LoyaltyPromotion +[Serializable] +public record LoyaltyPromotion : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the promotion. /// @@ -110,15 +115,11 @@ public record LoyaltyPromotion [JsonPropertyName("qualifying_category_ids")] public IEnumerable? QualifyingCategoryIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionAvailableTimeData.cs b/src/Square/Types/LoyaltyPromotionAvailableTimeData.cs index be73b790..050197c7 100644 --- a/src/Square/Types/LoyaltyPromotionAvailableTimeData.cs +++ b/src/Square/Types/LoyaltyPromotionAvailableTimeData.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents scheduling information that determines when purchases can qualify to earn points /// from a [loyalty promotion](entity:LoyaltyPromotion). /// -public record LoyaltyPromotionAvailableTimeData +[Serializable] +public record LoyaltyPromotionAvailableTimeData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The date that the promotion starts, in `YYYY-MM-DD` format. Square populates this field /// based on the provided `time_periods`. @@ -43,15 +48,11 @@ public record LoyaltyPromotionAvailableTimeData [JsonPropertyName("time_periods")] public IEnumerable TimePeriods { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionCreatedEvent.cs b/src/Square/Types/LoyaltyPromotionCreatedEvent.cs index 8f660d1c..e08e1951 100644 --- a/src/Square/Types/LoyaltyPromotionCreatedEvent.cs +++ b/src/Square/Types/LoyaltyPromotionCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [loyalty promotion](entity:LoyaltyPromotion) is created. /// -public record LoyaltyPromotionCreatedEvent +[Serializable] +public record LoyaltyPromotionCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -41,15 +46,11 @@ public record LoyaltyPromotionCreatedEvent [JsonPropertyName("data")] public LoyaltyPromotionCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionCreatedEventData.cs b/src/Square/Types/LoyaltyPromotionCreatedEventData.cs index dbeb4fd9..757c0060 100644 --- a/src/Square/Types/LoyaltyPromotionCreatedEventData.cs +++ b/src/Square/Types/LoyaltyPromotionCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.promotion.created` event. /// -public record LoyaltyPromotionCreatedEventData +[Serializable] +public record LoyaltyPromotionCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_promotion`. /// @@ -27,15 +32,11 @@ public record LoyaltyPromotionCreatedEventData [JsonPropertyName("object")] public LoyaltyPromotionCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionCreatedEventObject.cs b/src/Square/Types/LoyaltyPromotionCreatedEventObject.cs index 10f4e09a..7d866224 100644 --- a/src/Square/Types/LoyaltyPromotionCreatedEventObject.cs +++ b/src/Square/Types/LoyaltyPromotionCreatedEventObject.cs @@ -7,23 +7,24 @@ namespace Square; /// /// An object that contains the loyalty promotion associated with a `loyalty.promotion.created` event. /// -public record LoyaltyPromotionCreatedEventObject +[Serializable] +public record LoyaltyPromotionCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty promotion that was created. /// [JsonPropertyName("loyalty_promotion")] public LoyaltyPromotion? LoyaltyPromotion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionIncentive.cs b/src/Square/Types/LoyaltyPromotionIncentive.cs index 61ef149c..6a61847a 100644 --- a/src/Square/Types/LoyaltyPromotionIncentive.cs +++ b/src/Square/Types/LoyaltyPromotionIncentive.cs @@ -9,8 +9,13 @@ namespace Square; /// either by multiplying the points earned from the base program or by adding a specified number /// of points to the points earned from the base program. /// -public record LoyaltyPromotionIncentive +[Serializable] +public record LoyaltyPromotionIncentive : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of points incentive. /// See [LoyaltyPromotionIncentiveType](#type-loyaltypromotionincentivetype) for possible values @@ -30,15 +35,11 @@ public record LoyaltyPromotionIncentive [JsonPropertyName("points_addition_data")] public LoyaltyPromotionIncentivePointsAdditionData? PointsAdditionData { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionIncentivePointsAdditionData.cs b/src/Square/Types/LoyaltyPromotionIncentivePointsAdditionData.cs index af7300b2..23124b69 100644 --- a/src/Square/Types/LoyaltyPromotionIncentivePointsAdditionData.cs +++ b/src/Square/Types/LoyaltyPromotionIncentivePointsAdditionData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the metadata for a `POINTS_ADDITION` type of [loyalty promotion incentive](entity:LoyaltyPromotionIncentive). /// -public record LoyaltyPromotionIncentivePointsAdditionData +[Serializable] +public record LoyaltyPromotionIncentivePointsAdditionData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The number of additional points to earn each time the promotion is triggered. For example, /// suppose a purchase qualifies for 5 points from the base loyalty program. If the purchase also @@ -18,15 +23,11 @@ public record LoyaltyPromotionIncentivePointsAdditionData [JsonPropertyName("points_addition")] public required int PointsAddition { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionIncentivePointsMultiplierData.cs b/src/Square/Types/LoyaltyPromotionIncentivePointsMultiplierData.cs index 25cb2f55..ba7a5e9b 100644 --- a/src/Square/Types/LoyaltyPromotionIncentivePointsMultiplierData.cs +++ b/src/Square/Types/LoyaltyPromotionIncentivePointsMultiplierData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the metadata for a `POINTS_MULTIPLIER` type of [loyalty promotion incentive](entity:LoyaltyPromotionIncentive). /// -public record LoyaltyPromotionIncentivePointsMultiplierData +[Serializable] +public record LoyaltyPromotionIncentivePointsMultiplierData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The multiplier used to calculate the number of points earned each time the promotion /// is triggered. For example, suppose a purchase qualifies for 5 points from the base loyalty program. @@ -41,15 +46,11 @@ public record LoyaltyPromotionIncentivePointsMultiplierData [JsonPropertyName("multiplier")] public string? Multiplier { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionIncentiveType.cs b/src/Square/Types/LoyaltyPromotionIncentiveType.cs index b89780e5..76d6efa7 100644 --- a/src/Square/Types/LoyaltyPromotionIncentiveType.cs +++ b/src/Square/Types/LoyaltyPromotionIncentiveType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyPromotionIncentiveType : IStringEnum { public static readonly LoyaltyPromotionIncentiveType PointsMultiplier = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string PointsMultiplier = "POINTS_MULTIPLIER"; diff --git a/src/Square/Types/LoyaltyPromotionStatus.cs b/src/Square/Types/LoyaltyPromotionStatus.cs index 82198577..ca59abcc 100644 --- a/src/Square/Types/LoyaltyPromotionStatus.cs +++ b/src/Square/Types/LoyaltyPromotionStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyPromotionStatus : IStringEnum { public static readonly LoyaltyPromotionStatus Active = new(Values.Active); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/LoyaltyPromotionTriggerLimit.cs b/src/Square/Types/LoyaltyPromotionTriggerLimit.cs index 2b26a3ec..35fe7e21 100644 --- a/src/Square/Types/LoyaltyPromotionTriggerLimit.cs +++ b/src/Square/Types/LoyaltyPromotionTriggerLimit.cs @@ -11,8 +11,13 @@ namespace Square; /// /// A purchase that is disqualified from earning points because of this limit might qualify for another active promotion. /// -public record LoyaltyPromotionTriggerLimit +[Serializable] +public record LoyaltyPromotionTriggerLimit : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The maximum number of times a buyer can trigger the promotion during the specified `interval`. /// @@ -26,15 +31,11 @@ public record LoyaltyPromotionTriggerLimit [JsonPropertyName("interval")] public LoyaltyPromotionTriggerLimitInterval? Interval { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionTriggerLimitInterval.cs b/src/Square/Types/LoyaltyPromotionTriggerLimitInterval.cs index 92597858..83b3bfa8 100644 --- a/src/Square/Types/LoyaltyPromotionTriggerLimitInterval.cs +++ b/src/Square/Types/LoyaltyPromotionTriggerLimitInterval.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyPromotionTriggerLimitInterval : IStringEnum { public static readonly LoyaltyPromotionTriggerLimitInterval AllTime = new(Values.AllTime); @@ -56,6 +57,7 @@ public static explicit operator LoyaltyPromotionTriggerLimitInterval(string valu /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AllTime = "ALL_TIME"; diff --git a/src/Square/Types/LoyaltyPromotionUpdatedEvent.cs b/src/Square/Types/LoyaltyPromotionUpdatedEvent.cs index daf54ae6..06f05855 100644 --- a/src/Square/Types/LoyaltyPromotionUpdatedEvent.cs +++ b/src/Square/Types/LoyaltyPromotionUpdatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a [loyalty promotion](entity:LoyaltyPromotion) is updated. This event is /// invoked only when a loyalty promotion is canceled. /// -public record LoyaltyPromotionUpdatedEvent +[Serializable] +public record LoyaltyPromotionUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the Square seller associated with the event. /// @@ -42,15 +47,11 @@ public record LoyaltyPromotionUpdatedEvent [JsonPropertyName("data")] public LoyaltyPromotionUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionUpdatedEventData.cs b/src/Square/Types/LoyaltyPromotionUpdatedEventData.cs index 4407f7d0..62eaafc3 100644 --- a/src/Square/Types/LoyaltyPromotionUpdatedEventData.cs +++ b/src/Square/Types/LoyaltyPromotionUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The data associated with a `loyalty.promotion.updated` event. /// -public record LoyaltyPromotionUpdatedEventData +[Serializable] +public record LoyaltyPromotionUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of object affected by the event. For this event, the value is `loyalty_promotion`. /// @@ -27,15 +32,11 @@ public record LoyaltyPromotionUpdatedEventData [JsonPropertyName("object")] public LoyaltyPromotionUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyPromotionUpdatedEventObject.cs b/src/Square/Types/LoyaltyPromotionUpdatedEventObject.cs index e2183488..1224d94a 100644 --- a/src/Square/Types/LoyaltyPromotionUpdatedEventObject.cs +++ b/src/Square/Types/LoyaltyPromotionUpdatedEventObject.cs @@ -7,23 +7,24 @@ namespace Square; /// /// An object that contains the loyalty promotion associated with a `loyalty.promotion.updated` event. /// -public record LoyaltyPromotionUpdatedEventObject +[Serializable] +public record LoyaltyPromotionUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The loyalty promotion that was updated. /// [JsonPropertyName("loyalty_promotion")] public LoyaltyPromotion? LoyaltyPromotion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyReward.cs b/src/Square/Types/LoyaltyReward.cs index e9dbb6c0..86d3eb33 100644 --- a/src/Square/Types/LoyaltyReward.cs +++ b/src/Square/Types/LoyaltyReward.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a contract to redeem loyalty points for a [reward tier](entity:LoyaltyProgramRewardTier) discount. Loyalty rewards can be in an ISSUED, REDEEMED, or DELETED state. /// For more information, see [Manage loyalty rewards](https://developer.squareup.com/docs/loyalty-api/loyalty-rewards). /// -public record LoyaltyReward +[Serializable] +public record LoyaltyReward : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the loyalty reward. /// @@ -70,15 +75,11 @@ public record LoyaltyReward [JsonPropertyName("redeemed_at")] public string? RedeemedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/LoyaltyRewardStatus.cs b/src/Square/Types/LoyaltyRewardStatus.cs index fcc5e25c..d39f4eb8 100644 --- a/src/Square/Types/LoyaltyRewardStatus.cs +++ b/src/Square/Types/LoyaltyRewardStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct LoyaltyRewardStatus : IStringEnum { public static readonly LoyaltyRewardStatus Issued = new(Values.Issued); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Issued = "ISSUED"; diff --git a/src/Square/Types/MeasurementUnit.cs b/src/Square/Types/MeasurementUnit.cs index 538443cf..fdbe922c 100644 --- a/src/Square/Types/MeasurementUnit.cs +++ b/src/Square/Types/MeasurementUnit.cs @@ -9,8 +9,13 @@ namespace Square; /// or inches. Exactly one of the following fields are required: `custom_unit`, /// `area_unit`, `length_unit`, `volume_unit`, and `weight_unit`. /// -public record MeasurementUnit +[Serializable] +public record MeasurementUnit : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A custom unit of measurement defined by the seller using the Point of Sale /// app or ad-hoc as an order line item. @@ -67,15 +72,11 @@ public record MeasurementUnit [JsonPropertyName("type")] public MeasurementUnitUnitType? Type { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MeasurementUnitArea.cs b/src/Square/Types/MeasurementUnitArea.cs index c4136524..0bab53a5 100644 --- a/src/Square/Types/MeasurementUnitArea.cs +++ b/src/Square/Types/MeasurementUnitArea.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MeasurementUnitArea : IStringEnum { public static readonly MeasurementUnitArea ImperialAcre = new(Values.ImperialAcre); @@ -70,6 +71,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ImperialAcre = "IMPERIAL_ACRE"; diff --git a/src/Square/Types/MeasurementUnitCustom.cs b/src/Square/Types/MeasurementUnitCustom.cs index 8c225f6d..bfde4180 100644 --- a/src/Square/Types/MeasurementUnitCustom.cs +++ b/src/Square/Types/MeasurementUnitCustom.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The information needed to define a custom unit, provided by the seller. /// -public record MeasurementUnitCustom +[Serializable] +public record MeasurementUnitCustom : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the custom unit, for example "bushel". /// @@ -22,15 +27,11 @@ public record MeasurementUnitCustom [JsonPropertyName("abbreviation")] public required string Abbreviation { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MeasurementUnitLength.cs b/src/Square/Types/MeasurementUnitLength.cs index 722f4777..9d761b0c 100644 --- a/src/Square/Types/MeasurementUnitLength.cs +++ b/src/Square/Types/MeasurementUnitLength.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MeasurementUnitLength : IStringEnum { public static readonly MeasurementUnitLength ImperialInch = new(Values.ImperialInch); @@ -66,6 +67,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ImperialInch = "IMPERIAL_INCH"; diff --git a/src/Square/Types/MeasurementUnitTime.cs b/src/Square/Types/MeasurementUnitTime.cs index 12e145e5..e424ef37 100644 --- a/src/Square/Types/MeasurementUnitTime.cs +++ b/src/Square/Types/MeasurementUnitTime.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MeasurementUnitTime : IStringEnum { public static readonly MeasurementUnitTime GenericMillisecond = new(Values.GenericMillisecond); @@ -60,6 +61,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string GenericMillisecond = "GENERIC_MILLISECOND"; diff --git a/src/Square/Types/MeasurementUnitUnitType.cs b/src/Square/Types/MeasurementUnitUnitType.cs index c8da23da..e93612ff 100644 --- a/src/Square/Types/MeasurementUnitUnitType.cs +++ b/src/Square/Types/MeasurementUnitUnitType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MeasurementUnitUnitType : IStringEnum { public static readonly MeasurementUnitUnitType TypeCustom = new(Values.TypeCustom); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string TypeCustom = "TYPE_CUSTOM"; diff --git a/src/Square/Types/MeasurementUnitVolume.cs b/src/Square/Types/MeasurementUnitVolume.cs index 6336b976..8d8a8fe8 100644 --- a/src/Square/Types/MeasurementUnitVolume.cs +++ b/src/Square/Types/MeasurementUnitVolume.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MeasurementUnitVolume : IStringEnum { public static readonly MeasurementUnitVolume GenericFluidOunce = new(Values.GenericFluidOunce); @@ -72,6 +73,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string GenericFluidOunce = "GENERIC_FLUID_OUNCE"; diff --git a/src/Square/Types/MeasurementUnitWeight.cs b/src/Square/Types/MeasurementUnitWeight.cs index 78456aa8..6e04b79a 100644 --- a/src/Square/Types/MeasurementUnitWeight.cs +++ b/src/Square/Types/MeasurementUnitWeight.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MeasurementUnitWeight : IStringEnum { public static readonly MeasurementUnitWeight ImperialWeightOunce = new( @@ -64,6 +65,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string ImperialWeightOunce = "IMPERIAL_WEIGHT_OUNCE"; diff --git a/src/Square/Types/Merchant.cs b/src/Square/Types/Merchant.cs index d47af5fa..168d6eca 100644 --- a/src/Square/Types/Merchant.cs +++ b/src/Square/Types/Merchant.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a business that sells with Square. /// -public record Merchant +[Serializable] +public record Merchant : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-issued ID of the merchant. /// @@ -62,15 +67,11 @@ public record Merchant [JsonPropertyName("created_at")] public string? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeDefinitionOwnedCreatedEvent.cs b/src/Square/Types/MerchantCustomAttributeDefinitionOwnedCreatedEvent.cs index 4de83ae5..6513485f 100644 --- a/src/Square/Types/MerchantCustomAttributeDefinitionOwnedCreatedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeDefinitionOwnedCreatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is created by the subscribing application. Subscribe to this event to be notified /// when your application creates a merchant custom attribute definition. /// -public record MerchantCustomAttributeDefinitionOwnedCreatedEvent +[Serializable] +public record MerchantCustomAttributeDefinitionOwnedCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record MerchantCustomAttributeDefinitionOwnedCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeDefinitionOwnedDeletedEvent.cs b/src/Square/Types/MerchantCustomAttributeDefinitionOwnedDeletedEvent.cs index 7b92cd9f..712d6d69 100644 --- a/src/Square/Types/MerchantCustomAttributeDefinitionOwnedDeletedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeDefinitionOwnedDeletedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is deleted by the subscribing application. Subscribe to this event to be notified /// when your application deletes a merchant custom attribute definition. /// -public record MerchantCustomAttributeDefinitionOwnedDeletedEvent +[Serializable] +public record MerchantCustomAttributeDefinitionOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record MerchantCustomAttributeDefinitionOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeDefinitionOwnedUpdatedEvent.cs b/src/Square/Types/MerchantCustomAttributeDefinitionOwnedUpdatedEvent.cs index 292086e6..9a0cfe3c 100644 --- a/src/Square/Types/MerchantCustomAttributeDefinitionOwnedUpdatedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeDefinitionOwnedUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is updated by the subscribing application. Subscribe to this event to be notified /// when your application updates a merchant custom attribute definition. /// -public record MerchantCustomAttributeDefinitionOwnedUpdatedEvent +[Serializable] +public record MerchantCustomAttributeDefinitionOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -42,15 +47,11 @@ public record MerchantCustomAttributeDefinitionOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeDefinitionVisibleCreatedEvent.cs b/src/Square/Types/MerchantCustomAttributeDefinitionVisibleCreatedEvent.cs index 5ccf1a7a..f5462ede 100644 --- a/src/Square/Types/MerchantCustomAttributeDefinitionVisibleCreatedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeDefinitionVisibleCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// creates a custom attribute definition or another application creates a custom attribute definition whose /// `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record MerchantCustomAttributeDefinitionVisibleCreatedEvent +[Serializable] +public record MerchantCustomAttributeDefinitionVisibleCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeDefinitionVisibleCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeDefinitionVisibleDeletedEvent.cs b/src/Square/Types/MerchantCustomAttributeDefinitionVisibleDeletedEvent.cs index d8a5f0ce..4bbd3c92 100644 --- a/src/Square/Types/MerchantCustomAttributeDefinitionVisibleDeletedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeDefinitionVisibleDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// deletes a custom attribute definition or another application deletes a custom attribute definition whose /// `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record MerchantCustomAttributeDefinitionVisibleDeletedEvent +[Serializable] +public record MerchantCustomAttributeDefinitionVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeDefinitionVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeDefinitionVisibleUpdatedEvent.cs b/src/Square/Types/MerchantCustomAttributeDefinitionVisibleUpdatedEvent.cs index 3d7f5c41..69def6e6 100644 --- a/src/Square/Types/MerchantCustomAttributeDefinitionVisibleUpdatedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeDefinitionVisibleUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// updates a custom attribute definition or another application updates a custom attribute definition whose /// `visibility` is `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. /// -public record MerchantCustomAttributeDefinitionVisibleUpdatedEvent +[Serializable] +public record MerchantCustomAttributeDefinitionVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeDefinitionVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeOwnedDeletedEvent.cs b/src/Square/Types/MerchantCustomAttributeOwnedDeletedEvent.cs index 2bb3a508..4adb83ad 100644 --- a/src/Square/Types/MerchantCustomAttributeOwnedDeletedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeOwnedDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// owned by the subscribing application is deleted. Subscribe to this event to be notified /// when your application deletes a merchant custom attribute. /// -public record MerchantCustomAttributeOwnedDeletedEvent +[Serializable] +public record MerchantCustomAttributeOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeOwnedUpdatedEvent.cs b/src/Square/Types/MerchantCustomAttributeOwnedUpdatedEvent.cs index 5eeb3afa..ef3ef2fc 100644 --- a/src/Square/Types/MerchantCustomAttributeOwnedUpdatedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeOwnedUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// owned by the subscribing application is updated. Subscribe to this event to be notified /// when your application updates a merchant custom attribute. /// -public record MerchantCustomAttributeOwnedUpdatedEvent +[Serializable] +public record MerchantCustomAttributeOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeVisibleDeletedEvent.cs b/src/Square/Types/MerchantCustomAttributeVisibleDeletedEvent.cs index 479b2bfe..983b873a 100644 --- a/src/Square/Types/MerchantCustomAttributeVisibleDeletedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeVisibleDeletedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a merchant custom attribute is deleted /// by any application for which the subscribing application has read access to the merchant custom attribute. /// -public record MerchantCustomAttributeVisibleDeletedEvent +[Serializable] +public record MerchantCustomAttributeVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantCustomAttributeVisibleUpdatedEvent.cs b/src/Square/Types/MerchantCustomAttributeVisibleUpdatedEvent.cs index 36fa1fe0..527fa938 100644 --- a/src/Square/Types/MerchantCustomAttributeVisibleUpdatedEvent.cs +++ b/src/Square/Types/MerchantCustomAttributeVisibleUpdatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// An application that subscribes to this event is notified when a merchant custom attribute is updated /// by any application for which the subscribing application has read access to the merchant custom attribute. /// -public record MerchantCustomAttributeVisibleUpdatedEvent +[Serializable] +public record MerchantCustomAttributeVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the seller associated with the event that triggered the event notification. /// @@ -43,15 +48,11 @@ public record MerchantCustomAttributeVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantSettingsUpdatedEvent.cs b/src/Square/Types/MerchantSettingsUpdatedEvent.cs index b48f0bee..8cb39dde 100644 --- a/src/Square/Types/MerchantSettingsUpdatedEvent.cs +++ b/src/Square/Types/MerchantSettingsUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when online checkout merchant settings are updated /// -public record MerchantSettingsUpdatedEvent +[Serializable] +public record MerchantSettingsUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record MerchantSettingsUpdatedEvent [JsonPropertyName("data")] public MerchantSettingsUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantSettingsUpdatedEventData.cs b/src/Square/Types/MerchantSettingsUpdatedEventData.cs index c2029a72..ee8f20a3 100644 --- a/src/Square/Types/MerchantSettingsUpdatedEventData.cs +++ b/src/Square/Types/MerchantSettingsUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record MerchantSettingsUpdatedEventData +[Serializable] +public record MerchantSettingsUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the updated object’s type, `"online_checkout.merchant_settings"`. /// @@ -24,15 +29,11 @@ public record MerchantSettingsUpdatedEventData [JsonPropertyName("object")] public MerchantSettingsUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantSettingsUpdatedEventObject.cs b/src/Square/Types/MerchantSettingsUpdatedEventObject.cs index 92ce69c7..6984af6c 100644 --- a/src/Square/Types/MerchantSettingsUpdatedEventObject.cs +++ b/src/Square/Types/MerchantSettingsUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record MerchantSettingsUpdatedEventObject +[Serializable] +public record MerchantSettingsUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated merchant settings. /// [JsonPropertyName("merchant_settings")] public CheckoutMerchantSettings? MerchantSettings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/MerchantStatus.cs b/src/Square/Types/MerchantStatus.cs index b9ad758e..b7bf52f5 100644 --- a/src/Square/Types/MerchantStatus.cs +++ b/src/Square/Types/MerchantStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct MerchantStatus : IStringEnum { public static readonly MerchantStatus Active = new(Values.Active); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/ModifierLocationOverrides.cs b/src/Square/Types/ModifierLocationOverrides.cs index 8922de0b..1a15f8bb 100644 --- a/src/Square/Types/ModifierLocationOverrides.cs +++ b/src/Square/Types/ModifierLocationOverrides.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Location-specific overrides for specified properties of a `CatalogModifier` object. /// -public record ModifierLocationOverrides +[Serializable] +public record ModifierLocationOverrides : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the `Location` object representing the location. This can include a deactivated location. /// @@ -30,15 +35,11 @@ public record ModifierLocationOverrides [JsonPropertyName("sold_out")] public bool? SoldOut { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Money.cs b/src/Square/Types/Money.cs index 0cb3a280..81940642 100644 --- a/src/Square/Types/Money.cs +++ b/src/Square/Types/Money.cs @@ -12,8 +12,13 @@ namespace Square; /// [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts) /// for more information. /// -public record Money +[Serializable] +public record Money : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The amount of money, in the smallest denomination of the currency /// indicated by `currency`. For example, when `currency` is `USD`, `amount` is @@ -33,15 +38,11 @@ public record Money [JsonPropertyName("currency")] public Currency? Currency { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OauthAuthorizationRevokedEvent.cs b/src/Square/Types/OauthAuthorizationRevokedEvent.cs index b78b3b76..cabb0c78 100644 --- a/src/Square/Types/OauthAuthorizationRevokedEvent.cs +++ b/src/Square/Types/OauthAuthorizationRevokedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a merchant/application revokes all access tokens and refresh tokens granted to an application. /// -public record OauthAuthorizationRevokedEvent +[Serializable] +public record OauthAuthorizationRevokedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record OauthAuthorizationRevokedEvent [JsonPropertyName("data")] public OauthAuthorizationRevokedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OauthAuthorizationRevokedEventData.cs b/src/Square/Types/OauthAuthorizationRevokedEventData.cs index 9d12d3ad..54ead834 100644 --- a/src/Square/Types/OauthAuthorizationRevokedEventData.cs +++ b/src/Square/Types/OauthAuthorizationRevokedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record OauthAuthorizationRevokedEventData +[Serializable] +public record OauthAuthorizationRevokedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"revocation"`. /// @@ -24,15 +29,11 @@ public record OauthAuthorizationRevokedEventData [JsonPropertyName("object")] public OauthAuthorizationRevokedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OauthAuthorizationRevokedEventObject.cs b/src/Square/Types/OauthAuthorizationRevokedEventObject.cs index 1b74ef84..5696b5d5 100644 --- a/src/Square/Types/OauthAuthorizationRevokedEventObject.cs +++ b/src/Square/Types/OauthAuthorizationRevokedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record OauthAuthorizationRevokedEventObject +[Serializable] +public record OauthAuthorizationRevokedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The revocation event. /// [JsonPropertyName("revocation")] public OauthAuthorizationRevokedEventRevocationObject? Revocation { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OauthAuthorizationRevokedEventRevocationObject.cs b/src/Square/Types/OauthAuthorizationRevokedEventRevocationObject.cs index b58a0f31..11738f84 100644 --- a/src/Square/Types/OauthAuthorizationRevokedEventRevocationObject.cs +++ b/src/Square/Types/OauthAuthorizationRevokedEventRevocationObject.cs @@ -4,8 +4,13 @@ namespace Square; -public record OauthAuthorizationRevokedEventRevocationObject +[Serializable] +public record OauthAuthorizationRevokedEventRevocationObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Timestamp of when the revocation event occurred, in RFC 3339 format. /// @@ -19,15 +24,11 @@ public record OauthAuthorizationRevokedEventRevocationObject [JsonPropertyName("revoker_type")] public OauthAuthorizationRevokedEventRevokerType? RevokerType { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OauthAuthorizationRevokedEventRevokerType.cs b/src/Square/Types/OauthAuthorizationRevokedEventRevokerType.cs index 5dcfe188..edc6b384 100644 --- a/src/Square/Types/OauthAuthorizationRevokedEventRevokerType.cs +++ b/src/Square/Types/OauthAuthorizationRevokedEventRevokerType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OauthAuthorizationRevokedEventRevokerType : IStringEnum { public static readonly OauthAuthorizationRevokedEventRevokerType Application = new( @@ -66,6 +67,7 @@ public static explicit operator OauthAuthorizationRevokedEventRevokerType(string /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Application = "APPLICATION"; diff --git a/src/Square/Types/ObtainTokenResponse.cs b/src/Square/Types/ObtainTokenResponse.cs index b9a561b6..78adc115 100644 --- a/src/Square/Types/ObtainTokenResponse.cs +++ b/src/Square/Types/ObtainTokenResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an [ObtainToken](api-endpoint:OAuth-ObtainToken) response. /// -public record ObtainTokenResponse +[Serializable] +public record ObtainTokenResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// An OAuth access token used to authorize Square API requests on behalf of the seller. /// Include this token as a bearer token in the `Authorization` header of your API requests. @@ -101,15 +106,11 @@ public record ObtainTokenResponse [JsonPropertyName("refresh_token_expires_at")] public string? RefreshTokenExpiresAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OfflinePaymentDetails.cs b/src/Square/Types/OfflinePaymentDetails.cs index 49cc89bc..321866cf 100644 --- a/src/Square/Types/OfflinePaymentDetails.cs +++ b/src/Square/Types/OfflinePaymentDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Details specific to offline payments. /// -public record OfflinePaymentDetails +[Serializable] +public record OfflinePaymentDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The client-side timestamp of when the offline payment was created, in RFC 3339 format. /// @@ -16,15 +21,11 @@ public record OfflinePaymentDetails [JsonPropertyName("client_created_at")] public string? ClientCreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Order.cs b/src/Square/Types/Order.cs index 63823e6d..c9273f9f 100644 --- a/src/Square/Types/Order.cs +++ b/src/Square/Types/Order.cs @@ -12,8 +12,13 @@ namespace Square; /// All Connect V2 Transactions have all been converted to Orders including all associated /// itemization data. /// -public record Order +[Serializable] +public record Order : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order's unique ID. /// @@ -268,15 +273,11 @@ public record Order [JsonPropertyName("net_amount_due_money")] public Money? NetAmountDueMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCreated.cs b/src/Square/Types/OrderCreated.cs index 8a49a4fc..396abbff 100644 --- a/src/Square/Types/OrderCreated.cs +++ b/src/Square/Types/OrderCreated.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderCreated +[Serializable] +public record OrderCreated : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order's unique ID. /// @@ -42,15 +47,11 @@ public record OrderCreated [JsonPropertyName("created_at")] public string? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCreatedEvent.cs b/src/Square/Types/OrderCreatedEvent.cs index d22748b7..0d3420f8 100644 --- a/src/Square/Types/OrderCreatedEvent.cs +++ b/src/Square/Types/OrderCreatedEvent.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Creating an order in the Point of Sale app will **not** publish this event. /// -public record OrderCreatedEvent +[Serializable] +public record OrderCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -43,15 +48,11 @@ public record OrderCreatedEvent [JsonPropertyName("data")] public OrderCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCreatedEventData.cs b/src/Square/Types/OrderCreatedEventData.cs index f56c0ee2..842f2907 100644 --- a/src/Square/Types/OrderCreatedEventData.cs +++ b/src/Square/Types/OrderCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderCreatedEventData +[Serializable] +public record OrderCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"order_created"`. /// @@ -24,15 +29,11 @@ public record OrderCreatedEventData [JsonPropertyName("object")] public OrderCreatedObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCreatedObject.cs b/src/Square/Types/OrderCreatedObject.cs index 36d06158..62219ef0 100644 --- a/src/Square/Types/OrderCreatedObject.cs +++ b/src/Square/Types/OrderCreatedObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record OrderCreatedObject +[Serializable] +public record OrderCreatedObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the created order. /// [JsonPropertyName("order_created")] public OrderCreated? OrderCreated { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeDefinitionOwnedCreatedEvent.cs b/src/Square/Types/OrderCustomAttributeDefinitionOwnedCreatedEvent.cs index 13d3296f..2725897c 100644 --- a/src/Square/Types/OrderCustomAttributeDefinitionOwnedCreatedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeDefinitionOwnedCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute definition](entity:CustomAttributeDefinition) that is owned by the subscribing app is created. /// -public record OrderCustomAttributeDefinitionOwnedCreatedEvent +[Serializable] +public record OrderCustomAttributeDefinitionOwnedCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeDefinitionOwnedCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeDefinitionOwnedDeletedEvent.cs b/src/Square/Types/OrderCustomAttributeDefinitionOwnedDeletedEvent.cs index 6f8afa88..a51e5acb 100644 --- a/src/Square/Types/OrderCustomAttributeDefinitionOwnedDeletedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeDefinitionOwnedDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute definition](entity:CustomAttributeDefinition) that is owned by the subscribing app is deleted. /// -public record OrderCustomAttributeDefinitionOwnedDeletedEvent +[Serializable] +public record OrderCustomAttributeDefinitionOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeDefinitionOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeDefinitionOwnedUpdatedEvent.cs b/src/Square/Types/OrderCustomAttributeDefinitionOwnedUpdatedEvent.cs index 81cfa98b..c351de33 100644 --- a/src/Square/Types/OrderCustomAttributeDefinitionOwnedUpdatedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeDefinitionOwnedUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute definition](entity:CustomAttributeDefinition) that is owned by the subscribing app is updated. /// -public record OrderCustomAttributeDefinitionOwnedUpdatedEvent +[Serializable] +public record OrderCustomAttributeDefinitionOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeDefinitionOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeDefinitionVisibleCreatedEvent.cs b/src/Square/Types/OrderCustomAttributeDefinitionVisibleCreatedEvent.cs index 48a14214..4ee5cce4 100644 --- a/src/Square/Types/OrderCustomAttributeDefinitionVisibleCreatedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeDefinitionVisibleCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute definition](entity:CustomAttributeDefinition) that is visible to the subscribing app is created. /// -public record OrderCustomAttributeDefinitionVisibleCreatedEvent +[Serializable] +public record OrderCustomAttributeDefinitionVisibleCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeDefinitionVisibleCreatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeDefinitionVisibleDeletedEvent.cs b/src/Square/Types/OrderCustomAttributeDefinitionVisibleDeletedEvent.cs index 2f9f2e5c..1ef4c047 100644 --- a/src/Square/Types/OrderCustomAttributeDefinitionVisibleDeletedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeDefinitionVisibleDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute definition](entity:CustomAttributeDefinition) that is visible to the subscribing app is deleted. /// -public record OrderCustomAttributeDefinitionVisibleDeletedEvent +[Serializable] +public record OrderCustomAttributeDefinitionVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeDefinitionVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeDefinitionVisibleUpdatedEvent.cs b/src/Square/Types/OrderCustomAttributeDefinitionVisibleUpdatedEvent.cs index c6ebb8a6..a19ed448 100644 --- a/src/Square/Types/OrderCustomAttributeDefinitionVisibleUpdatedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeDefinitionVisibleUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute definition](entity:CustomAttributeDefinition) that is visible to the subscribing app is updated. /// -public record OrderCustomAttributeDefinitionVisibleUpdatedEvent +[Serializable] +public record OrderCustomAttributeDefinitionVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeDefinitionVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeDefinitionEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeOwnedDeletedEvent.cs b/src/Square/Types/OrderCustomAttributeOwnedDeletedEvent.cs index 025343ba..024ec04b 100644 --- a/src/Square/Types/OrderCustomAttributeOwnedDeletedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeOwnedDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute](entity:CustomAttribute) associated with a [custom attribute definition](entity:CustomAttributeDefinition) that is owned by the subscribing app is deleted. /// -public record OrderCustomAttributeOwnedDeletedEvent +[Serializable] +public record OrderCustomAttributeOwnedDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeOwnedDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeOwnedUpdatedEvent.cs b/src/Square/Types/OrderCustomAttributeOwnedUpdatedEvent.cs index 7d5119b0..65e247ab 100644 --- a/src/Square/Types/OrderCustomAttributeOwnedUpdatedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeOwnedUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute](entity:CustomAttribute) associated with a [custom attribute definition](entity:CustomAttributeDefinition) that is owned by the subscribing app is updated. /// -public record OrderCustomAttributeOwnedUpdatedEvent +[Serializable] +public record OrderCustomAttributeOwnedUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeOwnedUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeVisibleDeletedEvent.cs b/src/Square/Types/OrderCustomAttributeVisibleDeletedEvent.cs index 47e4b05c..a892c10d 100644 --- a/src/Square/Types/OrderCustomAttributeVisibleDeletedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeVisibleDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute](entity:CustomAttribute) that is visible to the subscribing app is deleted. /// -public record OrderCustomAttributeVisibleDeletedEvent +[Serializable] +public record OrderCustomAttributeVisibleDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeVisibleDeletedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderCustomAttributeVisibleUpdatedEvent.cs b/src/Square/Types/OrderCustomAttributeVisibleUpdatedEvent.cs index be1f98f0..29a76b57 100644 --- a/src/Square/Types/OrderCustomAttributeVisibleUpdatedEvent.cs +++ b/src/Square/Types/OrderCustomAttributeVisibleUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when an order [custom attribute](entity:CustomAttribute) that is visible to the subscribing app is updated. /// -public record OrderCustomAttributeVisibleUpdatedEvent +[Serializable] +public record OrderCustomAttributeVisibleUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target seller associated with the event. /// @@ -40,15 +45,11 @@ public record OrderCustomAttributeVisibleUpdatedEvent [JsonPropertyName("data")] public CustomAttributeEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderEntry.cs b/src/Square/Types/OrderEntry.cs index 36e6ae77..9d063d9a 100644 --- a/src/Square/Types/OrderEntry.cs +++ b/src/Square/Types/OrderEntry.cs @@ -8,8 +8,13 @@ namespace Square; /// A lightweight description of an [order](entity:Order) that is returned when /// `returned_entries` is `true` on a [SearchOrdersRequest](api-endpoint:Orders-SearchOrders). /// -public record OrderEntry +[Serializable] +public record OrderEntry : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the order. /// @@ -33,15 +38,11 @@ public record OrderEntry [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderFulfillmentDeliveryDetailsScheduleType.cs b/src/Square/Types/OrderFulfillmentDeliveryDetailsScheduleType.cs index a94bc022..2a93955a 100644 --- a/src/Square/Types/OrderFulfillmentDeliveryDetailsScheduleType.cs +++ b/src/Square/Types/OrderFulfillmentDeliveryDetailsScheduleType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderFulfillmentDeliveryDetailsScheduleType : IStringEnum { public static readonly OrderFulfillmentDeliveryDetailsScheduleType Scheduled = new( @@ -62,6 +63,7 @@ public static explicit operator OrderFulfillmentDeliveryDetailsScheduleType(stri /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Scheduled = "SCHEDULED"; diff --git a/src/Square/Types/OrderFulfillmentFulfillmentLineItemApplication.cs b/src/Square/Types/OrderFulfillmentFulfillmentLineItemApplication.cs index f4ac3794..5c0f60e9 100644 --- a/src/Square/Types/OrderFulfillmentFulfillmentLineItemApplication.cs +++ b/src/Square/Types/OrderFulfillmentFulfillmentLineItemApplication.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderFulfillmentFulfillmentLineItemApplication : IStringEnum { public static readonly OrderFulfillmentFulfillmentLineItemApplication All = new(Values.All); @@ -62,6 +63,7 @@ public static explicit operator OrderFulfillmentFulfillmentLineItemApplication(s /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string All = "ALL"; diff --git a/src/Square/Types/OrderFulfillmentPickupDetailsScheduleType.cs b/src/Square/Types/OrderFulfillmentPickupDetailsScheduleType.cs index 5eb8e74c..3e15bf95 100644 --- a/src/Square/Types/OrderFulfillmentPickupDetailsScheduleType.cs +++ b/src/Square/Types/OrderFulfillmentPickupDetailsScheduleType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderFulfillmentPickupDetailsScheduleType : IStringEnum { public static readonly OrderFulfillmentPickupDetailsScheduleType Scheduled = new( @@ -62,6 +63,7 @@ public static explicit operator OrderFulfillmentPickupDetailsScheduleType(string /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Scheduled = "SCHEDULED"; diff --git a/src/Square/Types/OrderFulfillmentState.cs b/src/Square/Types/OrderFulfillmentState.cs index 40465695..95b773a8 100644 --- a/src/Square/Types/OrderFulfillmentState.cs +++ b/src/Square/Types/OrderFulfillmentState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderFulfillmentState : IStringEnum { public static readonly OrderFulfillmentState Proposed = new(Values.Proposed); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Proposed = "PROPOSED"; diff --git a/src/Square/Types/OrderFulfillmentType.cs b/src/Square/Types/OrderFulfillmentType.cs index cfd23d70..bec5d4ca 100644 --- a/src/Square/Types/OrderFulfillmentType.cs +++ b/src/Square/Types/OrderFulfillmentType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderFulfillmentType : IStringEnum { public static readonly OrderFulfillmentType Pickup = new(Values.Pickup); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pickup = "PICKUP"; diff --git a/src/Square/Types/OrderFulfillmentUpdated.cs b/src/Square/Types/OrderFulfillmentUpdated.cs index 0e856df8..1d7647b7 100644 --- a/src/Square/Types/OrderFulfillmentUpdated.cs +++ b/src/Square/Types/OrderFulfillmentUpdated.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderFulfillmentUpdated +[Serializable] +public record OrderFulfillmentUpdated : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order's unique ID. /// @@ -55,15 +60,11 @@ public record OrderFulfillmentUpdated [JsonPropertyName("fulfillment_update")] public IEnumerable? FulfillmentUpdate { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderFulfillmentUpdatedEvent.cs b/src/Square/Types/OrderFulfillmentUpdatedEvent.cs index f8b8dfc8..ab8f387a 100644 --- a/src/Square/Types/OrderFulfillmentUpdatedEvent.cs +++ b/src/Square/Types/OrderFulfillmentUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// is created or updated. This event is triggered only by the /// [UpdateOrder](api-endpoint:Orders-UpdateOrder) endpoint call. /// -public record OrderFulfillmentUpdatedEvent +[Serializable] +public record OrderFulfillmentUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -42,15 +47,11 @@ public record OrderFulfillmentUpdatedEvent [JsonPropertyName("data")] public OrderFulfillmentUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderFulfillmentUpdatedEventData.cs b/src/Square/Types/OrderFulfillmentUpdatedEventData.cs index 6e587728..9bbb1830 100644 --- a/src/Square/Types/OrderFulfillmentUpdatedEventData.cs +++ b/src/Square/Types/OrderFulfillmentUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderFulfillmentUpdatedEventData +[Serializable] +public record OrderFulfillmentUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"order_fulfillment_updated"`. /// @@ -24,15 +29,11 @@ public record OrderFulfillmentUpdatedEventData [JsonPropertyName("object")] public OrderFulfillmentUpdatedObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderFulfillmentUpdatedObject.cs b/src/Square/Types/OrderFulfillmentUpdatedObject.cs index 6af4ce98..37f88e66 100644 --- a/src/Square/Types/OrderFulfillmentUpdatedObject.cs +++ b/src/Square/Types/OrderFulfillmentUpdatedObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record OrderFulfillmentUpdatedObject +[Serializable] +public record OrderFulfillmentUpdatedObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the updated order fulfillment. /// [JsonPropertyName("order_fulfillment_updated")] public OrderFulfillmentUpdated? OrderFulfillmentUpdated { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderFulfillmentUpdatedUpdate.cs b/src/Square/Types/OrderFulfillmentUpdatedUpdate.cs index c9578c31..fd8b9a3b 100644 --- a/src/Square/Types/OrderFulfillmentUpdatedUpdate.cs +++ b/src/Square/Types/OrderFulfillmentUpdatedUpdate.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Information about fulfillment updates. /// -public record OrderFulfillmentUpdatedUpdate +[Serializable] +public record OrderFulfillmentUpdatedUpdate : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the fulfillment only within this order. /// @@ -29,15 +34,11 @@ public record OrderFulfillmentUpdatedUpdate [JsonPropertyName("new_state")] public FulfillmentState? NewState { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItem.cs b/src/Square/Types/OrderLineItem.cs index 8b7fe5d4..4e8a985a 100644 --- a/src/Square/Types/OrderLineItem.cs +++ b/src/Square/Types/OrderLineItem.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a line item in an order. Each line item describes a different /// product to purchase, with its own quantity and price details. /// -public record OrderLineItem +[Serializable] +public record OrderLineItem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the line item only within this order. /// @@ -202,15 +207,11 @@ public record OrderLineItem [JsonPropertyName("total_service_charge_money")] public Money? TotalServiceChargeMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemAppliedDiscount.cs b/src/Square/Types/OrderLineItemAppliedDiscount.cs index e7020b2d..095e0991 100644 --- a/src/Square/Types/OrderLineItemAppliedDiscount.cs +++ b/src/Square/Types/OrderLineItemAppliedDiscount.cs @@ -12,8 +12,13 @@ namespace Square; /// items. The corresponding applied money is automatically computed based on participating /// line items. /// -public record OrderLineItemAppliedDiscount +[Serializable] +public record OrderLineItemAppliedDiscount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the applied discount only within this order. /// @@ -36,15 +41,11 @@ public record OrderLineItemAppliedDiscount [JsonPropertyName("applied_money")] public Money? AppliedMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemAppliedServiceCharge.cs b/src/Square/Types/OrderLineItemAppliedServiceCharge.cs index 70555ca7..d27cd7d5 100644 --- a/src/Square/Types/OrderLineItemAppliedServiceCharge.cs +++ b/src/Square/Types/OrderLineItemAppliedServiceCharge.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderLineItemAppliedServiceCharge +[Serializable] +public record OrderLineItemAppliedServiceCharge : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the applied service charge only within this order. /// @@ -28,15 +33,11 @@ public record OrderLineItemAppliedServiceCharge [JsonPropertyName("applied_money")] public Money? AppliedMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemAppliedTax.cs b/src/Square/Types/OrderLineItemAppliedTax.cs index 71d08f0a..62e93e8b 100644 --- a/src/Square/Types/OrderLineItemAppliedTax.cs +++ b/src/Square/Types/OrderLineItemAppliedTax.cs @@ -12,8 +12,13 @@ namespace Square; /// The corresponding applied money is automatically computed, based on the /// set of participating line items. /// -public record OrderLineItemAppliedTax +[Serializable] +public record OrderLineItemAppliedTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the applied tax only within this order. /// @@ -36,15 +41,11 @@ public record OrderLineItemAppliedTax [JsonPropertyName("applied_money")] public Money? AppliedMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemDiscount.cs b/src/Square/Types/OrderLineItemDiscount.cs index 470b19be..7bad5cb6 100644 --- a/src/Square/Types/OrderLineItemDiscount.cs +++ b/src/Square/Types/OrderLineItemDiscount.cs @@ -12,8 +12,13 @@ namespace Square; /// The amount distributed to each line item is relative to the /// amount contributed by the item to the order subtotal. /// -public record OrderLineItemDiscount +[Serializable] +public record OrderLineItemDiscount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the discount only within this order. /// @@ -133,15 +138,11 @@ public record OrderLineItemDiscount [JsonPropertyName("pricing_rule_id")] public string? PricingRuleId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemDiscountScope.cs b/src/Square/Types/OrderLineItemDiscountScope.cs index 434c01ff..2dc4bc17 100644 --- a/src/Square/Types/OrderLineItemDiscountScope.cs +++ b/src/Square/Types/OrderLineItemDiscountScope.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderLineItemDiscountScope : IStringEnum { public static readonly OrderLineItemDiscountScope OtherDiscountScope = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OtherDiscountScope = "OTHER_DISCOUNT_SCOPE"; diff --git a/src/Square/Types/OrderLineItemDiscountType.cs b/src/Square/Types/OrderLineItemDiscountType.cs index bacf1ae0..949bbf68 100644 --- a/src/Square/Types/OrderLineItemDiscountType.cs +++ b/src/Square/Types/OrderLineItemDiscountType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderLineItemDiscountType : IStringEnum { public static readonly OrderLineItemDiscountType UnknownDiscount = new(Values.UnknownDiscount); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string UnknownDiscount = "UNKNOWN_DISCOUNT"; diff --git a/src/Square/Types/OrderLineItemItemType.cs b/src/Square/Types/OrderLineItemItemType.cs index ad3d7558..d873f190 100644 --- a/src/Square/Types/OrderLineItemItemType.cs +++ b/src/Square/Types/OrderLineItemItemType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderLineItemItemType : IStringEnum { public static readonly OrderLineItemItemType Item = new(Values.Item); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Item = "ITEM"; diff --git a/src/Square/Types/OrderLineItemModifier.cs b/src/Square/Types/OrderLineItemModifier.cs index 6783d5bd..ac35e6b1 100644 --- a/src/Square/Types/OrderLineItemModifier.cs +++ b/src/Square/Types/OrderLineItemModifier.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A [CatalogModifier](entity:CatalogModifier). /// -public record OrderLineItemModifier +[Serializable] +public record OrderLineItemModifier : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the modifier only within this order. /// @@ -85,15 +90,11 @@ public record OrderLineItemModifier [JsonPropertyName("metadata")] public Dictionary? Metadata { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemPricingBlocklists.cs b/src/Square/Types/OrderLineItemPricingBlocklists.cs index b2409c97..be75f1f5 100644 --- a/src/Square/Types/OrderLineItemPricingBlocklists.cs +++ b/src/Square/Types/OrderLineItemPricingBlocklists.cs @@ -9,8 +9,13 @@ namespace Square; /// application to a line item. For more information, see /// [Apply Taxes and Discounts](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts). /// -public record OrderLineItemPricingBlocklists +[Serializable] +public record OrderLineItemPricingBlocklists : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of discounts blocked from applying to the line item. /// Discounts can be blocked by the `discount_uid` (for ad hoc discounts) or @@ -27,15 +32,11 @@ public record OrderLineItemPricingBlocklists [JsonPropertyName("blocked_taxes")] public IEnumerable? BlockedTaxes { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemPricingBlocklistsBlockedDiscount.cs b/src/Square/Types/OrderLineItemPricingBlocklistsBlockedDiscount.cs index 9bc3465e..9a1c1d4f 100644 --- a/src/Square/Types/OrderLineItemPricingBlocklistsBlockedDiscount.cs +++ b/src/Square/Types/OrderLineItemPricingBlocklistsBlockedDiscount.cs @@ -8,8 +8,13 @@ namespace Square; /// A discount to block from applying to a line item. The discount must be /// identified by either `discount_uid` or `discount_catalog_object_id`, but not both. /// -public record OrderLineItemPricingBlocklistsBlockedDiscount +[Serializable] +public record OrderLineItemPricingBlocklistsBlockedDiscount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID of the `BlockedDiscount` within the order. /// @@ -31,15 +36,11 @@ public record OrderLineItemPricingBlocklistsBlockedDiscount [JsonPropertyName("discount_catalog_object_id")] public string? DiscountCatalogObjectId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemPricingBlocklistsBlockedTax.cs b/src/Square/Types/OrderLineItemPricingBlocklistsBlockedTax.cs index 8332b7a1..9dfe2f33 100644 --- a/src/Square/Types/OrderLineItemPricingBlocklistsBlockedTax.cs +++ b/src/Square/Types/OrderLineItemPricingBlocklistsBlockedTax.cs @@ -8,8 +8,13 @@ namespace Square; /// A tax to block from applying to a line item. The tax must be /// identified by either `tax_uid` or `tax_catalog_object_id`, but not both. /// -public record OrderLineItemPricingBlocklistsBlockedTax +[Serializable] +public record OrderLineItemPricingBlocklistsBlockedTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID of the `BlockedTax` within the order. /// @@ -31,15 +36,11 @@ public record OrderLineItemPricingBlocklistsBlockedTax [JsonPropertyName("tax_catalog_object_id")] public string? TaxCatalogObjectId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemTax.cs b/src/Square/Types/OrderLineItemTax.cs index a35d94fe..5dcbc243 100644 --- a/src/Square/Types/OrderLineItemTax.cs +++ b/src/Square/Types/OrderLineItemTax.cs @@ -11,8 +11,13 @@ namespace Square; /// The amount distributed to each line item is relative to the amount the item /// contributes to the order subtotal. /// -public record OrderLineItemTax +[Serializable] +public record OrderLineItemTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the tax only within this order. /// @@ -106,15 +111,11 @@ public record OrderLineItemTax [JsonPropertyName("auto_applied")] public bool? AutoApplied { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderLineItemTaxScope.cs b/src/Square/Types/OrderLineItemTaxScope.cs index be856a20..d9b0ed22 100644 --- a/src/Square/Types/OrderLineItemTaxScope.cs +++ b/src/Square/Types/OrderLineItemTaxScope.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderLineItemTaxScope : IStringEnum { public static readonly OrderLineItemTaxScope OtherTaxScope = new(Values.OtherTaxScope); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OtherTaxScope = "OTHER_TAX_SCOPE"; diff --git a/src/Square/Types/OrderLineItemTaxType.cs b/src/Square/Types/OrderLineItemTaxType.cs index 64932cf0..2b530e6d 100644 --- a/src/Square/Types/OrderLineItemTaxType.cs +++ b/src/Square/Types/OrderLineItemTaxType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderLineItemTaxType : IStringEnum { public static readonly OrderLineItemTaxType UnknownTax = new(Values.UnknownTax); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string UnknownTax = "UNKNOWN_TAX"; diff --git a/src/Square/Types/OrderMoneyAmounts.cs b/src/Square/Types/OrderMoneyAmounts.cs index af73b24f..4da15f3f 100644 --- a/src/Square/Types/OrderMoneyAmounts.cs +++ b/src/Square/Types/OrderMoneyAmounts.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A collection of various money amounts. /// -public record OrderMoneyAmounts +[Serializable] +public record OrderMoneyAmounts : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The total money. /// @@ -39,15 +44,11 @@ public record OrderMoneyAmounts [JsonPropertyName("service_charge_money")] public Money? ServiceChargeMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderPricingOptions.cs b/src/Square/Types/OrderPricingOptions.cs index bccf127d..ceb165ed 100644 --- a/src/Square/Types/OrderPricingOptions.cs +++ b/src/Square/Types/OrderPricingOptions.cs @@ -9,8 +9,13 @@ namespace Square; /// They can be used, for example, to apply automatic price adjustments that are based on preconfigured /// [pricing rules](entity:CatalogPricingRule). /// -public record OrderPricingOptions +[Serializable] +public record OrderPricingOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The option to determine whether pricing rule-based /// discounts are automatically applied to an order. @@ -25,15 +30,11 @@ public record OrderPricingOptions [JsonPropertyName("auto_apply_taxes")] public bool? AutoApplyTaxes { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderQuantityUnit.cs b/src/Square/Types/OrderQuantityUnit.cs index fa9ea889..8a2a02ee 100644 --- a/src/Square/Types/OrderQuantityUnit.cs +++ b/src/Square/Types/OrderQuantityUnit.cs @@ -8,8 +8,13 @@ namespace Square; /// Contains the measurement unit for a quantity and a precision that /// specifies the number of digits after the decimal point for decimal quantities. /// -public record OrderQuantityUnit +[Serializable] +public record OrderQuantityUnit : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A [MeasurementUnit](entity:MeasurementUnit) that represents the /// unit of measure for the quantity. @@ -45,15 +50,11 @@ public record OrderQuantityUnit [JsonPropertyName("catalog_version")] public long? CatalogVersion { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturn.cs b/src/Square/Types/OrderReturn.cs index f57c7aab..3a6da0b6 100644 --- a/src/Square/Types/OrderReturn.cs +++ b/src/Square/Types/OrderReturn.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The set of line items, service charges, taxes, discounts, tips, and other items being returned in an order. /// -public record OrderReturn +[Serializable] +public record OrderReturn : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the return only within this order. /// @@ -72,15 +77,11 @@ public record OrderReturn [JsonPropertyName("return_amounts")] public OrderMoneyAmounts? ReturnAmounts { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturnDiscount.cs b/src/Square/Types/OrderReturnDiscount.cs index 71ad24d0..1cdfbd87 100644 --- a/src/Square/Types/OrderReturnDiscount.cs +++ b/src/Square/Types/OrderReturnDiscount.cs @@ -12,8 +12,13 @@ namespace Square; /// The amount distributed to each return line item is relative to that item’s contribution to the /// order subtotal. /// -public record OrderReturnDiscount +[Serializable] +public record OrderReturnDiscount : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the returned discount only within this order. /// @@ -89,15 +94,11 @@ public record OrderReturnDiscount [JsonPropertyName("scope")] public OrderLineItemDiscountScope? Scope { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturnLineItem.cs b/src/Square/Types/OrderReturnLineItem.cs index 63b0884d..eb52939b 100644 --- a/src/Square/Types/OrderReturnLineItem.cs +++ b/src/Square/Types/OrderReturnLineItem.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The line item being returned in an order. /// -public record OrderReturnLineItem +[Serializable] +public record OrderReturnLineItem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for this return line-item entry. /// @@ -152,15 +157,11 @@ public record OrderReturnLineItem [JsonPropertyName("total_service_charge_money")] public Money? TotalServiceChargeMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturnLineItemModifier.cs b/src/Square/Types/OrderReturnLineItemModifier.cs index 0d9479e0..d1ab6c2a 100644 --- a/src/Square/Types/OrderReturnLineItemModifier.cs +++ b/src/Square/Types/OrderReturnLineItemModifier.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A line item modifier being returned. /// -public record OrderReturnLineItemModifier +[Serializable] +public record OrderReturnLineItemModifier : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the return modifier only within this order. /// @@ -68,15 +73,11 @@ public record OrderReturnLineItemModifier [JsonPropertyName("quantity")] public string? Quantity { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturnServiceCharge.cs b/src/Square/Types/OrderReturnServiceCharge.cs index 938e2858..e8d05ea1 100644 --- a/src/Square/Types/OrderReturnServiceCharge.cs +++ b/src/Square/Types/OrderReturnServiceCharge.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the service charge applied to the original order. /// -public record OrderReturnServiceCharge +[Serializable] +public record OrderReturnServiceCharge : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the return service charge only within this order. /// @@ -130,15 +135,11 @@ public record OrderReturnServiceCharge [JsonPropertyName("scope")] public OrderServiceChargeScope? Scope { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturnTax.cs b/src/Square/Types/OrderReturnTax.cs index 367f0f61..8acd24fa 100644 --- a/src/Square/Types/OrderReturnTax.cs +++ b/src/Square/Types/OrderReturnTax.cs @@ -11,8 +11,13 @@ namespace Square; /// The amount distributed to each return line item is relative to that item’s contribution to the /// order subtotal. /// -public record OrderReturnTax +[Serializable] +public record OrderReturnTax : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the returned tax only within this order. /// @@ -73,15 +78,11 @@ public record OrderReturnTax [JsonPropertyName("scope")] public OrderLineItemTaxScope? Scope { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReturnTip.cs b/src/Square/Types/OrderReturnTip.cs index 66e6c4a0..e672e322 100644 --- a/src/Square/Types/OrderReturnTip.cs +++ b/src/Square/Types/OrderReturnTip.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A tip being returned. /// -public record OrderReturnTip +[Serializable] +public record OrderReturnTip : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the tip only within this order. /// @@ -34,15 +39,11 @@ public record OrderReturnTip [JsonPropertyName("source_tender_id")] public string? SourceTenderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderReward.cs b/src/Square/Types/OrderReward.cs index 616929ce..d1a65129 100644 --- a/src/Square/Types/OrderReward.cs +++ b/src/Square/Types/OrderReward.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a reward that can be applied to an order if the necessary /// reward tier criteria are met. Rewards are created through the Loyalty API. /// -public record OrderReward +[Serializable] +public record OrderReward : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The identifier of the reward. /// @@ -22,15 +27,11 @@ public record OrderReward [JsonPropertyName("reward_tier_id")] public required string RewardTierId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderRoundingAdjustment.cs b/src/Square/Types/OrderRoundingAdjustment.cs index 3e417ed9..198d97e8 100644 --- a/src/Square/Types/OrderRoundingAdjustment.cs +++ b/src/Square/Types/OrderRoundingAdjustment.cs @@ -8,8 +8,13 @@ namespace Square; /// A rounding adjustment of the money being returned. Commonly used to apply cash rounding /// when the minimum unit of the account is smaller than the lowest physical denomination of the currency. /// -public record OrderRoundingAdjustment +[Serializable] +public record OrderRoundingAdjustment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the rounding adjustment only within this order. /// @@ -28,15 +33,11 @@ public record OrderRoundingAdjustment [JsonPropertyName("amount_money")] public Money? AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderServiceCharge.cs b/src/Square/Types/OrderServiceCharge.cs index cadc8fcc..32806cfe 100644 --- a/src/Square/Types/OrderServiceCharge.cs +++ b/src/Square/Types/OrderServiceCharge.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a service charge applied to an order. /// -public record OrderServiceCharge +[Serializable] +public record OrderServiceCharge : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID that identifies the service charge only within this order. /// @@ -161,15 +166,11 @@ public record OrderServiceCharge [JsonPropertyName("scope")] public OrderServiceChargeScope? Scope { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderServiceChargeCalculationPhase.cs b/src/Square/Types/OrderServiceChargeCalculationPhase.cs index a4be19b5..d8087eb1 100644 --- a/src/Square/Types/OrderServiceChargeCalculationPhase.cs +++ b/src/Square/Types/OrderServiceChargeCalculationPhase.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderServiceChargeCalculationPhase : IStringEnum { public static readonly OrderServiceChargeCalculationPhase SubtotalPhase = new( @@ -64,6 +65,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string SubtotalPhase = "SUBTOTAL_PHASE"; diff --git a/src/Square/Types/OrderServiceChargeScope.cs b/src/Square/Types/OrderServiceChargeScope.cs index 94767e67..16042943 100644 --- a/src/Square/Types/OrderServiceChargeScope.cs +++ b/src/Square/Types/OrderServiceChargeScope.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderServiceChargeScope : IStringEnum { public static readonly OrderServiceChargeScope OtherServiceChargeScope = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OtherServiceChargeScope = "OTHER_SERVICE_CHARGE_SCOPE"; diff --git a/src/Square/Types/OrderServiceChargeTreatmentType.cs b/src/Square/Types/OrderServiceChargeTreatmentType.cs index 53021ed0..63e99dac 100644 --- a/src/Square/Types/OrderServiceChargeTreatmentType.cs +++ b/src/Square/Types/OrderServiceChargeTreatmentType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderServiceChargeTreatmentType : IStringEnum { public static readonly OrderServiceChargeTreatmentType LineItemTreatment = new( @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string LineItemTreatment = "LINE_ITEM_TREATMENT"; diff --git a/src/Square/Types/OrderServiceChargeType.cs b/src/Square/Types/OrderServiceChargeType.cs index 1587da77..d18a8397 100644 --- a/src/Square/Types/OrderServiceChargeType.cs +++ b/src/Square/Types/OrderServiceChargeType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderServiceChargeType : IStringEnum { public static readonly OrderServiceChargeType AutoGratuity = new(Values.AutoGratuity); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AutoGratuity = "AUTO_GRATUITY"; diff --git a/src/Square/Types/OrderSource.cs b/src/Square/Types/OrderSource.cs index a885b746..93b8dc5f 100644 --- a/src/Square/Types/OrderSource.cs +++ b/src/Square/Types/OrderSource.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the origination details of an order. /// -public record OrderSource +[Serializable] +public record OrderSource : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name used to identify the place (physical or digital) that an order originates. /// If unset, the name defaults to the name of the application that created the order. @@ -16,15 +21,11 @@ public record OrderSource [JsonPropertyName("name")] public string? Name { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderState.cs b/src/Square/Types/OrderState.cs index e13c8e89..0cc84556 100644 --- a/src/Square/Types/OrderState.cs +++ b/src/Square/Types/OrderState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct OrderState : IStringEnum { public static readonly OrderState Open = new(Values.Open); @@ -57,6 +58,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Open = "OPEN"; diff --git a/src/Square/Types/OrderUpdated.cs b/src/Square/Types/OrderUpdated.cs index 09d63072..bf9629a2 100644 --- a/src/Square/Types/OrderUpdated.cs +++ b/src/Square/Types/OrderUpdated.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderUpdated +[Serializable] +public record OrderUpdated : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order's unique ID. /// @@ -49,15 +54,11 @@ public record OrderUpdated [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderUpdatedEvent.cs b/src/Square/Types/OrderUpdatedEvent.cs index e9734707..7e51f436 100644 --- a/src/Square/Types/OrderUpdatedEvent.cs +++ b/src/Square/Types/OrderUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// event is triggered by the [UpdateOrder](api-endpoint:Orders-UpdateOrder) /// endpoint call, Order Manager, or the Square Dashboard. /// -public record OrderUpdatedEvent +[Serializable] +public record OrderUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -42,15 +47,11 @@ public record OrderUpdatedEvent [JsonPropertyName("data")] public OrderUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderUpdatedEventData.cs b/src/Square/Types/OrderUpdatedEventData.cs index 9e8e5d7d..8ba1ae7b 100644 --- a/src/Square/Types/OrderUpdatedEventData.cs +++ b/src/Square/Types/OrderUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record OrderUpdatedEventData +[Serializable] +public record OrderUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"order_updated"`. /// @@ -24,15 +29,11 @@ public record OrderUpdatedEventData [JsonPropertyName("object")] public OrderUpdatedObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/OrderUpdatedObject.cs b/src/Square/Types/OrderUpdatedObject.cs index a89bade4..705d113e 100644 --- a/src/Square/Types/OrderUpdatedObject.cs +++ b/src/Square/Types/OrderUpdatedObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record OrderUpdatedObject +[Serializable] +public record OrderUpdatedObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about the updated order. /// [JsonPropertyName("order_updated")] public OrderUpdated? OrderUpdated { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PauseSubscriptionResponse.cs b/src/Square/Types/PauseSubscriptionResponse.cs index 698688f9..222142f3 100644 --- a/src/Square/Types/PauseSubscriptionResponse.cs +++ b/src/Square/Types/PauseSubscriptionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [PauseSubscription](api-endpoint:Subscriptions-PauseSubscription) endpoint. /// -public record PauseSubscriptionResponse +[Serializable] +public record PauseSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -28,15 +33,11 @@ public record PauseSubscriptionResponse [JsonPropertyName("actions")] public IEnumerable? Actions { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayOrderResponse.cs b/src/Square/Types/PayOrderResponse.cs index 48918c18..d876b8c4 100644 --- a/src/Square/Types/PayOrderResponse.cs +++ b/src/Square/Types/PayOrderResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the response body of a request to the /// [PayOrder](api-endpoint:Orders-PayOrder) endpoint. /// -public record PayOrderResponse +[Serializable] +public record PayOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record PayOrderResponse [JsonPropertyName("order")] public Order? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Payment.cs b/src/Square/Types/Payment.cs index 374eb062..dfd57ee7 100644 --- a/src/Square/Types/Payment.cs +++ b/src/Square/Types/Payment.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a payment processed by the Square API. /// -public record Payment +[Serializable] +public record Payment : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for the payment. /// @@ -379,15 +384,11 @@ public record Payment [JsonPropertyName("version_token")] public string? VersionToken { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityAppFeeRefundDetail.cs b/src/Square/Types/PaymentBalanceActivityAppFeeRefundDetail.cs index 626bd5fb..8e639225 100644 --- a/src/Square/Types/PaymentBalanceActivityAppFeeRefundDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityAppFeeRefundDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityAppFeeRefundDetail +[Serializable] +public record PaymentBalanceActivityAppFeeRefundDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -24,15 +29,11 @@ public record PaymentBalanceActivityAppFeeRefundDetail [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityAppFeeRevenueDetail.cs b/src/Square/Types/PaymentBalanceActivityAppFeeRevenueDetail.cs index f50ad0be..7f4f4e42 100644 --- a/src/Square/Types/PaymentBalanceActivityAppFeeRevenueDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityAppFeeRevenueDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityAppFeeRevenueDetail +[Serializable] +public record PaymentBalanceActivityAppFeeRevenueDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityAppFeeRevenueDetail [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityAutomaticSavingsDetail.cs b/src/Square/Types/PaymentBalanceActivityAutomaticSavingsDetail.cs index 0970517d..db0d7d78 100644 --- a/src/Square/Types/PaymentBalanceActivityAutomaticSavingsDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityAutomaticSavingsDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityAutomaticSavingsDetail +[Serializable] +public record PaymentBalanceActivityAutomaticSavingsDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityAutomaticSavingsDetail [JsonPropertyName("payout_id")] public string? PayoutId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityAutomaticSavingsReversedDetail.cs b/src/Square/Types/PaymentBalanceActivityAutomaticSavingsReversedDetail.cs index 124b8e4b..b2b56619 100644 --- a/src/Square/Types/PaymentBalanceActivityAutomaticSavingsReversedDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityAutomaticSavingsReversedDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityAutomaticSavingsReversedDetail +[Serializable] +public record PaymentBalanceActivityAutomaticSavingsReversedDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityAutomaticSavingsReversedDetail [JsonPropertyName("payout_id")] public string? PayoutId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityChargeDetail.cs b/src/Square/Types/PaymentBalanceActivityChargeDetail.cs index 2a796581..8646de13 100644 --- a/src/Square/Types/PaymentBalanceActivityChargeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityChargeDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityChargeDetail +[Serializable] +public record PaymentBalanceActivityChargeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityDepositFeeDetail.cs b/src/Square/Types/PaymentBalanceActivityDepositFeeDetail.cs index fe5e6b04..6e516cb7 100644 --- a/src/Square/Types/PaymentBalanceActivityDepositFeeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityDepositFeeDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityDepositFeeDetail +[Serializable] +public record PaymentBalanceActivityDepositFeeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payout that triggered this deposit fee activity. /// [JsonPropertyName("payout_id")] public string? PayoutId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityDepositFeeReversedDetail.cs b/src/Square/Types/PaymentBalanceActivityDepositFeeReversedDetail.cs index 25cab638..63a84be6 100644 --- a/src/Square/Types/PaymentBalanceActivityDepositFeeReversedDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityDepositFeeReversedDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityDepositFeeReversedDetail +[Serializable] +public record PaymentBalanceActivityDepositFeeReversedDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payout that triggered this deposit fee activity. /// [JsonPropertyName("payout_id")] public string? PayoutId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityDisputeDetail.cs b/src/Square/Types/PaymentBalanceActivityDisputeDetail.cs index eb03ce27..a1bd56b0 100644 --- a/src/Square/Types/PaymentBalanceActivityDisputeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityDisputeDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityDisputeDetail +[Serializable] +public record PaymentBalanceActivityDisputeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityDisputeDetail [JsonPropertyName("dispute_id")] public string? DisputeId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityFeeDetail.cs b/src/Square/Types/PaymentBalanceActivityFeeDetail.cs index 797a68d3..7b6e416d 100644 --- a/src/Square/Types/PaymentBalanceActivityFeeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityFeeDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityFeeDetail +[Serializable] +public record PaymentBalanceActivityFeeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity /// This will only be populated when a principal LedgerEntryToken is also populated. @@ -15,15 +20,11 @@ public record PaymentBalanceActivityFeeDetail [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityFreeProcessingDetail.cs b/src/Square/Types/PaymentBalanceActivityFreeProcessingDetail.cs index 5ac34b5d..45e42a26 100644 --- a/src/Square/Types/PaymentBalanceActivityFreeProcessingDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityFreeProcessingDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityFreeProcessingDetail +[Serializable] +public record PaymentBalanceActivityFreeProcessingDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityHoldAdjustmentDetail.cs b/src/Square/Types/PaymentBalanceActivityHoldAdjustmentDetail.cs index a32c4634..ee0c1ad3 100644 --- a/src/Square/Types/PaymentBalanceActivityHoldAdjustmentDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityHoldAdjustmentDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityHoldAdjustmentDetail +[Serializable] +public record PaymentBalanceActivityHoldAdjustmentDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityOpenDisputeDetail.cs b/src/Square/Types/PaymentBalanceActivityOpenDisputeDetail.cs index f1f6ce2e..fe96f44e 100644 --- a/src/Square/Types/PaymentBalanceActivityOpenDisputeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityOpenDisputeDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityOpenDisputeDetail +[Serializable] +public record PaymentBalanceActivityOpenDisputeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityOpenDisputeDetail [JsonPropertyName("dispute_id")] public string? DisputeId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityOtherAdjustmentDetail.cs b/src/Square/Types/PaymentBalanceActivityOtherAdjustmentDetail.cs index 395eb83a..5f449a16 100644 --- a/src/Square/Types/PaymentBalanceActivityOtherAdjustmentDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityOtherAdjustmentDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityOtherAdjustmentDetail +[Serializable] +public record PaymentBalanceActivityOtherAdjustmentDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityOtherDetail.cs b/src/Square/Types/PaymentBalanceActivityOtherDetail.cs index fd02f3d2..f97bca00 100644 --- a/src/Square/Types/PaymentBalanceActivityOtherDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityOtherDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityOtherDetail +[Serializable] +public record PaymentBalanceActivityOtherDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityRefundDetail.cs b/src/Square/Types/PaymentBalanceActivityRefundDetail.cs index 1d2810cb..a52f18d1 100644 --- a/src/Square/Types/PaymentBalanceActivityRefundDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityRefundDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityRefundDetail +[Serializable] +public record PaymentBalanceActivityRefundDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityRefundDetail [JsonPropertyName("refund_id")] public string? RefundId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityReleaseAdjustmentDetail.cs b/src/Square/Types/PaymentBalanceActivityReleaseAdjustmentDetail.cs index ccdd03d0..8ac5a293 100644 --- a/src/Square/Types/PaymentBalanceActivityReleaseAdjustmentDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityReleaseAdjustmentDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityReleaseAdjustmentDetail +[Serializable] +public record PaymentBalanceActivityReleaseAdjustmentDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityReserveHoldDetail.cs b/src/Square/Types/PaymentBalanceActivityReserveHoldDetail.cs index 7570f281..8dbfedba 100644 --- a/src/Square/Types/PaymentBalanceActivityReserveHoldDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityReserveHoldDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityReserveHoldDetail +[Serializable] +public record PaymentBalanceActivityReserveHoldDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityReserveReleaseDetail.cs b/src/Square/Types/PaymentBalanceActivityReserveReleaseDetail.cs index 1678cdbb..909f20d4 100644 --- a/src/Square/Types/PaymentBalanceActivityReserveReleaseDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityReserveReleaseDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityReserveReleaseDetail +[Serializable] +public record PaymentBalanceActivityReserveReleaseDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivitySquareCapitalPaymentDetail.cs b/src/Square/Types/PaymentBalanceActivitySquareCapitalPaymentDetail.cs index 2096757e..75db6771 100644 --- a/src/Square/Types/PaymentBalanceActivitySquareCapitalPaymentDetail.cs +++ b/src/Square/Types/PaymentBalanceActivitySquareCapitalPaymentDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivitySquareCapitalPaymentDetail +[Serializable] +public record PaymentBalanceActivitySquareCapitalPaymentDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivitySquareCapitalReversedPaymentDetail.cs b/src/Square/Types/PaymentBalanceActivitySquareCapitalReversedPaymentDetail.cs index 77c6a24b..8e4cb331 100644 --- a/src/Square/Types/PaymentBalanceActivitySquareCapitalReversedPaymentDetail.cs +++ b/src/Square/Types/PaymentBalanceActivitySquareCapitalReversedPaymentDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivitySquareCapitalReversedPaymentDetail +[Serializable] +public record PaymentBalanceActivitySquareCapitalReversedPaymentDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferDetail.cs b/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferDetail.cs index e563d44f..069d4d43 100644 --- a/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferDetail.cs +++ b/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivitySquarePayrollTransferDetail +[Serializable] +public record PaymentBalanceActivitySquarePayrollTransferDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferReversedDetail.cs b/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferReversedDetail.cs index 3fcfdc3f..0f265630 100644 --- a/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferReversedDetail.cs +++ b/src/Square/Types/PaymentBalanceActivitySquarePayrollTransferReversedDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivitySquarePayrollTransferReversedDetail +[Serializable] +public record PaymentBalanceActivitySquarePayrollTransferReversedDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityTaxOnFeeDetail.cs b/src/Square/Types/PaymentBalanceActivityTaxOnFeeDetail.cs index 4a596143..da5fa258 100644 --- a/src/Square/Types/PaymentBalanceActivityTaxOnFeeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityTaxOnFeeDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityTaxOnFeeDetail +[Serializable] +public record PaymentBalanceActivityTaxOnFeeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityTaxOnFeeDetail [JsonPropertyName("tax_rate_description")] public string? TaxRateDescription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityThirdPartyFeeDetail.cs b/src/Square/Types/PaymentBalanceActivityThirdPartyFeeDetail.cs index 43672408..d29dfb4f 100644 --- a/src/Square/Types/PaymentBalanceActivityThirdPartyFeeDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityThirdPartyFeeDetail.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentBalanceActivityThirdPartyFeeDetail +[Serializable] +public record PaymentBalanceActivityThirdPartyFeeDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentBalanceActivityThirdPartyFeeRefundDetail.cs b/src/Square/Types/PaymentBalanceActivityThirdPartyFeeRefundDetail.cs index 4f5f7a9c..3e51af24 100644 --- a/src/Square/Types/PaymentBalanceActivityThirdPartyFeeRefundDetail.cs +++ b/src/Square/Types/PaymentBalanceActivityThirdPartyFeeRefundDetail.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentBalanceActivityThirdPartyFeeRefundDetail +[Serializable] +public record PaymentBalanceActivityThirdPartyFeeRefundDetail : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the payment associated with this activity. /// @@ -18,15 +23,11 @@ public record PaymentBalanceActivityThirdPartyFeeRefundDetail [JsonPropertyName("refund_id")] public string? RefundId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentCreatedEvent.cs b/src/Square/Types/PaymentCreatedEvent.cs index b2013b77..f14ae1be 100644 --- a/src/Square/Types/PaymentCreatedEvent.cs +++ b/src/Square/Types/PaymentCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Payment](entity:Payment) is created. /// -public record PaymentCreatedEvent +[Serializable] +public record PaymentCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record PaymentCreatedEvent [JsonPropertyName("data")] public PaymentCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentCreatedEventData.cs b/src/Square/Types/PaymentCreatedEventData.cs index 18909b90..e1b145a9 100644 --- a/src/Square/Types/PaymentCreatedEventData.cs +++ b/src/Square/Types/PaymentCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentCreatedEventData +[Serializable] +public record PaymentCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"payment"`. /// @@ -24,15 +29,11 @@ public record PaymentCreatedEventData [JsonPropertyName("object")] public PaymentCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentCreatedEventObject.cs b/src/Square/Types/PaymentCreatedEventObject.cs index 1db569b4..4c76129b 100644 --- a/src/Square/Types/PaymentCreatedEventObject.cs +++ b/src/Square/Types/PaymentCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentCreatedEventObject +[Serializable] +public record PaymentCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created payment. /// [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentLink.cs b/src/Square/Types/PaymentLink.cs index 5f9265fa..e8546b4c 100644 --- a/src/Square/Types/PaymentLink.cs +++ b/src/Square/Types/PaymentLink.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentLink +[Serializable] +public record PaymentLink : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the payment link. /// @@ -80,15 +85,11 @@ public record PaymentLink [JsonPropertyName("payment_note")] public string? PaymentNote { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentLinkRelatedResources.cs b/src/Square/Types/PaymentLinkRelatedResources.cs index 825f04ff..501f56cd 100644 --- a/src/Square/Types/PaymentLinkRelatedResources.cs +++ b/src/Square/Types/PaymentLinkRelatedResources.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentLinkRelatedResources +[Serializable] +public record PaymentLinkRelatedResources : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order associated with the payment link. /// @@ -18,15 +23,11 @@ public record PaymentLinkRelatedResources [JsonPropertyName("subscription_plans")] public IEnumerable? SubscriptionPlans { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentOptions.cs b/src/Square/Types/PaymentOptions.cs index e0dc6f43..fe501041 100644 --- a/src/Square/Types/PaymentOptions.cs +++ b/src/Square/Types/PaymentOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentOptions +[Serializable] +public record PaymentOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether the `Payment` objects created from this `TerminalCheckout` are /// automatically `COMPLETED` or left in an `APPROVED` state for later modification. @@ -63,15 +68,11 @@ public record PaymentOptions [JsonPropertyName("delay_action")] public PaymentOptionsDelayAction? DelayAction { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentOptionsDelayAction.cs b/src/Square/Types/PaymentOptionsDelayAction.cs index b0e9e3f3..b62b1945 100644 --- a/src/Square/Types/PaymentOptionsDelayAction.cs +++ b/src/Square/Types/PaymentOptionsDelayAction.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct PaymentOptionsDelayAction : IStringEnum { public static readonly PaymentOptionsDelayAction Cancel = new(Values.Cancel); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Cancel = "CANCEL"; diff --git a/src/Square/Types/PaymentRefund.cs b/src/Square/Types/PaymentRefund.cs index f8fb0956..150f3112 100644 --- a/src/Square/Types/PaymentRefund.cs +++ b/src/Square/Types/PaymentRefund.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a refund of a payment made using Square. Contains information about /// the original payment and the amount of money refunded. /// -public record PaymentRefund +[Serializable] +public record PaymentRefund : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique ID for this refund, generated by Square. /// @@ -123,15 +128,11 @@ public record PaymentRefund [JsonPropertyName("terminal_refund_id")] public string? TerminalRefundId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentUpdatedEvent.cs b/src/Square/Types/PaymentUpdatedEvent.cs index c66772fc..94e79e7e 100644 --- a/src/Square/Types/PaymentUpdatedEvent.cs +++ b/src/Square/Types/PaymentUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// Typically the `payment.status`, or `card_details.status` fields are updated /// as a payment is canceled, authorized, or completed. /// -public record PaymentUpdatedEvent +[Serializable] +public record PaymentUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -42,15 +47,11 @@ public record PaymentUpdatedEvent [JsonPropertyName("data")] public PaymentUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentUpdatedEventData.cs b/src/Square/Types/PaymentUpdatedEventData.cs index 76681f61..a0c4338e 100644 --- a/src/Square/Types/PaymentUpdatedEventData.cs +++ b/src/Square/Types/PaymentUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record PaymentUpdatedEventData +[Serializable] +public record PaymentUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"payment"`. /// @@ -24,15 +29,11 @@ public record PaymentUpdatedEventData [JsonPropertyName("object")] public PaymentUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PaymentUpdatedEventObject.cs b/src/Square/Types/PaymentUpdatedEventObject.cs index c96c09b2..1098e2d3 100644 --- a/src/Square/Types/PaymentUpdatedEventObject.cs +++ b/src/Square/Types/PaymentUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record PaymentUpdatedEventObject +[Serializable] +public record PaymentUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated payment. /// [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Payout.cs b/src/Square/Types/Payout.cs index 734e1c5b..d73df8b2 100644 --- a/src/Square/Types/Payout.cs +++ b/src/Square/Types/Payout.cs @@ -8,8 +8,13 @@ namespace Square; /// An accounting of the amount owed the seller and record of the actual transfer to their /// external bank account or to the Square balance. /// -public record Payout +[Serializable] +public record Payout : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for the payout. /// @@ -86,15 +91,11 @@ public record Payout [JsonPropertyName("end_to_end_id")] public string? EndToEndId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutEntry.cs b/src/Square/Types/PayoutEntry.cs index 2f313fac..40fd01d8 100644 --- a/src/Square/Types/PayoutEntry.cs +++ b/src/Square/Types/PayoutEntry.cs @@ -8,8 +8,13 @@ namespace Square; /// One or more PayoutEntries that make up a Payout. Each one has a date, amount, and type of activity. /// The total amount of the payout will equal the sum of the payout entries for a batch payout /// -public record PayoutEntry +[Serializable] +public record PayoutEntry : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for the payout entry. /// @@ -203,15 +208,11 @@ public record PayoutEntry [JsonPropertyName("type_square_payroll_transfer_reversed_details")] public PaymentBalanceActivitySquarePayrollTransferReversedDetail? TypeSquarePayrollTransferReversedDetails { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutFailedEvent.cs b/src/Square/Types/PayoutFailedEvent.cs index 0773be6a..096ba764 100644 --- a/src/Square/Types/PayoutFailedEvent.cs +++ b/src/Square/Types/PayoutFailedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Payout](entity:Payout) has failed. /// -public record PayoutFailedEvent +[Serializable] +public record PayoutFailedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -46,15 +51,11 @@ public record PayoutFailedEvent [JsonPropertyName("data")] public PayoutFailedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutFailedEventData.cs b/src/Square/Types/PayoutFailedEventData.cs index fec3d8f2..271d7d10 100644 --- a/src/Square/Types/PayoutFailedEventData.cs +++ b/src/Square/Types/PayoutFailedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record PayoutFailedEventData +[Serializable] +public record PayoutFailedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the affected object's type, `payout`. /// @@ -24,15 +29,11 @@ public record PayoutFailedEventData [JsonPropertyName("object")] public PayoutFailedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutFailedEventObject.cs b/src/Square/Types/PayoutFailedEventObject.cs index 889a11fe..74c9b615 100644 --- a/src/Square/Types/PayoutFailedEventObject.cs +++ b/src/Square/Types/PayoutFailedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record PayoutFailedEventObject +[Serializable] +public record PayoutFailedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The payout that failed. /// [JsonPropertyName("payout")] public Payout? Payout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutFee.cs b/src/Square/Types/PayoutFee.cs index 2712bd5e..77699a57 100644 --- a/src/Square/Types/PayoutFee.cs +++ b/src/Square/Types/PayoutFee.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a payout fee that can incur as part of a payout. /// -public record PayoutFee +[Serializable] +public record PayoutFee : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The money amount of the payout fee. /// @@ -28,15 +33,11 @@ public record PayoutFee [JsonPropertyName("type")] public PayoutFeeType? Type { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutFeeType.cs b/src/Square/Types/PayoutFeeType.cs index 771be464..d3fe3c53 100644 --- a/src/Square/Types/PayoutFeeType.cs +++ b/src/Square/Types/PayoutFeeType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct PayoutFeeType : IStringEnum { public static readonly PayoutFeeType TransferFee = new(Values.TransferFee); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string TransferFee = "TRANSFER_FEE"; diff --git a/src/Square/Types/PayoutPaidEvent.cs b/src/Square/Types/PayoutPaidEvent.cs index 8b0a5324..81177484 100644 --- a/src/Square/Types/PayoutPaidEvent.cs +++ b/src/Square/Types/PayoutPaidEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Payout](entity:Payout) is complete. /// -public record PayoutPaidEvent +[Serializable] +public record PayoutPaidEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -46,15 +51,11 @@ public record PayoutPaidEvent [JsonPropertyName("data")] public PayoutPaidEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutPaidEventData.cs b/src/Square/Types/PayoutPaidEventData.cs index ffa5d53a..afb8bf80 100644 --- a/src/Square/Types/PayoutPaidEventData.cs +++ b/src/Square/Types/PayoutPaidEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record PayoutPaidEventData +[Serializable] +public record PayoutPaidEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"payout"`. /// @@ -24,15 +29,11 @@ public record PayoutPaidEventData [JsonPropertyName("object")] public PayoutPaidEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutPaidEventObject.cs b/src/Square/Types/PayoutPaidEventObject.cs index cd160280..dd9815ae 100644 --- a/src/Square/Types/PayoutPaidEventObject.cs +++ b/src/Square/Types/PayoutPaidEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record PayoutPaidEventObject +[Serializable] +public record PayoutPaidEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The payout that has completed. /// [JsonPropertyName("payout")] public Payout? Payout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutSentEvent.cs b/src/Square/Types/PayoutSentEvent.cs index 82574adc..f04c01f9 100644 --- a/src/Square/Types/PayoutSentEvent.cs +++ b/src/Square/Types/PayoutSentEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Payout](entity:Payout) is sent. /// -public record PayoutSentEvent +[Serializable] +public record PayoutSentEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -46,15 +51,11 @@ public record PayoutSentEvent [JsonPropertyName("data")] public PayoutSentEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutSentEventData.cs b/src/Square/Types/PayoutSentEventData.cs index cd6320ce..3e0a6310 100644 --- a/src/Square/Types/PayoutSentEventData.cs +++ b/src/Square/Types/PayoutSentEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record PayoutSentEventData +[Serializable] +public record PayoutSentEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"payout"`. /// @@ -24,15 +29,11 @@ public record PayoutSentEventData [JsonPropertyName("object")] public PayoutSentEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutSentEventObject.cs b/src/Square/Types/PayoutSentEventObject.cs index 80efe778..ce16a256 100644 --- a/src/Square/Types/PayoutSentEventObject.cs +++ b/src/Square/Types/PayoutSentEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record PayoutSentEventObject +[Serializable] +public record PayoutSentEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The payout that was sent. /// [JsonPropertyName("payout")] public Payout? Payout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PayoutStatus.cs b/src/Square/Types/PayoutStatus.cs index 2152a6f5..f30f4c79 100644 --- a/src/Square/Types/PayoutStatus.cs +++ b/src/Square/Types/PayoutStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct PayoutStatus : IStringEnum { public static readonly PayoutStatus Sent = new(Values.Sent); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Sent = "SENT"; diff --git a/src/Square/Types/PayoutType.cs b/src/Square/Types/PayoutType.cs index eaafd6e7..722ad179 100644 --- a/src/Square/Types/PayoutType.cs +++ b/src/Square/Types/PayoutType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct PayoutType : IStringEnum { public static readonly PayoutType Batch = new(Values.Batch); @@ -53,6 +54,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Batch = "BATCH"; diff --git a/src/Square/Types/Phase.cs b/src/Square/Types/Phase.cs index 8481a469..52cbd95d 100644 --- a/src/Square/Types/Phase.cs +++ b/src/Square/Types/Phase.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a phase, which can override subscription phases as defined by plan_id /// -public record Phase +[Serializable] +public record Phase : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// id of subscription phase /// @@ -33,15 +38,11 @@ public record Phase [JsonPropertyName("plan_phase_uid")] public string? PlanPhaseUid { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PhaseInput.cs b/src/Square/Types/PhaseInput.cs index e70d723c..63c4727a 100644 --- a/src/Square/Types/PhaseInput.cs +++ b/src/Square/Types/PhaseInput.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the arguments used to construct a new phase. /// -public record PhaseInput +[Serializable] +public record PhaseInput : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// index of phase in total subscription plan /// @@ -21,15 +26,11 @@ public record PhaseInput [JsonPropertyName("order_template_id")] public string? OrderTemplateId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PrePopulatedData.cs b/src/Square/Types/PrePopulatedData.cs index a0834364..a42e4b79 100644 --- a/src/Square/Types/PrePopulatedData.cs +++ b/src/Square/Types/PrePopulatedData.cs @@ -9,8 +9,13 @@ namespace Square; /// For more information, /// see [Optional Checkout Configurations](https://developer.squareup.com/docs/checkout-api/optional-checkout-configurations). /// -public record PrePopulatedData +[Serializable] +public record PrePopulatedData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The buyer email to prepopulate in the payment form. /// @@ -29,15 +34,11 @@ public record PrePopulatedData [JsonPropertyName("buyer_address")] public Address? BuyerAddress { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ProcessingFee.cs b/src/Square/Types/ProcessingFee.cs index f0cf08a2..dae7103e 100644 --- a/src/Square/Types/ProcessingFee.cs +++ b/src/Square/Types/ProcessingFee.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the Square processing fee. /// -public record ProcessingFee +[Serializable] +public record ProcessingFee : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The timestamp of when the fee takes effect, in RFC 3339 format. /// @@ -30,15 +35,11 @@ public record ProcessingFee [JsonPropertyName("amount_money")] public Money? AmountMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Product.cs b/src/Square/Types/Product.cs index 5b82594a..78585e41 100644 --- a/src/Square/Types/Product.cs +++ b/src/Square/Types/Product.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct Product : IStringEnum { public static readonly Product SquarePos = new(Values.SquarePos); @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string SquarePos = "SQUARE_POS"; diff --git a/src/Square/Types/PublishInvoiceResponse.cs b/src/Square/Types/PublishInvoiceResponse.cs index 8bf0cdf5..38728cb9 100644 --- a/src/Square/Types/PublishInvoiceResponse.cs +++ b/src/Square/Types/PublishInvoiceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes a `PublishInvoice` response. /// -public record PublishInvoiceResponse +[Serializable] +public record PublishInvoiceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The published invoice. /// @@ -21,15 +26,11 @@ public record PublishInvoiceResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/PublishScheduledShiftResponse.cs b/src/Square/Types/PublishScheduledShiftResponse.cs index 0e011e3f..a7a6ab5c 100644 --- a/src/Square/Types/PublishScheduledShiftResponse.cs +++ b/src/Square/Types/PublishScheduledShiftResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [PublishScheduledShift](api-endpoint:Labor-PublishScheduledShift) response. /// Either `scheduled_shift` or `errors` is present in the response. /// -public record PublishScheduledShiftResponse +[Serializable] +public record PublishScheduledShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The published scheduled shift. /// @@ -22,15 +27,11 @@ public record PublishScheduledShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/QrCodeOptions.cs b/src/Square/Types/QrCodeOptions.cs index 09055bac..4a364cbb 100644 --- a/src/Square/Types/QrCodeOptions.cs +++ b/src/Square/Types/QrCodeOptions.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Fields to describe the action that displays QR-Codes. /// -public record QrCodeOptions +[Serializable] +public record QrCodeOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title text to display in the QR code flow on the Terminal. /// @@ -28,15 +33,11 @@ public record QrCodeOptions [JsonPropertyName("barcode_contents")] public required string BarcodeContents { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/QuickPay.cs b/src/Square/Types/QuickPay.cs index 8c339a21..458563cf 100644 --- a/src/Square/Types/QuickPay.cs +++ b/src/Square/Types/QuickPay.cs @@ -9,8 +9,13 @@ namespace Square; /// For more information, /// see [Quick Pay Checkout](https://developer.squareup.com/docs/checkout-api/quick-pay-checkout). /// -public record QuickPay +[Serializable] +public record QuickPay : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ad hoc item name. In the resulting `Order`, this name appears as the line item name. /// @@ -29,15 +34,11 @@ public record QuickPay [JsonPropertyName("location_id")] public required string LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Range.cs b/src/Square/Types/Range.cs index 7353c60c..07585983 100644 --- a/src/Square/Types/Range.cs +++ b/src/Square/Types/Range.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The range of a number value between the specified lower and upper bounds. /// -public record Range +[Serializable] +public record Range : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The lower bound of the number range. At least one of `min` or `max` must be specified. /// If unspecified, the results will have no minimum value. @@ -23,15 +28,11 @@ public record Range [JsonPropertyName("max")] public string? Max { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ReceiptOptions.cs b/src/Square/Types/ReceiptOptions.cs index 14c392d4..0d86a68d 100644 --- a/src/Square/Types/ReceiptOptions.cs +++ b/src/Square/Types/ReceiptOptions.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes receipt action fields. /// -public record ReceiptOptions +[Serializable] +public record ReceiptOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The reference to the Square payment ID for the receipt. /// @@ -30,15 +35,11 @@ public record ReceiptOptions [JsonPropertyName("is_duplicate")] public bool? IsDuplicate { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ReceiveTransferOrderResponse.cs b/src/Square/Types/ReceiveTransferOrderResponse.cs index 38fad55d..cf7938cc 100644 --- a/src/Square/Types/ReceiveTransferOrderResponse.cs +++ b/src/Square/Types/ReceiveTransferOrderResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response for receiving items for a transfer order /// -public record ReceiveTransferOrderResponse +[Serializable] +public record ReceiveTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated transfer order /// @@ -21,15 +26,11 @@ public record ReceiveTransferOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RedeemLoyaltyRewardResponse.cs b/src/Square/Types/RedeemLoyaltyRewardResponse.cs index 32853769..39a053f8 100644 --- a/src/Square/Types/RedeemLoyaltyRewardResponse.cs +++ b/src/Square/Types/RedeemLoyaltyRewardResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes the `LoyaltyEvent` published for redeeming the reward. /// -public record RedeemLoyaltyRewardResponse +[Serializable] +public record RedeemLoyaltyRewardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record RedeemLoyaltyRewardResponse [JsonPropertyName("event")] public LoyaltyEvent? Event { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Reference.cs b/src/Square/Types/Reference.cs index 0ba69d24..b7073ef9 100644 --- a/src/Square/Types/Reference.cs +++ b/src/Square/Types/Reference.cs @@ -4,8 +4,13 @@ namespace Square; -public record Reference +[Serializable] +public record Reference : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of entity a channel is associated with. /// See [Type](#type-type) for possible values @@ -19,15 +24,11 @@ public record Reference [JsonPropertyName("id")] public string? Id { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ReferenceType.cs b/src/Square/Types/ReferenceType.cs index a51d7d1a..d3cf4920 100644 --- a/src/Square/Types/ReferenceType.cs +++ b/src/Square/Types/ReferenceType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ReferenceType : IStringEnum { public static readonly ReferenceType UnknownType = new(Values.UnknownType); @@ -80,6 +81,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string UnknownType = "UNKNOWN_TYPE"; diff --git a/src/Square/Types/Refund.cs b/src/Square/Types/Refund.cs index eb8cb1d3..5b5f5ff7 100644 --- a/src/Square/Types/Refund.cs +++ b/src/Square/Types/Refund.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a refund processed for a Square transaction. /// -public record Refund +[Serializable] +public record Refund : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The refund's unique ID. /// @@ -73,15 +78,11 @@ public record Refund [JsonPropertyName("additional_recipients")] public IEnumerable? AdditionalRecipients { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundCreatedEvent.cs b/src/Square/Types/RefundCreatedEvent.cs index 74b8afcd..23ce82bd 100644 --- a/src/Square/Types/RefundCreatedEvent.cs +++ b/src/Square/Types/RefundCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Refund](entity:PaymentRefund) is created. /// -public record RefundCreatedEvent +[Serializable] +public record RefundCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record RefundCreatedEvent [JsonPropertyName("data")] public RefundCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundCreatedEventData.cs b/src/Square/Types/RefundCreatedEventData.cs index 3c976257..40f1a7b4 100644 --- a/src/Square/Types/RefundCreatedEventData.cs +++ b/src/Square/Types/RefundCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record RefundCreatedEventData +[Serializable] +public record RefundCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"refund"`. /// @@ -24,15 +29,11 @@ public record RefundCreatedEventData [JsonPropertyName("object")] public RefundCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundCreatedEventObject.cs b/src/Square/Types/RefundCreatedEventObject.cs index fa79ceb4..93d11395 100644 --- a/src/Square/Types/RefundCreatedEventObject.cs +++ b/src/Square/Types/RefundCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record RefundCreatedEventObject +[Serializable] +public record RefundCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created refund. /// [JsonPropertyName("refund")] public PaymentRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundPaymentResponse.cs b/src/Square/Types/RefundPaymentResponse.cs index 37894f4b..e90f7348 100644 --- a/src/Square/Types/RefundPaymentResponse.cs +++ b/src/Square/Types/RefundPaymentResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// If there are errors processing the request, the `refund` field might not be /// present, or it might be present with a status of `FAILED`. /// -public record RefundPaymentResponse +[Serializable] +public record RefundPaymentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -25,15 +30,11 @@ public record RefundPaymentResponse [JsonPropertyName("refund")] public PaymentRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundStatus.cs b/src/Square/Types/RefundStatus.cs index 1895947f..95407922 100644 --- a/src/Square/Types/RefundStatus.cs +++ b/src/Square/Types/RefundStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct RefundStatus : IStringEnum { public static readonly RefundStatus Pending = new(Values.Pending); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/RefundUpdatedEvent.cs b/src/Square/Types/RefundUpdatedEvent.cs index 94e4cf7f..41bdbe88 100644 --- a/src/Square/Types/RefundUpdatedEvent.cs +++ b/src/Square/Types/RefundUpdatedEvent.cs @@ -8,8 +8,13 @@ namespace Square; /// Published when a [Refund](entity:PaymentRefund) is updated. /// Typically the `refund.status` changes when a refund is completed. /// -public record RefundUpdatedEvent +[Serializable] +public record RefundUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -41,15 +46,11 @@ public record RefundUpdatedEvent [JsonPropertyName("data")] public RefundUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundUpdatedEventData.cs b/src/Square/Types/RefundUpdatedEventData.cs index c996ee24..4ca44b78 100644 --- a/src/Square/Types/RefundUpdatedEventData.cs +++ b/src/Square/Types/RefundUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record RefundUpdatedEventData +[Serializable] +public record RefundUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"refund"`. /// @@ -24,15 +29,11 @@ public record RefundUpdatedEventData [JsonPropertyName("object")] public RefundUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RefundUpdatedEventObject.cs b/src/Square/Types/RefundUpdatedEventObject.cs index 0d0c6501..872ba813 100644 --- a/src/Square/Types/RefundUpdatedEventObject.cs +++ b/src/Square/Types/RefundUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record RefundUpdatedEventObject +[Serializable] +public record RefundUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated refund. /// [JsonPropertyName("refund")] public PaymentRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RegisterDomainResponse.cs b/src/Square/Types/RegisterDomainResponse.cs index 7f29bcfd..f259869d 100644 --- a/src/Square/Types/RegisterDomainResponse.cs +++ b/src/Square/Types/RegisterDomainResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `status` are present in a given response (never both). /// -public record RegisterDomainResponse +[Serializable] +public record RegisterDomainResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -27,15 +32,11 @@ public record RegisterDomainResponse [JsonPropertyName("status")] public RegisterDomainResponseStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RegisterDomainResponseStatus.cs b/src/Square/Types/RegisterDomainResponseStatus.cs index cc2d6ea8..201d5cef 100644 --- a/src/Square/Types/RegisterDomainResponseStatus.cs +++ b/src/Square/Types/RegisterDomainResponseStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct RegisterDomainResponseStatus : IStringEnum { public static readonly RegisterDomainResponseStatus Pending = new(Values.Pending); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/RemoveGroupFromCustomerResponse.cs b/src/Square/Types/RemoveGroupFromCustomerResponse.cs index 927ae8cb..a14dbf0b 100644 --- a/src/Square/Types/RemoveGroupFromCustomerResponse.cs +++ b/src/Square/Types/RemoveGroupFromCustomerResponse.cs @@ -9,23 +9,24 @@ namespace Square; /// a request to the [RemoveGroupFromCustomer](api-endpoint:Customers-RemoveGroupFromCustomer) /// endpoint. /// -public record RemoveGroupFromCustomerResponse +[Serializable] +public record RemoveGroupFromCustomerResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ResumeSubscriptionResponse.cs b/src/Square/Types/ResumeSubscriptionResponse.cs index 9f373acc..7b11e001 100644 --- a/src/Square/Types/ResumeSubscriptionResponse.cs +++ b/src/Square/Types/ResumeSubscriptionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [ResumeSubscription](api-endpoint:Subscriptions-ResumeSubscription) endpoint. /// -public record ResumeSubscriptionResponse +[Serializable] +public record ResumeSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -28,15 +33,11 @@ public record ResumeSubscriptionResponse [JsonPropertyName("actions")] public IEnumerable? Actions { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveBookingCustomAttributeDefinitionResponse.cs b/src/Square/Types/RetrieveBookingCustomAttributeDefinitionResponse.cs index 28b67957..2f55aa7d 100644 --- a/src/Square/Types/RetrieveBookingCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/RetrieveBookingCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-RetrieveBookingCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record RetrieveBookingCustomAttributeDefinitionResponse +[Serializable] +public record RetrieveBookingCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definition. /// @@ -22,15 +27,11 @@ public record RetrieveBookingCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveBookingCustomAttributeResponse.cs b/src/Square/Types/RetrieveBookingCustomAttributeResponse.cs index 266a9128..94b917e8 100644 --- a/src/Square/Types/RetrieveBookingCustomAttributeResponse.cs +++ b/src/Square/Types/RetrieveBookingCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveBookingCustomAttribute](api-endpoint:BookingCustomAttributes-RetrieveBookingCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record RetrieveBookingCustomAttributeResponse +[Serializable] +public record RetrieveBookingCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute. If `with_definition` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field. @@ -23,15 +28,11 @@ public record RetrieveBookingCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveChannelResponse.cs b/src/Square/Types/RetrieveChannelResponse.cs index f1153acf..0ebfc0bd 100644 --- a/src/Square/Types/RetrieveChannelResponse.cs +++ b/src/Square/Types/RetrieveChannelResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record RetrieveChannelResponse +[Serializable] +public record RetrieveChannelResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -18,15 +23,11 @@ public record RetrieveChannelResponse [JsonPropertyName("channel")] public Channel? Channel { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveJobResponse.cs b/src/Square/Types/RetrieveJobResponse.cs index b8fe71de..4fdcae56 100644 --- a/src/Square/Types/RetrieveJobResponse.cs +++ b/src/Square/Types/RetrieveJobResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveJob](api-endpoint:Team-RetrieveJob) response. Either `job` or `errors` /// is present in the response. /// -public record RetrieveJobResponse +[Serializable] +public record RetrieveJobResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved job. /// @@ -22,15 +27,11 @@ public record RetrieveJobResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveLocationBookingProfileResponse.cs b/src/Square/Types/RetrieveLocationBookingProfileResponse.cs index 419d0412..8bd5576a 100644 --- a/src/Square/Types/RetrieveLocationBookingProfileResponse.cs +++ b/src/Square/Types/RetrieveLocationBookingProfileResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record RetrieveLocationBookingProfileResponse +[Serializable] +public record RetrieveLocationBookingProfileResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested location booking profile. /// @@ -18,15 +23,11 @@ public record RetrieveLocationBookingProfileResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveLocationCustomAttributeDefinitionResponse.cs b/src/Square/Types/RetrieveLocationCustomAttributeDefinitionResponse.cs index 8b01b3fd..d8f2cbd5 100644 --- a/src/Square/Types/RetrieveLocationCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/RetrieveLocationCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-RetrieveLocationCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record RetrieveLocationCustomAttributeDefinitionResponse +[Serializable] +public record RetrieveLocationCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definition. /// @@ -22,15 +27,11 @@ public record RetrieveLocationCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveLocationCustomAttributeResponse.cs b/src/Square/Types/RetrieveLocationCustomAttributeResponse.cs index 8d2072ea..f337b176 100644 --- a/src/Square/Types/RetrieveLocationCustomAttributeResponse.cs +++ b/src/Square/Types/RetrieveLocationCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveLocationCustomAttribute](api-endpoint:LocationCustomAttributes-RetrieveLocationCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record RetrieveLocationCustomAttributeResponse +[Serializable] +public record RetrieveLocationCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute. If `with_definition` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field. @@ -23,15 +28,11 @@ public record RetrieveLocationCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveLocationSettingsResponse.cs b/src/Square/Types/RetrieveLocationSettingsResponse.cs index f217f9ed..3b825692 100644 --- a/src/Square/Types/RetrieveLocationSettingsResponse.cs +++ b/src/Square/Types/RetrieveLocationSettingsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record RetrieveLocationSettingsResponse +[Serializable] +public record RetrieveLocationSettingsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record RetrieveLocationSettingsResponse [JsonPropertyName("location_settings")] public CheckoutLocationSettings? LocationSettings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveMerchantCustomAttributeDefinitionResponse.cs b/src/Square/Types/RetrieveMerchantCustomAttributeDefinitionResponse.cs index 6e04dd52..10a51776 100644 --- a/src/Square/Types/RetrieveMerchantCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/RetrieveMerchantCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-RetrieveMerchantCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record RetrieveMerchantCustomAttributeDefinitionResponse +[Serializable] +public record RetrieveMerchantCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definition. /// @@ -22,15 +27,11 @@ public record RetrieveMerchantCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveMerchantCustomAttributeResponse.cs b/src/Square/Types/RetrieveMerchantCustomAttributeResponse.cs index d61009f9..18de0d13 100644 --- a/src/Square/Types/RetrieveMerchantCustomAttributeResponse.cs +++ b/src/Square/Types/RetrieveMerchantCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-RetrieveMerchantCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record RetrieveMerchantCustomAttributeResponse +[Serializable] +public record RetrieveMerchantCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute. If `with_definition` was set to `true` in the request, /// the custom attribute definition is returned in the `definition` field. @@ -23,15 +28,11 @@ public record RetrieveMerchantCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveMerchantSettingsResponse.cs b/src/Square/Types/RetrieveMerchantSettingsResponse.cs index c21ba357..78946de1 100644 --- a/src/Square/Types/RetrieveMerchantSettingsResponse.cs +++ b/src/Square/Types/RetrieveMerchantSettingsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record RetrieveMerchantSettingsResponse +[Serializable] +public record RetrieveMerchantSettingsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record RetrieveMerchantSettingsResponse [JsonPropertyName("merchant_settings")] public CheckoutMerchantSettings? MerchantSettings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveOrderCustomAttributeDefinitionResponse.cs b/src/Square/Types/RetrieveOrderCustomAttributeDefinitionResponse.cs index 1e7c8720..92571d3c 100644 --- a/src/Square/Types/RetrieveOrderCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/RetrieveOrderCustomAttributeDefinitionResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from getting an order custom attribute definition. /// -public record RetrieveOrderCustomAttributeDefinitionResponse +[Serializable] +public record RetrieveOrderCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute definition. /// @@ -21,15 +26,11 @@ public record RetrieveOrderCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveOrderCustomAttributeResponse.cs b/src/Square/Types/RetrieveOrderCustomAttributeResponse.cs index cc1e803e..1285db0c 100644 --- a/src/Square/Types/RetrieveOrderCustomAttributeResponse.cs +++ b/src/Square/Types/RetrieveOrderCustomAttributeResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from getting an order custom attribute. /// -public record RetrieveOrderCustomAttributeResponse +[Serializable] +public record RetrieveOrderCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The retrieved custom attribute. If `with_definition` was set to `true` in the request, the custom attribute definition is returned in the `definition field. /// @@ -21,15 +26,11 @@ public record RetrieveOrderCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveScheduledShiftResponse.cs b/src/Square/Types/RetrieveScheduledShiftResponse.cs index f1921000..6405acc7 100644 --- a/src/Square/Types/RetrieveScheduledShiftResponse.cs +++ b/src/Square/Types/RetrieveScheduledShiftResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [RetrieveScheduledShift](api-endpoint:Labor-RetrieveScheduledShift) response. /// Either `scheduled_shift` or `errors` is present in the response. /// -public record RetrieveScheduledShiftResponse +[Serializable] +public record RetrieveScheduledShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested scheduled shift. /// @@ -22,15 +27,11 @@ public record RetrieveScheduledShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveTimecardResponse.cs b/src/Square/Types/RetrieveTimecardResponse.cs index 70d5cc44..428ba017 100644 --- a/src/Square/Types/RetrieveTimecardResponse.cs +++ b/src/Square/Types/RetrieveTimecardResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `Timecard` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record RetrieveTimecardResponse +[Serializable] +public record RetrieveTimecardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested `Timecard`. /// @@ -23,15 +28,11 @@ public record RetrieveTimecardResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveTokenStatusResponse.cs b/src/Square/Types/RetrieveTokenStatusResponse.cs index db1dfa8d..d16154d8 100644 --- a/src/Square/Types/RetrieveTokenStatusResponse.cs +++ b/src/Square/Types/RetrieveTokenStatusResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the `RetrieveTokenStatus` endpoint. /// -public record RetrieveTokenStatusResponse +[Serializable] +public record RetrieveTokenStatusResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of scopes associated with an access token. /// @@ -40,15 +45,11 @@ public record RetrieveTokenStatusResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RetrieveTransferOrderResponse.cs b/src/Square/Types/RetrieveTransferOrderResponse.cs index 50e9e64e..ef24d3c2 100644 --- a/src/Square/Types/RetrieveTransferOrderResponse.cs +++ b/src/Square/Types/RetrieveTransferOrderResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response containing the requested transfer order /// -public record RetrieveTransferOrderResponse +[Serializable] +public record RetrieveTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The requested transfer order /// @@ -21,15 +26,11 @@ public record RetrieveTransferOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RevokeTokenResponse.cs b/src/Square/Types/RevokeTokenResponse.cs index 099757f0..acc98f0f 100644 --- a/src/Square/Types/RevokeTokenResponse.cs +++ b/src/Square/Types/RevokeTokenResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record RevokeTokenResponse +[Serializable] +public record RevokeTokenResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// If the request is successful, this is `true`. /// @@ -18,15 +23,11 @@ public record RevokeTokenResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RiskEvaluation.cs b/src/Square/Types/RiskEvaluation.cs index 5d27befd..34a78d78 100644 --- a/src/Square/Types/RiskEvaluation.cs +++ b/src/Square/Types/RiskEvaluation.cs @@ -12,8 +12,13 @@ namespace Square; /// can use this information to determine the course of action (for example, /// provide the goods/services or refund the payment). /// -public record RiskEvaluation +[Serializable] +public record RiskEvaluation : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The timestamp when payment risk was evaluated, in RFC 3339 format. /// @@ -28,15 +33,11 @@ public record RiskEvaluation [JsonPropertyName("risk_level")] public RiskEvaluationRiskLevel? RiskLevel { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/RiskEvaluationRiskLevel.cs b/src/Square/Types/RiskEvaluationRiskLevel.cs index 05a00177..0853f610 100644 --- a/src/Square/Types/RiskEvaluationRiskLevel.cs +++ b/src/Square/Types/RiskEvaluationRiskLevel.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct RiskEvaluationRiskLevel : IStringEnum { public static readonly RiskEvaluationRiskLevel Pending = new(Values.Pending); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/SaveCardOptions.cs b/src/Square/Types/SaveCardOptions.cs index aec177b0..b7f0d9bb 100644 --- a/src/Square/Types/SaveCardOptions.cs +++ b/src/Square/Types/SaveCardOptions.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes save-card action fields. /// -public record SaveCardOptions +[Serializable] +public record SaveCardOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The square-assigned ID of the customer linked to the saved card. /// @@ -30,15 +35,11 @@ public record SaveCardOptions [JsonPropertyName("reference_id")] public string? ReferenceId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShift.cs b/src/Square/Types/ScheduledShift.cs index cbae8a7a..a36c27d6 100644 --- a/src/Square/Types/ScheduledShift.cs +++ b/src/Square/Types/ScheduledShift.cs @@ -9,8 +9,13 @@ namespace Square; /// lifecycle of a scheduled shift from the draft to published state. A scheduled shift contains /// the latest draft shift details and current published shift details. /// -public record ScheduledShift +[Serializable] +public record ScheduledShift : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// **Read only** The Square-issued ID of the scheduled shift. /// @@ -53,15 +58,11 @@ public record ScheduledShift [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShiftDetails.cs b/src/Square/Types/ScheduledShiftDetails.cs index 8d61999a..055b8af9 100644 --- a/src/Square/Types/ScheduledShiftDetails.cs +++ b/src/Square/Types/ScheduledShiftDetails.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents shift details for draft and published versions of a [scheduled shift](entity:ScheduledShift), /// such as job ID, team member assignment, and start and end times. /// -public record ScheduledShiftDetails +[Serializable] +public record ScheduledShiftDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [team member](entity:TeamMember) scheduled for the shift. /// @@ -66,15 +71,11 @@ public record ScheduledShiftDetails [JsonPropertyName("timezone")] public string? Timezone { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShiftFilter.cs b/src/Square/Types/ScheduledShiftFilter.cs index 08f9599c..2dbc23e3 100644 --- a/src/Square/Types/ScheduledShiftFilter.cs +++ b/src/Square/Types/ScheduledShiftFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines filter criteria for a [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) /// request. Multiple filters in a query are combined as an `AND` operation. /// -public record ScheduledShiftFilter +[Serializable] +public record ScheduledShiftFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Return shifts for the specified locations. When omitted, shifts for all /// locations are returned. If needed, call [ListLocations](api-endpoint:Locations-ListLocations) @@ -72,15 +77,11 @@ public record ScheduledShiftFilter [JsonPropertyName("scheduled_shift_statuses")] public IEnumerable? ScheduledShiftStatuses { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShiftFilterAssignmentStatus.cs b/src/Square/Types/ScheduledShiftFilterAssignmentStatus.cs index edc383ff..099d7b52 100644 --- a/src/Square/Types/ScheduledShiftFilterAssignmentStatus.cs +++ b/src/Square/Types/ScheduledShiftFilterAssignmentStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ScheduledShiftFilterAssignmentStatus : IStringEnum { public static readonly ScheduledShiftFilterAssignmentStatus Assigned = new(Values.Assigned); @@ -56,6 +57,7 @@ public static explicit operator ScheduledShiftFilterAssignmentStatus(string valu /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Assigned = "ASSIGNED"; diff --git a/src/Square/Types/ScheduledShiftFilterScheduledShiftStatus.cs b/src/Square/Types/ScheduledShiftFilterScheduledShiftStatus.cs index 26fc4469..7c4e71c8 100644 --- a/src/Square/Types/ScheduledShiftFilterScheduledShiftStatus.cs +++ b/src/Square/Types/ScheduledShiftFilterScheduledShiftStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ScheduledShiftFilterScheduledShiftStatus : IStringEnum { public static readonly ScheduledShiftFilterScheduledShiftStatus Draft = new(Values.Draft); @@ -62,6 +63,7 @@ public static explicit operator ScheduledShiftFilterScheduledShiftStatus(string /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Draft = "DRAFT"; diff --git a/src/Square/Types/ScheduledShiftNotificationAudience.cs b/src/Square/Types/ScheduledShiftNotificationAudience.cs index 678a322a..53b51615 100644 --- a/src/Square/Types/ScheduledShiftNotificationAudience.cs +++ b/src/Square/Types/ScheduledShiftNotificationAudience.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ScheduledShiftNotificationAudience : IStringEnum { public static readonly ScheduledShiftNotificationAudience All = new(Values.All); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string All = "ALL"; diff --git a/src/Square/Types/ScheduledShiftQuery.cs b/src/Square/Types/ScheduledShiftQuery.cs index 55c80986..638b2e8c 100644 --- a/src/Square/Types/ScheduledShiftQuery.cs +++ b/src/Square/Types/ScheduledShiftQuery.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents filter and sort criteria for the `query` field in a /// [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) request. /// -public record ScheduledShiftQuery +[Serializable] +public record ScheduledShiftQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filtering options for the query. /// @@ -22,15 +27,11 @@ public record ScheduledShiftQuery [JsonPropertyName("sort")] public ScheduledShiftSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShiftSort.cs b/src/Square/Types/ScheduledShiftSort.cs index a579eb29..c8c5fa86 100644 --- a/src/Square/Types/ScheduledShiftSort.cs +++ b/src/Square/Types/ScheduledShiftSort.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines sort criteria for a [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) /// request. /// -public record ScheduledShiftSort +[Serializable] +public record ScheduledShiftSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The field to sort on. The default value is `START_AT`. /// See [ScheduledShiftSortField](#type-scheduledshiftsortfield) for possible values @@ -24,15 +29,11 @@ public record ScheduledShiftSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShiftSortField.cs b/src/Square/Types/ScheduledShiftSortField.cs index 64c4dc80..e0888998 100644 --- a/src/Square/Types/ScheduledShiftSortField.cs +++ b/src/Square/Types/ScheduledShiftSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ScheduledShiftSortField : IStringEnum { public static readonly ScheduledShiftSortField StartAt = new(Values.StartAt); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartAt = "START_AT"; diff --git a/src/Square/Types/ScheduledShiftWorkday.cs b/src/Square/Types/ScheduledShiftWorkday.cs index 3b956944..7cd29399 100644 --- a/src/Square/Types/ScheduledShiftWorkday.cs +++ b/src/Square/Types/ScheduledShiftWorkday.cs @@ -8,8 +8,13 @@ namespace Square; /// A `ScheduledShift` search query filter parameter that sets a range of days that /// a `Shift` must start or end in before passing the filter condition. /// -public record ScheduledShiftWorkday +[Serializable] +public record ScheduledShiftWorkday : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Dates for fetching the scheduled shifts. /// @@ -32,15 +37,11 @@ public record ScheduledShiftWorkday [JsonPropertyName("default_timezone")] public string? DefaultTimezone { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ScheduledShiftWorkdayMatcher.cs b/src/Square/Types/ScheduledShiftWorkdayMatcher.cs index fc97a205..ebbce843 100644 --- a/src/Square/Types/ScheduledShiftWorkdayMatcher.cs +++ b/src/Square/Types/ScheduledShiftWorkdayMatcher.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ScheduledShiftWorkdayMatcher : IStringEnum { public static readonly ScheduledShiftWorkdayMatcher StartAt = new(Values.StartAt); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartAt = "START_AT"; diff --git a/src/Square/Types/SearchAvailabilityFilter.cs b/src/Square/Types/SearchAvailabilityFilter.cs index 51a52506..ef1e275c 100644 --- a/src/Square/Types/SearchAvailabilityFilter.cs +++ b/src/Square/Types/SearchAvailabilityFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A query filter to search for buyer-accessible availabilities by. /// -public record SearchAvailabilityFilter +[Serializable] +public record SearchAvailabilityFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The query expression to search for buy-accessible availabilities with their starting times falling within the specified time range. /// The time range must be at least 24 hours and at most 32 days long. @@ -41,15 +46,11 @@ public record SearchAvailabilityFilter [JsonPropertyName("booking_id")] public string? BookingId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchAvailabilityQuery.cs b/src/Square/Types/SearchAvailabilityQuery.cs index 77128d4c..e5668bed 100644 --- a/src/Square/Types/SearchAvailabilityQuery.cs +++ b/src/Square/Types/SearchAvailabilityQuery.cs @@ -7,23 +7,24 @@ namespace Square; /// /// The query used to search for buyer-accessible availabilities of bookings. /// -public record SearchAvailabilityQuery +[Serializable] +public record SearchAvailabilityQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The query filter to search for buyer-accessible availabilities of existing bookings. /// [JsonPropertyName("filter")] public required SearchAvailabilityFilter Filter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchAvailabilityResponse.cs b/src/Square/Types/SearchAvailabilityResponse.cs index 99d66719..4bc0db50 100644 --- a/src/Square/Types/SearchAvailabilityResponse.cs +++ b/src/Square/Types/SearchAvailabilityResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record SearchAvailabilityResponse +[Serializable] +public record SearchAvailabilityResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// List of appointment slots available for booking. /// @@ -18,15 +23,11 @@ public record SearchAvailabilityResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchCatalogItemsRequestStockLevel.cs b/src/Square/Types/SearchCatalogItemsRequestStockLevel.cs index 66c67a6e..84789e24 100644 --- a/src/Square/Types/SearchCatalogItemsRequestStockLevel.cs +++ b/src/Square/Types/SearchCatalogItemsRequestStockLevel.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SearchCatalogItemsRequestStockLevel : IStringEnum { public static readonly SearchCatalogItemsRequestStockLevel Out = new(Values.Out); @@ -55,6 +56,7 @@ public static explicit operator string(SearchCatalogItemsRequestStockLevel value /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Out = "OUT"; diff --git a/src/Square/Types/SearchCatalogItemsResponse.cs b/src/Square/Types/SearchCatalogItemsResponse.cs index aea6065b..e094de7f 100644 --- a/src/Square/Types/SearchCatalogItemsResponse.cs +++ b/src/Square/Types/SearchCatalogItemsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the response body returned from the [SearchCatalogItems](api-endpoint:Catalog-SearchCatalogItems) endpoint. /// -public record SearchCatalogItemsResponse +[Serializable] +public record SearchCatalogItemsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -33,15 +38,11 @@ public record SearchCatalogItemsResponse [JsonPropertyName("matched_variation_ids")] public IEnumerable? MatchedVariationIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchCatalogObjectsResponse.cs b/src/Square/Types/SearchCatalogObjectsResponse.cs index 6e957b40..78a83c09 100644 --- a/src/Square/Types/SearchCatalogObjectsResponse.cs +++ b/src/Square/Types/SearchCatalogObjectsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record SearchCatalogObjectsResponse +[Serializable] +public record SearchCatalogObjectsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -38,15 +43,11 @@ public record SearchCatalogObjectsResponse [JsonPropertyName("latest_time")] public string? LatestTime { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchCustomersResponse.cs b/src/Square/Types/SearchCustomersResponse.cs index fca9c2bd..8feb99b1 100644 --- a/src/Square/Types/SearchCustomersResponse.cs +++ b/src/Square/Types/SearchCustomersResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `customers` is present in a given response (never both). /// -public record SearchCustomersResponse +[Serializable] +public record SearchCustomersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -45,15 +50,11 @@ public record SearchCustomersResponse [JsonPropertyName("count")] public long? Count { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchEventsFilter.cs b/src/Square/Types/SearchEventsFilter.cs index 81d57bac..dac29e93 100644 --- a/src/Square/Types/SearchEventsFilter.cs +++ b/src/Square/Types/SearchEventsFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Criteria to filter events by. /// -public record SearchEventsFilter +[Serializable] +public record SearchEventsFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filter events by event types. /// @@ -33,15 +38,11 @@ public record SearchEventsFilter [JsonPropertyName("created_at")] public TimeRange? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchEventsQuery.cs b/src/Square/Types/SearchEventsQuery.cs index 807b58d6..85e1f0d2 100644 --- a/src/Square/Types/SearchEventsQuery.cs +++ b/src/Square/Types/SearchEventsQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains query criteria for the search. /// -public record SearchEventsQuery +[Serializable] +public record SearchEventsQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Criteria to filter events by. /// @@ -21,15 +26,11 @@ public record SearchEventsQuery [JsonPropertyName("sort")] public SearchEventsSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchEventsResponse.cs b/src/Square/Types/SearchEventsResponse.cs index fad9be4c..ec981d08 100644 --- a/src/Square/Types/SearchEventsResponse.cs +++ b/src/Square/Types/SearchEventsResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: if there are errors processing the request, the events field will not be /// present. /// -public record SearchEventsResponse +[Serializable] +public record SearchEventsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -39,15 +44,11 @@ public record SearchEventsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchEventsSort.cs b/src/Square/Types/SearchEventsSort.cs index 7f9e7ddc..bbf1e4c5 100644 --- a/src/Square/Types/SearchEventsSort.cs +++ b/src/Square/Types/SearchEventsSort.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Criteria to sort events by. /// -public record SearchEventsSort +[Serializable] +public record SearchEventsSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Sort events by event types. /// See [SearchEventsSortField](#type-searcheventssortfield) for possible values @@ -23,15 +28,11 @@ public record SearchEventsSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchInvoicesResponse.cs b/src/Square/Types/SearchInvoicesResponse.cs index 2b023366..fca72dc4 100644 --- a/src/Square/Types/SearchInvoicesResponse.cs +++ b/src/Square/Types/SearchInvoicesResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes a `SearchInvoices` response. /// -public record SearchInvoicesResponse +[Serializable] +public record SearchInvoicesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The list of invoices returned by the search. /// @@ -30,15 +35,11 @@ public record SearchInvoicesResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchLoyaltyAccountsRequestLoyaltyAccountQuery.cs b/src/Square/Types/SearchLoyaltyAccountsRequestLoyaltyAccountQuery.cs index c88381ca..4a76b04c 100644 --- a/src/Square/Types/SearchLoyaltyAccountsRequestLoyaltyAccountQuery.cs +++ b/src/Square/Types/SearchLoyaltyAccountsRequestLoyaltyAccountQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The search criteria for the loyalty accounts. /// -public record SearchLoyaltyAccountsRequestLoyaltyAccountQuery +[Serializable] +public record SearchLoyaltyAccountsRequestLoyaltyAccountQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The set of mappings to use in the loyalty account search. /// @@ -29,15 +34,11 @@ public record SearchLoyaltyAccountsRequestLoyaltyAccountQuery [JsonPropertyName("customer_ids")] public IEnumerable? CustomerIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchLoyaltyAccountsResponse.cs b/src/Square/Types/SearchLoyaltyAccountsResponse.cs index 07b32d4d..124c5d5e 100644 --- a/src/Square/Types/SearchLoyaltyAccountsResponse.cs +++ b/src/Square/Types/SearchLoyaltyAccountsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes loyalty accounts that satisfy the search criteria. /// -public record SearchLoyaltyAccountsResponse +[Serializable] +public record SearchLoyaltyAccountsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -31,15 +36,11 @@ public record SearchLoyaltyAccountsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchLoyaltyEventsResponse.cs b/src/Square/Types/SearchLoyaltyEventsResponse.cs index e949e647..050dad72 100644 --- a/src/Square/Types/SearchLoyaltyEventsResponse.cs +++ b/src/Square/Types/SearchLoyaltyEventsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains loyalty events that satisfy the search /// criteria, in order by the `created_at` date. /// -public record SearchLoyaltyEventsResponse +[Serializable] +public record SearchLoyaltyEventsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -31,15 +36,11 @@ public record SearchLoyaltyEventsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchLoyaltyRewardsRequestLoyaltyRewardQuery.cs b/src/Square/Types/SearchLoyaltyRewardsRequestLoyaltyRewardQuery.cs index 088ffcc9..8d527241 100644 --- a/src/Square/Types/SearchLoyaltyRewardsRequestLoyaltyRewardQuery.cs +++ b/src/Square/Types/SearchLoyaltyRewardsRequestLoyaltyRewardQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The set of search requirements. /// -public record SearchLoyaltyRewardsRequestLoyaltyRewardQuery +[Serializable] +public record SearchLoyaltyRewardsRequestLoyaltyRewardQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [loyalty account](entity:LoyaltyAccount) to which the loyalty reward belongs. /// @@ -22,15 +27,11 @@ public record SearchLoyaltyRewardsRequestLoyaltyRewardQuery [JsonPropertyName("status")] public LoyaltyRewardStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchLoyaltyRewardsResponse.cs b/src/Square/Types/SearchLoyaltyRewardsResponse.cs index afb4e39f..169c7a6e 100644 --- a/src/Square/Types/SearchLoyaltyRewardsResponse.cs +++ b/src/Square/Types/SearchLoyaltyRewardsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A response that includes the loyalty rewards satisfying the search criteria. /// -public record SearchLoyaltyRewardsResponse +[Serializable] +public record SearchLoyaltyRewardsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -29,15 +34,11 @@ public record SearchLoyaltyRewardsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersCustomerFilter.cs b/src/Square/Types/SearchOrdersCustomerFilter.cs index 9e3577da..1f32bd8f 100644 --- a/src/Square/Types/SearchOrdersCustomerFilter.cs +++ b/src/Square/Types/SearchOrdersCustomerFilter.cs @@ -9,8 +9,13 @@ namespace Square; /// associated with the order. It does not filter based on the /// [FulfillmentRecipient](entity:FulfillmentRecipient) `customer_id`. /// -public record SearchOrdersCustomerFilter +[Serializable] +public record SearchOrdersCustomerFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of customer IDs to filter by. /// @@ -19,15 +24,11 @@ public record SearchOrdersCustomerFilter [JsonPropertyName("customer_ids")] public IEnumerable? CustomerIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersDateTimeFilter.cs b/src/Square/Types/SearchOrdersDateTimeFilter.cs index 1916f39e..938e3443 100644 --- a/src/Square/Types/SearchOrdersDateTimeFilter.cs +++ b/src/Square/Types/SearchOrdersDateTimeFilter.cs @@ -20,8 +20,13 @@ namespace Square; /// `CLOSED_AT`. Otherwise, `SearchOrders` throws an error. /// [Learn more about filtering orders by time range.](https://developer.squareup.com/docs/orders-api/manage-orders/search-orders#important-note-about-filtering-orders-by-time-range) /// -public record SearchOrdersDateTimeFilter +[Serializable] +public record SearchOrdersDateTimeFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The time range for filtering on the `created_at` timestamp. If you use this /// value, you must set the `sort_field` in the `OrdersSearchSort` object to @@ -46,15 +51,11 @@ public record SearchOrdersDateTimeFilter [JsonPropertyName("closed_at")] public TimeRange? ClosedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersFilter.cs b/src/Square/Types/SearchOrdersFilter.cs index 18a17469..96a4b987 100644 --- a/src/Square/Types/SearchOrdersFilter.cs +++ b/src/Square/Types/SearchOrdersFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// Filtering criteria to use for a `SearchOrders` request. Multiple filters /// are ANDed together. /// -public record SearchOrdersFilter +[Serializable] +public record SearchOrdersFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filter by [OrderState](entity:OrderState). /// @@ -44,15 +49,11 @@ public record SearchOrdersFilter [JsonPropertyName("customer_filter")] public SearchOrdersCustomerFilter? CustomerFilter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersFulfillmentFilter.cs b/src/Square/Types/SearchOrdersFulfillmentFilter.cs index d7feb118..ea0aaa6b 100644 --- a/src/Square/Types/SearchOrdersFulfillmentFilter.cs +++ b/src/Square/Types/SearchOrdersFulfillmentFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Filter based on [order fulfillment](entity:Fulfillment) information. /// -public record SearchOrdersFulfillmentFilter +[Serializable] +public record SearchOrdersFulfillmentFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of [fulfillment types](entity:FulfillmentType) to filter /// for. The list returns orders if any of its fulfillments match any of the fulfillment types @@ -27,15 +32,11 @@ public record SearchOrdersFulfillmentFilter [JsonPropertyName("fulfillment_states")] public IEnumerable? FulfillmentStates { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersQuery.cs b/src/Square/Types/SearchOrdersQuery.cs index d4f70158..e452edac 100644 --- a/src/Square/Types/SearchOrdersQuery.cs +++ b/src/Square/Types/SearchOrdersQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains query criteria for the search. /// -public record SearchOrdersQuery +[Serializable] +public record SearchOrdersQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Criteria to filter results by. /// @@ -21,15 +26,11 @@ public record SearchOrdersQuery [JsonPropertyName("sort")] public SearchOrdersSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersResponse.cs b/src/Square/Types/SearchOrdersResponse.cs index 5c01c973..12cfb535 100644 --- a/src/Square/Types/SearchOrdersResponse.cs +++ b/src/Square/Types/SearchOrdersResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Either the `order_entries` or `orders` field is set, depending on whether /// `return_entries` is set on the [SearchOrdersRequest](api-endpoint:Orders-SearchOrders). /// -public record SearchOrdersResponse +[Serializable] +public record SearchOrdersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of [OrderEntries](entity:OrderEntry) that fit the query /// conditions. The list is populated only if `return_entries` is set to `true` in the request. @@ -39,15 +44,11 @@ public record SearchOrdersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersSort.cs b/src/Square/Types/SearchOrdersSort.cs index aec582de..76aa0e9d 100644 --- a/src/Square/Types/SearchOrdersSort.cs +++ b/src/Square/Types/SearchOrdersSort.cs @@ -8,8 +8,13 @@ namespace Square; /// Sorting criteria for a `SearchOrders` request. Results can only be sorted /// by a timestamp field. /// -public record SearchOrdersSort +[Serializable] +public record SearchOrdersSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The field to sort by. /// @@ -33,15 +38,11 @@ public record SearchOrdersSort [JsonPropertyName("sort_order")] public SortOrder? SortOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersSortField.cs b/src/Square/Types/SearchOrdersSortField.cs index 23b1cba0..7f9947f4 100644 --- a/src/Square/Types/SearchOrdersSortField.cs +++ b/src/Square/Types/SearchOrdersSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SearchOrdersSortField : IStringEnum { public static readonly SearchOrdersSortField CreatedAt = new(Values.CreatedAt); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CreatedAt = "CREATED_AT"; diff --git a/src/Square/Types/SearchOrdersSourceFilter.cs b/src/Square/Types/SearchOrdersSourceFilter.cs index a98b33ff..abc14cb4 100644 --- a/src/Square/Types/SearchOrdersSourceFilter.cs +++ b/src/Square/Types/SearchOrdersSourceFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A filter based on order `source` information. /// -public record SearchOrdersSourceFilter +[Serializable] +public record SearchOrdersSourceFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filters by the [Source](entity:OrderSource) `name`. The filter returns any orders /// with a `source.name` that matches any of the listed source names. @@ -18,15 +23,11 @@ public record SearchOrdersSourceFilter [JsonPropertyName("source_names")] public IEnumerable? SourceNames { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchOrdersStateFilter.cs b/src/Square/Types/SearchOrdersStateFilter.cs index f23508cc..029c14cb 100644 --- a/src/Square/Types/SearchOrdersStateFilter.cs +++ b/src/Square/Types/SearchOrdersStateFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Filter by the current order `state`. /// -public record SearchOrdersStateFilter +[Serializable] +public record SearchOrdersStateFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// States to filter for. /// See [OrderState](#type-orderstate) for possible values @@ -16,15 +21,11 @@ public record SearchOrdersStateFilter [JsonPropertyName("states")] public IEnumerable States { get; set; } = new List(); - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchScheduledShiftsResponse.cs b/src/Square/Types/SearchScheduledShiftsResponse.cs index 390a63f9..a5b73b87 100644 --- a/src/Square/Types/SearchScheduledShiftsResponse.cs +++ b/src/Square/Types/SearchScheduledShiftsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a [SearchScheduledShifts](api-endpoint:Labor-SearchScheduledShifts) response. /// Either `scheduled_shifts` or `errors` is present in the response. /// -public record SearchScheduledShiftsResponse +[Serializable] +public record SearchScheduledShiftsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A paginated list of scheduled shifts that match the query conditions. /// @@ -29,15 +34,11 @@ public record SearchScheduledShiftsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchShiftsResponse.cs b/src/Square/Types/SearchShiftsResponse.cs index 1c3b22f0..af81aee8 100644 --- a/src/Square/Types/SearchShiftsResponse.cs +++ b/src/Square/Types/SearchShiftsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `Shift` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record SearchShiftsResponse +[Serializable] +public record SearchShiftsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Shifts. /// @@ -29,15 +34,11 @@ public record SearchShiftsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchSubscriptionsFilter.cs b/src/Square/Types/SearchSubscriptionsFilter.cs index 7c119e38..3ca84ac0 100644 --- a/src/Square/Types/SearchSubscriptionsFilter.cs +++ b/src/Square/Types/SearchSubscriptionsFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a set of query expressions (filters) to narrow the scope of targeted subscriptions returned by /// the [SearchSubscriptions](api-endpoint:Subscriptions-SearchSubscriptions) endpoint. /// -public record SearchSubscriptionsFilter +[Serializable] +public record SearchSubscriptionsFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A filter to select subscriptions based on the subscribing customer IDs. /// @@ -28,15 +33,11 @@ public record SearchSubscriptionsFilter [JsonPropertyName("source_names")] public IEnumerable? SourceNames { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchSubscriptionsQuery.cs b/src/Square/Types/SearchSubscriptionsQuery.cs index f6fb4a38..ab0e9e37 100644 --- a/src/Square/Types/SearchSubscriptionsQuery.cs +++ b/src/Square/Types/SearchSubscriptionsQuery.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents a query, consisting of specified query expressions, used to search for subscriptions. /// -public record SearchSubscriptionsQuery +[Serializable] +public record SearchSubscriptionsQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A list of query expressions. /// [JsonPropertyName("filter")] public SearchSubscriptionsFilter? Filter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchSubscriptionsResponse.cs b/src/Square/Types/SearchSubscriptionsResponse.cs index 75c6ffdf..8ce36401 100644 --- a/src/Square/Types/SearchSubscriptionsResponse.cs +++ b/src/Square/Types/SearchSubscriptionsResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [SearchSubscriptions](api-endpoint:Subscriptions-SearchSubscriptions) endpoint. /// -public record SearchSubscriptionsResponse +[Serializable] +public record SearchSubscriptionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -32,15 +37,11 @@ public record SearchSubscriptionsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTeamMembersFilter.cs b/src/Square/Types/SearchTeamMembersFilter.cs index f3f3dc1e..332ac6e2 100644 --- a/src/Square/Types/SearchTeamMembersFilter.cs +++ b/src/Square/Types/SearchTeamMembersFilter.cs @@ -13,8 +13,13 @@ namespace Square; /// ``` /// returns only active team members assigned to either location "A" or "B". /// -public record SearchTeamMembersFilter +[Serializable] +public record SearchTeamMembersFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// When present, filters by team members assigned to the specified locations. /// When empty, includes team members assigned to any location. @@ -36,15 +41,11 @@ public record SearchTeamMembersFilter [JsonPropertyName("is_owner")] public bool? IsOwner { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTeamMembersQuery.cs b/src/Square/Types/SearchTeamMembersQuery.cs index f082ba99..1efedc68 100644 --- a/src/Square/Types/SearchTeamMembersQuery.cs +++ b/src/Square/Types/SearchTeamMembersQuery.cs @@ -7,23 +7,24 @@ namespace Square; /// /// Represents the parameters in a search for `TeamMember` objects. /// -public record SearchTeamMembersQuery +[Serializable] +public record SearchTeamMembersQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The options to filter by. /// [JsonPropertyName("filter")] public SearchTeamMembersFilter? Filter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTeamMembersResponse.cs b/src/Square/Types/SearchTeamMembersResponse.cs index 950f7b5c..bad9b9c9 100644 --- a/src/Square/Types/SearchTeamMembersResponse.cs +++ b/src/Square/Types/SearchTeamMembersResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from a search request containing a filtered list of `TeamMember` objects. /// -public record SearchTeamMembersResponse +[Serializable] +public record SearchTeamMembersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The filtered list of `TeamMember` objects. /// @@ -28,15 +33,11 @@ public record SearchTeamMembersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTerminalActionsResponse.cs b/src/Square/Types/SearchTerminalActionsResponse.cs index 83fb84fb..f301dc83 100644 --- a/src/Square/Types/SearchTerminalActionsResponse.cs +++ b/src/Square/Types/SearchTerminalActionsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record SearchTerminalActionsResponse +[Serializable] +public record SearchTerminalActionsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -28,15 +33,11 @@ public record SearchTerminalActionsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTerminalCheckoutsResponse.cs b/src/Square/Types/SearchTerminalCheckoutsResponse.cs index 6350ae4f..607fac50 100644 --- a/src/Square/Types/SearchTerminalCheckoutsResponse.cs +++ b/src/Square/Types/SearchTerminalCheckoutsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record SearchTerminalCheckoutsResponse +[Serializable] +public record SearchTerminalCheckoutsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -27,15 +32,11 @@ public record SearchTerminalCheckoutsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTerminalRefundsResponse.cs b/src/Square/Types/SearchTerminalRefundsResponse.cs index 3341bfbb..b5c0d6b3 100644 --- a/src/Square/Types/SearchTerminalRefundsResponse.cs +++ b/src/Square/Types/SearchTerminalRefundsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record SearchTerminalRefundsResponse +[Serializable] +public record SearchTerminalRefundsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -27,15 +32,11 @@ public record SearchTerminalRefundsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTimecardsResponse.cs b/src/Square/Types/SearchTimecardsResponse.cs index bc90f6ce..520e2aa4 100644 --- a/src/Square/Types/SearchTimecardsResponse.cs +++ b/src/Square/Types/SearchTimecardsResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `Timecard` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record SearchTimecardsResponse +[Serializable] +public record SearchTimecardsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Timecards. /// @@ -29,15 +34,11 @@ public record SearchTimecardsResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchTransferOrdersResponse.cs b/src/Square/Types/SearchTransferOrdersResponse.cs index f0ed29da..6e34ffc7 100644 --- a/src/Square/Types/SearchTransferOrdersResponse.cs +++ b/src/Square/Types/SearchTransferOrdersResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response for searching transfer orders /// -public record SearchTransferOrdersResponse +[Serializable] +public record SearchTransferOrdersResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// List of transfer orders matching the search criteria /// @@ -27,15 +32,11 @@ public record SearchTransferOrdersResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchVendorsRequestFilter.cs b/src/Square/Types/SearchVendorsRequestFilter.cs index d7c9843e..cda6bbeb 100644 --- a/src/Square/Types/SearchVendorsRequestFilter.cs +++ b/src/Square/Types/SearchVendorsRequestFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines supported query expressions to search for vendors by. /// -public record SearchVendorsRequestFilter +[Serializable] +public record SearchVendorsRequestFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The names of the [Vendor](entity:Vendor) objects to retrieve. /// @@ -22,15 +27,11 @@ public record SearchVendorsRequestFilter [JsonPropertyName("status")] public IEnumerable? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchVendorsRequestSort.cs b/src/Square/Types/SearchVendorsRequestSort.cs index 4ae66385..9a6020a1 100644 --- a/src/Square/Types/SearchVendorsRequestSort.cs +++ b/src/Square/Types/SearchVendorsRequestSort.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines a sorter used to sort results from [SearchVendors](api-endpoint:Vendors-SearchVendors). /// -public record SearchVendorsRequestSort +[Serializable] +public record SearchVendorsRequestSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Specifies the sort key to sort the returned vendors. /// See [Field](#type-field) for possible values @@ -23,15 +28,11 @@ public record SearchVendorsRequestSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SearchVendorsRequestSortField.cs b/src/Square/Types/SearchVendorsRequestSortField.cs index 0cf4381f..3bcb5829 100644 --- a/src/Square/Types/SearchVendorsRequestSortField.cs +++ b/src/Square/Types/SearchVendorsRequestSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SearchVendorsRequestSortField : IStringEnum { public static readonly SearchVendorsRequestSortField Name = new(Values.Name); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Name = "NAME"; diff --git a/src/Square/Types/SearchVendorsResponse.cs b/src/Square/Types/SearchVendorsResponse.cs index 745f3791..9cec9431 100644 --- a/src/Square/Types/SearchVendorsResponse.cs +++ b/src/Square/Types/SearchVendorsResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [SearchVendors](api-endpoint:Vendors-SearchVendors). /// -public record SearchVendorsResponse +[Serializable] +public record SearchVendorsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered when the request fails. /// @@ -30,15 +35,11 @@ public record SearchVendorsResponse [JsonPropertyName("cursor")] public string? Cursor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SegmentFilter.cs b/src/Square/Types/SegmentFilter.cs index cb28685a..6cbe0602 100644 --- a/src/Square/Types/SegmentFilter.cs +++ b/src/Square/Types/SegmentFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A query filter to search for buyer-accessible appointment segments by. /// -public record SegmentFilter +[Serializable] +public record SegmentFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [CatalogItemVariation](entity:CatalogItemVariation) object representing the service booked in this segment. /// @@ -26,15 +31,11 @@ public record SegmentFilter [JsonPropertyName("team_member_id_filter")] public FilterValue? TeamMemberIdFilter { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SelectOption.cs b/src/Square/Types/SelectOption.cs index f29e5fe3..d6c235ad 100644 --- a/src/Square/Types/SelectOption.cs +++ b/src/Square/Types/SelectOption.cs @@ -4,8 +4,13 @@ namespace Square; -public record SelectOption +[Serializable] +public record SelectOption : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The reference id for the option. /// @@ -18,15 +23,11 @@ public record SelectOption [JsonPropertyName("title")] public required string Title { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SelectOptions.cs b/src/Square/Types/SelectOptions.cs index 14c1c8cd..cf592a93 100644 --- a/src/Square/Types/SelectOptions.cs +++ b/src/Square/Types/SelectOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record SelectOptions +[Serializable] +public record SelectOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title text to display in the select flow on the Terminal. /// @@ -30,15 +35,11 @@ public record SelectOptions [JsonPropertyName("selected_option")] public SelectOption? SelectedOption { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Shift.cs b/src/Square/Types/Shift.cs index 4cf91c12..77d9fd64 100644 --- a/src/Square/Types/Shift.cs +++ b/src/Square/Types/Shift.cs @@ -12,8 +12,13 @@ namespace Square; /// Deprecated at Square API version 2025-05-21. Replaced by [Timecard](entity:Timecard). /// See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). /// -public record Shift +[Serializable] +public record Shift : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The UUID for this object. /// @@ -111,15 +116,11 @@ public record Shift [JsonPropertyName("declared_cash_tip_money")] public Money? DeclaredCashTipMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ShiftFilter.cs b/src/Square/Types/ShiftFilter.cs index 006df196..bfb77c79 100644 --- a/src/Square/Types/ShiftFilter.cs +++ b/src/Square/Types/ShiftFilter.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). /// -public record ShiftFilter +[Serializable] +public record ShiftFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Fetch shifts for the specified location. /// @@ -55,15 +60,11 @@ public record ShiftFilter [JsonPropertyName("team_member_ids")] public IEnumerable? TeamMemberIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ShiftFilterStatus.cs b/src/Square/Types/ShiftFilterStatus.cs index 49c2834a..5069ce06 100644 --- a/src/Square/Types/ShiftFilterStatus.cs +++ b/src/Square/Types/ShiftFilterStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ShiftFilterStatus : IStringEnum { public static readonly ShiftFilterStatus Open = new(Values.Open); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Open = "OPEN"; diff --git a/src/Square/Types/ShiftQuery.cs b/src/Square/Types/ShiftQuery.cs index e8aa26e4..cf3e06a0 100644 --- a/src/Square/Types/ShiftQuery.cs +++ b/src/Square/Types/ShiftQuery.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). /// -public record ShiftQuery +[Serializable] +public record ShiftQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Query filter options. /// @@ -23,15 +28,11 @@ public record ShiftQuery [JsonPropertyName("sort")] public ShiftSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ShiftSort.cs b/src/Square/Types/ShiftSort.cs index 2e30edba..93126e00 100644 --- a/src/Square/Types/ShiftSort.cs +++ b/src/Square/Types/ShiftSort.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). /// -public record ShiftSort +[Serializable] +public record ShiftSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The field to sort on. /// See [ShiftSortField](#type-shiftsortfield) for possible values @@ -25,15 +30,11 @@ public record ShiftSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ShiftSortField.cs b/src/Square/Types/ShiftSortField.cs index 2726c559..8100b0af 100644 --- a/src/Square/Types/ShiftSortField.cs +++ b/src/Square/Types/ShiftSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ShiftSortField : IStringEnum { public static readonly ShiftSortField StartAt = new(Values.StartAt); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartAt = "START_AT"; diff --git a/src/Square/Types/ShiftStatus.cs b/src/Square/Types/ShiftStatus.cs index bea28863..1aaec18e 100644 --- a/src/Square/Types/ShiftStatus.cs +++ b/src/Square/Types/ShiftStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ShiftStatus : IStringEnum { public static readonly ShiftStatus Open = new(Values.Open); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Open = "OPEN"; diff --git a/src/Square/Types/ShiftWage.cs b/src/Square/Types/ShiftWage.cs index ce999176..7292e28d 100644 --- a/src/Square/Types/ShiftWage.cs +++ b/src/Square/Types/ShiftWage.cs @@ -9,8 +9,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). /// -public record ShiftWage +[Serializable] +public record ShiftWage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the job performed during this shift. /// @@ -38,15 +43,11 @@ public record ShiftWage [JsonPropertyName("tip_eligible")] public bool? TipEligible { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ShiftWorkday.cs b/src/Square/Types/ShiftWorkday.cs index b3bb2b2a..c6e099c4 100644 --- a/src/Square/Types/ShiftWorkday.cs +++ b/src/Square/Types/ShiftWorkday.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Deprecated at Square API version 2025-05-21. See the [migration notes](https://developer.squareup.com/docs/labor-api/what-it-does#migration-notes). /// -public record ShiftWorkday +[Serializable] +public record ShiftWorkday : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Dates for fetching the shifts. /// @@ -34,15 +39,11 @@ public record ShiftWorkday [JsonPropertyName("default_timezone")] public string? DefaultTimezone { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/ShiftWorkdayMatcher.cs b/src/Square/Types/ShiftWorkdayMatcher.cs index c91ccd84..754c28d3 100644 --- a/src/Square/Types/ShiftWorkdayMatcher.cs +++ b/src/Square/Types/ShiftWorkdayMatcher.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct ShiftWorkdayMatcher : IStringEnum { public static readonly ShiftWorkdayMatcher StartAt = new(Values.StartAt); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartAt = "START_AT"; diff --git a/src/Square/Types/ShippingFee.cs b/src/Square/Types/ShippingFee.cs index 7b75a7b1..e2a148e7 100644 --- a/src/Square/Types/ShippingFee.cs +++ b/src/Square/Types/ShippingFee.cs @@ -4,8 +4,13 @@ namespace Square; -public record ShippingFee +[Serializable] +public record ShippingFee : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name for the shipping fee. /// @@ -18,15 +23,11 @@ public record ShippingFee [JsonPropertyName("charge")] public required Money Charge { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SignatureImage.cs b/src/Square/Types/SignatureImage.cs index f8e6ade6..9123c658 100644 --- a/src/Square/Types/SignatureImage.cs +++ b/src/Square/Types/SignatureImage.cs @@ -4,8 +4,13 @@ namespace Square; -public record SignatureImage +[Serializable] +public record SignatureImage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The mime/type of the image data. /// Use `image/png;base64` for png. @@ -21,15 +26,11 @@ public record SignatureImage [JsonPropertyName("data")] public string? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SignatureOptions.cs b/src/Square/Types/SignatureOptions.cs index 47939ee9..85180bd5 100644 --- a/src/Square/Types/SignatureOptions.cs +++ b/src/Square/Types/SignatureOptions.cs @@ -4,8 +4,13 @@ namespace Square; -public record SignatureOptions +[Serializable] +public record SignatureOptions : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The title text to display in the signature capture flow on the Terminal. /// @@ -25,15 +30,11 @@ public record SignatureOptions [JsonPropertyName("signature")] public IEnumerable? Signature { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Site.cs b/src/Square/Types/Site.cs index 28b9b2dd..30c2c7f8 100644 --- a/src/Square/Types/Site.cs +++ b/src/Square/Types/Site.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a Square Online site, which is an online store for a Square seller. /// -public record Site +[Serializable] +public record Site : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the site. /// @@ -48,15 +53,11 @@ public record Site [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Snippet.cs b/src/Square/Types/Snippet.cs index d66d8b3b..7c94bd56 100644 --- a/src/Square/Types/Snippet.cs +++ b/src/Square/Types/Snippet.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the snippet that is added to a Square Online site. The snippet code is injected into the `head` element of all pages on the site, except for checkout pages. /// -public record Snippet +[Serializable] +public record Snippet : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID for the snippet. /// @@ -43,15 +48,11 @@ public record Snippet [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SortOrder.cs b/src/Square/Types/SortOrder.cs index a06a37d5..eab9e5e6 100644 --- a/src/Square/Types/SortOrder.cs +++ b/src/Square/Types/SortOrder.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SortOrder : IStringEnum { public static readonly SortOrder Desc = new(Values.Desc); @@ -52,6 +53,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Desc = "DESC"; diff --git a/src/Square/Types/SourceApplication.cs b/src/Square/Types/SourceApplication.cs index b17c0f26..c1e856d7 100644 --- a/src/Square/Types/SourceApplication.cs +++ b/src/Square/Types/SourceApplication.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents information about the application used to generate a change. /// -public record SourceApplication +[Serializable] +public record SourceApplication : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// __Read only__ The [product](entity:Product) type of the application. /// See [Product](#type-product) for possible values @@ -30,15 +35,11 @@ public record SourceApplication [JsonPropertyName("name")] public string? Name { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SquareAccountDetails.cs b/src/Square/Types/SquareAccountDetails.cs index 97b35f10..21272031 100644 --- a/src/Square/Types/SquareAccountDetails.cs +++ b/src/Square/Types/SquareAccountDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Additional details about Square Account payments. /// -public record SquareAccountDetails +[Serializable] +public record SquareAccountDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique identifier for the payment source used for this payment. /// @@ -21,15 +26,11 @@ public record SquareAccountDetails [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/StandardUnitDescription.cs b/src/Square/Types/StandardUnitDescription.cs index 6fcfcda2..b3bca068 100644 --- a/src/Square/Types/StandardUnitDescription.cs +++ b/src/Square/Types/StandardUnitDescription.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Contains the name and abbreviation for standard measurement unit. /// -public record StandardUnitDescription +[Serializable] +public record StandardUnitDescription : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Identifies the measurement unit being described. /// @@ -27,15 +32,11 @@ public record StandardUnitDescription [JsonPropertyName("abbreviation")] public string? Abbreviation { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/StandardUnitDescriptionGroup.cs b/src/Square/Types/StandardUnitDescriptionGroup.cs index e43cf49e..b1364e94 100644 --- a/src/Square/Types/StandardUnitDescriptionGroup.cs +++ b/src/Square/Types/StandardUnitDescriptionGroup.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Group of standard measurement units. /// -public record StandardUnitDescriptionGroup +[Serializable] +public record StandardUnitDescriptionGroup : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// List of standard (non-custom) measurement units in this description group. /// @@ -21,15 +26,11 @@ public record StandardUnitDescriptionGroup [JsonPropertyName("language_code")] public string? LanguageCode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/StartTransferOrderResponse.cs b/src/Square/Types/StartTransferOrderResponse.cs index 0a9d6508..758ad66d 100644 --- a/src/Square/Types/StartTransferOrderResponse.cs +++ b/src/Square/Types/StartTransferOrderResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response for starting a transfer order. /// -public record StartTransferOrderResponse +[Serializable] +public record StartTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated transfer order with status changed to STARTED /// @@ -21,15 +26,11 @@ public record StartTransferOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubmitEvidenceResponse.cs b/src/Square/Types/SubmitEvidenceResponse.cs index d84da3c0..bfab953d 100644 --- a/src/Square/Types/SubmitEvidenceResponse.cs +++ b/src/Square/Types/SubmitEvidenceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the fields in a `SubmitEvidence` response. /// -public record SubmitEvidenceResponse +[Serializable] +public record SubmitEvidenceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record SubmitEvidenceResponse [JsonPropertyName("dispute")] public Dispute? Dispute { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Subscription.cs b/src/Square/Types/Subscription.cs index 08f861af..4530b41a 100644 --- a/src/Square/Types/Subscription.cs +++ b/src/Square/Types/Subscription.cs @@ -10,8 +10,13 @@ namespace Square; /// For more information, see /// [Manage Subscriptions](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions). /// -public record Subscription +[Serializable] +public record Subscription : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the subscription. /// @@ -173,15 +178,11 @@ public record Subscription [JsonPropertyName("completed_date")] public string? CompletedDate { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionAction.cs b/src/Square/Types/SubscriptionAction.cs index 5956a5cf..b0f76833 100644 --- a/src/Square/Types/SubscriptionAction.cs +++ b/src/Square/Types/SubscriptionAction.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an action as a pending change to a subscription. /// -public record SubscriptionAction +[Serializable] +public record SubscriptionAction : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of an action scoped to a subscription. /// @@ -46,15 +51,11 @@ public record SubscriptionAction [JsonPropertyName("new_plan_variation_id")] public string? NewPlanVariationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionActionType.cs b/src/Square/Types/SubscriptionActionType.cs index de05bd01..d9d57ff4 100644 --- a/src/Square/Types/SubscriptionActionType.cs +++ b/src/Square/Types/SubscriptionActionType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SubscriptionActionType : IStringEnum { public static readonly SubscriptionActionType Cancel = new(Values.Cancel); @@ -64,6 +65,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Cancel = "CANCEL"; diff --git a/src/Square/Types/SubscriptionCadence.cs b/src/Square/Types/SubscriptionCadence.cs index 06bc3b17..194511d6 100644 --- a/src/Square/Types/SubscriptionCadence.cs +++ b/src/Square/Types/SubscriptionCadence.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SubscriptionCadence : IStringEnum { public static readonly SubscriptionCadence Daily = new(Values.Daily); @@ -76,6 +77,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Daily = "DAILY"; diff --git a/src/Square/Types/SubscriptionCreatedEvent.cs b/src/Square/Types/SubscriptionCreatedEvent.cs index 0b50db90..dfeb9b18 100644 --- a/src/Square/Types/SubscriptionCreatedEvent.cs +++ b/src/Square/Types/SubscriptionCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Subscription](entity:Subscription) is created. /// -public record SubscriptionCreatedEvent +[Serializable] +public record SubscriptionCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record SubscriptionCreatedEvent [JsonPropertyName("data")] public SubscriptionCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionCreatedEventData.cs b/src/Square/Types/SubscriptionCreatedEventData.cs index 6c1edfd5..3bc33994 100644 --- a/src/Square/Types/SubscriptionCreatedEventData.cs +++ b/src/Square/Types/SubscriptionCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record SubscriptionCreatedEventData +[Serializable] +public record SubscriptionCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"subscription"`. /// @@ -24,15 +29,11 @@ public record SubscriptionCreatedEventData [JsonPropertyName("object")] public SubscriptionCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionCreatedEventObject.cs b/src/Square/Types/SubscriptionCreatedEventObject.cs index aecbd3d7..e33b5774 100644 --- a/src/Square/Types/SubscriptionCreatedEventObject.cs +++ b/src/Square/Types/SubscriptionCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record SubscriptionCreatedEventObject +[Serializable] +public record SubscriptionCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created subscription. /// [JsonPropertyName("subscription")] public Subscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionEvent.cs b/src/Square/Types/SubscriptionEvent.cs index 02a5e0fe..31353456 100644 --- a/src/Square/Types/SubscriptionEvent.cs +++ b/src/Square/Types/SubscriptionEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes changes to a subscription and the subscription status. /// -public record SubscriptionEvent +[Serializable] +public record SubscriptionEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the subscription event. /// @@ -53,15 +58,11 @@ public record SubscriptionEvent [JsonPropertyName("plan_variation_id")] public required string PlanVariationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionEventInfo.cs b/src/Square/Types/SubscriptionEventInfo.cs index f293fad8..edbd1cb8 100644 --- a/src/Square/Types/SubscriptionEventInfo.cs +++ b/src/Square/Types/SubscriptionEventInfo.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Provides information about the subscription event. /// -public record SubscriptionEventInfo +[Serializable] +public record SubscriptionEventInfo : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A human-readable explanation for the event. /// @@ -22,15 +27,11 @@ public record SubscriptionEventInfo [JsonPropertyName("code")] public SubscriptionEventInfoCode? Code { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionEventInfoCode.cs b/src/Square/Types/SubscriptionEventInfoCode.cs index b6d1017a..044bcd29 100644 --- a/src/Square/Types/SubscriptionEventInfoCode.cs +++ b/src/Square/Types/SubscriptionEventInfoCode.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SubscriptionEventInfoCode : IStringEnum { public static readonly SubscriptionEventInfoCode LocationNotActive = new( @@ -66,6 +67,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string LocationNotActive = "LOCATION_NOT_ACTIVE"; diff --git a/src/Square/Types/SubscriptionEventSubscriptionEventType.cs b/src/Square/Types/SubscriptionEventSubscriptionEventType.cs index a54c12c6..d150dc20 100644 --- a/src/Square/Types/SubscriptionEventSubscriptionEventType.cs +++ b/src/Square/Types/SubscriptionEventSubscriptionEventType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SubscriptionEventSubscriptionEventType : IStringEnum { public static readonly SubscriptionEventSubscriptionEventType StartSubscription = new( @@ -80,6 +81,7 @@ public static explicit operator SubscriptionEventSubscriptionEventType(string va /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartSubscription = "START_SUBSCRIPTION"; diff --git a/src/Square/Types/SubscriptionPhase.cs b/src/Square/Types/SubscriptionPhase.cs index fe54dfba..ab2523ba 100644 --- a/src/Square/Types/SubscriptionPhase.cs +++ b/src/Square/Types/SubscriptionPhase.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes a phase in a subscription plan variation. For more information, see [Subscription Plans and Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). /// -public record SubscriptionPhase +[Serializable] +public record SubscriptionPhase : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square-assigned ID of the subscription phase. This field cannot be changed after a `SubscriptionPhase` is created. /// @@ -46,15 +51,11 @@ public record SubscriptionPhase [JsonPropertyName("pricing")] public SubscriptionPricing? Pricing { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionPricing.cs b/src/Square/Types/SubscriptionPricing.cs index 596ec742..c8652323 100644 --- a/src/Square/Types/SubscriptionPricing.cs +++ b/src/Square/Types/SubscriptionPricing.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes the pricing for the subscription. /// -public record SubscriptionPricing +[Serializable] +public record SubscriptionPricing : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// RELATIVE or STATIC /// See [SubscriptionPricingType](#type-subscriptionpricingtype) for possible values @@ -28,15 +33,11 @@ public record SubscriptionPricing [JsonPropertyName("price_money")] public Money? PriceMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionPricingType.cs b/src/Square/Types/SubscriptionPricingType.cs index cf9b02af..7bda69a8 100644 --- a/src/Square/Types/SubscriptionPricingType.cs +++ b/src/Square/Types/SubscriptionPricingType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SubscriptionPricingType : IStringEnum { public static readonly SubscriptionPricingType Static = new(Values.Static); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Static = "STATIC"; diff --git a/src/Square/Types/SubscriptionSource.cs b/src/Square/Types/SubscriptionSource.cs index 841aec41..3c533e3c 100644 --- a/src/Square/Types/SubscriptionSource.cs +++ b/src/Square/Types/SubscriptionSource.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The origination details of the subscription. /// -public record SubscriptionSource +[Serializable] +public record SubscriptionSource : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name used to identify the place (physical or digital) that /// a subscription originates. If unset, the name defaults to the name @@ -17,15 +22,11 @@ public record SubscriptionSource [JsonPropertyName("name")] public string? Name { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionStatus.cs b/src/Square/Types/SubscriptionStatus.cs index ba254b74..944f2e76 100644 --- a/src/Square/Types/SubscriptionStatus.cs +++ b/src/Square/Types/SubscriptionStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct SubscriptionStatus : IStringEnum { public static readonly SubscriptionStatus Pending = new(Values.Pending); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/SubscriptionTestResult.cs b/src/Square/Types/SubscriptionTestResult.cs index dafb8f2b..879b253e 100644 --- a/src/Square/Types/SubscriptionTestResult.cs +++ b/src/Square/Types/SubscriptionTestResult.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the details of a webhook subscription, including notification URL, /// event types, and signature key. /// -public record SubscriptionTestResult +[Serializable] +public record SubscriptionTestResult : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A Square-generated unique ID for the subscription test result. /// @@ -45,15 +50,11 @@ public record SubscriptionTestResult [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionUpdatedEvent.cs b/src/Square/Types/SubscriptionUpdatedEvent.cs index 3f4fe941..f2d21a73 100644 --- a/src/Square/Types/SubscriptionUpdatedEvent.cs +++ b/src/Square/Types/SubscriptionUpdatedEvent.cs @@ -9,8 +9,13 @@ namespace Square; /// Typically the `subscription.status` is updated as subscriptions become active /// or cancelled. /// -public record SubscriptionUpdatedEvent +[Serializable] +public record SubscriptionUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -42,15 +47,11 @@ public record SubscriptionUpdatedEvent [JsonPropertyName("data")] public SubscriptionUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionUpdatedEventData.cs b/src/Square/Types/SubscriptionUpdatedEventData.cs index 5d375340..40592ee9 100644 --- a/src/Square/Types/SubscriptionUpdatedEventData.cs +++ b/src/Square/Types/SubscriptionUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record SubscriptionUpdatedEventData +[Serializable] +public record SubscriptionUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"subscription"`. /// @@ -24,15 +29,11 @@ public record SubscriptionUpdatedEventData [JsonPropertyName("object")] public SubscriptionUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SubscriptionUpdatedEventObject.cs b/src/Square/Types/SubscriptionUpdatedEventObject.cs index 23529ce5..095971d9 100644 --- a/src/Square/Types/SubscriptionUpdatedEventObject.cs +++ b/src/Square/Types/SubscriptionUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record SubscriptionUpdatedEventObject +[Serializable] +public record SubscriptionUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated subscription. /// [JsonPropertyName("subscription")] public Subscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/SwapPlanResponse.cs b/src/Square/Types/SwapPlanResponse.cs index d9fd193d..176b25ba 100644 --- a/src/Square/Types/SwapPlanResponse.cs +++ b/src/Square/Types/SwapPlanResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response of the /// [SwapPlan](api-endpoint:Subscriptions-SwapPlan) endpoint. /// -public record SwapPlanResponse +[Serializable] +public record SwapPlanResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -28,15 +33,11 @@ public record SwapPlanResponse [JsonPropertyName("actions")] public IEnumerable? Actions { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TaxCalculationPhase.cs b/src/Square/Types/TaxCalculationPhase.cs index 5bab5a4f..9e608935 100644 --- a/src/Square/Types/TaxCalculationPhase.cs +++ b/src/Square/Types/TaxCalculationPhase.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TaxCalculationPhase : IStringEnum { public static readonly TaxCalculationPhase TaxSubtotalPhase = new(Values.TaxSubtotalPhase); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string TaxSubtotalPhase = "TAX_SUBTOTAL_PHASE"; diff --git a/src/Square/Types/TaxIds.cs b/src/Square/Types/TaxIds.cs index 78864775..351aad36 100644 --- a/src/Square/Types/TaxIds.cs +++ b/src/Square/Types/TaxIds.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Identifiers for the location used by various governments for tax purposes. /// -public record TaxIds +[Serializable] +public record TaxIds : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The EU VAT number for this location. For example, `IE3426675K`. /// If the EU VAT number is present, it is well-formed and has been @@ -51,15 +56,11 @@ public record TaxIds [JsonPropertyName("jp_qii")] public string? JpQii { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TaxInclusionType.cs b/src/Square/Types/TaxInclusionType.cs index c408e292..ad05e69f 100644 --- a/src/Square/Types/TaxInclusionType.cs +++ b/src/Square/Types/TaxInclusionType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TaxInclusionType : IStringEnum { public static readonly TaxInclusionType Additive = new(Values.Additive); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Additive = "ADDITIVE"; diff --git a/src/Square/Types/TeamMember.cs b/src/Square/Types/TeamMember.cs index 043d8ef0..ac7d0b33 100644 --- a/src/Square/Types/TeamMember.cs +++ b/src/Square/Types/TeamMember.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A record representing an individual team member for a business. /// -public record TeamMember +[Serializable] +public record TeamMember : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique ID for the team member. /// @@ -89,15 +94,11 @@ public record TeamMember [JsonPropertyName("wage_setting")] public WageSetting? WageSetting { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberAssignedLocations.cs b/src/Square/Types/TeamMemberAssignedLocations.cs index 90d6e6a9..1e1fcc11 100644 --- a/src/Square/Types/TeamMemberAssignedLocations.cs +++ b/src/Square/Types/TeamMemberAssignedLocations.cs @@ -7,8 +7,13 @@ namespace Square; /// /// An object that represents a team member's assignment to locations. /// -public record TeamMemberAssignedLocations +[Serializable] +public record TeamMemberAssignedLocations : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The current assignment type of the team member. /// See [TeamMemberAssignedLocationsAssignmentType](#type-teammemberassignedlocationsassignmenttype) for possible values @@ -22,15 +27,11 @@ public record TeamMemberAssignedLocations [JsonPropertyName("location_ids")] public IEnumerable? LocationIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberAssignedLocationsAssignmentType.cs b/src/Square/Types/TeamMemberAssignedLocationsAssignmentType.cs index 417eb667..5665898e 100644 --- a/src/Square/Types/TeamMemberAssignedLocationsAssignmentType.cs +++ b/src/Square/Types/TeamMemberAssignedLocationsAssignmentType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TeamMemberAssignedLocationsAssignmentType : IStringEnum { public static readonly TeamMemberAssignedLocationsAssignmentType AllCurrentAndFutureLocations = @@ -63,6 +64,7 @@ public static explicit operator TeamMemberAssignedLocationsAssignmentType(string /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string AllCurrentAndFutureLocations = "ALL_CURRENT_AND_FUTURE_LOCATIONS"; diff --git a/src/Square/Types/TeamMemberBookingProfile.cs b/src/Square/Types/TeamMemberBookingProfile.cs index ce18afaf..0d17ed9b 100644 --- a/src/Square/Types/TeamMemberBookingProfile.cs +++ b/src/Square/Types/TeamMemberBookingProfile.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The booking profile of a seller's team member, including the team member's ID, display name, description and whether the team member can be booked as a service provider. /// -public record TeamMemberBookingProfile +[Serializable] +public record TeamMemberBookingProfile : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the [TeamMember](entity:TeamMember) object for the team member associated with the booking profile. /// @@ -43,15 +48,11 @@ public record TeamMemberBookingProfile [JsonPropertyName("profile_image_url")] public string? ProfileImageUrl { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberCreatedEvent.cs b/src/Square/Types/TeamMemberCreatedEvent.cs index 3802dcb4..eb6ba2ca 100644 --- a/src/Square/Types/TeamMemberCreatedEvent.cs +++ b/src/Square/Types/TeamMemberCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Team Member is created. /// -public record TeamMemberCreatedEvent +[Serializable] +public record TeamMemberCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TeamMemberCreatedEvent [JsonPropertyName("data")] public TeamMemberCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberCreatedEventData.cs b/src/Square/Types/TeamMemberCreatedEventData.cs index 06392762..68e2b297 100644 --- a/src/Square/Types/TeamMemberCreatedEventData.cs +++ b/src/Square/Types/TeamMemberCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TeamMemberCreatedEventData +[Serializable] +public record TeamMemberCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"team_member"`. /// @@ -24,15 +29,11 @@ public record TeamMemberCreatedEventData [JsonPropertyName("object")] public TeamMemberCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberCreatedEventObject.cs b/src/Square/Types/TeamMemberCreatedEventObject.cs index e027c07f..cd4a66d6 100644 --- a/src/Square/Types/TeamMemberCreatedEventObject.cs +++ b/src/Square/Types/TeamMemberCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TeamMemberCreatedEventObject +[Serializable] +public record TeamMemberCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created team member. /// [JsonPropertyName("team_member")] public TeamMember? TeamMember { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberInvitationStatus.cs b/src/Square/Types/TeamMemberInvitationStatus.cs index 6314af9a..fe27905c 100644 --- a/src/Square/Types/TeamMemberInvitationStatus.cs +++ b/src/Square/Types/TeamMemberInvitationStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TeamMemberInvitationStatus : IStringEnum { public static readonly TeamMemberInvitationStatus Uninvited = new(Values.Uninvited); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Uninvited = "UNINVITED"; diff --git a/src/Square/Types/TeamMemberStatus.cs b/src/Square/Types/TeamMemberStatus.cs index c94457be..c2adf920 100644 --- a/src/Square/Types/TeamMemberStatus.cs +++ b/src/Square/Types/TeamMemberStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TeamMemberStatus : IStringEnum { public static readonly TeamMemberStatus Active = new(Values.Active); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/TeamMemberUpdatedEvent.cs b/src/Square/Types/TeamMemberUpdatedEvent.cs index 05d5c682..4a11ef9c 100644 --- a/src/Square/Types/TeamMemberUpdatedEvent.cs +++ b/src/Square/Types/TeamMemberUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Team Member is updated. /// -public record TeamMemberUpdatedEvent +[Serializable] +public record TeamMemberUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TeamMemberUpdatedEvent [JsonPropertyName("data")] public TeamMemberUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberUpdatedEventData.cs b/src/Square/Types/TeamMemberUpdatedEventData.cs index ae711727..722054e0 100644 --- a/src/Square/Types/TeamMemberUpdatedEventData.cs +++ b/src/Square/Types/TeamMemberUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TeamMemberUpdatedEventData +[Serializable] +public record TeamMemberUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"team_member"`. /// @@ -24,15 +29,11 @@ public record TeamMemberUpdatedEventData [JsonPropertyName("object")] public TeamMemberUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberUpdatedEventObject.cs b/src/Square/Types/TeamMemberUpdatedEventObject.cs index 15bd79fc..10aa2a2e 100644 --- a/src/Square/Types/TeamMemberUpdatedEventObject.cs +++ b/src/Square/Types/TeamMemberUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TeamMemberUpdatedEventObject +[Serializable] +public record TeamMemberUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated team member. /// [JsonPropertyName("team_member")] public TeamMember? TeamMember { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberWage.cs b/src/Square/Types/TeamMemberWage.cs index 7444c74c..5b95b1f9 100644 --- a/src/Square/Types/TeamMemberWage.cs +++ b/src/Square/Types/TeamMemberWage.cs @@ -9,8 +9,13 @@ namespace Square; /// This convenience object provides details needed to specify the `wage` /// field for a [timecard](entity:Timecard). /// -public record TeamMemberWage +[Serializable] +public record TeamMemberWage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The UUID for this object. /// @@ -48,15 +53,11 @@ public record TeamMemberWage [JsonPropertyName("tip_eligible")] public bool? TipEligible { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberWageSettingUpdatedEvent.cs b/src/Square/Types/TeamMemberWageSettingUpdatedEvent.cs index 9afa87f0..2cebb346 100644 --- a/src/Square/Types/TeamMemberWageSettingUpdatedEvent.cs +++ b/src/Square/Types/TeamMemberWageSettingUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Wage Setting is updated. /// -public record TeamMemberWageSettingUpdatedEvent +[Serializable] +public record TeamMemberWageSettingUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TeamMemberWageSettingUpdatedEvent [JsonPropertyName("data")] public TeamMemberWageSettingUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberWageSettingUpdatedEventData.cs b/src/Square/Types/TeamMemberWageSettingUpdatedEventData.cs index 598d7643..fc27ef16 100644 --- a/src/Square/Types/TeamMemberWageSettingUpdatedEventData.cs +++ b/src/Square/Types/TeamMemberWageSettingUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TeamMemberWageSettingUpdatedEventData +[Serializable] +public record TeamMemberWageSettingUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"wage_setting"`. /// @@ -24,15 +29,11 @@ public record TeamMemberWageSettingUpdatedEventData [JsonPropertyName("object")] public TeamMemberWageSettingUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TeamMemberWageSettingUpdatedEventObject.cs b/src/Square/Types/TeamMemberWageSettingUpdatedEventObject.cs index 44169636..c38b7bbf 100644 --- a/src/Square/Types/TeamMemberWageSettingUpdatedEventObject.cs +++ b/src/Square/Types/TeamMemberWageSettingUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TeamMemberWageSettingUpdatedEventObject +[Serializable] +public record TeamMemberWageSettingUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated team member wage setting. /// [JsonPropertyName("wage_setting")] public WageSetting? WageSetting { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Tender.cs b/src/Square/Types/Tender.cs index a5a833ea..81eff3d0 100644 --- a/src/Square/Types/Tender.cs +++ b/src/Square/Types/Tender.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a tender (i.e., a method of payment) used in a Square transaction. /// -public record Tender +[Serializable] +public record Tender : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The tender's unique ID. It is the associated payment ID. /// @@ -131,15 +136,11 @@ public record Tender [JsonPropertyName("payment_id")] public string? PaymentId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TenderBankAccountDetails.cs b/src/Square/Types/TenderBankAccountDetails.cs index a0d598dc..3e925acc 100644 --- a/src/Square/Types/TenderBankAccountDetails.cs +++ b/src/Square/Types/TenderBankAccountDetails.cs @@ -10,8 +10,13 @@ namespace Square; /// See [BankAccountPaymentDetails](entity:BankAccountPaymentDetails) /// for more exposed details of a bank account payment. /// -public record TenderBankAccountDetails +[Serializable] +public record TenderBankAccountDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The bank account payment's current state. /// @@ -21,15 +26,11 @@ public record TenderBankAccountDetails [JsonPropertyName("status")] public TenderBankAccountDetailsStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TenderBankAccountDetailsStatus.cs b/src/Square/Types/TenderBankAccountDetailsStatus.cs index 26528c25..b42456e5 100644 --- a/src/Square/Types/TenderBankAccountDetailsStatus.cs +++ b/src/Square/Types/TenderBankAccountDetailsStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderBankAccountDetailsStatus : IStringEnum { public static readonly TenderBankAccountDetailsStatus Pending = new(Values.Pending); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/TenderBuyNowPayLaterDetails.cs b/src/Square/Types/TenderBuyNowPayLaterDetails.cs index 4721abb3..9825049f 100644 --- a/src/Square/Types/TenderBuyNowPayLaterDetails.cs +++ b/src/Square/Types/TenderBuyNowPayLaterDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the details of a tender with `type` `BUY_NOW_PAY_LATER`. /// -public record TenderBuyNowPayLaterDetails +[Serializable] +public record TenderBuyNowPayLaterDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Buy Now Pay Later brand. /// See [Brand](#type-brand) for possible values @@ -25,15 +30,11 @@ public record TenderBuyNowPayLaterDetails [JsonPropertyName("status")] public TenderBuyNowPayLaterDetailsStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TenderBuyNowPayLaterDetailsBrand.cs b/src/Square/Types/TenderBuyNowPayLaterDetailsBrand.cs index 154b0cc2..d887b1b7 100644 --- a/src/Square/Types/TenderBuyNowPayLaterDetailsBrand.cs +++ b/src/Square/Types/TenderBuyNowPayLaterDetailsBrand.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderBuyNowPayLaterDetailsBrand : IStringEnum { public static readonly TenderBuyNowPayLaterDetailsBrand OtherBrand = new(Values.OtherBrand); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OtherBrand = "OTHER_BRAND"; diff --git a/src/Square/Types/TenderBuyNowPayLaterDetailsStatus.cs b/src/Square/Types/TenderBuyNowPayLaterDetailsStatus.cs index 548a83ce..e911b586 100644 --- a/src/Square/Types/TenderBuyNowPayLaterDetailsStatus.cs +++ b/src/Square/Types/TenderBuyNowPayLaterDetailsStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderBuyNowPayLaterDetailsStatus : IStringEnum { public static readonly TenderBuyNowPayLaterDetailsStatus Authorized = new(Values.Authorized); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Authorized = "AUTHORIZED"; diff --git a/src/Square/Types/TenderCardDetails.cs b/src/Square/Types/TenderCardDetails.cs index 774a2f2a..e3e8f9e3 100644 --- a/src/Square/Types/TenderCardDetails.cs +++ b/src/Square/Types/TenderCardDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents additional details of a tender with `type` `CARD` or `SQUARE_GIFT_CARD` /// -public record TenderCardDetails +[Serializable] +public record TenderCardDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The credit card payment's current state (such as `AUTHORIZED` or /// `CAPTURED`). See [TenderCardDetailsStatus](entity:TenderCardDetailsStatus) @@ -31,15 +36,11 @@ public record TenderCardDetails [JsonPropertyName("entry_method")] public TenderCardDetailsEntryMethod? EntryMethod { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TenderCardDetailsEntryMethod.cs b/src/Square/Types/TenderCardDetailsEntryMethod.cs index 09424608..0044355d 100644 --- a/src/Square/Types/TenderCardDetailsEntryMethod.cs +++ b/src/Square/Types/TenderCardDetailsEntryMethod.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderCardDetailsEntryMethod : IStringEnum { public static readonly TenderCardDetailsEntryMethod Swiped = new(Values.Swiped); @@ -60,6 +61,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Swiped = "SWIPED"; diff --git a/src/Square/Types/TenderCardDetailsStatus.cs b/src/Square/Types/TenderCardDetailsStatus.cs index c1f46726..14771872 100644 --- a/src/Square/Types/TenderCardDetailsStatus.cs +++ b/src/Square/Types/TenderCardDetailsStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderCardDetailsStatus : IStringEnum { public static readonly TenderCardDetailsStatus Authorized = new(Values.Authorized); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Authorized = "AUTHORIZED"; diff --git a/src/Square/Types/TenderCashDetails.cs b/src/Square/Types/TenderCashDetails.cs index d280db96..cf7152bc 100644 --- a/src/Square/Types/TenderCashDetails.cs +++ b/src/Square/Types/TenderCashDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the details of a tender with `type` `CASH`. /// -public record TenderCashDetails +[Serializable] +public record TenderCashDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The total amount of cash provided by the buyer, before change is given. /// @@ -21,15 +26,11 @@ public record TenderCashDetails [JsonPropertyName("change_back_money")] public Money? ChangeBackMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TenderSquareAccountDetails.cs b/src/Square/Types/TenderSquareAccountDetails.cs index 170d865f..d763b482 100644 --- a/src/Square/Types/TenderSquareAccountDetails.cs +++ b/src/Square/Types/TenderSquareAccountDetails.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents the details of a tender with `type` `SQUARE_ACCOUNT`. /// -public record TenderSquareAccountDetails +[Serializable] +public record TenderSquareAccountDetails : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The Square Account payment's current state (such as `AUTHORIZED` or /// `CAPTURED`). See [TenderSquareAccountDetailsStatus](entity:TenderSquareAccountDetailsStatus) @@ -18,15 +23,11 @@ public record TenderSquareAccountDetails [JsonPropertyName("status")] public TenderSquareAccountDetailsStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TenderSquareAccountDetailsStatus.cs b/src/Square/Types/TenderSquareAccountDetailsStatus.cs index b6864c63..a642c49a 100644 --- a/src/Square/Types/TenderSquareAccountDetailsStatus.cs +++ b/src/Square/Types/TenderSquareAccountDetailsStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderSquareAccountDetailsStatus : IStringEnum { public static readonly TenderSquareAccountDetailsStatus Authorized = new(Values.Authorized); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Authorized = "AUTHORIZED"; diff --git a/src/Square/Types/TenderType.cs b/src/Square/Types/TenderType.cs index a6fa525b..55dc3585 100644 --- a/src/Square/Types/TenderType.cs +++ b/src/Square/Types/TenderType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TenderType : IStringEnum { public static readonly TenderType Card = new(Values.Card); @@ -69,6 +70,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Card = "CARD"; diff --git a/src/Square/Types/TerminalAction.cs b/src/Square/Types/TerminalAction.cs index 87f9bb85..f5f2a79c 100644 --- a/src/Square/Types/TerminalAction.cs +++ b/src/Square/Types/TerminalAction.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an action processed by the Square Terminal. /// -public record TerminalAction +[Serializable] +public record TerminalAction : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for this `TerminalAction`. /// @@ -156,15 +161,11 @@ public record TerminalAction [JsonPropertyName("await_next_action_duration")] public string? AwaitNextActionDuration { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionActionType.cs b/src/Square/Types/TerminalActionActionType.cs index 329ba949..2ebeb21c 100644 --- a/src/Square/Types/TerminalActionActionType.cs +++ b/src/Square/Types/TerminalActionActionType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TerminalActionActionType : IStringEnum { public static readonly TerminalActionActionType QrCode = new(Values.QrCode); @@ -66,6 +67,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string QrCode = "QR_CODE"; diff --git a/src/Square/Types/TerminalActionCreatedEvent.cs b/src/Square/Types/TerminalActionCreatedEvent.cs index c448904f..c982f20f 100644 --- a/src/Square/Types/TerminalActionCreatedEvent.cs +++ b/src/Square/Types/TerminalActionCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a TerminalAction is created. /// -public record TerminalActionCreatedEvent +[Serializable] +public record TerminalActionCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TerminalActionCreatedEvent [JsonPropertyName("data")] public TerminalActionCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionCreatedEventData.cs b/src/Square/Types/TerminalActionCreatedEventData.cs index 62d2ef72..b605129f 100644 --- a/src/Square/Types/TerminalActionCreatedEventData.cs +++ b/src/Square/Types/TerminalActionCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalActionCreatedEventData +[Serializable] +public record TerminalActionCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the created object’s type, `"action"`. /// @@ -24,15 +29,11 @@ public record TerminalActionCreatedEventData [JsonPropertyName("object")] public TerminalActionCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionCreatedEventObject.cs b/src/Square/Types/TerminalActionCreatedEventObject.cs index fc9fca88..a34d448e 100644 --- a/src/Square/Types/TerminalActionCreatedEventObject.cs +++ b/src/Square/Types/TerminalActionCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TerminalActionCreatedEventObject +[Serializable] +public record TerminalActionCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created terminal action. /// [JsonPropertyName("action")] public TerminalAction? Action { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionQuery.cs b/src/Square/Types/TerminalActionQuery.cs index 847216d5..3fc5c76b 100644 --- a/src/Square/Types/TerminalActionQuery.cs +++ b/src/Square/Types/TerminalActionQuery.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalActionQuery +[Serializable] +public record TerminalActionQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Options for filtering returned `TerminalAction`s /// @@ -18,15 +23,11 @@ public record TerminalActionQuery [JsonPropertyName("sort")] public TerminalActionQuerySort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionQueryFilter.cs b/src/Square/Types/TerminalActionQueryFilter.cs index 27ab98cd..b574c024 100644 --- a/src/Square/Types/TerminalActionQueryFilter.cs +++ b/src/Square/Types/TerminalActionQueryFilter.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalActionQueryFilter +[Serializable] +public record TerminalActionQueryFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// `TerminalAction`s associated with a specific device. If no device is specified then all /// `TerminalAction`s for the merchant will be displayed. @@ -35,15 +40,11 @@ public record TerminalActionQueryFilter [JsonPropertyName("type")] public TerminalActionActionType? Type { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionQuerySort.cs b/src/Square/Types/TerminalActionQuerySort.cs index a83509d8..3caa51ca 100644 --- a/src/Square/Types/TerminalActionQuerySort.cs +++ b/src/Square/Types/TerminalActionQuerySort.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalActionQuerySort +[Serializable] +public record TerminalActionQuerySort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order in which results are listed. /// - `ASC` - Oldest to newest. @@ -15,15 +20,11 @@ public record TerminalActionQuerySort [JsonPropertyName("sort_order")] public SortOrder? SortOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionUpdatedEvent.cs b/src/Square/Types/TerminalActionUpdatedEvent.cs index f39e237e..6b8bfcb9 100644 --- a/src/Square/Types/TerminalActionUpdatedEvent.cs +++ b/src/Square/Types/TerminalActionUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a TerminalAction is updated. /// -public record TerminalActionUpdatedEvent +[Serializable] +public record TerminalActionUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TerminalActionUpdatedEvent [JsonPropertyName("data")] public TerminalActionUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionUpdatedEventData.cs b/src/Square/Types/TerminalActionUpdatedEventData.cs index 519fb596..9b032281 100644 --- a/src/Square/Types/TerminalActionUpdatedEventData.cs +++ b/src/Square/Types/TerminalActionUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalActionUpdatedEventData +[Serializable] +public record TerminalActionUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the updated object’s type, `"action"`. /// @@ -24,15 +29,11 @@ public record TerminalActionUpdatedEventData [JsonPropertyName("object")] public TerminalActionUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalActionUpdatedEventObject.cs b/src/Square/Types/TerminalActionUpdatedEventObject.cs index 038616fa..fb094fd9 100644 --- a/src/Square/Types/TerminalActionUpdatedEventObject.cs +++ b/src/Square/Types/TerminalActionUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TerminalActionUpdatedEventObject +[Serializable] +public record TerminalActionUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated terminal action. /// [JsonPropertyName("action")] public TerminalAction? Action { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckout.cs b/src/Square/Types/TerminalCheckout.cs index 7f68f5a3..d5603fc5 100644 --- a/src/Square/Types/TerminalCheckout.cs +++ b/src/Square/Types/TerminalCheckout.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a checkout processed by the Square Terminal. /// -public record TerminalCheckout +[Serializable] +public record TerminalCheckout : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for this `TerminalCheckout`. /// @@ -169,15 +174,11 @@ public record TerminalCheckout [JsonPropertyName("tip_money")] public Money? TipMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutCreatedEvent.cs b/src/Square/Types/TerminalCheckoutCreatedEvent.cs index 65620db2..42a457cc 100644 --- a/src/Square/Types/TerminalCheckoutCreatedEvent.cs +++ b/src/Square/Types/TerminalCheckoutCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [TerminalCheckout](entity:TerminalCheckout) is created. /// -public record TerminalCheckoutCreatedEvent +[Serializable] +public record TerminalCheckoutCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TerminalCheckoutCreatedEvent [JsonPropertyName("data")] public TerminalCheckoutCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutCreatedEventData.cs b/src/Square/Types/TerminalCheckoutCreatedEventData.cs index f8cd247c..11ae3585 100644 --- a/src/Square/Types/TerminalCheckoutCreatedEventData.cs +++ b/src/Square/Types/TerminalCheckoutCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalCheckoutCreatedEventData +[Serializable] +public record TerminalCheckoutCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the created object’s type, `"checkout"`. /// @@ -24,15 +29,11 @@ public record TerminalCheckoutCreatedEventData [JsonPropertyName("object")] public TerminalCheckoutCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutCreatedEventObject.cs b/src/Square/Types/TerminalCheckoutCreatedEventObject.cs index c1ea97d2..b0388fea 100644 --- a/src/Square/Types/TerminalCheckoutCreatedEventObject.cs +++ b/src/Square/Types/TerminalCheckoutCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TerminalCheckoutCreatedEventObject +[Serializable] +public record TerminalCheckoutCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created terminal checkout /// [JsonPropertyName("checkout")] public TerminalCheckout? Checkout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutQuery.cs b/src/Square/Types/TerminalCheckoutQuery.cs index e07e4dd5..530130f4 100644 --- a/src/Square/Types/TerminalCheckoutQuery.cs +++ b/src/Square/Types/TerminalCheckoutQuery.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalCheckoutQuery +[Serializable] +public record TerminalCheckoutQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Options for filtering returned `TerminalCheckout` objects. /// @@ -18,15 +23,11 @@ public record TerminalCheckoutQuery [JsonPropertyName("sort")] public TerminalCheckoutQuerySort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutQueryFilter.cs b/src/Square/Types/TerminalCheckoutQueryFilter.cs index 19094444..efcd4774 100644 --- a/src/Square/Types/TerminalCheckoutQueryFilter.cs +++ b/src/Square/Types/TerminalCheckoutQueryFilter.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalCheckoutQueryFilter +[Serializable] +public record TerminalCheckoutQueryFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The `TerminalCheckout` objects associated with a specific device. If no device is specified, then all /// `TerminalCheckout` objects for the merchant are displayed. @@ -28,15 +33,11 @@ public record TerminalCheckoutQueryFilter [JsonPropertyName("status")] public string? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutQuerySort.cs b/src/Square/Types/TerminalCheckoutQuerySort.cs index 40046d17..c83adf2f 100644 --- a/src/Square/Types/TerminalCheckoutQuerySort.cs +++ b/src/Square/Types/TerminalCheckoutQuerySort.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalCheckoutQuerySort +[Serializable] +public record TerminalCheckoutQuerySort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order in which results are listed. /// Default: `DESC` @@ -14,15 +19,11 @@ public record TerminalCheckoutQuerySort [JsonPropertyName("sort_order")] public SortOrder? SortOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutUpdatedEvent.cs b/src/Square/Types/TerminalCheckoutUpdatedEvent.cs index c2e5ba71..749b724b 100644 --- a/src/Square/Types/TerminalCheckoutUpdatedEvent.cs +++ b/src/Square/Types/TerminalCheckoutUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [TerminalCheckout](entity:TerminalCheckout) is updated. /// -public record TerminalCheckoutUpdatedEvent +[Serializable] +public record TerminalCheckoutUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TerminalCheckoutUpdatedEvent [JsonPropertyName("data")] public TerminalCheckoutUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutUpdatedEventData.cs b/src/Square/Types/TerminalCheckoutUpdatedEventData.cs index 529de642..9f840f47 100644 --- a/src/Square/Types/TerminalCheckoutUpdatedEventData.cs +++ b/src/Square/Types/TerminalCheckoutUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalCheckoutUpdatedEventData +[Serializable] +public record TerminalCheckoutUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the updated object’s type, `"checkout"`. /// @@ -24,15 +29,11 @@ public record TerminalCheckoutUpdatedEventData [JsonPropertyName("object")] public TerminalCheckoutUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalCheckoutUpdatedEventObject.cs b/src/Square/Types/TerminalCheckoutUpdatedEventObject.cs index 80d3447c..d7c4775c 100644 --- a/src/Square/Types/TerminalCheckoutUpdatedEventObject.cs +++ b/src/Square/Types/TerminalCheckoutUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TerminalCheckoutUpdatedEventObject +[Serializable] +public record TerminalCheckoutUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated terminal checkout /// [JsonPropertyName("checkout")] public TerminalCheckout? Checkout { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefund.cs b/src/Square/Types/TerminalRefund.cs index ac6416c4..da7367a9 100644 --- a/src/Square/Types/TerminalRefund.cs +++ b/src/Square/Types/TerminalRefund.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a payment refund processed by the Square Terminal. Only supports Interac (Canadian debit network) payment refunds. /// -public record TerminalRefund +[Serializable] +public record TerminalRefund : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique ID for this `TerminalRefund`. /// @@ -112,15 +117,11 @@ public record TerminalRefund [JsonPropertyName("location_id")] public string? LocationId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundCreatedEvent.cs b/src/Square/Types/TerminalRefundCreatedEvent.cs index 54753e55..2b0e490c 100644 --- a/src/Square/Types/TerminalRefundCreatedEvent.cs +++ b/src/Square/Types/TerminalRefundCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Terminal API refund is created. /// -public record TerminalRefundCreatedEvent +[Serializable] +public record TerminalRefundCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TerminalRefundCreatedEvent [JsonPropertyName("data")] public TerminalRefundCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundCreatedEventData.cs b/src/Square/Types/TerminalRefundCreatedEventData.cs index 7fc44312..59a93e44 100644 --- a/src/Square/Types/TerminalRefundCreatedEventData.cs +++ b/src/Square/Types/TerminalRefundCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalRefundCreatedEventData +[Serializable] +public record TerminalRefundCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the created object’s type, `"refund"`. /// @@ -24,15 +29,11 @@ public record TerminalRefundCreatedEventData [JsonPropertyName("object")] public TerminalRefundCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundCreatedEventObject.cs b/src/Square/Types/TerminalRefundCreatedEventObject.cs index aaefc877..1741c7fa 100644 --- a/src/Square/Types/TerminalRefundCreatedEventObject.cs +++ b/src/Square/Types/TerminalRefundCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TerminalRefundCreatedEventObject +[Serializable] +public record TerminalRefundCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created terminal refund. /// [JsonPropertyName("refund")] public TerminalRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundQuery.cs b/src/Square/Types/TerminalRefundQuery.cs index b1ce8df0..77c8ae6b 100644 --- a/src/Square/Types/TerminalRefundQuery.cs +++ b/src/Square/Types/TerminalRefundQuery.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalRefundQuery +[Serializable] +public record TerminalRefundQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The filter for the Terminal refund query. /// @@ -18,15 +23,11 @@ public record TerminalRefundQuery [JsonPropertyName("sort")] public TerminalRefundQuerySort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundQueryFilter.cs b/src/Square/Types/TerminalRefundQueryFilter.cs index 0c1df8d5..23be29ef 100644 --- a/src/Square/Types/TerminalRefundQueryFilter.cs +++ b/src/Square/Types/TerminalRefundQueryFilter.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalRefundQueryFilter +[Serializable] +public record TerminalRefundQueryFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// `TerminalRefund` objects associated with a specific device. If no device is specified, then all /// `TerminalRefund` objects for the signed-in account are displayed. @@ -28,15 +33,11 @@ public record TerminalRefundQueryFilter [JsonPropertyName("status")] public string? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundQuerySort.cs b/src/Square/Types/TerminalRefundQuerySort.cs index b0584fb1..d4c39558 100644 --- a/src/Square/Types/TerminalRefundQuerySort.cs +++ b/src/Square/Types/TerminalRefundQuerySort.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalRefundQuerySort +[Serializable] +public record TerminalRefundQuerySort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order in which results are listed. /// - `ASC` - Oldest to newest. @@ -14,15 +19,11 @@ public record TerminalRefundQuerySort [JsonPropertyName("sort_order")] public string? SortOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundUpdatedEvent.cs b/src/Square/Types/TerminalRefundUpdatedEvent.cs index c9cff34f..49013f9d 100644 --- a/src/Square/Types/TerminalRefundUpdatedEvent.cs +++ b/src/Square/Types/TerminalRefundUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a Terminal API refund is updated. /// -public record TerminalRefundUpdatedEvent +[Serializable] +public record TerminalRefundUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TerminalRefundUpdatedEvent [JsonPropertyName("data")] public TerminalRefundUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundUpdatedEventData.cs b/src/Square/Types/TerminalRefundUpdatedEventData.cs index 60ea7bef..c1e33be1 100644 --- a/src/Square/Types/TerminalRefundUpdatedEventData.cs +++ b/src/Square/Types/TerminalRefundUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TerminalRefundUpdatedEventData +[Serializable] +public record TerminalRefundUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the updated object’s type, `"refund"`. /// @@ -24,15 +29,11 @@ public record TerminalRefundUpdatedEventData [JsonPropertyName("object")] public TerminalRefundUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TerminalRefundUpdatedEventObject.cs b/src/Square/Types/TerminalRefundUpdatedEventObject.cs index 7a35f6c9..8b5514bc 100644 --- a/src/Square/Types/TerminalRefundUpdatedEventObject.cs +++ b/src/Square/Types/TerminalRefundUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TerminalRefundUpdatedEventObject +[Serializable] +public record TerminalRefundUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated terminal refund. /// [JsonPropertyName("refund")] public TerminalRefund? Refund { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TestWebhookSubscriptionResponse.cs b/src/Square/Types/TestWebhookSubscriptionResponse.cs index 8aef41a0..b15d04ac 100644 --- a/src/Square/Types/TestWebhookSubscriptionResponse.cs +++ b/src/Square/Types/TestWebhookSubscriptionResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: If there are errors processing the request, the [SubscriptionTestResult](entity:SubscriptionTestResult) field is not /// present. /// -public record TestWebhookSubscriptionResponse +[Serializable] +public record TestWebhookSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -25,15 +30,11 @@ public record TestWebhookSubscriptionResponse [JsonPropertyName("subscription_test_result")] public SubscriptionTestResult? SubscriptionTestResult { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimeRange.cs b/src/Square/Types/TimeRange.cs index b44ce613..ae21bf8d 100644 --- a/src/Square/Types/TimeRange.cs +++ b/src/Square/Types/TimeRange.cs @@ -11,8 +11,13 @@ namespace Square; /// Refer to the relevant endpoint-specific documentation to determine /// how time ranges are handled. /// -public record TimeRange +[Serializable] +public record TimeRange : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A datetime value in RFC 3339 format indicating when the time range /// starts. @@ -27,15 +32,11 @@ public record TimeRange [JsonPropertyName("end_at")] public string? EndAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Timecard.cs b/src/Square/Types/Timecard.cs index a1689801..b3a981cf 100644 --- a/src/Square/Types/Timecard.cs +++ b/src/Square/Types/Timecard.cs @@ -9,8 +9,13 @@ namespace Square; /// for a team member. This might include a record of the start and end times of breaks /// taken during the shift. /// -public record Timecard +[Serializable] +public record Timecard : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// **Read only** The Square-issued UUID for this object. /// @@ -101,15 +106,11 @@ public record Timecard [JsonPropertyName("declared_cash_tip_money")] public Money? DeclaredCashTipMoney { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimecardFilter.cs b/src/Square/Types/TimecardFilter.cs index aa3916e7..b8d01864 100644 --- a/src/Square/Types/TimecardFilter.cs +++ b/src/Square/Types/TimecardFilter.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines a filter used in a search for `Timecard` records. `AND` logic is /// used by Square's servers to apply each filter property specified. /// -public record TimecardFilter +[Serializable] +public record TimecardFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Fetch timecards for the specified location. /// @@ -47,15 +52,11 @@ public record TimecardFilter [JsonPropertyName("team_member_ids")] public IEnumerable? TeamMemberIds { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimecardFilterStatus.cs b/src/Square/Types/TimecardFilterStatus.cs index ce042077..758e9198 100644 --- a/src/Square/Types/TimecardFilterStatus.cs +++ b/src/Square/Types/TimecardFilterStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TimecardFilterStatus : IStringEnum { public static readonly TimecardFilterStatus Open = new(Values.Open); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Open = "OPEN"; diff --git a/src/Square/Types/TimecardQuery.cs b/src/Square/Types/TimecardQuery.cs index 2275f1ce..16a7c38a 100644 --- a/src/Square/Types/TimecardQuery.cs +++ b/src/Square/Types/TimecardQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The parameters of a `Timecard` search query, which includes filter and sort options. /// -public record TimecardQuery +[Serializable] +public record TimecardQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Query filter options. /// @@ -21,15 +26,11 @@ public record TimecardQuery [JsonPropertyName("sort")] public TimecardSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimecardSort.cs b/src/Square/Types/TimecardSort.cs index d18204e6..7ced0ef7 100644 --- a/src/Square/Types/TimecardSort.cs +++ b/src/Square/Types/TimecardSort.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Sets the sort order of search results. /// -public record TimecardSort +[Serializable] +public record TimecardSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The field to sort on. /// See [TimecardSortField](#type-timecardsortfield) for possible values @@ -23,15 +28,11 @@ public record TimecardSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimecardSortField.cs b/src/Square/Types/TimecardSortField.cs index 8cd15a39..d1d6e488 100644 --- a/src/Square/Types/TimecardSortField.cs +++ b/src/Square/Types/TimecardSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TimecardSortField : IStringEnum { public static readonly TimecardSortField StartAt = new(Values.StartAt); @@ -58,6 +59,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartAt = "START_AT"; diff --git a/src/Square/Types/TimecardStatus.cs b/src/Square/Types/TimecardStatus.cs index 939a95be..9c346137 100644 --- a/src/Square/Types/TimecardStatus.cs +++ b/src/Square/Types/TimecardStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TimecardStatus : IStringEnum { public static readonly TimecardStatus Open = new(Values.Open); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Open = "OPEN"; diff --git a/src/Square/Types/TimecardWage.cs b/src/Square/Types/TimecardWage.cs index 393c1d71..5b2831a7 100644 --- a/src/Square/Types/TimecardWage.cs +++ b/src/Square/Types/TimecardWage.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The hourly wage rate used to compensate a team member for a [timecard](entity:Timecard). /// -public record TimecardWage +[Serializable] +public record TimecardWage : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The name of the job performed during this timecard. /// @@ -36,15 +41,11 @@ public record TimecardWage [JsonPropertyName("tip_eligible")] public bool? TipEligible { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimecardWorkday.cs b/src/Square/Types/TimecardWorkday.cs index 55c13438..2b7de5d5 100644 --- a/src/Square/Types/TimecardWorkday.cs +++ b/src/Square/Types/TimecardWorkday.cs @@ -8,8 +8,13 @@ namespace Square; /// A `Timecard` search query filter parameter that sets a range of days that /// a `Timecard` must start or end in before passing the filter condition. /// -public record TimecardWorkday +[Serializable] +public record TimecardWorkday : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Dates for fetching the timecards. /// @@ -32,15 +37,11 @@ public record TimecardWorkday [JsonPropertyName("default_timezone")] public string? DefaultTimezone { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TimecardWorkdayMatcher.cs b/src/Square/Types/TimecardWorkdayMatcher.cs index fa84f1a9..c35c9366 100644 --- a/src/Square/Types/TimecardWorkdayMatcher.cs +++ b/src/Square/Types/TimecardWorkdayMatcher.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TimecardWorkdayMatcher : IStringEnum { public static readonly TimecardWorkdayMatcher StartAt = new(Values.StartAt); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string StartAt = "START_AT"; diff --git a/src/Square/Types/TipSettings.cs b/src/Square/Types/TipSettings.cs index 2e8fc058..f9217cba 100644 --- a/src/Square/Types/TipSettings.cs +++ b/src/Square/Types/TipSettings.cs @@ -4,8 +4,13 @@ namespace Square; -public record TipSettings +[Serializable] +public record TipSettings : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Indicates whether tipping is enabled for this checkout. Defaults to false. /// @@ -48,15 +53,11 @@ public record TipSettings [JsonPropertyName("smart_tipping")] public bool? SmartTipping { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Transaction.cs b/src/Square/Types/Transaction.cs index c1b3f181..c588755d 100644 --- a/src/Square/Types/Transaction.cs +++ b/src/Square/Types/Transaction.cs @@ -11,8 +11,13 @@ namespace Square; /// The `tenders` field of this object lists all methods of payment used to pay in /// the transaction. /// -public record Transaction +[Serializable] +public record Transaction : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The transaction's unique ID, issued by Square payments servers. /// @@ -85,15 +90,11 @@ public record Transaction [JsonPropertyName("order_id")] public string? OrderId { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransactionProduct.cs b/src/Square/Types/TransactionProduct.cs index 55a759a8..bb64f7d9 100644 --- a/src/Square/Types/TransactionProduct.cs +++ b/src/Square/Types/TransactionProduct.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TransactionProduct : IStringEnum { public static readonly TransactionProduct Register = new(Values.Register); @@ -66,6 +67,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Register = "REGISTER"; diff --git a/src/Square/Types/TransactionType.cs b/src/Square/Types/TransactionType.cs index 64fb3ad5..57f79e36 100644 --- a/src/Square/Types/TransactionType.cs +++ b/src/Square/Types/TransactionType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TransactionType : IStringEnum { public static readonly TransactionType Debit = new(Values.Debit); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Debit = "DEBIT"; diff --git a/src/Square/Types/TransferOrder.cs b/src/Square/Types/TransferOrder.cs index bc87539f..86f1b15f 100644 --- a/src/Square/Types/TransferOrder.cs +++ b/src/Square/Types/TransferOrder.cs @@ -20,8 +20,13 @@ namespace Square; /// - Monitor transfer progress and shipping status /// - Audit inventory movement history /// -public record TransferOrder +[Serializable] +public record TransferOrder : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique system-generated identifier for this transfer order. Use this ID for: /// - Retrieving transfer order details @@ -145,15 +150,11 @@ public record TransferOrder [JsonPropertyName("version")] public long? Version { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderCreatedEvent.cs b/src/Square/Types/TransferOrderCreatedEvent.cs index d06fcb5b..dedf9d6f 100644 --- a/src/Square/Types/TransferOrderCreatedEvent.cs +++ b/src/Square/Types/TransferOrderCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a transfer_order is created. /// -public record TransferOrderCreatedEvent +[Serializable] +public record TransferOrderCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TransferOrderCreatedEvent [JsonPropertyName("data")] public TransferOrderCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderCreatedEventData.cs b/src/Square/Types/TransferOrderCreatedEventData.cs index 55b54997..6f778faf 100644 --- a/src/Square/Types/TransferOrderCreatedEventData.cs +++ b/src/Square/Types/TransferOrderCreatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TransferOrderCreatedEventData +[Serializable] +public record TransferOrderCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"transfer_order"`. /// @@ -24,15 +29,11 @@ public record TransferOrderCreatedEventData [JsonPropertyName("object")] public TransferOrderCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderCreatedEventObject.cs b/src/Square/Types/TransferOrderCreatedEventObject.cs index 02a9d545..25aaa2d0 100644 --- a/src/Square/Types/TransferOrderCreatedEventObject.cs +++ b/src/Square/Types/TransferOrderCreatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TransferOrderCreatedEventObject +[Serializable] +public record TransferOrderCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The created transfer_order. /// [JsonPropertyName("transfer_order")] public TransferOrder? TransferOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderDeletedEvent.cs b/src/Square/Types/TransferOrderDeletedEvent.cs index 47181f64..e272fc46 100644 --- a/src/Square/Types/TransferOrderDeletedEvent.cs +++ b/src/Square/Types/TransferOrderDeletedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a transfer_order is deleted. /// -public record TransferOrderDeletedEvent +[Serializable] +public record TransferOrderDeletedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TransferOrderDeletedEvent [JsonPropertyName("data")] public TransferOrderDeletedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderDeletedEventData.cs b/src/Square/Types/TransferOrderDeletedEventData.cs index dbf6d35b..1a932781 100644 --- a/src/Square/Types/TransferOrderDeletedEventData.cs +++ b/src/Square/Types/TransferOrderDeletedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TransferOrderDeletedEventData +[Serializable] +public record TransferOrderDeletedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"transfer_order"`. /// @@ -24,15 +29,11 @@ public record TransferOrderDeletedEventData [JsonPropertyName("deleted")] public bool? Deleted { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderFilter.cs b/src/Square/Types/TransferOrderFilter.cs index 244e1b12..b334551b 100644 --- a/src/Square/Types/TransferOrderFilter.cs +++ b/src/Square/Types/TransferOrderFilter.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Filter criteria for searching transfer orders /// -public record TransferOrderFilter +[Serializable] +public record TransferOrderFilter : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filter by source location IDs /// @@ -28,15 +33,11 @@ public record TransferOrderFilter [JsonPropertyName("statuses")] public IEnumerable? Statuses { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderGoodsReceipt.cs b/src/Square/Types/TransferOrderGoodsReceipt.cs index de2edb30..e034cfa2 100644 --- a/src/Square/Types/TransferOrderGoodsReceipt.cs +++ b/src/Square/Types/TransferOrderGoodsReceipt.cs @@ -24,8 +24,13 @@ namespace Square; /// - Adjusts received quantities /// - Updates inventory levels at both source and destination [Location](entity:Location)s /// -public record TransferOrderGoodsReceipt +[Serializable] +public record TransferOrderGoodsReceipt : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Line items being received. Each line item specifies: /// - The item being received @@ -42,15 +47,11 @@ public record TransferOrderGoodsReceipt [JsonPropertyName("line_items")] public IEnumerable? LineItems { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderGoodsReceiptLineItem.cs b/src/Square/Types/TransferOrderGoodsReceiptLineItem.cs index 27cb1073..22080090 100644 --- a/src/Square/Types/TransferOrderGoodsReceiptLineItem.cs +++ b/src/Square/Types/TransferOrderGoodsReceiptLineItem.cs @@ -7,8 +7,13 @@ namespace Square; /// /// A simplified line item for goods receipts in transfer orders /// -public record TransferOrderGoodsReceiptLineItem +[Serializable] +public record TransferOrderGoodsReceiptLineItem : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The unique identifier of the Transfer Order line being received /// @@ -35,15 +40,11 @@ public record TransferOrderGoodsReceiptLineItem [JsonPropertyName("quantity_canceled")] public string? QuantityCanceled { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderLine.cs b/src/Square/Types/TransferOrderLine.cs index 267c859c..1cb01a42 100644 --- a/src/Square/Types/TransferOrderLine.cs +++ b/src/Square/Types/TransferOrderLine.cs @@ -9,8 +9,13 @@ namespace Square; /// [CatalogItemVariation](entity:CatalogItemVariation) being transferred, including ordered quantities /// and receipt status. /// -public record TransferOrderLine +[Serializable] +public record TransferOrderLine : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Unique system-generated identifier for the line item. Provide when updating/removing a line via [UpdateTransferOrder](api-endpoint:TransferOrders-UpdateTransferOrder). /// @@ -69,15 +74,11 @@ public record TransferOrderLine [JsonPropertyName("quantity_canceled")] public string? QuantityCanceled { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderQuery.cs b/src/Square/Types/TransferOrderQuery.cs index fa9cff6a..7baa8ad9 100644 --- a/src/Square/Types/TransferOrderQuery.cs +++ b/src/Square/Types/TransferOrderQuery.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Query parameters for searching transfer orders /// -public record TransferOrderQuery +[Serializable] +public record TransferOrderQuery : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Filter criteria /// @@ -21,15 +26,11 @@ public record TransferOrderQuery [JsonPropertyName("sort")] public TransferOrderSort? Sort { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderSort.cs b/src/Square/Types/TransferOrderSort.cs index 6898aef7..13ef8e23 100644 --- a/src/Square/Types/TransferOrderSort.cs +++ b/src/Square/Types/TransferOrderSort.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Sort configuration for search results /// -public record TransferOrderSort +[Serializable] +public record TransferOrderSort : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Field to sort by /// See [TransferOrderSortField](#type-transferordersortfield) for possible values @@ -23,15 +28,11 @@ public record TransferOrderSort [JsonPropertyName("order")] public SortOrder? Order { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderSortField.cs b/src/Square/Types/TransferOrderSortField.cs index 4c4b6caf..10bffe87 100644 --- a/src/Square/Types/TransferOrderSortField.cs +++ b/src/Square/Types/TransferOrderSortField.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TransferOrderSortField : IStringEnum { public static readonly TransferOrderSortField CreatedAt = new(Values.CreatedAt); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CreatedAt = "CREATED_AT"; diff --git a/src/Square/Types/TransferOrderStatus.cs b/src/Square/Types/TransferOrderStatus.cs index b51f35e1..80a9b3c4 100644 --- a/src/Square/Types/TransferOrderStatus.cs +++ b/src/Square/Types/TransferOrderStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct TransferOrderStatus : IStringEnum { public static readonly TransferOrderStatus Draft = new(Values.Draft); @@ -60,6 +61,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Draft = "DRAFT"; diff --git a/src/Square/Types/TransferOrderUpdatedEvent.cs b/src/Square/Types/TransferOrderUpdatedEvent.cs index 275df07a..0e7b1b5e 100644 --- a/src/Square/Types/TransferOrderUpdatedEvent.cs +++ b/src/Square/Types/TransferOrderUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a transfer_order is updated. /// -public record TransferOrderUpdatedEvent +[Serializable] +public record TransferOrderUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the target merchant associated with the event. /// @@ -40,15 +45,11 @@ public record TransferOrderUpdatedEvent [JsonPropertyName("data")] public TransferOrderUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderUpdatedEventData.cs b/src/Square/Types/TransferOrderUpdatedEventData.cs index 42106068..371eb121 100644 --- a/src/Square/Types/TransferOrderUpdatedEventData.cs +++ b/src/Square/Types/TransferOrderUpdatedEventData.cs @@ -4,8 +4,13 @@ namespace Square; -public record TransferOrderUpdatedEventData +[Serializable] +public record TransferOrderUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Name of the affected object’s type, `"transfer_order"`. /// @@ -24,15 +29,11 @@ public record TransferOrderUpdatedEventData [JsonPropertyName("object")] public TransferOrderUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/TransferOrderUpdatedEventObject.cs b/src/Square/Types/TransferOrderUpdatedEventObject.cs index 3475944f..57a77418 100644 --- a/src/Square/Types/TransferOrderUpdatedEventObject.cs +++ b/src/Square/Types/TransferOrderUpdatedEventObject.cs @@ -4,23 +4,24 @@ namespace Square; -public record TransferOrderUpdatedEventObject +[Serializable] +public record TransferOrderUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated transfer_order. /// [JsonPropertyName("transfer_order")] public TransferOrder? TransferOrder { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UnlinkCustomerFromGiftCardResponse.cs b/src/Square/Types/UnlinkCustomerFromGiftCardResponse.cs index 2bd8cf0e..608680df 100644 --- a/src/Square/Types/UnlinkCustomerFromGiftCardResponse.cs +++ b/src/Square/Types/UnlinkCustomerFromGiftCardResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// A response that contains the unlinked `GiftCard` object. If the request resulted in errors, /// the response contains a set of `Error` objects. /// -public record UnlinkCustomerFromGiftCardResponse +[Serializable] +public record UnlinkCustomerFromGiftCardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -23,15 +28,11 @@ public record UnlinkCustomerFromGiftCardResponse [JsonPropertyName("gift_card")] public GiftCard? GiftCard { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateBookingCustomAttributeDefinitionResponse.cs b/src/Square/Types/UpdateBookingCustomAttributeDefinitionResponse.cs index 86d67717..571bbac8 100644 --- a/src/Square/Types/UpdateBookingCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/UpdateBookingCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpdateBookingCustomAttributeDefinition](api-endpoint:BookingCustomAttributes-UpdateBookingCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpdateBookingCustomAttributeDefinitionResponse +[Serializable] +public record UpdateBookingCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated custom attribute definition. /// @@ -22,15 +27,11 @@ public record UpdateBookingCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateBookingResponse.cs b/src/Square/Types/UpdateBookingResponse.cs index 7d24b9b2..e6a32286 100644 --- a/src/Square/Types/UpdateBookingResponse.cs +++ b/src/Square/Types/UpdateBookingResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateBookingResponse +[Serializable] +public record UpdateBookingResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The booking that was updated. /// @@ -18,15 +23,11 @@ public record UpdateBookingResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateBreakTypeResponse.cs b/src/Square/Types/UpdateBreakTypeResponse.cs index eea25bbe..98754e10 100644 --- a/src/Square/Types/UpdateBreakTypeResponse.cs +++ b/src/Square/Types/UpdateBreakTypeResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the requested `BreakType` objects and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record UpdateBreakTypeResponse +[Serializable] +public record UpdateBreakTypeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The response object. /// @@ -23,15 +28,11 @@ public record UpdateBreakTypeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateCatalogImageRequest.cs b/src/Square/Types/UpdateCatalogImageRequest.cs index 666b0663..8e9cc7d1 100644 --- a/src/Square/Types/UpdateCatalogImageRequest.cs +++ b/src/Square/Types/UpdateCatalogImageRequest.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateCatalogImageRequest +[Serializable] +public record UpdateCatalogImageRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique string that identifies this UpdateCatalogImage request. /// Keys can be any valid string but must be unique for every UpdateCatalogImage request. @@ -15,15 +20,11 @@ public record UpdateCatalogImageRequest [JsonPropertyName("idempotency_key")] public required string IdempotencyKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateCatalogImageResponse.cs b/src/Square/Types/UpdateCatalogImageResponse.cs index 2ea41d7f..cec35285 100644 --- a/src/Square/Types/UpdateCatalogImageResponse.cs +++ b/src/Square/Types/UpdateCatalogImageResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateCatalogImageResponse +[Serializable] +public record UpdateCatalogImageResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -19,15 +24,11 @@ public record UpdateCatalogImageResponse [JsonPropertyName("image")] public CatalogObject? Image { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateCustomerCustomAttributeDefinitionResponse.cs b/src/Square/Types/UpdateCustomerCustomAttributeDefinitionResponse.cs index bb4a2637..aa470c65 100644 --- a/src/Square/Types/UpdateCustomerCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/UpdateCustomerCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpdateCustomerCustomAttributeDefinition](api-endpoint:CustomerCustomAttributes-UpdateCustomerCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpdateCustomerCustomAttributeDefinitionResponse +[Serializable] +public record UpdateCustomerCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated custom attribute definition. /// @@ -22,15 +27,11 @@ public record UpdateCustomerCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateCustomerGroupResponse.cs b/src/Square/Types/UpdateCustomerGroupResponse.cs index ddd1e79b..1fd94b50 100644 --- a/src/Square/Types/UpdateCustomerGroupResponse.cs +++ b/src/Square/Types/UpdateCustomerGroupResponse.cs @@ -10,8 +10,13 @@ namespace Square; /// /// Either `errors` or `group` is present in a given response (never both). /// -public record UpdateCustomerGroupResponse +[Serializable] +public record UpdateCustomerGroupResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record UpdateCustomerGroupResponse [JsonPropertyName("group")] public CustomerGroup? Group { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateCustomerResponse.cs b/src/Square/Types/UpdateCustomerResponse.cs index 51ea8d50..427e1ff2 100644 --- a/src/Square/Types/UpdateCustomerResponse.cs +++ b/src/Square/Types/UpdateCustomerResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// /// Either `errors` or `customer` is present in a given response (never both). /// -public record UpdateCustomerResponse +[Serializable] +public record UpdateCustomerResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -25,15 +30,11 @@ public record UpdateCustomerResponse [JsonPropertyName("customer")] public Customer? Customer { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateInvoiceResponse.cs b/src/Square/Types/UpdateInvoiceResponse.cs index 1258eaa2..de5ca6d9 100644 --- a/src/Square/Types/UpdateInvoiceResponse.cs +++ b/src/Square/Types/UpdateInvoiceResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Describes a `UpdateInvoice` response. /// -public record UpdateInvoiceResponse +[Serializable] +public record UpdateInvoiceResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated invoice. /// @@ -21,15 +26,11 @@ public record UpdateInvoiceResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateItemModifierListsResponse.cs b/src/Square/Types/UpdateItemModifierListsResponse.cs index 8c4120da..61b7fc77 100644 --- a/src/Square/Types/UpdateItemModifierListsResponse.cs +++ b/src/Square/Types/UpdateItemModifierListsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateItemModifierListsResponse +[Serializable] +public record UpdateItemModifierListsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record UpdateItemModifierListsResponse [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateItemTaxesResponse.cs b/src/Square/Types/UpdateItemTaxesResponse.cs index 1dc37c95..9394c0d4 100644 --- a/src/Square/Types/UpdateItemTaxesResponse.cs +++ b/src/Square/Types/UpdateItemTaxesResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateItemTaxesResponse +[Serializable] +public record UpdateItemTaxesResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -18,15 +23,11 @@ public record UpdateItemTaxesResponse [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateJobResponse.cs b/src/Square/Types/UpdateJobResponse.cs index 0954d03e..774f1170 100644 --- a/src/Square/Types/UpdateJobResponse.cs +++ b/src/Square/Types/UpdateJobResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpdateJob](api-endpoint:Team-UpdateJob) response. Either `job` or `errors` /// is present in the response. /// -public record UpdateJobResponse +[Serializable] +public record UpdateJobResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated job. /// @@ -22,15 +27,11 @@ public record UpdateJobResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateLocationCustomAttributeDefinitionResponse.cs b/src/Square/Types/UpdateLocationCustomAttributeDefinitionResponse.cs index 0e0316d6..d2108b8b 100644 --- a/src/Square/Types/UpdateLocationCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/UpdateLocationCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpdateLocationCustomAttributeDefinition](api-endpoint:LocationCustomAttributes-UpdateLocationCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpdateLocationCustomAttributeDefinitionResponse +[Serializable] +public record UpdateLocationCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated custom attribute definition. /// @@ -22,15 +27,11 @@ public record UpdateLocationCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateLocationResponse.cs b/src/Square/Types/UpdateLocationResponse.cs index 8fb59867..fbd4a209 100644 --- a/src/Square/Types/UpdateLocationResponse.cs +++ b/src/Square/Types/UpdateLocationResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// The response object returned by the [UpdateLocation](api-endpoint:Locations-UpdateLocation) endpoint. /// -public record UpdateLocationResponse +[Serializable] +public record UpdateLocationResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information about errors encountered during the request. /// @@ -21,15 +26,11 @@ public record UpdateLocationResponse [JsonPropertyName("location")] public Location? Location { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateLocationSettingsResponse.cs b/src/Square/Types/UpdateLocationSettingsResponse.cs index cc4a7d41..ceae3716 100644 --- a/src/Square/Types/UpdateLocationSettingsResponse.cs +++ b/src/Square/Types/UpdateLocationSettingsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateLocationSettingsResponse +[Serializable] +public record UpdateLocationSettingsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred when updating the location settings. /// @@ -18,15 +23,11 @@ public record UpdateLocationSettingsResponse [JsonPropertyName("location_settings")] public CheckoutLocationSettings? LocationSettings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateMerchantCustomAttributeDefinitionResponse.cs b/src/Square/Types/UpdateMerchantCustomAttributeDefinitionResponse.cs index 69f861bb..19d2bdbd 100644 --- a/src/Square/Types/UpdateMerchantCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/UpdateMerchantCustomAttributeDefinitionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpdateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-UpdateMerchantCustomAttributeDefinition) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpdateMerchantCustomAttributeDefinitionResponse +[Serializable] +public record UpdateMerchantCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated custom attribute definition. /// @@ -22,15 +27,11 @@ public record UpdateMerchantCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateMerchantSettingsResponse.cs b/src/Square/Types/UpdateMerchantSettingsResponse.cs index 94beb569..cb3493c4 100644 --- a/src/Square/Types/UpdateMerchantSettingsResponse.cs +++ b/src/Square/Types/UpdateMerchantSettingsResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdateMerchantSettingsResponse +[Serializable] +public record UpdateMerchantSettingsResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred when updating the merchant settings. /// @@ -18,15 +23,11 @@ public record UpdateMerchantSettingsResponse [JsonPropertyName("merchant_settings")] public CheckoutMerchantSettings? MerchantSettings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateOrderCustomAttributeDefinitionResponse.cs b/src/Square/Types/UpdateOrderCustomAttributeDefinitionResponse.cs index 318bb74e..d18ee47b 100644 --- a/src/Square/Types/UpdateOrderCustomAttributeDefinitionResponse.cs +++ b/src/Square/Types/UpdateOrderCustomAttributeDefinitionResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from updating an order custom attribute definition. /// -public record UpdateOrderCustomAttributeDefinitionResponse +[Serializable] +public record UpdateOrderCustomAttributeDefinitionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated order custom attribute definition. /// @@ -21,15 +26,11 @@ public record UpdateOrderCustomAttributeDefinitionResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateOrderResponse.cs b/src/Square/Types/UpdateOrderResponse.cs index 640ecf0a..2a99e48b 100644 --- a/src/Square/Types/UpdateOrderResponse.cs +++ b/src/Square/Types/UpdateOrderResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [UpdateOrder](api-endpoint:Orders-UpdateOrder) endpoint. /// -public record UpdateOrderResponse +[Serializable] +public record UpdateOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated order. /// @@ -22,15 +27,11 @@ public record UpdateOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdatePaymentLinkResponse.cs b/src/Square/Types/UpdatePaymentLinkResponse.cs index 6d8cea8f..41e79a86 100644 --- a/src/Square/Types/UpdatePaymentLinkResponse.cs +++ b/src/Square/Types/UpdatePaymentLinkResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpdatePaymentLinkResponse +[Serializable] +public record UpdatePaymentLinkResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred when updating the payment link. /// @@ -18,15 +23,11 @@ public record UpdatePaymentLinkResponse [JsonPropertyName("payment_link")] public PaymentLink? PaymentLink { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdatePaymentResponse.cs b/src/Square/Types/UpdatePaymentResponse.cs index e1b22d79..427abef6 100644 --- a/src/Square/Types/UpdatePaymentResponse.cs +++ b/src/Square/Types/UpdatePaymentResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines the response returned by /// [UpdatePayment](api-endpoint:Payments-UpdatePayment). /// -public record UpdatePaymentResponse +[Serializable] +public record UpdatePaymentResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -22,15 +27,11 @@ public record UpdatePaymentResponse [JsonPropertyName("payment")] public Payment? Payment { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateScheduledShiftResponse.cs b/src/Square/Types/UpdateScheduledShiftResponse.cs index b937e230..7d0263bc 100644 --- a/src/Square/Types/UpdateScheduledShiftResponse.cs +++ b/src/Square/Types/UpdateScheduledShiftResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpdateScheduledShift](api-endpoint:Labor-UpdateScheduledShift) response. /// Either `scheduled_shift` or `errors` is present in the response. /// -public record UpdateScheduledShiftResponse +[Serializable] +public record UpdateScheduledShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated scheduled shift. To make the changes public, call /// [PublishScheduledShift](api-endpoint:Labor-PublishScheduledShift) or @@ -24,15 +29,11 @@ public record UpdateScheduledShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateShiftResponse.cs b/src/Square/Types/UpdateShiftResponse.cs index 11eb6e3b..b475105d 100644 --- a/src/Square/Types/UpdateShiftResponse.cs +++ b/src/Square/Types/UpdateShiftResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the updated `Shift` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record UpdateShiftResponse +[Serializable] +public record UpdateShiftResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated `Shift`. /// @@ -23,15 +28,11 @@ public record UpdateShiftResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateSubscriptionResponse.cs b/src/Square/Types/UpdateSubscriptionResponse.cs index b3b4892a..bfa45385 100644 --- a/src/Square/Types/UpdateSubscriptionResponse.cs +++ b/src/Square/Types/UpdateSubscriptionResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Defines output parameters in a response from the /// [UpdateSubscription](api-endpoint:Subscriptions-UpdateSubscription) endpoint. /// -public record UpdateSubscriptionResponse +[Serializable] +public record UpdateSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors encountered during the request. /// @@ -22,15 +27,11 @@ public record UpdateSubscriptionResponse [JsonPropertyName("subscription")] public Subscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateTeamMemberRequest.cs b/src/Square/Types/UpdateTeamMemberRequest.cs index 002671a4..d87c9f59 100644 --- a/src/Square/Types/UpdateTeamMemberRequest.cs +++ b/src/Square/Types/UpdateTeamMemberRequest.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an update request for a `TeamMember` object. /// -public record UpdateTeamMemberRequest +[Serializable] +public record UpdateTeamMemberRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The team member fields to add, change, or clear. Fields can be cleared using a null value. To update /// `wage_setting.job_assignments`, you must provide the complete list of job assignments. If needed, call @@ -17,15 +22,11 @@ public record UpdateTeamMemberRequest [JsonPropertyName("team_member")] public TeamMember? TeamMember { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateTeamMemberResponse.cs b/src/Square/Types/UpdateTeamMemberResponse.cs index 49cece59..a9d209b8 100644 --- a/src/Square/Types/UpdateTeamMemberResponse.cs +++ b/src/Square/Types/UpdateTeamMemberResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from an update request containing the updated `TeamMember` object or error messages. /// -public record UpdateTeamMemberResponse +[Serializable] +public record UpdateTeamMemberResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully updated `TeamMember` object. /// @@ -21,15 +26,11 @@ public record UpdateTeamMemberResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateTimecardResponse.cs b/src/Square/Types/UpdateTimecardResponse.cs index bfed3fba..3aa5e865 100644 --- a/src/Square/Types/UpdateTimecardResponse.cs +++ b/src/Square/Types/UpdateTimecardResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the updated `Timecard` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record UpdateTimecardResponse +[Serializable] +public record UpdateTimecardResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated `Timecard`. /// @@ -23,15 +28,11 @@ public record UpdateTimecardResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateTransferOrderData.cs b/src/Square/Types/UpdateTransferOrderData.cs index e54fec63..a7b7e13c 100644 --- a/src/Square/Types/UpdateTransferOrderData.cs +++ b/src/Square/Types/UpdateTransferOrderData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Data model for updating a transfer order. All fields are optional. /// -public record UpdateTransferOrderData +[Serializable] +public record UpdateTransferOrderData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The source [Location](entity:Location) that will send the items. Must be an active location /// in your Square account with sufficient inventory of the requested items. @@ -47,15 +52,11 @@ public record UpdateTransferOrderData [JsonPropertyName("line_items")] public IEnumerable? LineItems { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateTransferOrderLineData.cs b/src/Square/Types/UpdateTransferOrderLineData.cs index 46b6ad68..b580eb7b 100644 --- a/src/Square/Types/UpdateTransferOrderLineData.cs +++ b/src/Square/Types/UpdateTransferOrderLineData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a line item update in a transfer order /// -public record UpdateTransferOrderLineData +[Serializable] +public record UpdateTransferOrderLineData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Line item id being updated. Required for updating/removing existing line items, but should not be set for new line items. /// @@ -35,15 +40,11 @@ public record UpdateTransferOrderLineData [JsonPropertyName("remove")] public bool? Remove { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateTransferOrderResponse.cs b/src/Square/Types/UpdateTransferOrderResponse.cs index 021d9ca7..6267c9e2 100644 --- a/src/Square/Types/UpdateTransferOrderResponse.cs +++ b/src/Square/Types/UpdateTransferOrderResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Response for updating a transfer order /// -public record UpdateTransferOrderResponse +[Serializable] +public record UpdateTransferOrderResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The updated transfer order /// @@ -21,15 +26,11 @@ public record UpdateTransferOrderResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateVendorRequest.cs b/src/Square/Types/UpdateVendorRequest.cs index cb401418..c271d6ec 100644 --- a/src/Square/Types/UpdateVendorRequest.cs +++ b/src/Square/Types/UpdateVendorRequest.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an input to a call to [UpdateVendor](api-endpoint:Vendors-UpdateVendor). /// -public record UpdateVendorRequest +[Serializable] +public record UpdateVendorRequest : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A client-supplied, universally unique identifier (UUID) for the /// request. @@ -26,15 +31,11 @@ public record UpdateVendorRequest [JsonPropertyName("vendor")] public required Vendor Vendor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateVendorResponse.cs b/src/Square/Types/UpdateVendorResponse.cs index 540ca887..3f24ccab 100644 --- a/src/Square/Types/UpdateVendorResponse.cs +++ b/src/Square/Types/UpdateVendorResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an output from a call to [UpdateVendor](api-endpoint:Vendors-UpdateVendor). /// -public record UpdateVendorResponse +[Serializable] +public record UpdateVendorResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Errors occurred when the request fails. /// @@ -21,15 +26,11 @@ public record UpdateVendorResponse [JsonPropertyName("vendor")] public Vendor? Vendor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateWageSettingResponse.cs b/src/Square/Types/UpdateWageSettingResponse.cs index 8c7e0bb0..c76b328e 100644 --- a/src/Square/Types/UpdateWageSettingResponse.cs +++ b/src/Square/Types/UpdateWageSettingResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents a response from an update request containing the updated `WageSetting` object /// or error messages. /// -public record UpdateWageSettingResponse +[Serializable] +public record UpdateWageSettingResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The successfully updated `WageSetting` object. /// @@ -22,15 +27,11 @@ public record UpdateWageSettingResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateWebhookSubscriptionResponse.cs b/src/Square/Types/UpdateWebhookSubscriptionResponse.cs index 5ba562d2..3ce0f387 100644 --- a/src/Square/Types/UpdateWebhookSubscriptionResponse.cs +++ b/src/Square/Types/UpdateWebhookSubscriptionResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: If there are errors processing the request, the [Subscription](entity:WebhookSubscription) is not /// present. /// -public record UpdateWebhookSubscriptionResponse +[Serializable] +public record UpdateWebhookSubscriptionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -25,15 +30,11 @@ public record UpdateWebhookSubscriptionResponse [JsonPropertyName("subscription")] public WebhookSubscription? Subscription { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateWebhookSubscriptionSignatureKeyResponse.cs b/src/Square/Types/UpdateWebhookSubscriptionSignatureKeyResponse.cs index bdcc2528..1954f95f 100644 --- a/src/Square/Types/UpdateWebhookSubscriptionSignatureKeyResponse.cs +++ b/src/Square/Types/UpdateWebhookSubscriptionSignatureKeyResponse.cs @@ -11,8 +11,13 @@ namespace Square; /// Note: If there are errors processing the request, the [Subscription](entity:WebhookSubscription) is not /// present. /// -public record UpdateWebhookSubscriptionSignatureKeyResponse +[Serializable] +public record UpdateWebhookSubscriptionSignatureKeyResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Information on errors encountered during the request. /// @@ -26,15 +31,11 @@ public record UpdateWebhookSubscriptionSignatureKeyResponse [JsonPropertyName("signature_key")] public string? SignatureKey { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpdateWorkweekConfigResponse.cs b/src/Square/Types/UpdateWorkweekConfigResponse.cs index 90d9ba32..06340895 100644 --- a/src/Square/Types/UpdateWorkweekConfigResponse.cs +++ b/src/Square/Types/UpdateWorkweekConfigResponse.cs @@ -9,8 +9,13 @@ namespace Square; /// the updated `WorkweekConfig` object and might contain a set of `Error` objects if /// the request resulted in errors. /// -public record UpdateWorkweekConfigResponse +[Serializable] +public record UpdateWorkweekConfigResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The response object. /// @@ -23,15 +28,11 @@ public record UpdateWorkweekConfigResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertBookingCustomAttributeResponse.cs b/src/Square/Types/UpsertBookingCustomAttributeResponse.cs index af2cd6df..d1517067 100644 --- a/src/Square/Types/UpsertBookingCustomAttributeResponse.cs +++ b/src/Square/Types/UpsertBookingCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpsertBookingCustomAttribute](api-endpoint:BookingCustomAttributes-UpsertBookingCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpsertBookingCustomAttributeResponse +[Serializable] +public record UpsertBookingCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new or updated custom attribute. /// @@ -22,15 +27,11 @@ public record UpsertBookingCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertCatalogObjectResponse.cs b/src/Square/Types/UpsertCatalogObjectResponse.cs index f00f3e7e..812b94bb 100644 --- a/src/Square/Types/UpsertCatalogObjectResponse.cs +++ b/src/Square/Types/UpsertCatalogObjectResponse.cs @@ -4,8 +4,13 @@ namespace Square; -public record UpsertCatalogObjectResponse +[Serializable] +public record UpsertCatalogObjectResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -24,15 +29,11 @@ public record UpsertCatalogObjectResponse [JsonPropertyName("id_mappings")] public IEnumerable? IdMappings { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertCustomerCustomAttributeResponse.cs b/src/Square/Types/UpsertCustomerCustomAttributeResponse.cs index fcc75fa2..80120eb4 100644 --- a/src/Square/Types/UpsertCustomerCustomAttributeResponse.cs +++ b/src/Square/Types/UpsertCustomerCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpsertCustomerCustomAttribute](api-endpoint:CustomerCustomAttributes-UpsertCustomerCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpsertCustomerCustomAttributeResponse +[Serializable] +public record UpsertCustomerCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new or updated custom attribute. /// @@ -22,15 +27,11 @@ public record UpsertCustomerCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertLocationCustomAttributeResponse.cs b/src/Square/Types/UpsertLocationCustomAttributeResponse.cs index f2e242e1..7840a6df 100644 --- a/src/Square/Types/UpsertLocationCustomAttributeResponse.cs +++ b/src/Square/Types/UpsertLocationCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpsertLocationCustomAttribute](api-endpoint:LocationCustomAttributes-UpsertLocationCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpsertLocationCustomAttributeResponse +[Serializable] +public record UpsertLocationCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new or updated custom attribute. /// @@ -22,15 +27,11 @@ public record UpsertLocationCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertMerchantCustomAttributeResponse.cs b/src/Square/Types/UpsertMerchantCustomAttributeResponse.cs index fec41178..600fb9b8 100644 --- a/src/Square/Types/UpsertMerchantCustomAttributeResponse.cs +++ b/src/Square/Types/UpsertMerchantCustomAttributeResponse.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents an [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) response. /// Either `custom_attribute_definition` or `errors` is present in the response. /// -public record UpsertMerchantCustomAttributeResponse +[Serializable] +public record UpsertMerchantCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The new or updated custom attribute. /// @@ -22,15 +27,11 @@ public record UpsertMerchantCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertOrderCustomAttributeResponse.cs b/src/Square/Types/UpsertOrderCustomAttributeResponse.cs index 1523a67f..991da5ca 100644 --- a/src/Square/Types/UpsertOrderCustomAttributeResponse.cs +++ b/src/Square/Types/UpsertOrderCustomAttributeResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a response from upserting order custom attribute definitions. /// -public record UpsertOrderCustomAttributeResponse +[Serializable] +public record UpsertOrderCustomAttributeResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The order custom attribute that was created or modified. /// @@ -21,15 +26,11 @@ public record UpsertOrderCustomAttributeResponse [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/UpsertSnippetResponse.cs b/src/Square/Types/UpsertSnippetResponse.cs index 54f42495..977396d4 100644 --- a/src/Square/Types/UpsertSnippetResponse.cs +++ b/src/Square/Types/UpsertSnippetResponse.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents an `UpsertSnippet` response. The response can include either `snippet` or `errors`. /// -public record UpsertSnippetResponse +[Serializable] +public record UpsertSnippetResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -21,15 +26,11 @@ public record UpsertSnippetResponse [JsonPropertyName("snippet")] public Snippet? Snippet { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/V1Money.cs b/src/Square/Types/V1Money.cs index bb16777c..c214ab7c 100644 --- a/src/Square/Types/V1Money.cs +++ b/src/Square/Types/V1Money.cs @@ -4,8 +4,13 @@ namespace Square; -public record V1Money +[Serializable] +public record V1Money : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Amount in the lowest denominated value of this Currency. E.g. in USD /// these are cents, in JPY they are Yen (which do not have a 'cent' concept). @@ -19,15 +24,11 @@ public record V1Money [JsonPropertyName("currency_code")] public Currency? CurrencyCode { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/V1Order.cs b/src/Square/Types/V1Order.cs index 3ab880c5..e6a38cab 100644 --- a/src/Square/Types/V1Order.cs +++ b/src/Square/Types/V1Order.cs @@ -7,8 +7,13 @@ namespace Square; /// /// V1Order /// -public record V1Order +[Serializable] +public record V1Order : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// @@ -160,15 +165,11 @@ public record V1Order [JsonPropertyName("btc_price_satoshi")] public double? BtcPriceSatoshi { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/V1OrderHistoryEntry.cs b/src/Square/Types/V1OrderHistoryEntry.cs index 90d7125b..fcb96f67 100644 --- a/src/Square/Types/V1OrderHistoryEntry.cs +++ b/src/Square/Types/V1OrderHistoryEntry.cs @@ -7,8 +7,13 @@ namespace Square; /// /// V1OrderHistoryEntry /// -public record V1OrderHistoryEntry +[Serializable] +public record V1OrderHistoryEntry : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of action performed on the order. /// See [V1OrderHistoryEntryAction](#type-v1orderhistoryentryaction) for possible values @@ -22,15 +27,11 @@ public record V1OrderHistoryEntry [JsonPropertyName("created_at")] public string? CreatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/V1OrderHistoryEntryAction.cs b/src/Square/Types/V1OrderHistoryEntryAction.cs index 37c77375..7fd9e362 100644 --- a/src/Square/Types/V1OrderHistoryEntryAction.cs +++ b/src/Square/Types/V1OrderHistoryEntryAction.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct V1OrderHistoryEntryAction : IStringEnum { public static readonly V1OrderHistoryEntryAction OrderPlaced = new(Values.OrderPlaced); @@ -64,6 +65,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OrderPlaced = "ORDER_PLACED"; diff --git a/src/Square/Types/V1OrderState.cs b/src/Square/Types/V1OrderState.cs index 08452037..1a4e053e 100644 --- a/src/Square/Types/V1OrderState.cs +++ b/src/Square/Types/V1OrderState.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct V1OrderState : IStringEnum { public static readonly V1OrderState Pending = new(Values.Pending); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Pending = "PENDING"; diff --git a/src/Square/Types/V1Tender.cs b/src/Square/Types/V1Tender.cs index 7ec280d0..cd6c9171 100644 --- a/src/Square/Types/V1Tender.cs +++ b/src/Square/Types/V1Tender.cs @@ -28,8 +28,13 @@ namespace Square; /// `SQUARE_GIFT_CARD` indicates a gift card was used for some or all of the /// associated payment. /// -public record V1Tender +[Serializable] +public record V1Tender : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The tender's unique ID. /// @@ -129,15 +134,11 @@ public record V1Tender [JsonPropertyName("is_exchange")] public bool? IsExchange { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/V1TenderCardBrand.cs b/src/Square/Types/V1TenderCardBrand.cs index 95b0e349..1de74258 100644 --- a/src/Square/Types/V1TenderCardBrand.cs +++ b/src/Square/Types/V1TenderCardBrand.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct V1TenderCardBrand : IStringEnum { public static readonly V1TenderCardBrand OtherBrand = new(Values.OtherBrand); @@ -68,6 +69,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string OtherBrand = "OTHER_BRAND"; diff --git a/src/Square/Types/V1TenderEntryMethod.cs b/src/Square/Types/V1TenderEntryMethod.cs index 003cd52c..fa435b67 100644 --- a/src/Square/Types/V1TenderEntryMethod.cs +++ b/src/Square/Types/V1TenderEntryMethod.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct V1TenderEntryMethod : IStringEnum { public static readonly V1TenderEntryMethod Manual = new(Values.Manual); @@ -64,6 +65,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Manual = "MANUAL"; diff --git a/src/Square/Types/V1TenderType.cs b/src/Square/Types/V1TenderType.cs index 6dc80920..bc0db05f 100644 --- a/src/Square/Types/V1TenderType.cs +++ b/src/Square/Types/V1TenderType.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct V1TenderType : IStringEnum { public static readonly V1TenderType CreditCard = new(Values.CreditCard); @@ -66,6 +67,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string CreditCard = "CREDIT_CARD"; diff --git a/src/Square/Types/V1UpdateOrderRequestAction.cs b/src/Square/Types/V1UpdateOrderRequestAction.cs index 93333c9e..d1066b69 100644 --- a/src/Square/Types/V1UpdateOrderRequestAction.cs +++ b/src/Square/Types/V1UpdateOrderRequestAction.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct V1UpdateOrderRequestAction : IStringEnum { public static readonly V1UpdateOrderRequestAction Complete = new(Values.Complete); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Complete = "COMPLETE"; diff --git a/src/Square/Types/Vendor.cs b/src/Square/Types/Vendor.cs index e491feac..0d92b37d 100644 --- a/src/Square/Types/Vendor.cs +++ b/src/Square/Types/Vendor.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a supplier to a seller. /// -public record Vendor +[Serializable] +public record Vendor : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique Square-generated ID for the [Vendor](entity:Vendor). /// This field is required when attempting to update a [Vendor](entity:Vendor). @@ -76,15 +81,11 @@ public record Vendor [JsonPropertyName("status")] public VendorStatus? Status { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorContact.cs b/src/Square/Types/VendorContact.cs index caeac17f..40199b37 100644 --- a/src/Square/Types/VendorContact.cs +++ b/src/Square/Types/VendorContact.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Represents a contact of a [Vendor](entity:Vendor). /// -public record VendorContact +[Serializable] +public record VendorContact : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A unique Square-generated ID for the [VendorContact](entity:VendorContact). /// This field is required when attempting to update a [VendorContact](entity:VendorContact). @@ -47,15 +52,11 @@ public record VendorContact [JsonPropertyName("ordinal")] public required int Ordinal { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorCreatedEvent.cs b/src/Square/Types/VendorCreatedEvent.cs index cbaac8fe..60e46dbc 100644 --- a/src/Square/Types/VendorCreatedEvent.cs +++ b/src/Square/Types/VendorCreatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Vendor](entity:Vendor) is created. /// -public record VendorCreatedEvent +[Serializable] +public record VendorCreatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of a seller associated with this event. /// @@ -46,15 +51,11 @@ public record VendorCreatedEvent [JsonPropertyName("data")] public VendorCreatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorCreatedEventData.cs b/src/Square/Types/VendorCreatedEventData.cs index d7997859..68932acc 100644 --- a/src/Square/Types/VendorCreatedEventData.cs +++ b/src/Square/Types/VendorCreatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the `vendor.created` event data structure. /// -public record VendorCreatedEventData +[Serializable] +public record VendorCreatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `vendor` /// @@ -27,15 +32,11 @@ public record VendorCreatedEventData [JsonPropertyName("object")] public VendorCreatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorCreatedEventObject.cs b/src/Square/Types/VendorCreatedEventObject.cs index f9dbb3f9..3b0b1290 100644 --- a/src/Square/Types/VendorCreatedEventObject.cs +++ b/src/Square/Types/VendorCreatedEventObject.cs @@ -4,8 +4,13 @@ namespace Square; -public record VendorCreatedEventObject +[Serializable] +public record VendorCreatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The operation on the vendor that caused the event to be published. The value is `CREATED`. /// See [Operation](#type-operation) for possible values @@ -19,15 +24,11 @@ public record VendorCreatedEventObject [JsonPropertyName("vendor")] public Vendor? Vendor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorStatus.cs b/src/Square/Types/VendorStatus.cs index b5f6145e..6d473eb2 100644 --- a/src/Square/Types/VendorStatus.cs +++ b/src/Square/Types/VendorStatus.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct VendorStatus : IStringEnum { public static readonly VendorStatus Active = new(Values.Active); @@ -54,6 +55,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Active = "ACTIVE"; diff --git a/src/Square/Types/VendorUpdatedEvent.cs b/src/Square/Types/VendorUpdatedEvent.cs index 4b59c3e4..474958fd 100644 --- a/src/Square/Types/VendorUpdatedEvent.cs +++ b/src/Square/Types/VendorUpdatedEvent.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Published when a [Vendor](entity:Vendor) is updated. /// -public record VendorUpdatedEvent +[Serializable] +public record VendorUpdatedEvent : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of a seller associated with this event. /// @@ -46,15 +51,11 @@ public record VendorUpdatedEvent [JsonPropertyName("data")] public VendorUpdatedEventData? Data { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorUpdatedEventData.cs b/src/Square/Types/VendorUpdatedEventData.cs index c20773f7..ea465967 100644 --- a/src/Square/Types/VendorUpdatedEventData.cs +++ b/src/Square/Types/VendorUpdatedEventData.cs @@ -7,8 +7,13 @@ namespace Square; /// /// Defines the `vendor.updated` event data structure. /// -public record VendorUpdatedEventData +[Serializable] +public record VendorUpdatedEventData : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The type of the event data object. The value is `vendor`. /// @@ -27,15 +32,11 @@ public record VendorUpdatedEventData [JsonPropertyName("object")] public VendorUpdatedEventObject? Object { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VendorUpdatedEventObject.cs b/src/Square/Types/VendorUpdatedEventObject.cs index fc69c60b..6f77bdb0 100644 --- a/src/Square/Types/VendorUpdatedEventObject.cs +++ b/src/Square/Types/VendorUpdatedEventObject.cs @@ -4,8 +4,13 @@ namespace Square; -public record VendorUpdatedEventObject +[Serializable] +public record VendorUpdatedEventObject : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The operation on the vendor that caused the event to be published. The value is `UPDATED`. /// See [Operation](#type-operation) for possible values @@ -19,15 +24,11 @@ public record VendorUpdatedEventObject [JsonPropertyName("vendor")] public Vendor? Vendor { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/VisibilityFilter.cs b/src/Square/Types/VisibilityFilter.cs index 7d536461..6557b1b0 100644 --- a/src/Square/Types/VisibilityFilter.cs +++ b/src/Square/Types/VisibilityFilter.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct VisibilityFilter : IStringEnum { public static readonly VisibilityFilter All = new(Values.All); @@ -56,6 +57,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string All = "ALL"; diff --git a/src/Square/Types/VoidTransactionResponse.cs b/src/Square/Types/VoidTransactionResponse.cs index 88d86388..3901dcfd 100644 --- a/src/Square/Types/VoidTransactionResponse.cs +++ b/src/Square/Types/VoidTransactionResponse.cs @@ -8,23 +8,24 @@ namespace Square; /// Defines the fields that are included in the response body of /// a request to the [VoidTransaction](api-endpoint:Transactions-VoidTransaction) endpoint. /// -public record VoidTransactionResponse +[Serializable] +public record VoidTransactionResponse : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// Any errors that occurred during the request. /// [JsonPropertyName("errors")] public IEnumerable? Errors { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/WageSetting.cs b/src/Square/Types/WageSetting.cs index 93c1af57..5a593541 100644 --- a/src/Square/Types/WageSetting.cs +++ b/src/Square/Types/WageSetting.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents information about the overtime exemption status, job assignments, and compensation /// for a [team member](entity:TeamMember). /// -public record WageSetting +[Serializable] +public record WageSetting : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The ID of the team member associated with the wage setting. /// @@ -52,15 +57,11 @@ public record WageSetting [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/WebhookSubscription.cs b/src/Square/Types/WebhookSubscription.cs index cb3117c1..0427cb67 100644 --- a/src/Square/Types/WebhookSubscription.cs +++ b/src/Square/Types/WebhookSubscription.cs @@ -8,8 +8,13 @@ namespace Square; /// Represents the details of a webhook subscription, including notification URL, /// event types, and signature key. /// -public record WebhookSubscription +[Serializable] +public record WebhookSubscription : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// A Square-generated unique ID for the subscription. /// @@ -71,15 +76,11 @@ public record WebhookSubscription [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/Types/Weekday.cs b/src/Square/Types/Weekday.cs index 8264ba6c..24b5014a 100644 --- a/src/Square/Types/Weekday.cs +++ b/src/Square/Types/Weekday.cs @@ -4,6 +4,7 @@ namespace Square; [JsonConverter(typeof(StringEnumSerializer))] +[Serializable] public readonly record struct Weekday : IStringEnum { public static readonly Weekday Mon = new(Values.Mon); @@ -62,6 +63,7 @@ public override string ToString() /// /// Constant strings for enum values /// + [Serializable] public static class Values { public const string Mon = "MON"; diff --git a/src/Square/Types/WorkweekConfig.cs b/src/Square/Types/WorkweekConfig.cs index 8ddc0dbe..846e3fbc 100644 --- a/src/Square/Types/WorkweekConfig.cs +++ b/src/Square/Types/WorkweekConfig.cs @@ -8,8 +8,13 @@ namespace Square; /// Sets the day of the week and hour of the day that a business starts a /// workweek. This is used to calculate overtime pay. /// -public record WorkweekConfig +[Serializable] +public record WorkweekConfig : IJsonOnDeserialized { + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + /// /// The UUID for this object. /// @@ -55,15 +60,11 @@ public record WorkweekConfig [JsonPropertyName("updated_at")] public string? UpdatedAt { get; set; } - /// - /// Additional properties received from the response, if any. - /// - /// - /// [EXPERIMENTAL] This API is experimental and may change in future releases. - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; internal set; } = - new Dictionary(); + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); /// public override string ToString() diff --git a/src/Square/V1Transactions/Requests/V1ListOrdersRequest.cs b/src/Square/V1Transactions/Requests/V1ListOrdersRequest.cs index 1d368afd..eee32de3 100644 --- a/src/Square/V1Transactions/Requests/V1ListOrdersRequest.cs +++ b/src/Square/V1Transactions/Requests/V1ListOrdersRequest.cs @@ -4,6 +4,7 @@ namespace Square.V1Transactions; +[Serializable] public record V1ListOrdersRequest { /// diff --git a/src/Square/V1Transactions/Requests/V1RetrieveOrderRequest.cs b/src/Square/V1Transactions/Requests/V1RetrieveOrderRequest.cs index 716d71b3..fbc52e63 100644 --- a/src/Square/V1Transactions/Requests/V1RetrieveOrderRequest.cs +++ b/src/Square/V1Transactions/Requests/V1RetrieveOrderRequest.cs @@ -3,6 +3,7 @@ namespace Square.V1Transactions; +[Serializable] public record V1RetrieveOrderRequest { /// diff --git a/src/Square/V1Transactions/Requests/V1UpdateOrderRequest.cs b/src/Square/V1Transactions/Requests/V1UpdateOrderRequest.cs index bf833625..3682553f 100644 --- a/src/Square/V1Transactions/Requests/V1UpdateOrderRequest.cs +++ b/src/Square/V1Transactions/Requests/V1UpdateOrderRequest.cs @@ -4,6 +4,7 @@ namespace Square.V1Transactions; +[Serializable] public record V1UpdateOrderRequest { /// diff --git a/src/Square/V1Transactions/V1TransactionsClient.cs b/src/Square/V1Transactions/V1TransactionsClient.cs index baeba677..b7a3b0eb 100644 --- a/src/Square/V1Transactions/V1TransactionsClient.cs +++ b/src/Square/V1Transactions/V1TransactionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Vendors/Requests/BatchCreateVendorsRequest.cs b/src/Square/Vendors/Requests/BatchCreateVendorsRequest.cs index 9dad8e28..47c39ea7 100644 --- a/src/Square/Vendors/Requests/BatchCreateVendorsRequest.cs +++ b/src/Square/Vendors/Requests/BatchCreateVendorsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Vendors; +[Serializable] public record BatchCreateVendorsRequest { /// diff --git a/src/Square/Vendors/Requests/BatchGetVendorsRequest.cs b/src/Square/Vendors/Requests/BatchGetVendorsRequest.cs index 4be358d7..30f1eb26 100644 --- a/src/Square/Vendors/Requests/BatchGetVendorsRequest.cs +++ b/src/Square/Vendors/Requests/BatchGetVendorsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Vendors; +[Serializable] public record BatchGetVendorsRequest { /// diff --git a/src/Square/Vendors/Requests/BatchUpdateVendorsRequest.cs b/src/Square/Vendors/Requests/BatchUpdateVendorsRequest.cs index ca26d691..3a7195d6 100644 --- a/src/Square/Vendors/Requests/BatchUpdateVendorsRequest.cs +++ b/src/Square/Vendors/Requests/BatchUpdateVendorsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Vendors; +[Serializable] public record BatchUpdateVendorsRequest { /// diff --git a/src/Square/Vendors/Requests/CreateVendorRequest.cs b/src/Square/Vendors/Requests/CreateVendorRequest.cs index 5fcd56f1..8fbc6096 100644 --- a/src/Square/Vendors/Requests/CreateVendorRequest.cs +++ b/src/Square/Vendors/Requests/CreateVendorRequest.cs @@ -4,6 +4,7 @@ namespace Square.Vendors; +[Serializable] public record CreateVendorRequest { /// diff --git a/src/Square/Vendors/Requests/GetVendorsRequest.cs b/src/Square/Vendors/Requests/GetVendorsRequest.cs index bb265d33..4173cbe8 100644 --- a/src/Square/Vendors/Requests/GetVendorsRequest.cs +++ b/src/Square/Vendors/Requests/GetVendorsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Vendors; +[Serializable] public record GetVendorsRequest { /// diff --git a/src/Square/Vendors/Requests/SearchVendorsRequest.cs b/src/Square/Vendors/Requests/SearchVendorsRequest.cs index cfbb99d6..bb0a8ba3 100644 --- a/src/Square/Vendors/Requests/SearchVendorsRequest.cs +++ b/src/Square/Vendors/Requests/SearchVendorsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Vendors; +[Serializable] public record SearchVendorsRequest { /// diff --git a/src/Square/Vendors/Requests/UpdateVendorsRequest.cs b/src/Square/Vendors/Requests/UpdateVendorsRequest.cs index 0d0e8d05..1d7ba6f2 100644 --- a/src/Square/Vendors/Requests/UpdateVendorsRequest.cs +++ b/src/Square/Vendors/Requests/UpdateVendorsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Vendors; +[Serializable] public record UpdateVendorsRequest { /// diff --git a/src/Square/Vendors/VendorsClient.cs b/src/Square/Vendors/VendorsClient.cs index 85a8db0e..dc9bbbb8 100644 --- a/src/Square/Vendors/VendorsClient.cs +++ b/src/Square/Vendors/VendorsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; diff --git a/src/Square/Webhooks/EventTypes/EventTypesClient.cs b/src/Square/Webhooks/EventTypes/EventTypesClient.cs index 0ea5ec9b..5f8f6b47 100644 --- a/src/Square/Webhooks/EventTypes/EventTypesClient.cs +++ b/src/Square/Webhooks/EventTypes/EventTypesClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -20,7 +21,7 @@ internal EventTypesClient(RawClient client) /// /// /// await client.Webhooks.EventTypes.ListAsync( - /// new ListEventTypesRequest { ApiVersion = "api_version" } + /// new Square.Webhooks.EventTypes.ListEventTypesRequest { ApiVersion = "api_version" } /// ); /// public async Task ListAsync( diff --git a/src/Square/Webhooks/EventTypes/Requests/ListEventTypesRequest.cs b/src/Square/Webhooks/EventTypes/Requests/ListEventTypesRequest.cs index 305ad875..073c4c66 100644 --- a/src/Square/Webhooks/EventTypes/Requests/ListEventTypesRequest.cs +++ b/src/Square/Webhooks/EventTypes/Requests/ListEventTypesRequest.cs @@ -3,6 +3,7 @@ namespace Square.Webhooks.EventTypes; +[Serializable] public record ListEventTypesRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/CreateWebhookSubscriptionRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/CreateWebhookSubscriptionRequest.cs index 8385f450..80a26ab7 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/CreateWebhookSubscriptionRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/CreateWebhookSubscriptionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record CreateWebhookSubscriptionRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/DeleteSubscriptionsRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/DeleteSubscriptionsRequest.cs index 6970dd48..868a7056 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/DeleteSubscriptionsRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/DeleteSubscriptionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record DeleteSubscriptionsRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/GetSubscriptionsRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/GetSubscriptionsRequest.cs index 7a421623..26b9dc42 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/GetSubscriptionsRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/GetSubscriptionsRequest.cs @@ -3,6 +3,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record GetSubscriptionsRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/ListSubscriptionsRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/ListSubscriptionsRequest.cs index 4568904f..4cd498ba 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/ListSubscriptionsRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/ListSubscriptionsRequest.cs @@ -4,6 +4,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record ListSubscriptionsRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/TestWebhookSubscriptionRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/TestWebhookSubscriptionRequest.cs index 7d9b59a7..3344da29 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/TestWebhookSubscriptionRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/TestWebhookSubscriptionRequest.cs @@ -3,6 +3,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record TestWebhookSubscriptionRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionRequest.cs index 0be17171..da508395 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionRequest.cs @@ -4,6 +4,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record UpdateWebhookSubscriptionRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionSignatureKeyRequest.cs b/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionSignatureKeyRequest.cs index 161ebec8..dfb45d99 100644 --- a/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionSignatureKeyRequest.cs +++ b/src/Square/Webhooks/Subscriptions/Requests/UpdateWebhookSubscriptionSignatureKeyRequest.cs @@ -3,6 +3,7 @@ namespace Square.Webhooks.Subscriptions; +[Serializable] public record UpdateWebhookSubscriptionSignatureKeyRequest { /// diff --git a/src/Square/Webhooks/Subscriptions/SubscriptionsClient.cs b/src/Square/Webhooks/Subscriptions/SubscriptionsClient.cs index 58fcfc21..9a3d49c3 100644 --- a/src/Square/Webhooks/Subscriptions/SubscriptionsClient.cs +++ b/src/Square/Webhooks/Subscriptions/SubscriptionsClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Square; using Square.Core; @@ -190,7 +191,7 @@ public async Task CreateAsync( /// /// /// await client.Webhooks.Subscriptions.GetAsync( - /// new GetSubscriptionsRequest { SubscriptionId = "subscription_id" } + /// new Square.Webhooks.Subscriptions.GetSubscriptionsRequest { SubscriptionId = "subscription_id" } /// ); /// public async Task GetAsync( diff --git a/src/Square/Webhooks/WebhooksClient.cs b/src/Square/Webhooks/WebhooksClient.cs index 384860a6..cc9fb8b2 100644 --- a/src/Square/Webhooks/WebhooksClient.cs +++ b/src/Square/Webhooks/WebhooksClient.cs @@ -1,6 +1,5 @@ using Square.Core; using Square.Webhooks.EventTypes; -using Square.Webhooks.Subscriptions; namespace Square.Webhooks; @@ -12,10 +11,10 @@ internal WebhooksClient(RawClient client) { _client = client; EventTypes = new EventTypesClient(_client); - Subscriptions = new SubscriptionsClient(_client); + Subscriptions = new Square.Webhooks.Subscriptions.SubscriptionsClient(_client); } public EventTypesClient EventTypes { get; } - public SubscriptionsClient Subscriptions { get; } + public Square.Webhooks.Subscriptions.SubscriptionsClient Subscriptions { get; } }