diff --git a/package.json b/package.json
index e4a923579..112e02e6c 100644
--- a/package.json
+++ b/package.json
@@ -2,40 +2,53 @@
"name": "square",
"version": "43.0.1",
"private": false,
- "repository": "https://github.com/square/square-nodejs-sdk",
+ "repository": "github:square/square-nodejs-sdk",
"license": "MIT",
- "main": "./index.js",
- "types": "./index.d.ts",
+ "type": "commonjs",
+ "main": "./dist/cjs/index.js",
+ "module": "./dist/esm/index.mjs",
+ "types": "./dist/cjs/index.d.ts",
+ "exports": {
+ ".": "./index.js",
+ "./package.json": "./package.json",
+ "./legacy": {
+ "types": "./legacy/exports/index.d.ts",
+ "require": {
+ "types": "./legacy/exports/index.d.ts",
+ "default": "./legacy/exports/index.js"
+ },
+ "import": {
+ "types": "./legacy/exports/index.d.mts",
+ "default": "./legacy/exports/index.mjs"
+ }
+ }
+ },
+ "files": [
+ "dist",
+ "reference.md",
+ "README.md",
+ "LICENSE"
+ ],
"scripts": {
"format": "prettier . --write --ignore-unknown",
- "build": "tsc",
- "prepack": "cp -rv dist/. .",
+ "build": "yarn build:cjs && yarn build:esm",
+ "build:cjs": "tsc --project ./tsconfig.cjs.json",
+ "build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
"test": "yarn test:unit",
"test:unit": "jest --testPathPattern=tests/unit",
+ "test:browser": "jest --selectProjects browser",
+ "test:wire": "jest --selectProjects wire",
"test:integration": "jest --testPathPattern=tests/integration"
},
- "dependencies": {
- "url-join": "4.0.1",
- "form-data": "^4.0.0",
- "formdata-node": "^6.0.3",
- "node-fetch": "^2.7.0",
- "qs": "^6.13.1",
- "readable-stream": "^4.5.2",
- "js-base64": "3.7.7",
- "form-data-encoder": "^4.0.2",
- "square-legacy": "npm:square@^39.1.1"
- },
"devDependencies": {
- "@types/url-join": "4.0.1",
- "@types/qs": "^6.9.17",
- "@types/node-fetch": "^2.6.12",
- "@types/readable-stream": "^4.0.18",
"webpack": "^5.97.1",
"ts-loader": "^9.5.1",
"jest": "^29.7.0",
+ "@jest/globals": "^29.7.0",
"@types/jest": "^29.5.14",
- "ts-jest": "^29.1.1",
+ "ts-jest": "^29.3.4",
"jest-environment-jsdom": "^29.7.0",
+ "msw": "^2.8.4",
"@types/node": "^18.19.70",
"prettier": "^3.4.2",
"typescript": "~5.7.2"
@@ -43,8 +56,14 @@
"browser": {
"fs": false,
"os": false,
- "path": false
+ "path": false,
+ "stream": false
},
+ "packageManager": "yarn@1.22.22",
+ "engines": {
+ "node": ">=18.0.0"
+ },
+ "sideEffects": false,
"description": "Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.",
"author": {
"name": "Square Developer Platform",
@@ -55,18 +74,7 @@
"url": "https://developer.squareup.com",
"email": "developers@squareup.com"
},
- "exports": {
- ".": "./index.js",
- "./legacy": {
- "types": "./legacy/exports/index.d.ts",
- "require": {
- "types": "./legacy/exports/index.d.ts",
- "default": "./legacy/exports/index.js"
- },
- "import": {
- "types": "./legacy/exports/index.d.mts",
- "default": "./legacy/exports/index.mjs"
- }
- }
+ "dependencies": {
+ "square-legacy": "npm:square@^39.1.1"
}
}
diff --git a/reference.md b/reference.md
index d03ead60a..02b1184fa 100644
--- a/reference.md
+++ b/reference.md
@@ -45,7 +45,7 @@ Replace `ACCESS_TOKEN` with a
```typescript
await client.mobile.authorizationCode({
- locationId: "YOUR_LOCATION_ID",
+ location_id: "YOUR_LOCATION_ID",
});
```
@@ -125,8 +125,8 @@ page for your application in the Developer Dashboard.
```typescript
await client.oAuth.revokeToken({
- clientId: "CLIENT_ID",
- accessToken: "ACCESS_TOKEN",
+ client_id: "CLIENT_ID",
+ access_token: "ACCESS_TOKEN",
});
```
@@ -213,10 +213,10 @@ Application clients should never interact directly with OAuth tokens.
```typescript
await client.oAuth.obtainToken({
- clientId: "sq0idp-uaPHILoPzWZk3tlJqlML0g",
- clientSecret: "sq0csp-30a-4C_tVOnTh14Piza2BfTPBXyLafLPWSzY1qAjeBfM",
+ client_id: "sq0idp-uaPHILoPzWZk3tlJqlML0g",
+ client_secret: "sq0csp-30a-4C_tVOnTh14Piza2BfTPBXyLafLPWSzY1qAjeBfM",
code: "sq0cgb-l0SBqxs4uwxErTVyYOdemg",
- grantType: "authorization_code",
+ grant_type: "authorization_code",
});
```
@@ -391,7 +391,7 @@ Provides summary information for a merchant's online store orders.
```typescript
await client.v1Transactions.v1ListOrders({
- locationId: "location_id",
+ location_id: "location_id",
});
```
@@ -456,8 +456,8 @@ Provides comprehensive information for a single online store order, including th
```typescript
await client.v1Transactions.v1RetrieveOrder({
- locationId: "location_id",
- orderId: "order_id",
+ location_id: "location_id",
+ order_id: "order_id",
});
```
@@ -522,8 +522,8 @@ Updates the details of an online store order. Every update you perform on an ord
```typescript
await client.v1Transactions.v1UpdateOrder({
- locationId: "location_id",
- orderId: "order_id",
+ location_id: "location_id",
+ order_id: "order_id",
action: "COMPLETE",
});
```
@@ -604,7 +604,7 @@ To learn more about the Web Payments SDK and how to add Apple Pay, see [Take an
```typescript
await client.applePay.registerDomain({
- domainName: "example.com",
+ domain_name: "example.com",
});
```
@@ -676,7 +676,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.bankAccounts.list();
+let page = await client.bankAccounts.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -743,7 +743,7 @@ Returns details of a [BankAccount](entity:BankAccount) identified by V1 bank acc
```typescript
await client.bankAccounts.getByV1Id({
- v1BankAccountId: "v1_bank_account_id",
+ v1_bank_account_id: "v1_bank_account_id",
});
```
@@ -809,7 +809,7 @@ linked to a Square account.
```typescript
await client.bankAccounts.get({
- bankAccountId: "bank_account_id",
+ bank_account_id: "bank_account_id",
});
```
@@ -884,7 +884,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.bookings.list();
+let page = await client.bookings.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -1035,7 +1035,7 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ`
await client.bookings.searchAvailability({
query: {
filter: {
- startAtRange: {},
+ start_at_range: {},
},
},
});
@@ -1105,7 +1105,7 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ`
```typescript
await client.bookings.bulkRetrieveBookings({
- bookingIds: ["booking_ids"],
+ booking_ids: ["booking_ids"],
});
```
@@ -1225,7 +1225,7 @@ Retrieves a seller's location booking profile.
```typescript
await client.bookings.retrieveLocationBookingProfile({
- locationId: "location_id",
+ location_id: "location_id",
});
```
@@ -1290,7 +1290,7 @@ Retrieves one or more team members' booking profiles.
```typescript
await client.bookings.bulkRetrieveTeamMemberBookingProfiles({
- teamMemberIds: ["team_member_ids"],
+ team_member_ids: ["team_member_ids"],
});
```
@@ -1358,7 +1358,7 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ`
```typescript
await client.bookings.get({
- bookingId: "booking_id",
+ booking_id: "booking_id",
});
```
@@ -1429,7 +1429,7 @@ or _Appointments Premium_.
```typescript
await client.bookings.update({
- bookingId: "booking_id",
+ booking_id: "booking_id",
booking: {},
});
```
@@ -1501,7 +1501,7 @@ or _Appointments Premium_.
```typescript
await client.bookings.cancel({
- bookingId: "booking_id",
+ booking_id: "booking_id",
});
```
@@ -1574,7 +1574,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.cards.list();
+let page = await client.cards.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -1641,20 +1641,20 @@ Adds a card on file to an existing merchant.
```typescript
await client.cards.create({
- idempotencyKey: "4935a656-a929-4792-b97c-8848be85c27c",
- sourceId: "cnon:uIbfJXhXETSP197M3GB",
+ idempotency_key: "4935a656-a929-4792-b97c-8848be85c27c",
+ source_id: "cnon:uIbfJXhXETSP197M3GB",
card: {
- cardholderName: "Amelia Earhart",
- billingAddress: {
- addressLine1: "500 Electric Ave",
- addressLine2: "Suite 600",
+ cardholder_name: "Amelia Earhart",
+ billing_address: {
+ address_line_1: "500 Electric Ave",
+ address_line_2: "Suite 600",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
- customerId: "VDKXEEKPJN48QDG3BGGFAK05P8",
- referenceId: "user-id-1",
+ customer_id: "VDKXEEKPJN48QDG3BGGFAK05P8",
+ reference_id: "user-id-1",
},
});
```
@@ -1720,7 +1720,7 @@ Retrieves details for a specific Card.
```typescript
await client.cards.get({
- cardId: "card_id",
+ card_id: "card_id",
});
```
@@ -1786,7 +1786,7 @@ Disabling an already disabled card is allowed but has no effect.
```typescript
await client.cards.disable({
- cardId: "card_id",
+ card_id: "card_id",
});
```
@@ -1866,7 +1866,7 @@ delete requests are rejected with the `429` error code.
```typescript
await client.catalog.batchDelete({
- objectIds: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
+ object_ids: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
});
```
@@ -1936,8 +1936,8 @@ any [CatalogTax](entity:CatalogTax) objects that apply to it.
```typescript
await client.catalog.batchGet({
- objectIds: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
- includeRelatedObjects: true,
+ object_ids: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
+ include_related_objects: true,
});
```
@@ -2014,7 +2014,7 @@ update requests are rejected with the `429` error code.
```typescript
await client.catalog.batchUpsert({
- idempotencyKey: "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
+ idempotency_key: "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
batches: [
{
objects: [
@@ -2169,7 +2169,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.catalog.list();
+let page = await client.catalog.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -2244,11 +2244,11 @@ endpoint in the following aspects:
```typescript
await client.catalog.search({
- objectTypes: ["ITEM"],
+ object_types: ["ITEM"],
query: {
- prefixQuery: {
- attributeName: "name",
- attributePrefix: "tea",
+ prefix_query: {
+ attribute_name: "name",
+ attribute_prefix: "tea",
},
},
limit: 100,
@@ -2324,31 +2324,31 @@ endpoint in the following aspects:
```typescript
await client.catalog.searchItems({
- textFilter: "red",
- categoryIds: ["WINE_CATEGORY_ID"],
- stockLevels: ["OUT", "LOW"],
- enabledLocationIds: ["ATL_LOCATION_ID"],
+ text_filter: "red",
+ category_ids: ["WINE_CATEGORY_ID"],
+ stock_levels: ["OUT", "LOW"],
+ enabled_location_ids: ["ATL_LOCATION_ID"],
limit: 100,
- sortOrder: "ASC",
- productTypes: ["REGULAR"],
- customAttributeFilters: [
+ sort_order: "ASC",
+ product_types: ["REGULAR"],
+ custom_attribute_filters: [
{
- customAttributeDefinitionId: "VEGAN_DEFINITION_ID",
- boolFilter: true,
+ custom_attribute_definition_id: "VEGAN_DEFINITION_ID",
+ bool_filter: true,
},
{
- customAttributeDefinitionId: "BRAND_DEFINITION_ID",
- stringFilter: "Dark Horse",
+ custom_attribute_definition_id: "BRAND_DEFINITION_ID",
+ string_filter: "Dark Horse",
},
{
key: "VINTAGE",
- numberFilter: {
+ number_filter: {
min: "min",
max: "max",
},
},
{
- customAttributeDefinitionId: "VARIETAL_DEFINITION_ID",
+ custom_attribute_definition_id: "VARIETAL_DEFINITION_ID",
},
],
});
@@ -2417,9 +2417,9 @@ to perform an upsert on the entire item.
```typescript
await client.catalog.updateItemModifierLists({
- itemIds: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- modifierListsToEnable: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- modifierListsToDisable: ["7WRC16CJZDVLSNDQ35PP6YAD"],
+ item_ids: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ modifier_lists_to_enable: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ modifier_lists_to_disable: ["7WRC16CJZDVLSNDQ35PP6YAD"],
});
```
@@ -2486,9 +2486,9 @@ upsert on the entire item.
```typescript
await client.catalog.updateItemTaxes({
- itemIds: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- taxesToEnable: ["4WRCNHCJZDVLSNDQ35PP6YAD"],
- taxesToDisable: ["AQCEGCEBBQONINDOHRGZISEX"],
+ item_ids: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ taxes_to_enable: ["4WRCNHCJZDVLSNDQ35PP6YAD"],
+ taxes_to_disable: ["AQCEGCEBBQONINDOHRGZISEX"],
});
```
@@ -2564,7 +2564,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.customers.list();
+let page = await client.customers.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -2639,19 +2639,19 @@ endpoint:
```typescript
await client.customers.create({
- givenName: "Amelia",
- familyName: "Earhart",
- emailAddress: "Amelia.Earhart@example.com",
+ given_name: "Amelia",
+ family_name: "Earhart",
+ email_address: "Amelia.Earhart@example.com",
address: {
- addressLine1: "500 Electric Ave",
- addressLine2: "Suite 600",
+ address_line_1: "500 Electric Ave",
+ address_line_2: "Suite 600",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
- phoneNumber: "+1-212-555-4240",
- referenceId: "YOUR_REFERENCE_ID",
+ phone_number: "+1-212-555-4240",
+ reference_id: "YOUR_REFERENCE_ID",
note: "a customer",
});
```
@@ -2728,35 +2728,35 @@ You must provide at least one of the following values in each create request:
await client.customers.batchCreate({
customers: {
"8bb76c4f-e35d-4c5b-90de-1194cd9179f0": {
- givenName: "Amelia",
- familyName: "Earhart",
- emailAddress: "Amelia.Earhart@example.com",
+ given_name: "Amelia",
+ family_name: "Earhart",
+ email_address: "Amelia.Earhart@example.com",
address: {
- addressLine1: "500 Electric Ave",
- addressLine2: "Suite 600",
+ address_line_1: "500 Electric Ave",
+ address_line_2: "Suite 600",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
- phoneNumber: "+1-212-555-4240",
- referenceId: "YOUR_REFERENCE_ID",
+ phone_number: "+1-212-555-4240",
+ reference_id: "YOUR_REFERENCE_ID",
note: "a customer",
},
"d1689f23-b25d-4932-b2f0-aed00f5e2029": {
- givenName: "Marie",
- familyName: "Curie",
- emailAddress: "Marie.Curie@example.com",
+ given_name: "Marie",
+ family_name: "Curie",
+ email_address: "Marie.Curie@example.com",
address: {
- addressLine1: "500 Electric Ave",
- addressLine2: "Suite 601",
+ address_line_1: "500 Electric Ave",
+ address_line_2: "Suite 601",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
- phoneNumber: "+1-212-444-4240",
- referenceId: "YOUR_REFERENCE_ID",
+ phone_number: "+1-212-444-4240",
+ reference_id: "YOUR_REFERENCE_ID",
note: "another customer",
},
},
@@ -2826,7 +2826,7 @@ The endpoint takes a list of customer IDs and returns a map of responses.
```typescript
await client.customers.bulkDeleteCustomers({
- customerIds: ["8DDA5NZVBZFGAX0V3HPF81HHE0", "N18CPRVXR5214XPBBA6BZQWF3C", "2GYD7WNXF7BJZW1PMGNXZ3Y8M8"],
+ customer_ids: ["8DDA5NZVBZFGAX0V3HPF81HHE0", "N18CPRVXR5214XPBBA6BZQWF3C", "2GYD7WNXF7BJZW1PMGNXZ3Y8M8"],
});
```
@@ -2893,7 +2893,7 @@ This endpoint takes a list of customer IDs and returns a map of responses.
```typescript
await client.customers.bulkRetrieveCustomers({
- customerIds: ["8DDA5NZVBZFGAX0V3HPF81HHE0", "N18CPRVXR5214XPBBA6BZQWF3C", "2GYD7WNXF7BJZW1PMGNXZ3Y8M8"],
+ customer_ids: ["8DDA5NZVBZFGAX0V3HPF81HHE0", "N18CPRVXR5214XPBBA6BZQWF3C", "2GYD7WNXF7BJZW1PMGNXZ3Y8M8"],
});
```
@@ -2962,14 +2962,14 @@ This endpoint takes a map of individual update requests and returns a map of res
await client.customers.bulkUpdateCustomers({
customers: {
"8DDA5NZVBZFGAX0V3HPF81HHE0": {
- emailAddress: "New.Amelia.Earhart@example.com",
+ email_address: "New.Amelia.Earhart@example.com",
note: "updated customer note",
- version: 2,
+ version: BigInt("2"),
},
N18CPRVXR5214XPBBA6BZQWF3C: {
- givenName: "Marie",
- familyName: "Curie",
- version: 0,
+ given_name: "Marie",
+ family_name: "Curie",
+ version: BigInt("0"),
},
},
});
@@ -3044,21 +3044,21 @@ profiles can take closer to one minute or longer, especially during network inci
```typescript
await client.customers.search({
- limit: 2,
+ limit: BigInt("2"),
query: {
filter: {
- creationSource: {
+ creation_source: {
values: ["THIRD_PARTY"],
rule: "INCLUDE",
},
- createdAt: {
- startAt: "2018-01-01T00:00:00-00:00",
- endAt: "2018-02-01T00:00:00-00:00",
+ created_at: {
+ start_at: "2018-01-01T00:00:00-00:00",
+ end_at: "2018-02-01T00:00:00-00:00",
},
- emailAddress: {
+ email_address: {
fuzzy: "example.com",
},
- groupIds: {
+ group_ids: {
all: ["545AXB44B4XXWMVQ4W8SBT3HHF"],
},
},
@@ -3131,7 +3131,7 @@ Returns details for a single customer.
```typescript
await client.customers.get({
- customerId: "customer_id",
+ customer_id: "customer_id",
});
```
@@ -3199,10 +3199,10 @@ To update a customer profile that was created by merging existing profiles, you
```typescript
await client.customers.update({
- customerId: "customer_id",
- emailAddress: "New.Amelia.Earhart@example.com",
+ customer_id: "customer_id",
+ email_address: "New.Amelia.Earhart@example.com",
note: "updated customer note",
- version: 2,
+ version: BigInt("2"),
});
```
@@ -3269,7 +3269,7 @@ To delete a customer profile that was created by merging existing profiles, you
```typescript
await client.customers.delete({
- customerId: "customer_id",
+ customer_id: "customer_id",
});
```
@@ -3342,7 +3342,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.devices.list();
+let page = await client.devices.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -3409,7 +3409,7 @@ Retrieves Device with the associated `device_id`.
```typescript
await client.devices.get({
- deviceId: "device_id",
+ device_id: "device_id",
});
```
@@ -3481,7 +3481,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.disputes.list();
+let page = await client.disputes.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -3548,7 +3548,7 @@ Returns details about a specific dispute.
```typescript
await client.disputes.get({
- disputeId: "dispute_id",
+ dispute_id: "dispute_id",
});
```
@@ -3617,7 +3617,7 @@ does not have sufficient funds, Square debits the associated bank account.
```typescript
await client.disputes.accept({
- disputeId: "dispute_id",
+ dispute_id: "dispute_id",
});
```
@@ -3683,7 +3683,7 @@ multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF formats
```typescript
await client.disputes.createEvidenceFile({
- disputeId: "dispute_id",
+ dispute_id: "dispute_id",
});
```
@@ -3748,10 +3748,10 @@ Uploads text to use as evidence for a dispute challenge.
```typescript
await client.disputes.createEvidenceText({
- disputeId: "dispute_id",
- idempotencyKey: "ed3ee3933d946f1514d505d173c82648",
- evidenceType: "TRACKING_NUMBER",
- evidenceText: "1Z8888888888888888",
+ dispute_id: "dispute_id",
+ idempotency_key: "ed3ee3933d946f1514d505d173c82648",
+ evidence_type: "TRACKING_NUMBER",
+ evidence_text: "1Z8888888888888888",
});
```
@@ -3822,7 +3822,7 @@ a dispute after submission.
```typescript
await client.disputes.submitEvidence({
- disputeId: "dispute_id",
+ dispute_id: "dispute_id",
});
```
@@ -3892,7 +3892,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.employees.list();
+let page = await client.employees.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -4270,7 +4270,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.giftCards.list();
+let page = await client.giftCards.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -4341,9 +4341,9 @@ to refund a payment to the new gift card.
```typescript
await client.giftCards.create({
- idempotencyKey: "NC9Tm69EjbjtConu",
- locationId: "81FN9BNFZTKS4",
- giftCard: {
+ idempotency_key: "NC9Tm69EjbjtConu",
+ location_id: "81FN9BNFZTKS4",
+ gift_card: {
type: "DIGITAL",
},
});
@@ -4540,8 +4540,8 @@ Links a customer to a gift card, which is also referred to as adding a card on f
```typescript
await client.giftCards.linkCustomer({
- giftCardId: "gift_card_id",
- customerId: "GKY0FZ3V717AH8Q2D821PNT2ZW",
+ gift_card_id: "gift_card_id",
+ customer_id: "GKY0FZ3V717AH8Q2D821PNT2ZW",
});
```
@@ -4606,8 +4606,8 @@ Unlinks a customer from a gift card, which is also referred to as removing a car
```typescript
await client.giftCards.unlinkCustomer({
- giftCardId: "gift_card_id",
- customerId: "GKY0FZ3V717AH8Q2D821PNT2ZW",
+ gift_card_id: "gift_card_id",
+ customer_id: "GKY0FZ3V717AH8Q2D821PNT2ZW",
});
```
@@ -4740,7 +4740,7 @@ is updated to conform to the standard convention.
```typescript
await client.inventory.deprecatedGetAdjustment({
- adjustmentId: "adjustment_id",
+ adjustment_id: "adjustment_id",
});
```
@@ -4806,7 +4806,7 @@ with the provided `adjustment_id`.
```typescript
await client.inventory.getAdjustment({
- adjustmentId: "adjustment_id",
+ adjustment_id: "adjustment_id",
});
```
@@ -4872,22 +4872,22 @@ is updated to conform to the standard convention.
```typescript
await client.inventory.deprecatedBatchChange({
- idempotencyKey: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
+ idempotency_key: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
changes: [
{
type: "PHYSICAL_COUNT",
- physicalCount: {
- referenceId: "1536bfbf-efed-48bf-b17d-a197141b2a92",
- catalogObjectId: "W62UWFY35CWMYGVWK6TWJDNI",
+ physical_count: {
+ reference_id: "1536bfbf-efed-48bf-b17d-a197141b2a92",
+ catalog_object_id: "W62UWFY35CWMYGVWK6TWJDNI",
state: "IN_STOCK",
- locationId: "C6W5YS5QM06F5",
+ location_id: "C6W5YS5QM06F5",
quantity: "53",
- teamMemberId: "LRK57NSQ5X7PUD05",
- occurredAt: "2016-11-16T22:25:24.878Z",
+ team_member_id: "LRK57NSQ5X7PUD05",
+ occurred_at: "2016-11-16T22:25:24.878Z",
},
},
],
- ignoreUnchangedCounts: true,
+ ignore_unchanged_counts: true,
});
```
@@ -4953,12 +4953,12 @@ is updated to conform to the standard convention.
```typescript
await client.inventory.deprecatedBatchGetChanges({
- catalogObjectIds: ["W62UWFY35CWMYGVWK6TWJDNI"],
- locationIds: ["C6W5YS5QM06F5"],
+ catalog_object_ids: ["W62UWFY35CWMYGVWK6TWJDNI"],
+ location_ids: ["C6W5YS5QM06F5"],
types: ["PHYSICAL_COUNT"],
states: ["IN_STOCK"],
- updatedAfter: "2016-11-01T00:00:00.000Z",
- updatedBefore: "2016-12-01T00:00:00.000Z",
+ updated_after: "2016-11-01T00:00:00.000Z",
+ updated_before: "2016-12-01T00:00:00.000Z",
});
```
@@ -5024,9 +5024,9 @@ is updated to conform to the standard convention.
```typescript
await client.inventory.deprecatedBatchGetCounts({
- catalogObjectIds: ["W62UWFY35CWMYGVWK6TWJDNI"],
- locationIds: ["59TNP9SA8VGDA"],
- updatedAfter: "2016-11-16T00:00:00.000Z",
+ catalog_object_ids: ["W62UWFY35CWMYGVWK6TWJDNI"],
+ location_ids: ["59TNP9SA8VGDA"],
+ updated_after: "2016-11-16T00:00:00.000Z",
});
```
@@ -5095,22 +5095,22 @@ On failure: returns a list of related errors.
```typescript
await client.inventory.batchCreateChanges({
- idempotencyKey: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
+ idempotency_key: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
changes: [
{
type: "PHYSICAL_COUNT",
- physicalCount: {
- referenceId: "1536bfbf-efed-48bf-b17d-a197141b2a92",
- catalogObjectId: "W62UWFY35CWMYGVWK6TWJDNI",
+ physical_count: {
+ reference_id: "1536bfbf-efed-48bf-b17d-a197141b2a92",
+ catalog_object_id: "W62UWFY35CWMYGVWK6TWJDNI",
state: "IN_STOCK",
- locationId: "C6W5YS5QM06F5",
+ location_id: "C6W5YS5QM06F5",
quantity: "53",
- teamMemberId: "LRK57NSQ5X7PUD05",
- occurredAt: "2016-11-16T22:25:24.878Z",
+ team_member_id: "LRK57NSQ5X7PUD05",
+ occurred_at: "2016-11-16T22:25:24.878Z",
},
},
],
- ignoreUnchangedCounts: true,
+ ignore_unchanged_counts: true,
});
```
@@ -5182,25 +5182,25 @@ that cannot be handled by other, simpler endpoints.
```typescript
const response = await client.inventory.batchGetChanges({
- catalogObjectIds: ["W62UWFY35CWMYGVWK6TWJDNI"],
- locationIds: ["C6W5YS5QM06F5"],
+ catalog_object_ids: ["W62UWFY35CWMYGVWK6TWJDNI"],
+ location_ids: ["C6W5YS5QM06F5"],
types: ["PHYSICAL_COUNT"],
states: ["IN_STOCK"],
- updatedAfter: "2016-11-01T00:00:00.000Z",
- updatedBefore: "2016-12-01T00:00:00.000Z",
+ updated_after: "2016-11-01T00:00:00.000Z",
+ updated_before: "2016-12-01T00:00:00.000Z",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.inventory.batchGetChanges({
- catalogObjectIds: ["W62UWFY35CWMYGVWK6TWJDNI"],
- locationIds: ["C6W5YS5QM06F5"],
+let page = await client.inventory.batchGetChanges({
+ catalog_object_ids: ["W62UWFY35CWMYGVWK6TWJDNI"],
+ location_ids: ["C6W5YS5QM06F5"],
types: ["PHYSICAL_COUNT"],
states: ["IN_STOCK"],
- updatedAfter: "2016-11-01T00:00:00.000Z",
- updatedBefore: "2016-12-01T00:00:00.000Z",
+ updated_after: "2016-11-01T00:00:00.000Z",
+ updated_before: "2016-12-01T00:00:00.000Z",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -5278,19 +5278,19 @@ in response to receiving a Webhook notification.
```typescript
const response = await client.inventory.batchGetCounts({
- catalogObjectIds: ["W62UWFY35CWMYGVWK6TWJDNI"],
- locationIds: ["59TNP9SA8VGDA"],
- updatedAfter: "2016-11-16T00:00:00.000Z",
+ catalog_object_ids: ["W62UWFY35CWMYGVWK6TWJDNI"],
+ location_ids: ["59TNP9SA8VGDA"],
+ updated_after: "2016-11-16T00:00:00.000Z",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.inventory.batchGetCounts({
- catalogObjectIds: ["W62UWFY35CWMYGVWK6TWJDNI"],
- locationIds: ["59TNP9SA8VGDA"],
- updatedAfter: "2016-11-16T00:00:00.000Z",
+let page = await client.inventory.batchGetCounts({
+ catalog_object_ids: ["W62UWFY35CWMYGVWK6TWJDNI"],
+ location_ids: ["59TNP9SA8VGDA"],
+ updated_after: "2016-11-16T00:00:00.000Z",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -5359,7 +5359,7 @@ is updated to conform to the standard convention.
```typescript
await client.inventory.deprecatedGetPhysicalCount({
- physicalCountId: "physical_count_id",
+ physical_count_id: "physical_count_id",
});
```
@@ -5425,7 +5425,7 @@ object with the provided `physical_count_id`.
```typescript
await client.inventory.getPhysicalCount({
- physicalCountId: "physical_count_id",
+ physical_count_id: "physical_count_id",
});
```
@@ -5491,7 +5491,7 @@ with the provided `transfer_id`.
```typescript
await client.inventory.getTransfer({
- transferId: "transfer_id",
+ transfer_id: "transfer_id",
});
```
@@ -5559,15 +5559,15 @@ For more sophisticated queries, use a batch endpoint.
```typescript
const response = await client.inventory.get({
- catalogObjectId: "catalog_object_id",
+ catalog_object_id: "catalog_object_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.inventory.get({
- catalogObjectId: "catalog_object_id",
+let page = await client.inventory.get({
+ catalog_object_id: "catalog_object_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -5647,15 +5647,15 @@ sophisticated queries, use a batch endpoint.
```typescript
const response = await client.inventory.changes({
- catalogObjectId: "catalog_object_id",
+ catalog_object_id: "catalog_object_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.inventory.changes({
- catalogObjectId: "catalog_object_id",
+let page = await client.inventory.changes({
+ catalog_object_id: "catalog_object_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -5727,15 +5727,15 @@ use in a subsequent request to retrieve the next set of invoices.
```typescript
const response = await client.invoices.list({
- locationId: "location_id",
+ location_id: "location_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.invoices.list({
- locationId: "location_id",
+let page = await client.invoices.list({
+ location_id: "location_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -5808,38 +5808,38 @@ You must publish the invoice before Square can process it (send it to the custom
```typescript
await client.invoices.create({
invoice: {
- locationId: "ES0RJRZYEC39A",
- orderId: "CAISENgvlJ6jLWAzERDzjyHVybY",
- primaryRecipient: {
- customerId: "JDKYHBWT1D4F8MFH63DBMEN8Y4",
+ location_id: "ES0RJRZYEC39A",
+ order_id: "CAISENgvlJ6jLWAzERDzjyHVybY",
+ primary_recipient: {
+ customer_id: "JDKYHBWT1D4F8MFH63DBMEN8Y4",
},
- paymentRequests: [
+ payment_requests: [
{
- requestType: "BALANCE",
- dueDate: "2030-01-24",
- tippingEnabled: true,
- automaticPaymentSource: "NONE",
+ request_type: "BALANCE",
+ due_date: "2030-01-24",
+ tipping_enabled: true,
+ automatic_payment_source: "NONE",
reminders: [
{
- relativeScheduledDays: -1,
+ relative_scheduled_days: -1,
message: "Your invoice is due tomorrow",
},
],
},
],
- deliveryMethod: "EMAIL",
- invoiceNumber: "inv-100",
+ delivery_method: "EMAIL",
+ invoice_number: "inv-100",
title: "Event Planning Services",
description: "We appreciate your business!",
- scheduledAt: "2030-01-13T10:00:00Z",
- acceptedPaymentMethods: {
+ scheduled_at: "2030-01-13T10:00:00Z",
+ accepted_payment_methods: {
card: true,
- squareGiftCard: false,
- bankAccount: false,
- buyNowPayLater: false,
- cashAppPay: false,
+ square_gift_card: false,
+ bank_account: false,
+ buy_now_pay_later: false,
+ cash_app_pay: false,
},
- customFields: [
+ custom_fields: [
{
label: "Event Reference Number",
value: "Ref. #1234",
@@ -5851,10 +5851,10 @@ await client.invoices.create({
placement: "BELOW_LINE_ITEMS",
},
],
- saleOrServiceDate: "2030-01-24",
- storePaymentMethodEnabled: false,
+ sale_or_service_date: "2030-01-24",
+ store_payment_method_enabled: false,
},
- idempotencyKey: "ce3748f9-5fc1-4762-aa12-aae5e843f1f4",
+ idempotency_key: "ce3748f9-5fc1-4762-aa12-aae5e843f1f4",
});
```
@@ -5927,8 +5927,8 @@ that you use in a subsequent request to retrieve the next set of invoices.
await client.invoices.search({
query: {
filter: {
- locationIds: ["ES0RJRZYEC39A"],
- customerIds: ["JDKYHBWT1D4F8MFH63DBMEN8Y4"],
+ location_ids: ["ES0RJRZYEC39A"],
+ customer_ids: ["JDKYHBWT1D4F8MFH63DBMEN8Y4"],
},
sort: {
field: "INVOICE_SORT_DATE",
@@ -6000,7 +6000,7 @@ Retrieves an invoice by invoice ID.
```typescript
await client.invoices.get({
- invoiceId: "invoice_id",
+ invoice_id: "invoice_id",
});
```
@@ -6068,17 +6068,17 @@ Some restrictions apply to updating invoices. For example, you cannot change the
```typescript
await client.invoices.update({
- invoiceId: "invoice_id",
+ invoice_id: "invoice_id",
invoice: {
version: 1,
- paymentRequests: [
+ payment_requests: [
{
uid: "2da7964f-f3d2-4f43-81e8-5aa220bf3355",
- tippingEnabled: false,
+ tipping_enabled: false,
},
],
},
- idempotencyKey: "4ee82288-0910-499e-ab4c-5d0071dad1be",
+ idempotency_key: "4ee82288-0910-499e-ab4c-5d0071dad1be",
});
```
@@ -6145,7 +6145,7 @@ invoice (you cannot delete a published invoice, including one that is scheduled
```typescript
await client.invoices.delete({
- invoiceId: "invoice_id",
+ invoice_id: "invoice_id",
});
```
@@ -6217,7 +6217,7 @@ in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state.
```typescript
await client.invoices.createInvoiceAttachment({
- invoiceId: "invoice_id",
+ invoice_id: "invoice_id",
});
```
@@ -6283,8 +6283,8 @@ from invoices in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state.
```typescript
await client.invoices.deleteInvoiceAttachment({
- invoiceId: "invoice_id",
- attachmentId: "attachment_id",
+ invoice_id: "invoice_id",
+ attachment_id: "attachment_id",
});
```
@@ -6352,7 +6352,7 @@ You cannot cancel an invoice in the `DRAFT` state or in a terminal state: `PAID`
```typescript
await client.invoices.cancel({
- invoiceId: "invoice_id",
+ invoice_id: "invoice_id",
version: 0,
});
```
@@ -6431,9 +6431,9 @@ and `PAYMENTS_WRITE` are required when publishing invoices configured for card-o
```typescript
await client.invoices.publish({
- invoiceId: "invoice_id",
+ invoice_id: "invoice_id",
version: 1,
- idempotencyKey: "32da42d0-1997-41b0-826b-f09464fc2c2e",
+ idempotency_key: "32da42d0-1997-41b0-826b-f09464fc2c2e",
});
```
@@ -6507,16 +6507,16 @@ The following `draft_shift_details` fields are required:
```typescript
await client.labor.createScheduledShift({
- idempotencyKey: "HIDSNG5KS478L",
- scheduledShift: {
- draftShiftDetails: {
- teamMemberId: "ormj0jJJZ5OZIzxrZYJI",
- locationId: "PAA1RJZZKXBFG",
- jobId: "FzbJAtt9qEWncK1BWgVCxQ6M",
- startAt: "2019-01-25T03:11:00-05:00",
- endAt: "2019-01-25T13:11:00-05:00",
+ 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",
- isDeleted: false,
+ is_deleted: false,
},
},
});
@@ -6588,10 +6588,10 @@ The minimum `start_at` and maximum `end_at` timestamps of all shifts in a
```typescript
await client.labor.bulkPublishScheduledShifts({
- scheduledShifts: {
+ scheduled_shifts: {
key: {},
},
- scheduledShiftNotificationAudience: "AFFECTED",
+ scheduled_shift_notification_audience: "AFFECTED",
});
```
@@ -6659,7 +6659,7 @@ By default, results are sorted by `start_at` in ascending order.
await client.labor.searchScheduledShifts({
query: {
filter: {
- assignmentStatus: "ASSIGNED",
+ assignment_status: "ASSIGNED",
},
sort: {
field: "CREATED_AT",
@@ -6807,15 +6807,15 @@ and then publish the shift.
```typescript
await client.labor.updateScheduledShift({
id: "id",
- scheduledShift: {
- draftShiftDetails: {
- teamMemberId: "ormj0jJJZ5OZIzxrZYJI",
- locationId: "PAA1RJZZKXBFG",
- jobId: "FzbJAtt9qEWncK1BWgVCxQ6M",
- startAt: "2019-03-25T03:11:00-05:00",
- endAt: "2019-03-25T13:18:00-05:00",
+ 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",
- isDeleted: false,
+ is_deleted: false,
},
version: 1,
},
@@ -6885,9 +6885,9 @@ Publishes a scheduled shift. When a scheduled shift is published, Square keeps t
```typescript
await client.labor.publishScheduledShift({
id: "id",
- idempotencyKey: "HIDSNG5KS478L",
+ idempotency_key: "HIDSNG5KS478L",
version: 2,
- scheduledShiftNotificationAudience: "ALL",
+ scheduled_shift_notification_audience: "ALL",
});
```
@@ -6969,32 +6969,32 @@ the `Timecard.end_at`, or both.
```typescript
await client.labor.createTimecard({
- idempotencyKey: "HIDSNG5KS478L",
+ idempotency_key: "HIDSNG5KS478L",
timecard: {
- locationId: "PAA1RJZZKXBFG",
- startAt: "2019-01-25T03:11:00-05:00",
- endAt: "2019-01-25T13:11:00-05:00",
+ location_id: "PAA1RJZZKXBFG",
+ start_at: "2019-01-25T03:11:00-05:00",
+ end_at: "2019-01-25T13:11:00-05:00",
wage: {
title: "Barista",
- hourlyRate: {
- amount: 1100,
+ hourly_rate: {
+ amount: BigInt("1100"),
currency: "USD",
},
- tipEligible: true,
+ tip_eligible: true,
},
breaks: [
{
- startAt: "2019-01-25T06:11:00-05:00",
- endAt: "2019-01-25T06:16:00-05:00",
- breakTypeId: "REGS1EQR1TPZ5",
+ 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",
- expectedDuration: "PT5M",
- isPaid: true,
+ expected_duration: "PT5M",
+ is_paid: true,
},
],
- teamMemberId: "ormj0jJJZ5OZIzxrZYJI",
- declaredCashTipMoney: {
- amount: 500,
+ team_member_id: "ormj0jJJZ5OZIzxrZYJI",
+ declared_cash_tip_money: {
+ amount: BigInt("500"),
currency: "USD",
},
},
@@ -7079,12 +7079,12 @@ await client.labor.searchTimecards({
query: {
filter: {
workday: {
- dateRange: {
- startDate: "2019-01-20",
- endDate: "2019-02-03",
+ date_range: {
+ start_date: "2019-01-20",
+ end_date: "2019-02-03",
},
- matchTimecardsBy: "START_AT",
- defaultTimezone: "America/Los_Angeles",
+ match_timecards_by: "START_AT",
+ default_timezone: "America/Los_Angeles",
},
},
},
@@ -7226,33 +7226,33 @@ set on each `Break`.
await client.labor.updateTimecard({
id: "id",
timecard: {
- locationId: "PAA1RJZZKXBFG",
- startAt: "2019-01-25T03:11:00-05:00",
- endAt: "2019-01-25T13:11:00-05:00",
+ location_id: "PAA1RJZZKXBFG",
+ start_at: "2019-01-25T03:11:00-05:00",
+ end_at: "2019-01-25T13:11:00-05:00",
wage: {
title: "Bartender",
- hourlyRate: {
- amount: 1500,
+ hourly_rate: {
+ amount: BigInt("1500"),
currency: "USD",
},
- tipEligible: true,
+ tip_eligible: true,
},
breaks: [
{
id: "X7GAQYVVRRG6P",
- startAt: "2019-01-25T06:11:00-05:00",
- endAt: "2019-01-25T06:16:00-05:00",
- breakTypeId: "REGS1EQR1TPZ5",
+ 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",
- expectedDuration: "PT5M",
- isPaid: true,
+ expected_duration: "PT5M",
+ is_paid: true,
},
],
status: "CLOSED",
version: 1,
- teamMemberId: "ormj0jJJZ5OZIzxrZYJI",
- declaredCashTipMoney: {
- amount: 500,
+ team_member_id: "ormj0jJJZ5OZIzxrZYJI",
+ declared_cash_tip_money: {
+ amount: BigInt("500"),
currency: "USD",
},
},
@@ -7452,10 +7452,10 @@ await client.locations.create({
location: {
name: "Midtown",
address: {
- addressLine1: "1234 Peachtree St. NE",
+ address_line_1: "1234 Peachtree St. NE",
locality: "Atlanta",
- administrativeDistrictLevel1: "GA",
- postalCode: "30309",
+ administrative_district_level_1: "GA",
+ postal_code: "30309",
},
description: "Midtown Atlanta store",
},
@@ -7524,7 +7524,7 @@ as the location ID to retrieve details of the [main location](https://developer.
```typescript
await client.locations.get({
- locationId: "location_id",
+ location_id: "location_id",
});
```
@@ -7589,24 +7589,24 @@ Updates a [location](https://developer.squareup.com/docs/locations-api).
```typescript
await client.locations.update({
- locationId: "location_id",
+ location_id: "location_id",
location: {
- businessHours: {
+ business_hours: {
periods: [
{
- dayOfWeek: "FRI",
- startLocalTime: "07:00",
- endLocalTime: "18:00",
+ day_of_week: "FRI",
+ start_local_time: "07:00",
+ end_local_time: "18:00",
},
{
- dayOfWeek: "SAT",
- startLocalTime: "07:00",
- endLocalTime: "18:00",
+ day_of_week: "SAT",
+ start_local_time: "07:00",
+ end_local_time: "18:00",
},
{
- dayOfWeek: "SUN",
- startLocalTime: "09:00",
- endLocalTime: "15:00",
+ day_of_week: "SUN",
+ start_local_time: "09:00",
+ end_local_time: "15:00",
},
],
},
@@ -7681,45 +7681,45 @@ For more information, see [Checkout API highlights](https://developer.squareup.c
```typescript
await client.locations.checkouts({
- locationId: "location_id",
- idempotencyKey: "86ae1696-b1e3-4328-af6d-f1e04d947ad6",
+ location_id: "location_id",
+ idempotency_key: "86ae1696-b1e3-4328-af6d-f1e04d947ad6",
order: {
order: {
- locationId: "location_id",
- referenceId: "reference_id",
- customerId: "customer_id",
- lineItems: [
+ location_id: "location_id",
+ reference_id: "reference_id",
+ customer_id: "customer_id",
+ line_items: [
{
name: "Printed T Shirt",
quantity: "2",
- appliedTaxes: [
+ applied_taxes: [
{
- taxUid: "38ze1696-z1e3-5628-af6d-f1e04d947fg3",
+ tax_uid: "38ze1696-z1e3-5628-af6d-f1e04d947fg3",
},
],
- appliedDiscounts: [
+ applied_discounts: [
{
- discountUid: "56ae1696-z1e3-9328-af6d-f1e04d947gd4",
+ discount_uid: "56ae1696-z1e3-9328-af6d-f1e04d947gd4",
},
],
- basePriceMoney: {
- amount: 1500,
+ base_price_money: {
+ amount: BigInt("1500"),
currency: "USD",
},
},
{
name: "Slim Jeans",
quantity: "1",
- basePriceMoney: {
- amount: 2500,
+ base_price_money: {
+ amount: BigInt("2500"),
currency: "USD",
},
},
{
name: "Woven Sweater",
quantity: "3",
- basePriceMoney: {
- amount: 3500,
+ base_price_money: {
+ amount: BigInt("3500"),
currency: "USD",
},
},
@@ -7736,36 +7736,36 @@ await client.locations.checkouts({
{
uid: "56ae1696-z1e3-9328-af6d-f1e04d947gd4",
type: "FIXED_AMOUNT",
- amountMoney: {
- amount: 100,
+ amount_money: {
+ amount: BigInt("100"),
currency: "USD",
},
scope: "LINE_ITEM",
},
],
},
- idempotencyKey: "12ae1696-z1e3-4328-af6d-f1e04d947gd4",
+ idempotency_key: "12ae1696-z1e3-4328-af6d-f1e04d947gd4",
},
- askForShippingAddress: true,
- merchantSupportEmail: "merchant+support@website.com",
- prePopulateBuyerEmail: "example@email.com",
- prePopulateShippingAddress: {
- addressLine1: "1455 Market St.",
- addressLine2: "Suite 600",
+ 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",
- administrativeDistrictLevel1: "CA",
- postalCode: "94103",
+ administrative_district_level_1: "CA",
+ postal_code: "94103",
country: "US",
- firstName: "Jane",
- lastName: "Doe",
+ first_name: "Jane",
+ last_name: "Doe",
},
- redirectUrl: "https://merchant.website.com/order-confirm",
- additionalRecipients: [
+ redirect_url: "https://merchant.website.com/order-confirm",
+ additional_recipients: [
{
- locationId: "057P5VYJ4A5X1",
+ location_id: "057P5VYJ4A5X1",
description: "Application fees",
- amountMoney: {
- amount: 60,
+ amount_money: {
+ amount: BigInt("60"),
currency: "USD",
},
},
@@ -7845,8 +7845,8 @@ Search results are sorted by `created_at` in descending order.
await client.loyalty.searchEvents({
query: {
filter: {
- orderFilter: {
- orderId: "PyATxhYLfsMqpVkcKJITPydgEYfZY",
+ order_filter: {
+ order_id: "PyATxhYLfsMqpVkcKJITPydgEYfZY",
},
},
},
@@ -7931,7 +7931,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.merchants.list();
+let page = await client.merchants.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -7998,7 +7998,7 @@ Retrieves the `Merchant` object for the given `merchant_id`.
```typescript
await client.merchants.get({
- merchantId: "merchant_id",
+ merchant_id: "merchant_id",
});
```
@@ -8065,7 +8065,7 @@ Retrieves the location-level settings for a Square-hosted checkout page.
```typescript
await client.checkout.retrieveLocationSettings({
- locationId: "location_id",
+ location_id: "location_id",
});
```
@@ -8130,8 +8130,8 @@ Updates the location-level settings for a Square-hosted checkout page.
```typescript
await client.checkout.updateLocationSettings({
- locationId: "location_id",
- locationSettings: {},
+ location_id: "location_id",
+ location_settings: {},
});
```
@@ -8251,7 +8251,7 @@ Updates the merchant-level settings for a Square-hosted checkout page.
```typescript
await client.checkout.updateMerchantSettings({
- merchantSettings: {},
+ merchant_settings: {},
});
```
@@ -8325,28 +8325,28 @@ You can modify open orders using the [UpdateOrder](api-endpoint:Orders-UpdateOrd
```typescript
await client.orders.create({
order: {
- locationId: "057P5VYJ4A5X1",
- referenceId: "my-order-001",
- lineItems: [
+ location_id: "057P5VYJ4A5X1",
+ reference_id: "my-order-001",
+ line_items: [
{
name: "New York Strip Steak",
quantity: "1",
- basePriceMoney: {
- amount: 1599,
+ base_price_money: {
+ amount: BigInt("1599"),
currency: "USD",
},
},
{
quantity: "2",
- catalogObjectId: "BEMYCSMIJL46OCDV4KYIKXIB",
+ catalog_object_id: "BEMYCSMIJL46OCDV4KYIKXIB",
modifiers: [
{
- catalogObjectId: "CHQX7Y4KY6N5KINJKZCFURPZ",
+ catalog_object_id: "CHQX7Y4KY6N5KINJKZCFURPZ",
},
],
- appliedDiscounts: [
+ applied_discounts: [
{
- discountUid: "one-dollar-off",
+ discount_uid: "one-dollar-off",
},
],
},
@@ -8368,21 +8368,21 @@ await client.orders.create({
},
{
uid: "membership-discount",
- catalogObjectId: "DB7L55ZH2BGWI4H23ULIWOQ7",
+ catalog_object_id: "DB7L55ZH2BGWI4H23ULIWOQ7",
scope: "ORDER",
},
{
uid: "one-dollar-off",
name: "Sale - $1.00 off",
- amountMoney: {
- amount: 100,
+ amount_money: {
+ amount: BigInt("100"),
currency: "USD",
},
scope: "LINE_ITEM",
},
],
},
- idempotencyKey: "8193148c-9586-11e6-99f9-28cfe92138cf",
+ idempotency_key: "8193148c-9586-11e6-99f9-28cfe92138cf",
});
```
@@ -8449,8 +8449,8 @@ If a given order ID does not exist, the ID is ignored instead of generating an e
```typescript
await client.orders.batchGet({
- locationId: "057P5VYJ4A5X1",
- orderIds: ["CAISEM82RcpmcFBM0TfOyiHV3es", "CAISENgvlJ6jLWAzERDzjyHVybY"],
+ location_id: "057P5VYJ4A5X1",
+ order_ids: ["CAISEM82RcpmcFBM0TfOyiHV3es", "CAISENgvlJ6jLWAzERDzjyHVybY"],
});
```
@@ -8516,21 +8516,21 @@ Enables applications to preview order pricing without creating an order.
```typescript
await client.orders.calculate({
order: {
- locationId: "D7AVYMEAPJ3A3",
- lineItems: [
+ location_id: "D7AVYMEAPJ3A3",
+ line_items: [
{
name: "Item 1",
quantity: "1",
- basePriceMoney: {
- amount: 500,
+ base_price_money: {
+ amount: BigInt("500"),
currency: "USD",
},
},
{
name: "Item 2",
quantity: "2",
- basePriceMoney: {
- amount: 300,
+ base_price_money: {
+ amount: BigInt("300"),
currency: "USD",
},
},
@@ -8608,9 +8608,9 @@ only the core fields (such as line items, taxes, and discounts) copied from the
```typescript
await client.orders.clone({
- orderId: "ZAISEM52YcpmcWAzERDOyiWS123",
+ order_id: "ZAISEM52YcpmcWAzERDOyiWS123",
version: 3,
- idempotencyKey: "UNIQUE_STRING",
+ idempotency_key: "UNIQUE_STRING",
});
```
@@ -8691,26 +8691,26 @@ not the time it was subsequently transmitted to Square.
```typescript
await client.orders.search({
- locationIds: ["057P5VYJ4A5X1", "18YC4JDH91E1H"],
+ location_ids: ["057P5VYJ4A5X1", "18YC4JDH91E1H"],
query: {
filter: {
- stateFilter: {
+ state_filter: {
states: ["COMPLETED"],
},
- dateTimeFilter: {
- closedAt: {
- startAt: "2018-03-03T20:00:00+00:00",
- endAt: "2019-03-04T21:54:45+00:00",
+ date_time_filter: {
+ closed_at: {
+ start_at: "2018-03-03T20:00:00+00:00",
+ end_at: "2019-03-04T21:54:45+00:00",
},
},
},
sort: {
- sortField: "CLOSED_AT",
- sortOrder: "DESC",
+ sort_field: "CLOSED_AT",
+ sort_order: "DESC",
},
},
limit: 3,
- returnEntries: true,
+ return_entries: true,
});
```
@@ -8775,7 +8775,7 @@ Retrieves an [Order](entity:Order) by ID.
```typescript
await client.orders.get({
- orderId: "order_id",
+ order_id: "order_id",
});
```
@@ -8854,24 +8854,24 @@ To pay for an order, see
```typescript
await client.orders.update({
- orderId: "order_id",
+ order_id: "order_id",
order: {
- locationId: "location_id",
- lineItems: [
+ location_id: "location_id",
+ line_items: [
{
uid: "cookie_uid",
name: "COOKIE",
quantity: "2",
- basePriceMoney: {
- amount: 200,
+ base_price_money: {
+ amount: BigInt("200"),
currency: "USD",
},
},
],
version: 1,
},
- fieldsToClear: ["discounts"],
- idempotencyKey: "UNIQUE_STRING",
+ fields_to_clear: ["discounts"],
+ idempotency_key: "UNIQUE_STRING",
});
```
@@ -8948,9 +8948,9 @@ Using a delayed capture payment with `PayOrder` completes the approved payment.
```typescript
await client.orders.pay({
- orderId: "order_id",
- idempotencyKey: "c043a359-7ad9-4136-82a9-c3f1d66dcbff",
- paymentIds: ["EnZdNAlWCmfh6Mt5FMNST1o7taB", "0LRiVlbXVwe8ozu4KbZxd12mvaB"],
+ order_id: "order_id",
+ idempotency_key: "c043a359-7ad9-4136-82a9-c3f1d66dcbff",
+ payment_ids: ["EnZdNAlWCmfh6Mt5FMNST1o7taB", "0LRiVlbXVwe8ozu4KbZxd12mvaB"],
});
```
@@ -9027,7 +9027,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.payments.list();
+let page = await client.payments.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -9101,20 +9101,20 @@ The endpoint creates a
```typescript
await client.payments.create({
- sourceId: "ccof:GaJGNaZa8x4OgDJn4GB",
- idempotencyKey: "7b0f3ec5-086a-4871-8f13-3c81b3875218",
- amountMoney: {
- amount: 1000,
+ source_id: "ccof:GaJGNaZa8x4OgDJn4GB",
+ idempotency_key: "7b0f3ec5-086a-4871-8f13-3c81b3875218",
+ amount_money: {
+ amount: BigInt("1000"),
currency: "USD",
},
- appFeeMoney: {
- amount: 10,
+ app_fee_money: {
+ amount: BigInt("10"),
currency: "USD",
},
autocomplete: true,
- customerId: "W92WH6P11H4Z77CTET0RNTGFW8",
- locationId: "L88917AVBK2S5",
- referenceId: "123456",
+ customer_id: "W92WH6P11H4Z77CTET0RNTGFW8",
+ location_id: "L88917AVBK2S5",
+ reference_id: "123456",
note: "Brief description",
});
```
@@ -9190,7 +9190,7 @@ returns successfully.
```typescript
await client.payments.cancelByIdempotencyKey({
- idempotencyKey: "a7e36d40-d24b-11e8-b568-0800200c9a66",
+ idempotency_key: "a7e36d40-d24b-11e8-b568-0800200c9a66",
});
```
@@ -9255,7 +9255,7 @@ Retrieves details for a specific payment.
```typescript
await client.payments.get({
- paymentId: "payment_id",
+ payment_id: "payment_id",
});
```
@@ -9321,19 +9321,19 @@ You can update the `amount_money` and `tip_money` using this endpoint.
```typescript
await client.payments.update({
- paymentId: "payment_id",
+ payment_id: "payment_id",
payment: {
- amountMoney: {
- amount: 1000,
+ amount_money: {
+ amount: BigInt("1000"),
currency: "USD",
},
- tipMoney: {
- amount: 100,
+ tip_money: {
+ amount: BigInt("100"),
currency: "USD",
},
- versionToken: "ODhwVQ35xwlzRuoZEwKXucfu7583sPTzK48c5zoGd0g6o",
+ version_token: "ODhwVQ35xwlzRuoZEwKXucfu7583sPTzK48c5zoGd0g6o",
},
- idempotencyKey: "956f8b13-e4ec-45d6-85e8-d1d95ef0c5de",
+ idempotency_key: "956f8b13-e4ec-45d6-85e8-d1d95ef0c5de",
});
```
@@ -9399,7 +9399,7 @@ the APPROVED `status`.
```typescript
await client.payments.cancel({
- paymentId: "payment_id",
+ payment_id: "payment_id",
});
```
@@ -9467,7 +9467,7 @@ You can use this endpoint to complete a payment with the APPROVED `status`.
```typescript
await client.payments.complete({
- paymentId: "payment_id",
+ payment_id: "payment_id",
});
```
@@ -9541,7 +9541,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.payouts.list();
+let page = await client.payouts.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -9609,7 +9609,7 @@ To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
```typescript
await client.payouts.get({
- payoutId: "payout_id",
+ payout_id: "payout_id",
});
```
@@ -9675,15 +9675,15 @@ To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
```typescript
const response = await client.payouts.listEntries({
- payoutId: "payout_id",
+ payout_id: "payout_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.payouts.listEntries({
- payoutId: "payout_id",
+let page = await client.payouts.listEntries({
+ payout_id: "payout_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -9763,7 +9763,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.refunds.list();
+let page = await client.refunds.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -9833,16 +9833,16 @@ refund of a cash or external payment. For more information, see
```typescript
await client.refunds.refundPayment({
- idempotencyKey: "9b7f2dcf-49da-4411-b23e-a2d6af21333a",
- amountMoney: {
- amount: 1000,
+ idempotency_key: "9b7f2dcf-49da-4411-b23e-a2d6af21333a",
+ amount_money: {
+ amount: BigInt("1000"),
currency: "USD",
},
- appFeeMoney: {
- amount: 10,
+ app_fee_money: {
+ amount: BigInt("10"),
currency: "USD",
},
- paymentId: "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
+ payment_id: "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
reason: "Example",
});
```
@@ -9908,7 +9908,7 @@ Retrieves a specific refund using the `refund_id`.
```typescript
await client.refunds.get({
- refundId: "refund_id",
+ refund_id: "refund_id",
});
```
@@ -10038,7 +10038,7 @@ You can call [ListSites](api-endpoint:Sites-ListSites) to get the IDs of the sit
```typescript
await client.snippets.get({
- siteId: "site_id",
+ site_id: "site_id",
});
```
@@ -10108,7 +10108,7 @@ You can call [ListSites](api-endpoint:Sites-ListSites) to get the IDs of the sit
```typescript
await client.snippets.upsert({
- siteId: "site_id",
+ site_id: "site_id",
snippet: {
content: "",
},
@@ -10180,7 +10180,7 @@ You can call [ListSites](api-endpoint:Sites-ListSites) to get the IDs of the sit
```typescript
await client.snippets.delete({
- siteId: "site_id",
+ site_id: "site_id",
});
```
@@ -10254,20 +10254,20 @@ For more information, see [Create a subscription](https://developer.squareup.com
```typescript
await client.subscriptions.create({
- idempotencyKey: "8193148c-9586-11e6-99f9-28cfe92138cf",
- locationId: "S8GWD5R9QB376",
- planVariationId: "6JHXF3B2CW3YKHDV4XEM674H",
- customerId: "CHFGVKYY8RSV93M5KCYTG4PN0G",
- startDate: "2023-06-20",
- cardId: "ccof:qy5x8hHGYsgLrp4Q4GB",
+ 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,
- orderTemplateId: "U2NaowWxzXwpsZU697x7ZHOAnCNZY",
+ ordinal: BigInt("0"),
+ order_template_id: "U2NaowWxzXwpsZU697x7ZHOAnCNZY",
},
],
});
@@ -10335,9 +10335,9 @@ variation. For more information, see [Swap Subscription Plan Variations](https:/
```typescript
await client.subscriptions.bulkSwapPlan({
- newPlanVariationId: "FQ7CDXXWSLUJRPM3GFJSJGZ7",
- oldPlanVariationId: "6JHXF3B2CW3YKHDV4XEM674H",
- locationId: "S8GWD5R9QB376",
+ new_plan_variation_id: "FQ7CDXXWSLUJRPM3GFJSJGZ7",
+ old_plan_variation_id: "6JHXF3B2CW3YKHDV4XEM674H",
+ location_id: "S8GWD5R9QB376",
});
```
@@ -10417,9 +10417,9 @@ customer by subscription creation date.
await client.subscriptions.search({
query: {
filter: {
- customerIds: ["CHFGVKYY8RSV93M5KCYTG4PN0G"],
- locationIds: ["S8GWD5R9QB376"],
- sourceNames: ["My App"],
+ customer_ids: ["CHFGVKYY8RSV93M5KCYTG4PN0G"],
+ location_ids: ["S8GWD5R9QB376"],
+ source_names: ["My App"],
},
},
});
@@ -10486,7 +10486,7 @@ Retrieves a specific subscription.
```typescript
await client.subscriptions.get({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
```
@@ -10552,9 +10552,9 @@ To clear a field, set its value to `null`.
```typescript
await client.subscriptions.update({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
subscription: {
- cardId: "{NEW CARD ID}",
+ card_id: "{NEW CARD ID}",
},
});
```
@@ -10620,8 +10620,8 @@ Deletes a scheduled action for a subscription.
```typescript
await client.subscriptions.deleteAction({
- subscriptionId: "subscription_id",
- actionId: "action_id",
+ subscription_id: "subscription_id",
+ action_id: "action_id",
});
```
@@ -10687,8 +10687,8 @@ for a subscription.
```typescript
await client.subscriptions.changeBillingAnchorDate({
- subscriptionId: "subscription_id",
- monthlyBillingAnchorDate: 1,
+ subscription_id: "subscription_id",
+ monthly_billing_anchor_date: 1,
});
```
@@ -10755,7 +10755,7 @@ the subscription status changes from ACTIVE to CANCELED.
```typescript
await client.subscriptions.cancel({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
```
@@ -10820,15 +10820,15 @@ Lists all [events](https://developer.squareup.com/docs/subscriptions-api/actions
```typescript
const response = await client.subscriptions.listEvents({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.subscriptions.listEvents({
- subscriptionId: "subscription_id",
+let page = await client.subscriptions.listEvents({
+ subscription_id: "subscription_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -10896,7 +10896,7 @@ Schedules a `PAUSE` action to pause an active subscription.
```typescript
await client.subscriptions.pause({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
```
@@ -10961,7 +10961,7 @@ Schedules a `RESUME` action to resume a paused or a deactivated subscription.
```typescript
await client.subscriptions.resume({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
```
@@ -11027,12 +11027,12 @@ For more information, see [Swap Subscription Plan Variations](https://developer.
```typescript
await client.subscriptions.swapPlan({
- subscriptionId: "subscription_id",
- newPlanVariationId: "FQ7CDXXWSLUJRPM3GFJSJGZ7",
+ subscription_id: "subscription_id",
+ new_plan_variation_id: "FQ7CDXXWSLUJRPM3GFJSJGZ7",
phases: [
{
- ordinal: 0,
- orderTemplateId: "uhhnjH9osVv3shUADwaC0b3hNxQZY",
+ ordinal: BigInt("0"),
+ order_template_id: "uhhnjH9osVv3shUADwaC0b3hNxQZY",
},
],
});
@@ -11107,39 +11107,39 @@ Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/t
```typescript
await client.teamMembers.create({
- idempotencyKey: "idempotency-key-0",
- teamMember: {
- referenceId: "reference_id_1",
+ idempotency_key: "idempotency-key-0",
+ team_member: {
+ reference_id: "reference_id_1",
status: "ACTIVE",
- givenName: "Joe",
- familyName: "Doe",
- emailAddress: "joe_doe@gmail.com",
- phoneNumber: "+14159283333",
- assignedLocations: {
- assignmentType: "EXPLICIT_LOCATIONS",
- locationIds: ["YSGH2WBKG94QZ", "GA2Y9HSJ8KRYT"],
+ 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"],
},
- wageSetting: {
- jobAssignments: [
+ wage_setting: {
+ job_assignments: [
{
- payType: "SALARY",
- annualRate: {
- amount: 3000000,
+ pay_type: "SALARY",
+ annual_rate: {
+ amount: BigInt("3000000"),
currency: "USD",
},
- weeklyHours: 40,
- jobId: "FjS8x95cqHiMenw4f1NAUH4P",
+ weekly_hours: 40,
+ job_id: "FjS8x95cqHiMenw4f1NAUH4P",
},
{
- payType: "HOURLY",
- hourlyRate: {
- amount: 2000,
+ pay_type: "HOURLY",
+ hourly_rate: {
+ amount: BigInt("2000"),
currency: "USD",
},
- jobId: "VDNpRv8da51NU8qZFC5zDWpF",
+ job_id: "VDNpRv8da51NU8qZFC5zDWpF",
},
],
- isOvertimeExempt: true,
+ is_overtime_exempt: true,
},
},
});
@@ -11211,29 +11211,29 @@ Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/t
```typescript
await client.teamMembers.batchCreate({
- teamMembers: {
+ team_members: {
"idempotency-key-1": {
- teamMember: {
- referenceId: "reference_id_1",
- givenName: "Joe",
- familyName: "Doe",
- emailAddress: "joe_doe@gmail.com",
- phoneNumber: "+14159283333",
- assignedLocations: {
- assignmentType: "EXPLICIT_LOCATIONS",
- locationIds: ["YSGH2WBKG94QZ", "GA2Y9HSJ8KRYT"],
+ 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": {
- teamMember: {
- referenceId: "reference_id_2",
- givenName: "Jane",
- familyName: "Smith",
- emailAddress: "jane_smith@gmail.com",
- phoneNumber: "+14159223334",
- assignedLocations: {
- assignmentType: "ALL_CURRENT_AND_FUTURE_LOCATIONS",
+ 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",
},
},
},
@@ -11306,33 +11306,33 @@ Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/t
```typescript
await client.teamMembers.batchUpdate({
- teamMembers: {
+ team_members: {
"AFMwA08kR-MIF-3Vs0OE": {
- teamMember: {
- referenceId: "reference_id_2",
- isOwner: false,
+ team_member: {
+ reference_id: "reference_id_2",
+ is_owner: false,
status: "ACTIVE",
- givenName: "Jane",
- familyName: "Smith",
- emailAddress: "jane_smith@gmail.com",
- phoneNumber: "+14159223334",
- assignedLocations: {
- assignmentType: "ALL_CURRENT_AND_FUTURE_LOCATIONS",
+ 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": {
- teamMember: {
- referenceId: "reference_id_1",
- isOwner: false,
+ team_member: {
+ reference_id: "reference_id_1",
+ is_owner: false,
status: "ACTIVE",
- givenName: "Joe",
- familyName: "Doe",
- emailAddress: "joe_doe@gmail.com",
- phoneNumber: "+14159283333",
- assignedLocations: {
- assignmentType: "EXPLICIT_LOCATIONS",
- locationIds: ["YSGH2WBKG94QZ", "GA2Y9HSJ8KRYT"],
+ 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"],
},
},
},
@@ -11405,7 +11405,7 @@ the team member is the Square account owner.
await client.teamMembers.search({
query: {
filter: {
- locationIds: ["0G5P3VGACMMQZ"],
+ location_ids: ["0G5P3VGACMMQZ"],
status: "ACTIVE",
},
},
@@ -11475,7 +11475,7 @@ Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/t
```typescript
await client.teamMembers.get({
- teamMemberId: "team_member_id",
+ team_member_id: "team_member_id",
});
```
@@ -11541,40 +11541,40 @@ Learn about [Troubleshooting the Team API](https://developer.squareup.com/docs/t
```typescript
await client.teamMembers.update({
- teamMemberId: "team_member_id",
+ team_member_id: "team_member_id",
body: {
- teamMember: {
- referenceId: "reference_id_1",
+ team_member: {
+ reference_id: "reference_id_1",
status: "ACTIVE",
- givenName: "Joe",
- familyName: "Doe",
- emailAddress: "joe_doe@gmail.com",
- phoneNumber: "+14159283333",
- assignedLocations: {
- assignmentType: "EXPLICIT_LOCATIONS",
- locationIds: ["YSGH2WBKG94QZ", "GA2Y9HSJ8KRYT"],
+ 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"],
},
- wageSetting: {
- jobAssignments: [
+ wage_setting: {
+ job_assignments: [
{
- payType: "SALARY",
- annualRate: {
- amount: 3000000,
+ pay_type: "SALARY",
+ annual_rate: {
+ amount: BigInt("3000000"),
currency: "USD",
},
- weeklyHours: 40,
- jobId: "FjS8x95cqHiMenw4f1NAUH4P",
+ weekly_hours: 40,
+ job_id: "FjS8x95cqHiMenw4f1NAUH4P",
},
{
- payType: "HOURLY",
- hourlyRate: {
- amount: 1200,
+ pay_type: "HOURLY",
+ hourly_rate: {
+ amount: BigInt("1200"),
currency: "USD",
},
- jobId: "VDNpRv8da51NU8qZFC5zDWpF",
+ job_id: "VDNpRv8da51NU8qZFC5zDWpF",
},
],
- isOvertimeExempt: true,
+ is_overtime_exempt: true,
},
},
},
@@ -11710,9 +11710,9 @@ compensation is defined in a [job assignment](entity:JobAssignment) in a team me
await client.team.createJob({
job: {
title: "Cashier",
- isTipEligible: true,
+ is_tip_eligible: true,
},
- idempotencyKey: "idempotency-key-0",
+ idempotency_key: "idempotency-key-0",
});
```
@@ -11777,7 +11777,7 @@ Retrieves a specified job.
```typescript
await client.team.retrieveJob({
- jobId: "job_id",
+ job_id: "job_id",
});
```
@@ -11844,10 +11844,10 @@ tip eligibility propagate to all `TeamMemberWage` objects that reference the job
```typescript
await client.team.updateJob({
- jobId: "job_id",
+ job_id: "job_id",
job: {
title: "Cashier 1",
- isTipEligible: true,
+ is_tip_eligible: true,
},
});
```
@@ -11917,7 +11917,7 @@ See [Link and Dismiss Actions](https://developer.squareup.com/docs/terminal-api/
```typescript
await client.terminal.dismissTerminalAction({
- actionId: "action_id",
+ action_id: "action_id",
});
```
@@ -11982,7 +11982,7 @@ Dismisses a Terminal checkout request if the status and type of the request perm
```typescript
await client.terminal.dismissTerminalCheckout({
- checkoutId: "checkout_id",
+ checkout_id: "checkout_id",
});
```
@@ -12047,7 +12047,7 @@ Dismisses a Terminal refund request if the status and type of the request permit
```typescript
await client.terminal.dismissTerminalRefund({
- terminalRefundId: "terminal_refund_id",
+ terminal_refund_id: "terminal_refund_id",
});
```
@@ -12118,22 +12118,22 @@ await client.vendors.batchCreate({
"8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe": {
name: "Joe's Fresh Seafood",
address: {
- addressLine1: "505 Electric Ave",
- addressLine2: "Suite 600",
+ address_line_1: "505 Electric Ave",
+ address_line_2: "Suite 600",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
contacts: [
{
name: "Joe Burrow",
- emailAddress: "joe@joesfreshseafood.com",
- phoneNumber: "1-212-555-4250",
+ email_address: "joe@joesfreshseafood.com",
+ phone_number: "1-212-555-4250",
ordinal: 1,
},
],
- accountNumber: "4025391",
+ account_number: "4025391",
note: "a vendor",
},
},
@@ -12201,7 +12201,7 @@ Retrieves one or more vendors of specified [Vendor](entity:Vendor) IDs.
```typescript
await client.vendors.batchGet({
- vendorIds: ["INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4"],
+ vendor_ids: ["INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4"],
});
```
@@ -12338,26 +12338,26 @@ Creates a single [Vendor](entity:Vendor) object to represent a supplier to a sel
```typescript
await client.vendors.create({
- idempotencyKey: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
+ idempotency_key: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
vendor: {
name: "Joe's Fresh Seafood",
address: {
- addressLine1: "505 Electric Ave",
- addressLine2: "Suite 600",
+ address_line_1: "505 Electric Ave",
+ address_line_2: "Suite 600",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
contacts: [
{
name: "Joe Burrow",
- emailAddress: "joe@joesfreshseafood.com",
- phoneNumber: "1-212-555-4250",
+ email_address: "joe@joesfreshseafood.com",
+ phone_number: "1-212-555-4250",
ordinal: 1,
},
],
- accountNumber: "4025391",
+ account_number: "4025391",
note: "a vendor",
},
});
@@ -12487,7 +12487,7 @@ Retrieves the vendor of a specified [Vendor](entity:Vendor) ID.
```typescript
await client.vendors.get({
- vendorId: "vendor_id",
+ vendor_id: "vendor_id",
});
```
@@ -12552,9 +12552,9 @@ Updates an existing [Vendor](entity:Vendor) object as a supplier to a seller.
```typescript
await client.vendors.update({
- vendorId: "vendor_id",
+ vendor_id: "vendor_id",
body: {
- idempotencyKey: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
+ idempotency_key: "8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe",
vendor: {
id: "INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4",
name: "Jack's Chicken Shack",
@@ -12636,7 +12636,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.bookings.customAttributeDefinitions.list();
+let page = await client.bookings.customAttributeDefinitions.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -12709,7 +12709,7 @@ or _Appointments Premium_.
```typescript
await client.bookings.customAttributeDefinitions.create({
- customAttributeDefinition: {},
+ custom_attribute_definition: {},
});
```
@@ -12849,7 +12849,7 @@ or _Appointments Premium_.
```typescript
await client.bookings.customAttributeDefinitions.update({
key: "key",
- customAttributeDefinition: {},
+ custom_attribute_definition: {},
});
```
@@ -12995,7 +12995,7 @@ or _Appointments Premium_.
await client.bookings.customAttributes.batchDelete({
values: {
key: {
- bookingId: "booking_id",
+ booking_id: "booking_id",
key: "key",
},
},
@@ -13071,8 +13071,8 @@ or _Appointments Premium_.
await client.bookings.customAttributes.batchUpsert({
values: {
key: {
- bookingId: "booking_id",
- customAttribute: {},
+ booking_id: "booking_id",
+ custom_attribute: {},
},
},
});
@@ -13142,15 +13142,15 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ`
```typescript
const response = await client.bookings.customAttributes.list({
- bookingId: "booking_id",
+ booking_id: "booking_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.bookings.customAttributes.list({
- bookingId: "booking_id",
+let page = await client.bookings.customAttributes.list({
+ booking_id: "booking_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -13221,7 +13221,7 @@ To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ`
```typescript
await client.bookings.customAttributes.get({
- bookingId: "booking_id",
+ booking_id: "booking_id",
key: "key",
});
```
@@ -13293,9 +13293,9 @@ or _Appointments Premium_.
```typescript
await client.bookings.customAttributes.upsert({
- bookingId: "booking_id",
+ booking_id: "booking_id",
key: "key",
- customAttribute: {},
+ custom_attribute: {},
});
```
@@ -13366,7 +13366,7 @@ or _Appointments Premium_.
```typescript
await client.bookings.customAttributes.delete({
- bookingId: "booking_id",
+ booking_id: "booking_id",
key: "key",
});
```
@@ -13439,7 +13439,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.bookings.locationProfiles.list();
+let page = await client.bookings.locationProfiles.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -13513,7 +13513,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.bookings.teamMemberProfiles.list();
+let page = await client.bookings.teamMemberProfiles.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -13580,7 +13580,7 @@ Retrieves a team member's booking profile.
```typescript
await client.bookings.teamMemberProfiles.get({
- teamMemberId: "team_member_id",
+ team_member_id: "team_member_id",
});
```
@@ -13648,15 +13648,15 @@ in a date range.
```typescript
const response = await client.cashDrawers.shifts.list({
- locationId: "location_id",
+ location_id: "location_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.cashDrawers.shifts.list({
- locationId: "location_id",
+let page = await client.cashDrawers.shifts.list({
+ location_id: "location_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -13725,8 +13725,8 @@ Provides the summary details for a single cash drawer shift. See
```typescript
await client.cashDrawers.shifts.get({
- shiftId: "shift_id",
- locationId: "location_id",
+ shift_id: "shift_id",
+ location_id: "location_id",
});
```
@@ -13791,17 +13791,17 @@ Provides a paginated list of events for a single cash drawer shift.
```typescript
const response = await client.cashDrawers.shifts.listEvents({
- shiftId: "shift_id",
- locationId: "location_id",
+ shift_id: "shift_id",
+ location_id: "location_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.cashDrawers.shifts.listEvents({
- shiftId: "shift_id",
- locationId: "location_id",
+let page = await client.cashDrawers.shifts.listEvents({
+ shift_id: "shift_id",
+ location_id: "location_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -13942,7 +13942,7 @@ JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
```typescript
await client.catalog.images.update({
- imageId: "image_id",
+ image_id: "image_id",
});
```
@@ -14013,7 +14013,7 @@ update requests are rejected with the `429` error code.
```typescript
await client.catalog.object.upsert({
- idempotencyKey: "af3d1afc-7212-4300-b463-0bfc5314a5ae",
+ idempotency_key: "af3d1afc-7212-4300-b463-0bfc5314a5ae",
object: {
type: "ITEM",
id: "id",
@@ -14088,7 +14088,7 @@ any [CatalogTax](entity:CatalogTax) objects that apply to it.
```typescript
await client.catalog.object.get({
- objectId: "object_id",
+ object_id: "object_id",
});
```
@@ -14162,7 +14162,7 @@ delete requests are rejected with the `429` error code.
```typescript
await client.catalog.object.delete({
- objectId: "object_id",
+ object_id: "object_id",
});
```
@@ -14234,7 +14234,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.checkout.paymentLinks.list();
+let page = await client.checkout.paymentLinks.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -14301,14 +14301,14 @@ Creates a Square-hosted checkout page. Applications can share the resulting paym
```typescript
await client.checkout.paymentLinks.create({
- idempotencyKey: "cd9e25dc-d9f2-4430-aedb-61605070e95f",
- quickPay: {
+ idempotency_key: "cd9e25dc-d9f2-4430-aedb-61605070e95f",
+ quick_pay: {
name: "Auto Detailing",
- priceMoney: {
- amount: 10000,
+ price_money: {
+ amount: BigInt("10000"),
currency: "USD",
},
- locationId: "A9Y43N9ABXZBP",
+ location_id: "A9Y43N9ABXZBP",
},
});
```
@@ -14442,10 +14442,10 @@ You cannot update other fields such as the `order_id`, `version`, `URL`, or `tim
```typescript
await client.checkout.paymentLinks.update({
id: "id",
- paymentLink: {
+ payment_link: {
version: 1,
- checkoutOptions: {
- askForShippingAddress: true,
+ checkout_options: {
+ ask_for_shipping_address: true,
},
},
});
@@ -14589,7 +14589,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.customers.customAttributeDefinitions.list();
+let page = await client.customers.customAttributeDefinitions.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -14666,7 +14666,7 @@ Sellers can view all custom attributes in exported customer data, including thos
```typescript
await client.customers.customAttributeDefinitions.create({
- customAttributeDefinition: {
+ custom_attribute_definition: {
key: "favoritemovie",
schema: {
ref: "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String",
@@ -14815,7 +14815,7 @@ all custom attributes in exported customer data, including those set to `VISIBIL
```typescript
await client.customers.customAttributeDefinitions.update({
key: "key",
- customAttributeDefinition: {
+ custom_attribute_definition: {
description: "Update the description as desired.",
visibility: "VISIBILITY_READ_ONLY",
},
@@ -14968,36 +14968,36 @@ must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attribut
await client.customers.customAttributeDefinitions.batchUpsert({
values: {
id1: {
- customerId: "N3NCVYY3WS27HF0HKANA3R9FP8",
- customAttribute: {
+ customer_id: "N3NCVYY3WS27HF0HKANA3R9FP8",
+ custom_attribute: {
key: "favoritemovie",
value: "Dune",
},
},
id2: {
- customerId: "SY8EMWRNDN3TQDP2H4KS1QWMMM",
- customAttribute: {
+ customer_id: "SY8EMWRNDN3TQDP2H4KS1QWMMM",
+ custom_attribute: {
key: "ownsmovie",
value: false,
},
},
id3: {
- customerId: "SY8EMWRNDN3TQDP2H4KS1QWMMM",
- customAttribute: {
+ customer_id: "SY8EMWRNDN3TQDP2H4KS1QWMMM",
+ custom_attribute: {
key: "favoritemovie",
value: "Star Wars",
},
},
id4: {
- customerId: "N3NCVYY3WS27HF0HKANA3R9FP8",
- customAttribute: {
+ customer_id: "N3NCVYY3WS27HF0HKANA3R9FP8",
+ custom_attribute: {
key: "square:a0f1505a-2aa1-490d-91a8-8d31ff181808",
value: "10.5",
},
},
id5: {
- customerId: "70548QG1HN43B05G0KCZ4MMC1G",
- customAttribute: {
+ customer_id: "70548QG1HN43B05G0KCZ4MMC1G",
+ custom_attribute: {
key: "sq0ids-0evKIskIGaY45fCyNL66aw:backupemail",
value: "fake-email@squareup.com",
},
@@ -15074,7 +15074,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.customers.groups.list();
+let page = await client.customers.groups.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -15210,7 +15210,7 @@ Retrieves a specific customer group as identified by the `group_id` value.
```typescript
await client.customers.groups.get({
- groupId: "group_id",
+ group_id: "group_id",
});
```
@@ -15275,7 +15275,7 @@ Updates a customer group as identified by the `group_id` value.
```typescript
await client.customers.groups.update({
- groupId: "group_id",
+ group_id: "group_id",
group: {
name: "Loyal Customers",
},
@@ -15343,7 +15343,7 @@ Deletes a customer group as identified by the `group_id` value.
```typescript
await client.customers.groups.delete({
- groupId: "group_id",
+ group_id: "group_id",
});
```
@@ -15411,8 +15411,8 @@ and the customer group is identified by the `group_id` value.
```typescript
await client.customers.groups.add({
- customerId: "customer_id",
- groupId: "group_id",
+ customer_id: "customer_id",
+ group_id: "group_id",
});
```
@@ -15480,8 +15480,8 @@ and the customer group is identified by the `group_id` value.
```typescript
await client.customers.groups.remove({
- customerId: "customer_id",
- groupId: "group_id",
+ customer_id: "customer_id",
+ group_id: "group_id",
});
```
@@ -15553,7 +15553,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.customers.segments.list();
+let page = await client.customers.segments.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -15620,7 +15620,7 @@ Retrieves a specific customer segment as identified by the `segment_id` value.
```typescript
await client.customers.segments.get({
- segmentId: "segment_id",
+ segment_id: "segment_id",
});
```
@@ -15691,17 +15691,17 @@ with the provided nonce during the _first_ call.
```typescript
await client.customers.cards.create({
- customerId: "customer_id",
- cardNonce: "YOUR_CARD_NONCE",
- billingAddress: {
- addressLine1: "500 Electric Ave",
- addressLine2: "Suite 600",
+ customer_id: "customer_id",
+ card_nonce: "YOUR_CARD_NONCE",
+ billing_address: {
+ address_line_1: "500 Electric Ave",
+ address_line_2: "Suite 600",
locality: "New York",
- administrativeDistrictLevel1: "NY",
- postalCode: "10003",
+ administrative_district_level_1: "NY",
+ postal_code: "10003",
country: "US",
},
- cardholderName: "Amelia Earhart",
+ cardholder_name: "Amelia Earhart",
});
```
@@ -15766,8 +15766,8 @@ Removes a card on file from a customer.
```typescript
await client.customers.cards.delete({
- customerId: "customer_id",
- cardId: "card_id",
+ customer_id: "customer_id",
+ card_id: "card_id",
});
```
@@ -15841,15 +15841,15 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
```typescript
const response = await client.customers.customAttributes.list({
- customerId: "customer_id",
+ customer_id: "customer_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.customers.customAttributes.list({
- customerId: "customer_id",
+let page = await client.customers.customAttributes.list({
+ customer_id: "customer_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -15924,7 +15924,7 @@ To retrieve a custom attribute owned by another application, the `visibility` se
```typescript
await client.customers.customAttributes.get({
- customerId: "customer_id",
+ customer_id: "customer_id",
key: "key",
});
```
@@ -15998,9 +15998,9 @@ must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attribut
```typescript
await client.customers.customAttributes.upsert({
- customerId: "customer_id",
+ customer_id: "customer_id",
key: "key",
- customAttribute: {
+ custom_attribute: {
value: "Dune",
},
});
@@ -16071,7 +16071,7 @@ To delete a custom attribute owned by another application, the `visibility` sett
```typescript
await client.customers.customAttributes.delete({
- customerId: "customer_id",
+ customer_id: "customer_id",
key: "key",
});
```
@@ -16144,7 +16144,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.devices.codes.list();
+let page = await client.devices.codes.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -16212,11 +16212,11 @@ terminal mode.
```typescript
await client.devices.codes.create({
- idempotencyKey: "01bb00a6-0c86-4770-94ed-f5fca973cd56",
- deviceCode: {
+ idempotency_key: "01bb00a6-0c86-4770-94ed-f5fca973cd56",
+ device_code: {
name: "Counter 1",
- productType: "TERMINAL_API",
- locationId: "B5E4484SHHNYH",
+ product_type: "TERMINAL_API",
+ location_id: "B5E4484SHHNYH",
},
});
```
@@ -16349,15 +16349,15 @@ Returns a list of evidence associated with a dispute.
```typescript
const response = await client.disputes.evidence.list({
- disputeId: "dispute_id",
+ dispute_id: "dispute_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.disputes.evidence.list({
- disputeId: "dispute_id",
+let page = await client.disputes.evidence.list({
+ dispute_id: "dispute_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -16427,8 +16427,8 @@ You must maintain a copy of any evidence uploaded if you want to reference it la
```typescript
await client.disputes.evidence.get({
- disputeId: "dispute_id",
- evidenceId: "evidence_id",
+ dispute_id: "dispute_id",
+ evidence_id: "evidence_id",
});
```
@@ -16494,8 +16494,8 @@ Square does not send the bank any evidence that is removed.
```typescript
await client.disputes.evidence.delete({
- disputeId: "dispute_id",
- evidenceId: "evidence_id",
+ dispute_id: "dispute_id",
+ evidence_id: "evidence_id",
});
```
@@ -16570,7 +16570,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.giftCards.activities.list();
+let page = await client.giftCards.activities.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -16638,14 +16638,14 @@ For example, create an `ACTIVATE` activity to activate a gift card with an initi
```typescript
await client.giftCards.activities.create({
- idempotencyKey: "U16kfr-kA70er-q4Rsym-7U7NnY",
- giftCardActivity: {
+ idempotency_key: "U16kfr-kA70er-q4Rsym-7U7NnY",
+ gift_card_activity: {
type: "ACTIVATE",
- locationId: "81FN9BNFZTKS4",
- giftCardId: "gftc:6d55a72470d940c6ba09c0ab8ad08d20",
- activateActivityDetails: {
- orderId: "jJNGHm4gLI6XkFbwtiSLqK72KkAZY",
- lineItemUid: "eIWl7X0nMuO9Ewbh0ChIx",
+ location_id: "81FN9BNFZTKS4",
+ gift_card_id: "gftc:6d55a72470d940c6ba09c0ab8ad08d20",
+ activate_activity_details: {
+ order_id: "jJNGHm4gLI6XkFbwtiSLqK72KkAZY",
+ line_item_uid: "eIWl7X0nMuO9Ewbh0ChIx",
},
},
});
@@ -16719,7 +16719,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.labor.breakTypes.list();
+let page = await client.labor.breakTypes.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -16799,12 +16799,12 @@ is returned.
```typescript
await client.labor.breakTypes.create({
- idempotencyKey: "PAD3NG5KSN2GL",
- breakType: {
- locationId: "CGJN03P1D08GF",
- breakName: "Lunch Break",
- expectedDuration: "PT30M",
- isPaid: true,
+ idempotency_key: "PAD3NG5KSN2GL",
+ break_type: {
+ location_id: "CGJN03P1D08GF",
+ break_name: "Lunch Break",
+ expected_duration: "PT30M",
+ is_paid: true,
},
});
```
@@ -16936,11 +16936,11 @@ Updates an existing `BreakType`.
```typescript
await client.labor.breakTypes.update({
id: "id",
- breakType: {
- locationId: "26M7H24AZ9N6R",
- breakName: "Lunch",
- expectedDuration: "PT50M",
- isPaid: true,
+ break_type: {
+ location_id: "26M7H24AZ9N6R",
+ break_name: "Lunch",
+ expected_duration: "PT50M",
+ is_paid: true,
version: 1,
},
});
@@ -17081,7 +17081,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.labor.employeeWages.list();
+let page = await client.labor.employeeWages.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -17232,32 +17232,32 @@ the `Shift.end_at`, or both.
```typescript
await client.labor.shifts.create({
- idempotencyKey: "HIDSNG5KS478L",
+ idempotency_key: "HIDSNG5KS478L",
shift: {
- locationId: "PAA1RJZZKXBFG",
- startAt: "2019-01-25T03:11:00-05:00",
- endAt: "2019-01-25T13:11:00-05:00",
+ location_id: "PAA1RJZZKXBFG",
+ start_at: "2019-01-25T03:11:00-05:00",
+ end_at: "2019-01-25T13:11:00-05:00",
wage: {
title: "Barista",
- hourlyRate: {
- amount: 1100,
+ hourly_rate: {
+ amount: BigInt("1100"),
currency: "USD",
},
- tipEligible: true,
+ tip_eligible: true,
},
breaks: [
{
- startAt: "2019-01-25T06:11:00-05:00",
- endAt: "2019-01-25T06:16:00-05:00",
- breakTypeId: "REGS1EQR1TPZ5",
+ 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",
- expectedDuration: "PT5M",
- isPaid: true,
+ expected_duration: "PT5M",
+ is_paid: true,
},
],
- teamMemberId: "ormj0jJJZ5OZIzxrZYJI",
- declaredCashTipMoney: {
- amount: 500,
+ team_member_id: "ormj0jJJZ5OZIzxrZYJI",
+ declared_cash_tip_money: {
+ amount: BigInt("500"),
currency: "USD",
},
},
@@ -17342,12 +17342,12 @@ await client.labor.shifts.search({
query: {
filter: {
workday: {
- dateRange: {
- startDate: "2019-01-20",
- endDate: "2019-02-03",
+ date_range: {
+ start_date: "2019-01-20",
+ end_date: "2019-02-03",
},
- matchShiftsBy: "START_AT",
- defaultTimezone: "America/Los_Angeles",
+ match_shifts_by: "START_AT",
+ default_timezone: "America/Los_Angeles",
},
},
},
@@ -17489,32 +17489,32 @@ set on each `Break`.
await client.labor.shifts.update({
id: "id",
shift: {
- locationId: "PAA1RJZZKXBFG",
- startAt: "2019-01-25T03:11:00-05:00",
- endAt: "2019-01-25T13:11:00-05:00",
+ location_id: "PAA1RJZZKXBFG",
+ start_at: "2019-01-25T03:11:00-05:00",
+ end_at: "2019-01-25T13:11:00-05:00",
wage: {
title: "Bartender",
- hourlyRate: {
- amount: 1500,
+ hourly_rate: {
+ amount: BigInt("1500"),
currency: "USD",
},
- tipEligible: true,
+ tip_eligible: true,
},
breaks: [
{
id: "X7GAQYVVRRG6P",
- startAt: "2019-01-25T06:11:00-05:00",
- endAt: "2019-01-25T06:16:00-05:00",
- breakTypeId: "REGS1EQR1TPZ5",
+ 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",
- expectedDuration: "PT5M",
- isPaid: true,
+ expected_duration: "PT5M",
+ is_paid: true,
},
],
version: 1,
- teamMemberId: "ormj0jJJZ5OZIzxrZYJI",
- declaredCashTipMoney: {
- amount: 500,
+ team_member_id: "ormj0jJJZ5OZIzxrZYJI",
+ declared_cash_tip_money: {
+ amount: BigInt("500"),
currency: "USD",
},
},
@@ -17654,7 +17654,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.labor.teamMemberWages.list();
+let page = await client.labor.teamMemberWages.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -17793,7 +17793,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.labor.workweekConfigs.list();
+let page = await client.labor.workweekConfigs.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -17861,9 +17861,9 @@ Updates a `WorkweekConfig`.
```typescript
await client.labor.workweekConfigs.get({
id: "id",
- workweekConfig: {
- startOfWeek: "MON",
- startOfDayLocalTime: "10:00",
+ workweek_config: {
+ start_of_week: "MON",
+ start_of_day_local_time: "10:00",
version: 10,
},
});
@@ -17940,7 +17940,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.locations.customAttributeDefinitions.list();
+let page = await client.locations.customAttributeDefinitions.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -18013,7 +18013,7 @@ to set the custom attribute for locations.
```typescript
await client.locations.customAttributeDefinitions.create({
- customAttributeDefinition: {
+ custom_attribute_definition: {
key: "bestseller",
schema: {
ref: "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String",
@@ -18157,7 +18157,7 @@ Only the definition owner can update a custom attribute definition.
```typescript
await client.locations.customAttributeDefinitions.update({
key: "key",
- customAttributeDefinition: {
+ custom_attribute_definition: {
description: "Update the description as desired.",
visibility: "VISIBILITY_READ_ONLY",
},
@@ -18383,22 +18383,22 @@ must be `VISIBILITY_READ_WRITE_VALUES`.
await client.locations.customAttributes.batchUpsert({
values: {
id1: {
- locationId: "L0TBCBTB7P8RQ",
- customAttribute: {
+ location_id: "L0TBCBTB7P8RQ",
+ custom_attribute: {
key: "bestseller",
value: "hot cocoa",
},
},
id2: {
- locationId: "L9XMD04V3STJX",
- customAttribute: {
+ location_id: "L9XMD04V3STJX",
+ custom_attribute: {
key: "bestseller",
value: "berry smoothie",
},
},
id3: {
- locationId: "L0TBCBTB7P8RQ",
- customAttribute: {
+ location_id: "L0TBCBTB7P8RQ",
+ custom_attribute: {
key: "phone-number",
value: "+12223334444",
},
@@ -18473,15 +18473,15 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
```typescript
const response = await client.locations.customAttributes.list({
- locationId: "location_id",
+ location_id: "location_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.locations.customAttributes.list({
- locationId: "location_id",
+let page = await client.locations.customAttributes.list({
+ location_id: "location_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -18553,7 +18553,7 @@ To retrieve a custom attribute owned by another application, the `visibility` se
```typescript
await client.locations.customAttributes.get({
- locationId: "location_id",
+ location_id: "location_id",
key: "key",
});
```
@@ -18624,9 +18624,9 @@ must be `VISIBILITY_READ_WRITE_VALUES`.
```typescript
await client.locations.customAttributes.upsert({
- locationId: "location_id",
+ location_id: "location_id",
key: "key",
- customAttribute: {
+ custom_attribute: {
value: "hot cocoa",
},
});
@@ -18695,7 +18695,7 @@ To delete a custom attribute owned by another application, the `visibility` sett
```typescript
await client.locations.customAttributes.delete({
- locationId: "location_id",
+ location_id: "location_id",
key: "key",
});
```
@@ -18768,7 +18768,7 @@ Max results per [page](https://developer.squareup.com/docs/working-with-apis/pag
```typescript
await client.locations.transactions.list({
- locationId: "location_id",
+ location_id: "location_id",
});
```
@@ -18833,8 +18833,8 @@ Retrieves details for a single transaction.
```typescript
await client.locations.transactions.get({
- locationId: "location_id",
- transactionId: "transaction_id",
+ location_id: "location_id",
+ transaction_id: "transaction_id",
});
```
@@ -18903,8 +18903,8 @@ for more information.
```typescript
await client.locations.transactions.capture({
- locationId: "location_id",
- transactionId: "transaction_id",
+ location_id: "location_id",
+ transaction_id: "transaction_id",
});
```
@@ -18973,8 +18973,8 @@ for more information.
```typescript
await client.locations.transactions.void({
- locationId: "location_id",
- transactionId: "transaction_id",
+ location_id: "location_id",
+ transaction_id: "transaction_id",
});
```
@@ -19041,13 +19041,13 @@ Creates a loyalty account. To create a loyalty account, you must provide the `pr
```typescript
await client.loyalty.accounts.create({
- loyaltyAccount: {
- programId: "d619f755-2d17-41f3-990d-c04ecedd64dd",
+ loyalty_account: {
+ program_id: "d619f755-2d17-41f3-990d-c04ecedd64dd",
mapping: {
- phoneNumber: "+14155551234",
+ phone_number: "+14155551234",
},
},
- idempotencyKey: "ec78c477-b1c3-4899-a209-a4e71337c996",
+ idempotency_key: "ec78c477-b1c3-4899-a209-a4e71337c996",
});
```
@@ -19119,7 +19119,7 @@ await client.loyalty.accounts.search({
query: {
mappings: [
{
- phoneNumber: "+14155551234",
+ phone_number: "+14155551234",
},
],
},
@@ -19188,7 +19188,7 @@ Retrieves a loyalty account.
```typescript
await client.loyalty.accounts.get({
- accountId: "account_id",
+ account_id: "account_id",
});
```
@@ -19265,12 +19265,12 @@ to compute the points earned from the base loyalty program. For information abou
```typescript
await client.loyalty.accounts.accumulatePoints({
- accountId: "account_id",
- accumulatePoints: {
- orderId: "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY",
+ account_id: "account_id",
+ accumulate_points: {
+ order_id: "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY",
},
- idempotencyKey: "58b90739-c3e8-4b11-85f7-e636d48d72cb",
- locationId: "P034NEENMD09F",
+ idempotency_key: "58b90739-c3e8-4b11-85f7-e636d48d72cb",
+ location_id: "P034NEENMD09F",
});
```
@@ -19339,9 +19339,9 @@ to add points when a buyer pays for the purchase.
```typescript
await client.loyalty.accounts.adjust({
- accountId: "account_id",
- idempotencyKey: "bc29a517-3dc9-450e-aa76-fae39ee849d1",
- adjustPoints: {
+ account_id: "account_id",
+ idempotency_key: "bc29a517-3dc9-450e-aa76-fae39ee849d1",
+ adjust_points: {
points: 10,
reason: "Complimentary points",
},
@@ -19471,7 +19471,7 @@ Loyalty programs define how buyers can earn points and redeem points for rewards
```typescript
await client.loyalty.programs.get({
- programId: "program_id",
+ program_id: "program_id",
});
```
@@ -19549,9 +19549,9 @@ to calculate whether the purchase also qualifies for promotion points. For more
```typescript
await client.loyalty.programs.calculate({
- programId: "program_id",
- orderId: "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY",
- loyaltyAccountId: "79b807d2-d786-46a9-933b-918028d7a8c5",
+ program_id: "program_id",
+ order_id: "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY",
+ loyalty_account_id: "79b807d2-d786-46a9-933b-918028d7a8c5",
});
```
@@ -19626,11 +19626,11 @@ not available for the buyer to redeem another reward.
```typescript
await client.loyalty.rewards.create({
reward: {
- loyaltyAccountId: "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd",
- rewardTierId: "e1b39225-9da5-43d1-a5db-782cdd8ad94f",
- orderId: "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY",
+ loyalty_account_id: "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd",
+ reward_tier_id: "e1b39225-9da5-43d1-a5db-782cdd8ad94f",
+ order_id: "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY",
},
- idempotencyKey: "18c2e5ea-a620-4b1f-ad60-7b167285e451",
+ idempotency_key: "18c2e5ea-a620-4b1f-ad60-7b167285e451",
});
```
@@ -19702,7 +19702,7 @@ Search results are sorted by `updated_at` in descending order.
```typescript
await client.loyalty.rewards.search({
query: {
- loyaltyAccountId: "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd",
+ loyalty_account_id: "5adcb100-07f1-4ee7-b8c6-6bb9ebc474bd",
},
limit: 10,
});
@@ -19769,7 +19769,7 @@ Retrieves a loyalty reward.
```typescript
await client.loyalty.rewards.get({
- rewardId: "reward_id",
+ reward_id: "reward_id",
});
```
@@ -19842,7 +19842,7 @@ You cannot delete a reward that has reached the terminal state (REDEEMED).
```typescript
await client.loyalty.rewards.delete({
- rewardId: "reward_id",
+ reward_id: "reward_id",
});
```
@@ -19917,9 +19917,9 @@ to the account.
```typescript
await client.loyalty.rewards.redeem({
- rewardId: "reward_id",
- idempotencyKey: "98adc7f7-6963-473b-b29c-f3c9cdd7d994",
- locationId: "P034NEENMD09F",
+ reward_id: "reward_id",
+ idempotency_key: "98adc7f7-6963-473b-b29c-f3c9cdd7d994",
+ location_id: "P034NEENMD09F",
});
```
@@ -19987,15 +19987,15 @@ Results are sorted by the `created_at` date in descending order (newest to oldes
```typescript
const response = await client.loyalty.programs.promotions.list({
- programId: "program_id",
+ program_id: "program_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.loyalty.programs.promotions.list({
- programId: "program_id",
+let page = await client.loyalty.programs.promotions.list({
+ program_id: "program_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -20068,31 +20068,31 @@ This endpoint sets the loyalty promotion to the `ACTIVE` or `SCHEDULED` status,
```typescript
await client.loyalty.programs.promotions.create({
- programId: "program_id",
- loyaltyPromotion: {
+ program_id: "program_id",
+ loyalty_promotion: {
name: "Tuesday Happy Hour Promo",
incentive: {
type: "POINTS_MULTIPLIER",
- pointsMultiplierData: {
+ points_multiplier_data: {
multiplier: "3.0",
},
},
- availableTime: {
- timePeriods: [
+ available_time: {
+ time_periods: [
"BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT",
],
},
- triggerLimit: {
+ trigger_limit: {
times: 1,
interval: "DAY",
},
- minimumSpendAmountMoney: {
- amount: 2000,
+ minimum_spend_amount_money: {
+ amount: BigInt("2000"),
currency: "USD",
},
- qualifyingCategoryIds: ["XTQPYLR3IIU9C44VRCB3XD12"],
+ qualifying_category_ids: ["XTQPYLR3IIU9C44VRCB3XD12"],
},
- idempotencyKey: "ec78c477-b1c3-4899-a209-a4e71337c996",
+ idempotency_key: "ec78c477-b1c3-4899-a209-a4e71337c996",
});
```
@@ -20157,8 +20157,8 @@ Retrieves a loyalty promotion.
```typescript
await client.loyalty.programs.promotions.get({
- promotionId: "promotion_id",
- programId: "program_id",
+ promotion_id: "promotion_id",
+ program_id: "program_id",
});
```
@@ -20228,8 +20228,8 @@ This endpoint sets the loyalty promotion to the `CANCELED` state
```typescript
await client.loyalty.programs.promotions.cancel({
- promotionId: "promotion_id",
- programId: "program_id",
+ promotion_id: "promotion_id",
+ program_id: "program_id",
});
```
@@ -20304,7 +20304,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.merchants.customAttributeDefinitions.list();
+let page = await client.merchants.customAttributeDefinitions.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -20377,7 +20377,7 @@ to set the custom attribute for a merchant.
```typescript
await client.merchants.customAttributeDefinitions.create({
- customAttributeDefinition: {
+ custom_attribute_definition: {
key: "alternative_seller_name",
schema: {
ref: "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.String",
@@ -20521,7 +20521,7 @@ Only the definition owner can update a custom attribute definition.
```typescript
await client.merchants.customAttributeDefinitions.update({
key: "key",
- customAttributeDefinition: {
+ custom_attribute_definition: {
description: "Update the description as desired.",
visibility: "VISIBILITY_READ_ONLY",
},
@@ -20744,15 +20744,15 @@ must be `VISIBILITY_READ_WRITE_VALUES`.
await client.merchants.customAttributes.batchUpsert({
values: {
id1: {
- merchantId: "DM7VKY8Q63GNP",
- customAttribute: {
+ merchant_id: "DM7VKY8Q63GNP",
+ custom_attribute: {
key: "alternative_seller_name",
value: "Ultimate Sneaker Store",
},
},
id2: {
- merchantId: "DM7VKY8Q63GNP",
- customAttribute: {
+ merchant_id: "DM7VKY8Q63GNP",
+ custom_attribute: {
key: "has_seen_tutorial",
value: true,
},
@@ -20827,15 +20827,15 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
```typescript
const response = await client.merchants.customAttributes.list({
- merchantId: "merchant_id",
+ merchant_id: "merchant_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.merchants.customAttributes.list({
- merchantId: "merchant_id",
+let page = await client.merchants.customAttributes.list({
+ merchant_id: "merchant_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -20907,7 +20907,7 @@ To retrieve a custom attribute owned by another application, the `visibility` se
```typescript
await client.merchants.customAttributes.get({
- merchantId: "merchant_id",
+ merchant_id: "merchant_id",
key: "key",
});
```
@@ -20978,9 +20978,9 @@ must be `VISIBILITY_READ_WRITE_VALUES`.
```typescript
await client.merchants.customAttributes.upsert({
- merchantId: "merchant_id",
+ merchant_id: "merchant_id",
key: "key",
- customAttribute: {
+ custom_attribute: {
value: "Ultimate Sneaker Store",
},
});
@@ -21049,7 +21049,7 @@ To delete a custom attribute owned by another application, the `visibility` sett
```typescript
await client.merchants.customAttributes.delete({
- merchantId: "merchant_id",
+ merchant_id: "merchant_id",
key: "key",
});
```
@@ -21127,7 +21127,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.orders.customAttributeDefinitions.list();
+let page = await client.orders.customAttributeDefinitions.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -21198,7 +21198,7 @@ in the Square seller account.
```typescript
await client.orders.customAttributeDefinitions.create({
- customAttributeDefinition: {
+ custom_attribute_definition: {
key: "cover-count",
schema: {
ref: "https://developer-production-s.squarecdn.com/schemas/v1/common.json#squareup.common.Number",
@@ -21207,7 +21207,7 @@ await client.orders.customAttributeDefinitions.create({
description: "The number of people seated at a table",
visibility: "VISIBILITY_READ_WRITE_VALUES",
},
- idempotencyKey: "IDEMPOTENCY_KEY",
+ idempotency_key: "IDEMPOTENCY_KEY",
});
```
@@ -21344,12 +21344,12 @@ Only the definition owner can update a custom attribute definition. Note that se
```typescript
await client.orders.customAttributeDefinitions.update({
key: "key",
- customAttributeDefinition: {
+ custom_attribute_definition: {
key: "cover-count",
visibility: "VISIBILITY_READ_ONLY",
version: 1,
},
- idempotencyKey: "IDEMPOTENCY_KEY",
+ idempotency_key: "IDEMPOTENCY_KEY",
});
```
@@ -21499,11 +21499,11 @@ await client.orders.customAttributes.batchDelete({
values: {
"cover-count": {
key: "cover-count",
- orderId: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
+ order_id: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
},
"table-number": {
key: "table-number",
- orderId: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
+ order_id: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
},
},
});
@@ -21585,20 +21585,20 @@ must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attribut
await client.orders.customAttributes.batchUpsert({
values: {
"cover-count": {
- customAttribute: {
+ custom_attribute: {
key: "cover-count",
value: "6",
version: 2,
},
- orderId: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
+ order_id: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
},
"table-number": {
- customAttribute: {
+ custom_attribute: {
key: "table-number",
value: "11",
version: 4,
},
- orderId: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
+ order_id: "7BbXGEIWNldxAzrtGf9GPVZTwZ4F",
},
},
});
@@ -21672,15 +21672,15 @@ and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
```typescript
const response = await client.orders.customAttributes.list({
- orderId: "order_id",
+ order_id: "order_id",
});
for await (const item of response) {
console.log(item);
}
// Or you can manually iterate page-by-page
-const page = await client.orders.customAttributes.list({
- orderId: "order_id",
+let page = await client.orders.customAttributes.list({
+ order_id: "order_id",
});
while (page.hasNextPage()) {
page = page.getNextPage();
@@ -21755,8 +21755,8 @@ also known as custom fields) are always set to `VISIBILITY_READ_WRITE_VALUES`.
```typescript
await client.orders.customAttributes.get({
- orderId: "order_id",
- customAttributeKey: "custom_attribute_key",
+ order_id: "order_id",
+ custom_attribute_key: "custom_attribute_key",
});
```
@@ -21829,9 +21829,9 @@ must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attribut
```typescript
await client.orders.customAttributes.upsert({
- orderId: "order_id",
- customAttributeKey: "custom_attribute_key",
- customAttribute: {
+ order_id: "order_id",
+ custom_attribute_key: "custom_attribute_key",
+ custom_attribute: {
key: "table-number",
value: "42",
version: 1,
@@ -21904,8 +21904,8 @@ To delete a custom attribute owned by another application, the `visibility` sett
```typescript
await client.orders.customAttributes.delete({
- orderId: "order_id",
- customAttributeKey: "custom_attribute_key",
+ order_id: "order_id",
+ custom_attribute_key: "custom_attribute_key",
});
```
@@ -21977,7 +21977,7 @@ to get this information directly from the `TeamMember.wage_setting` field.
```typescript
await client.teamMembers.wageSetting.get({
- teamMemberId: "team_member_id",
+ team_member_id: "team_member_id",
});
```
@@ -22049,28 +22049,28 @@ to manage the `TeamMember.wage_setting` field directly.
```typescript
await client.teamMembers.wageSetting.update({
- teamMemberId: "team_member_id",
- wageSetting: {
- jobAssignments: [
+ team_member_id: "team_member_id",
+ wage_setting: {
+ job_assignments: [
{
- jobTitle: "Manager",
- payType: "SALARY",
- annualRate: {
- amount: 3000000,
+ job_title: "Manager",
+ pay_type: "SALARY",
+ annual_rate: {
+ amount: BigInt("3000000"),
currency: "USD",
},
- weeklyHours: 40,
+ weekly_hours: 40,
},
{
- jobTitle: "Cashier",
- payType: "HOURLY",
- hourlyRate: {
- amount: 2000,
+ job_title: "Cashier",
+ pay_type: "HOURLY",
+ hourly_rate: {
+ amount: BigInt("2000"),
currency: "USD",
},
},
],
- isOvertimeExempt: true,
+ is_overtime_exempt: true,
},
});
```
@@ -22138,14 +22138,14 @@ Creates a Terminal action request and sends it to the specified device.
```typescript
await client.terminal.actions.create({
- idempotencyKey: "thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e",
+ idempotency_key: "thahn-70e75c10-47f7-4ab6-88cc-aaa4076d065e",
action: {
- deviceId: "{{DEVICE_ID}}",
- deadlineDuration: "PT5M",
+ device_id: "{{DEVICE_ID}}",
+ deadline_duration: "PT5M",
type: "SAVE_CARD",
- saveCardOptions: {
- customerId: "{{CUSTOMER_ID}}",
- referenceId: "user-id-1",
+ save_card_options: {
+ customer_id: "{{CUSTOMER_ID}}",
+ reference_id: "user-id-1",
},
},
});
@@ -22214,12 +22214,12 @@ Retrieves a filtered list of Terminal action requests created by the account mak
await client.terminal.actions.search({
query: {
filter: {
- createdAt: {
- startAt: "2022-04-01T00:00:00.000Z",
+ created_at: {
+ start_at: "2022-04-01T00:00:00.000Z",
},
},
sort: {
- sortOrder: "DESC",
+ sort_order: "DESC",
},
},
limit: 2,
@@ -22287,7 +22287,7 @@ Retrieves a Terminal action request by `action_id`. Terminal action requests are
```typescript
await client.terminal.actions.get({
- actionId: "action_id",
+ action_id: "action_id",
});
```
@@ -22352,7 +22352,7 @@ Cancels a Terminal action request if the status of the request permits it.
```typescript
await client.terminal.actions.cancel({
- actionId: "action_id",
+ action_id: "action_id",
});
```
@@ -22420,16 +22420,16 @@ for the requested amount.
```typescript
await client.terminal.checkouts.create({
- idempotencyKey: "28a0c3bc-7839-11ea-bc55-0242ac130003",
+ idempotency_key: "28a0c3bc-7839-11ea-bc55-0242ac130003",
checkout: {
- amountMoney: {
- amount: 2610,
+ amount_money: {
+ amount: BigInt("2610"),
currency: "USD",
},
- referenceId: "id11572",
+ reference_id: "id11572",
note: "A brief note",
- deviceOptions: {
- deviceId: "dbb5d83a-7838-11ea-bc55-0242ac130003",
+ device_options: {
+ device_id: "dbb5d83a-7838-11ea-bc55-0242ac130003",
},
},
});
@@ -22566,7 +22566,7 @@ Retrieves a Terminal checkout request by `checkout_id`. Terminal checkout reques
```typescript
await client.terminal.checkouts.get({
- checkoutId: "checkout_id",
+ checkout_id: "checkout_id",
});
```
@@ -22631,7 +22631,7 @@ Cancels a Terminal checkout request if the status of the request permits it.
```typescript
await client.terminal.checkouts.cancel({
- checkoutId: "checkout_id",
+ checkout_id: "checkout_id",
});
```
@@ -22698,15 +22698,15 @@ Creates a request to refund an Interac payment completed on a Square Terminal. R
```typescript
await client.terminal.refunds.create({
- idempotencyKey: "402a640b-b26f-401f-b406-46f839590c04",
+ idempotency_key: "402a640b-b26f-401f-b406-46f839590c04",
refund: {
- paymentId: "5O5OvgkcNUhl7JBuINflcjKqUzXZY",
- amountMoney: {
- amount: 111,
+ payment_id: "5O5OvgkcNUhl7JBuINflcjKqUzXZY",
+ amount_money: {
+ amount: BigInt("111"),
currency: "CAD",
},
reason: "Returning items",
- deviceId: "f72dfb8e-4d65-4e56-aade-ec3fb8d33291",
+ device_id: "f72dfb8e-4d65-4e56-aade-ec3fb8d33291",
},
});
```
@@ -22842,7 +22842,7 @@ Retrieves an Interac Terminal refund object by ID. Terminal refund objects are a
```typescript
await client.terminal.refunds.get({
- terminalRefundId: "terminal_refund_id",
+ terminal_refund_id: "terminal_refund_id",
});
```
@@ -22907,7 +22907,7 @@ Cancels an Interac Terminal refund request by refund request ID if the status of
```typescript
await client.terminal.refunds.cancel({
- terminalRefundId: "terminal_refund_id",
+ terminal_refund_id: "terminal_refund_id",
});
```
@@ -23044,7 +23044,7 @@ for await (const item of response) {
}
// Or you can manually iterate page-by-page
-const page = await client.webhooks.subscriptions.list();
+let page = await client.webhooks.subscriptions.list();
while (page.hasNextPage()) {
page = page.getNextPage();
}
@@ -23111,12 +23111,12 @@ Creates a webhook subscription.
```typescript
await client.webhooks.subscriptions.create({
- idempotencyKey: "63f84c6c-2200-4c99-846c-2670a1311fbf",
+ idempotency_key: "63f84c6c-2200-4c99-846c-2670a1311fbf",
subscription: {
name: "Example Webhook Subscription",
- eventTypes: ["payment.created", "payment.updated"],
- notificationUrl: "https://example-webhook-url.com",
- apiVersion: "2021-12-15",
+ event_types: ["payment.created", "payment.updated"],
+ notification_url: "https://example-webhook-url.com",
+ api_version: "2021-12-15",
},
});
```
@@ -23182,7 +23182,7 @@ Retrieves a webhook subscription identified by its ID.
```typescript
await client.webhooks.subscriptions.get({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
```
@@ -23247,7 +23247,7 @@ Updates a webhook subscription.
```typescript
await client.webhooks.subscriptions.update({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
subscription: {
name: "Updated Example Webhook Subscription",
enabled: false,
@@ -23316,7 +23316,7 @@ Deletes a webhook subscription.
```typescript
await client.webhooks.subscriptions.delete({
- subscriptionId: "subscription_id",
+ subscription_id: "subscription_id",
});
```
@@ -23381,8 +23381,8 @@ Updates a webhook subscription by replacing the existing signature key with a ne
```typescript
await client.webhooks.subscriptions.updateSignatureKey({
- subscriptionId: "subscription_id",
- idempotencyKey: "ed80ae6b-0654-473b-bbab-a39aee89a60d",
+ subscription_id: "subscription_id",
+ idempotency_key: "ed80ae6b-0654-473b-bbab-a39aee89a60d",
});
```
@@ -23447,8 +23447,8 @@ Tests a webhook subscription by sending a test event to the notification URL.
```typescript
await client.webhooks.subscriptions.test({
- subscriptionId: "subscription_id",
- eventType: "payment.created",
+ subscription_id: "subscription_id",
+ event_type: "payment.created",
});
```
diff --git a/scripts/rename-to-esm-files.js b/scripts/rename-to-esm-files.js
index 81dac6a75..dc1df1cbb 100644
--- a/scripts/rename-to-esm-files.js
+++ b/scripts/rename-to-esm-files.js
@@ -50,8 +50,16 @@ async function updateFileContents(file) {
let newContent = content;
// Update each extension type defined in the map
for (const [oldExt, newExt] of Object.entries(extensionMap)) {
- const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
- newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
+ // Handle static imports/exports
+ const staticRegex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
+ newContent = newContent.replace(staticRegex, `$1$2$3${newExt}$5`);
+
+ // Handle dynamic imports (yield import, await import, regular import())
+ const dynamicRegex = new RegExp(
+ `(yield\\s+import|await\\s+import|import)\\s*\\(\\s*['"](\\.\\.\?\\/[^'"]+)(\\${oldExt})['"]\\s*\\)`,
+ "g",
+ );
+ newContent = newContent.replace(dynamicRegex, `$1("$2${newExt}")`);
}
if (content !== newContent) {
diff --git a/src/Client.ts b/src/Client.ts
index ad3bfb92a..ffcb061b7 100644
--- a/src/Client.ts
+++ b/src/Client.ts
@@ -2,42 +2,43 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "./environments";
-import * as core from "./core";
-import { Mobile } from "./api/resources/mobile/client/Client";
-import { OAuth } from "./api/resources/oAuth/client/Client";
-import { V1Transactions } from "./api/resources/v1Transactions/client/Client";
-import { ApplePay } from "./api/resources/applePay/client/Client";
-import { BankAccounts } from "./api/resources/bankAccounts/client/Client";
-import { Bookings } from "./api/resources/bookings/client/Client";
-import { Cards } from "./api/resources/cards/client/Client";
-import { Catalog } from "./api/resources/catalog/client/Client";
-import { Customers } from "./api/resources/customers/client/Client";
-import { Devices } from "./api/resources/devices/client/Client";
-import { Disputes } from "./api/resources/disputes/client/Client";
-import { Employees } from "./api/resources/employees/client/Client";
-import { Events } from "./api/resources/events/client/Client";
-import { GiftCards } from "./api/resources/giftCards/client/Client";
-import { Inventory } from "./api/resources/inventory/client/Client";
-import { Invoices } from "./api/resources/invoices/client/Client";
-import { Labor } from "./api/resources/labor/client/Client";
-import { Locations } from "./api/resources/locations/client/Client";
-import { Loyalty } from "./api/resources/loyalty/client/Client";
-import { Merchants } from "./api/resources/merchants/client/Client";
-import { Checkout } from "./api/resources/checkout/client/Client";
-import { Orders } from "./api/resources/orders/client/Client";
-import { Payments } from "./api/resources/payments/client/Client";
-import { Payouts } from "./api/resources/payouts/client/Client";
-import { Refunds } from "./api/resources/refunds/client/Client";
-import { Sites } from "./api/resources/sites/client/Client";
-import { Snippets } from "./api/resources/snippets/client/Client";
-import { Subscriptions } from "./api/resources/subscriptions/client/Client";
-import { TeamMembers } from "./api/resources/teamMembers/client/Client";
-import { Team } from "./api/resources/team/client/Client";
-import { Terminal } from "./api/resources/terminal/client/Client";
-import { Vendors } from "./api/resources/vendors/client/Client";
-import { CashDrawers } from "./api/resources/cashDrawers/client/Client";
-import { Webhooks } from "./api/resources/webhooks/client/Client";
+import * as environments from "./environments.js";
+import * as core from "./core/index.js";
+import { mergeHeaders } from "./core/headers.js";
+import { Mobile } from "./api/resources/mobile/client/Client.js";
+import { OAuth } from "./api/resources/oAuth/client/Client.js";
+import { V1Transactions } from "./api/resources/v1Transactions/client/Client.js";
+import { ApplePay } from "./api/resources/applePay/client/Client.js";
+import { BankAccounts } from "./api/resources/bankAccounts/client/Client.js";
+import { Bookings } from "./api/resources/bookings/client/Client.js";
+import { Cards } from "./api/resources/cards/client/Client.js";
+import { Catalog } from "./api/resources/catalog/client/Client.js";
+import { Customers } from "./api/resources/customers/client/Client.js";
+import { Devices } from "./api/resources/devices/client/Client.js";
+import { Disputes } from "./api/resources/disputes/client/Client.js";
+import { Employees } from "./api/resources/employees/client/Client.js";
+import { Events } from "./api/resources/events/client/Client.js";
+import { GiftCards } from "./api/resources/giftCards/client/Client.js";
+import { Inventory } from "./api/resources/inventory/client/Client.js";
+import { Invoices } from "./api/resources/invoices/client/Client.js";
+import { Labor } from "./api/resources/labor/client/Client.js";
+import { Locations } from "./api/resources/locations/client/Client.js";
+import { Loyalty } from "./api/resources/loyalty/client/Client.js";
+import { Merchants } from "./api/resources/merchants/client/Client.js";
+import { Checkout } from "./api/resources/checkout/client/Client.js";
+import { Orders } from "./api/resources/orders/client/Client.js";
+import { Payments } from "./api/resources/payments/client/Client.js";
+import { Payouts } from "./api/resources/payouts/client/Client.js";
+import { Refunds } from "./api/resources/refunds/client/Client.js";
+import { Sites } from "./api/resources/sites/client/Client.js";
+import { Snippets } from "./api/resources/snippets/client/Client.js";
+import { Subscriptions } from "./api/resources/subscriptions/client/Client.js";
+import { TeamMembers } from "./api/resources/teamMembers/client/Client.js";
+import { Team } from "./api/resources/team/client/Client.js";
+import { Terminal } from "./api/resources/terminal/client/Client.js";
+import { Vendors } from "./api/resources/vendors/client/Client.js";
+import { CashDrawers } from "./api/resources/cashDrawers/client/Client.js";
+import { Webhooks } from "./api/resources/webhooks/client/Client.js";
export declare namespace SquareClient {
export interface Options {
@@ -47,6 +48,8 @@ export declare namespace SquareClient {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -60,11 +63,12 @@ export declare namespace SquareClient {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class SquareClient {
+ protected readonly _options: SquareClient.Options;
protected _mobile: Mobile | undefined;
protected _oAuth: OAuth | undefined;
protected _v1Transactions: V1Transactions | undefined;
@@ -100,7 +104,23 @@ export class SquareClient {
protected _cashDrawers: CashDrawers | undefined;
protected _webhooks: Webhooks | undefined;
- constructor(protected readonly _options: SquareClient.Options = {}) {}
+ constructor(_options: SquareClient.Options = {}) {
+ this._options = {
+ ..._options,
+ headers: mergeHeaders(
+ {
+ "Square-Version": _options?.version ?? "2025-07-16",
+ "X-Fern-Language": "JavaScript",
+ "X-Fern-SDK-Name": "square",
+ "X-Fern-SDK-Version": "43.0.1",
+ "User-Agent": "square/43.0.1",
+ "X-Fern-Runtime": core.RUNTIME.type,
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
+ },
+ _options?.headers,
+ ),
+ };
+ }
public get mobile(): Mobile {
return (this._mobile ??= new Mobile(this._options));
diff --git a/src/api/index.ts b/src/api/index.ts
index 3ce0a3e38..bab7cb3de 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,2 +1,2 @@
-export * from "./types";
-export * from "./resources";
+export * from "./types/index.js";
+export * from "./resources/index.js";
diff --git a/src/api/resources/applePay/client/Client.ts b/src/api/resources/applePay/client/Client.ts
index 7fe8fc31a..3b9d3eeca 100644
--- a/src/api/resources/applePay/client/Client.ts
+++ b/src/api/resources/applePay/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import * as Square from "../../../index";
-import * as serializers from "../../../../serialization/index";
-import urlJoin from "url-join";
-import * as errors from "../../../../errors/index";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import * as Square from "../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as errors from "../../../../errors/index.js";
export declare namespace ApplePay {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace ApplePay {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace ApplePay {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class ApplePay {
- constructor(protected readonly _options: ApplePay.Options = {}) {}
+ protected readonly _options: ApplePay.Options;
+
+ constructor(_options: ApplePay.Options = {}) {
+ this._options = _options;
+ }
/**
* Activates a domain for use with Apple Pay on the Web and Square. A validation
@@ -58,56 +63,52 @@ export class ApplePay {
*
* @example
* await client.applePay.registerDomain({
- * domainName: "example.com"
+ * domain_name: "example.com"
* })
*/
- public async registerDomain(
+ public registerDomain(
+ request: Square.RegisterDomainRequest,
+ requestOptions?: ApplePay.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__registerDomain(request, requestOptions));
+ }
+
+ private async __registerDomain(
request: Square.RegisterDomainRequest,
requestOptions?: ApplePay.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/apple-pay/domains",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.RegisterDomainRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.RegisterDomainResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.RegisterDomainResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -116,12 +117,14 @@ export class ApplePay {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/apple-pay/domains.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/applePay/client/index.ts b/src/api/resources/applePay/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/applePay/client/index.ts
+++ b/src/api/resources/applePay/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/applePay/client/requests/RegisterDomainRequest.ts b/src/api/resources/applePay/client/requests/RegisterDomainRequest.ts
index d2aa825f6..b266912de 100644
--- a/src/api/resources/applePay/client/requests/RegisterDomainRequest.ts
+++ b/src/api/resources/applePay/client/requests/RegisterDomainRequest.ts
@@ -5,10 +5,10 @@
/**
* @example
* {
- * domainName: "example.com"
+ * domain_name: "example.com"
* }
*/
export interface RegisterDomainRequest {
/** A domain name as described in RFC-1034 that will be registered with ApplePay. */
- domainName: string;
+ domain_name: string;
}
diff --git a/src/api/resources/applePay/client/requests/index.ts b/src/api/resources/applePay/client/requests/index.ts
index 11c98648b..4165a77a5 100644
--- a/src/api/resources/applePay/client/requests/index.ts
+++ b/src/api/resources/applePay/client/requests/index.ts
@@ -1 +1 @@
-export { type RegisterDomainRequest } from "./RegisterDomainRequest";
+export { type RegisterDomainRequest } from "./RegisterDomainRequest.js";
diff --git a/src/api/resources/applePay/index.ts b/src/api/resources/applePay/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/applePay/index.ts
+++ b/src/api/resources/applePay/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/bankAccounts/client/Client.ts b/src/api/resources/bankAccounts/client/Client.ts
index f1d305a72..b2bda8e37 100644
--- a/src/api/resources/bankAccounts/client/Client.ts
+++ b/src/api/resources/bankAccounts/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import * as Square from "../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../serialization/index";
-import * as errors from "../../../../errors/index";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import * as Square from "../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as errors from "../../../../errors/index.js";
export declare namespace BankAccounts {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace BankAccounts {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace BankAccounts {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class BankAccounts {
- constructor(protected readonly _options: BankAccounts.Options = {}) {}
+ protected readonly _options: BankAccounts.Options;
+
+ constructor(_options: BankAccounts.Options = {}) {
+ this._options = _options;
+ }
/**
* Returns a list of [BankAccount](entity:BankAccount) objects linked to a Square account.
@@ -50,77 +55,80 @@ export class BankAccounts {
request: Square.ListBankAccountsRequest = {},
requestOptions?: BankAccounts.RequestOptions,
): Promise> {
- const list = async (request: Square.ListBankAccountsRequest): Promise => {
- const { cursor, limit, locationId } = request;
- const _queryParams: Record = {};
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (locationId !== undefined) {
- _queryParams["location_id"] = locationId;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/bank-accounts",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListBankAccountsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.ListBankAccountsRequest,
+ ): Promise> => {
+ const { cursor, limit, location_id: locationId } = request;
+ const _queryParams: Record = {};
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (locationId !== undefined) {
+ _queryParams["location_id"] = locationId;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/bank-accounts",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListBankAccountsResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- case "timeout":
- throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/bank-accounts.");
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
- });
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/bank-accounts.");
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.bankAccounts ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.bank_accounts ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
@@ -135,53 +143,50 @@ export class BankAccounts {
*
* @example
* await client.bankAccounts.getByV1Id({
- * v1BankAccountId: "v1_bank_account_id"
+ * v1_bank_account_id: "v1_bank_account_id"
* })
*/
- public async getByV1Id(
+ public getByV1Id(
+ request: Square.GetByV1IdBankAccountsRequest,
+ requestOptions?: BankAccounts.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__getByV1Id(request, requestOptions));
+ }
+
+ private async __getByV1Id(
request: Square.GetByV1IdBankAccountsRequest,
requestOptions?: BankAccounts.RequestOptions,
- ): Promise {
- const { v1BankAccountId } = request;
+ ): Promise> {
+ const { v1_bank_account_id: v1BankAccountId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bank-accounts/by-v1-id/${encodeURIComponent(v1BankAccountId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetBankAccountByV1IdResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.GetBankAccountByV1IdResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -190,6 +195,7 @@ export class BankAccounts {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -198,6 +204,7 @@ export class BankAccounts {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -211,53 +218,50 @@ export class BankAccounts {
*
* @example
* await client.bankAccounts.get({
- * bankAccountId: "bank_account_id"
+ * bank_account_id: "bank_account_id"
* })
*/
- public async get(
+ public get(
request: Square.GetBankAccountsRequest,
requestOptions?: BankAccounts.RequestOptions,
- ): Promise {
- const { bankAccountId } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
+ request: Square.GetBankAccountsRequest,
+ requestOptions?: BankAccounts.RequestOptions,
+ ): Promise> {
+ const { bank_account_id: bankAccountId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bank-accounts/${encodeURIComponent(bankAccountId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetBankAccountResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.GetBankAccountResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -266,6 +270,7 @@ export class BankAccounts {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -274,6 +279,7 @@ export class BankAccounts {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/bankAccounts/client/index.ts b/src/api/resources/bankAccounts/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/bankAccounts/client/index.ts
+++ b/src/api/resources/bankAccounts/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/bankAccounts/client/requests/GetBankAccountsRequest.ts b/src/api/resources/bankAccounts/client/requests/GetBankAccountsRequest.ts
index 2e0fe1f5c..99eacd42b 100644
--- a/src/api/resources/bankAccounts/client/requests/GetBankAccountsRequest.ts
+++ b/src/api/resources/bankAccounts/client/requests/GetBankAccountsRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * bankAccountId: "bank_account_id"
+ * bank_account_id: "bank_account_id"
* }
*/
export interface GetBankAccountsRequest {
/**
* Square-issued ID of the desired `BankAccount`.
*/
- bankAccountId: string;
+ bank_account_id: string;
}
diff --git a/src/api/resources/bankAccounts/client/requests/GetByV1IdBankAccountsRequest.ts b/src/api/resources/bankAccounts/client/requests/GetByV1IdBankAccountsRequest.ts
index f567ca2bf..65b811041 100644
--- a/src/api/resources/bankAccounts/client/requests/GetByV1IdBankAccountsRequest.ts
+++ b/src/api/resources/bankAccounts/client/requests/GetByV1IdBankAccountsRequest.ts
@@ -5,7 +5,7 @@
/**
* @example
* {
- * v1BankAccountId: "v1_bank_account_id"
+ * v1_bank_account_id: "v1_bank_account_id"
* }
*/
export interface GetByV1IdBankAccountsRequest {
@@ -13,5 +13,5 @@ export interface GetByV1IdBankAccountsRequest {
* 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).
*/
- v1BankAccountId: string;
+ v1_bank_account_id: string;
}
diff --git a/src/api/resources/bankAccounts/client/requests/ListBankAccountsRequest.ts b/src/api/resources/bankAccounts/client/requests/ListBankAccountsRequest.ts
index b5ffadfe8..6de5eb28c 100644
--- a/src/api/resources/bankAccounts/client/requests/ListBankAccountsRequest.ts
+++ b/src/api/resources/bankAccounts/client/requests/ListBankAccountsRequest.ts
@@ -25,5 +25,5 @@ export interface ListBankAccountsRequest {
* Location ID. You can specify this optional filter
* to retrieve only the linked bank accounts belonging to a specific location.
*/
- locationId?: string | null;
+ location_id?: string | null;
}
diff --git a/src/api/resources/bankAccounts/client/requests/index.ts b/src/api/resources/bankAccounts/client/requests/index.ts
index 15a87c836..12237b1bd 100644
--- a/src/api/resources/bankAccounts/client/requests/index.ts
+++ b/src/api/resources/bankAccounts/client/requests/index.ts
@@ -1,3 +1,3 @@
-export { type ListBankAccountsRequest } from "./ListBankAccountsRequest";
-export { type GetByV1IdBankAccountsRequest } from "./GetByV1IdBankAccountsRequest";
-export { type GetBankAccountsRequest } from "./GetBankAccountsRequest";
+export { type ListBankAccountsRequest } from "./ListBankAccountsRequest.js";
+export { type GetByV1IdBankAccountsRequest } from "./GetByV1IdBankAccountsRequest.js";
+export { type GetBankAccountsRequest } from "./GetBankAccountsRequest.js";
diff --git a/src/api/resources/bankAccounts/index.ts b/src/api/resources/bankAccounts/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/bankAccounts/index.ts
+++ b/src/api/resources/bankAccounts/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/bookings/client/Client.ts b/src/api/resources/bookings/client/Client.ts
index 5e299eff9..2af421f41 100644
--- a/src/api/resources/bookings/client/Client.ts
+++ b/src/api/resources/bookings/client/Client.ts
@@ -2,16 +2,15 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import * as Square from "../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../serialization/index";
-import * as errors from "../../../../errors/index";
-import { CustomAttributeDefinitions } from "../resources/customAttributeDefinitions/client/Client";
-import { CustomAttributes } from "../resources/customAttributes/client/Client";
-import { LocationProfiles } from "../resources/locationProfiles/client/Client";
-import { TeamMemberProfiles } from "../resources/teamMemberProfiles/client/Client";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import * as Square from "../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as errors from "../../../../errors/index.js";
+import { CustomAttributeDefinitions } from "../resources/customAttributeDefinitions/client/Client.js";
+import { CustomAttributes } from "../resources/customAttributes/client/Client.js";
+import { LocationProfiles } from "../resources/locationProfiles/client/Client.js";
+import { TeamMemberProfiles } from "../resources/teamMemberProfiles/client/Client.js";
export declare namespace Bookings {
export interface Options {
@@ -21,6 +20,8 @@ export declare namespace Bookings {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -34,17 +35,20 @@ export declare namespace Bookings {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Bookings {
+ protected readonly _options: Bookings.Options;
protected _customAttributeDefinitions: CustomAttributeDefinitions | undefined;
protected _customAttributes: CustomAttributes | undefined;
protected _locationProfiles: LocationProfiles | undefined;
protected _teamMemberProfiles: TeamMemberProfiles | undefined;
- constructor(protected readonly _options: Bookings.Options = {}) {}
+ constructor(_options: Bookings.Options = {}) {
+ this._options = _options;
+ }
public get customAttributeDefinitions(): CustomAttributeDefinitions {
return (this._customAttributeDefinitions ??= new CustomAttributeDefinitions(this._options));
@@ -78,88 +82,94 @@ export class Bookings {
request: Square.ListBookingsRequest = {},
requestOptions?: Bookings.RequestOptions,
): Promise> {
- const list = async (request: Square.ListBookingsRequest): Promise => {
- const { limit, cursor, customerId, teamMemberId, locationId, startAtMin, startAtMax } = request;
- const _queryParams: Record = {};
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- if (customerId !== undefined) {
- _queryParams["customer_id"] = customerId;
- }
- if (teamMemberId !== undefined) {
- _queryParams["team_member_id"] = teamMemberId;
- }
- if (locationId !== undefined) {
- _queryParams["location_id"] = locationId;
- }
- if (startAtMin !== undefined) {
- _queryParams["start_at_min"] = startAtMin;
- }
- if (startAtMax !== undefined) {
- _queryParams["start_at_max"] = startAtMax;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/bookings",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListBookingsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Square.ListBookingsRequest): Promise> => {
+ const {
+ limit,
+ cursor,
+ customer_id: customerId,
+ team_member_id: teamMemberId,
+ location_id: locationId,
+ start_at_min: startAtMin,
+ start_at_max: startAtMax,
+ } = request;
+ const _queryParams: Record = {};
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ if (customerId !== undefined) {
+ _queryParams["customer_id"] = customerId;
+ }
+ if (teamMemberId !== undefined) {
+ _queryParams["team_member_id"] = teamMemberId;
+ }
+ if (locationId !== undefined) {
+ _queryParams["location_id"] = locationId;
+ }
+ if (startAtMin !== undefined) {
+ _queryParams["start_at_min"] = startAtMin;
+ }
+ if (startAtMax !== undefined) {
+ _queryParams["start_at_max"] = startAtMax;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/bookings",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return { data: _response.body as Square.ListBookingsResponse, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- case "timeout":
- throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/bookings.");
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
- });
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/bookings.");
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
getItems: (response) => response?.bookings ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
@@ -191,53 +201,49 @@ export class Bookings {
* booking: {}
* })
*/
- public async create(
+ public create(
+ request: Square.CreateBookingRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
request: Square.CreateBookingRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.CreateBookingRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.CreateBookingResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.CreateBookingResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -246,12 +252,14 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/bookings.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -269,58 +277,54 @@ export class Bookings {
* await client.bookings.searchAvailability({
* query: {
* filter: {
- * startAtRange: {}
+ * start_at_range: {}
* }
* }
* })
*/
- public async searchAvailability(
+ public searchAvailability(
request: Square.SearchAvailabilityRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__searchAvailability(request, requestOptions));
+ }
+
+ private async __searchAvailability(
+ request: Square.SearchAvailabilityRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/availability/search",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.SearchAvailabilityRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.SearchAvailabilityResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.SearchAvailabilityResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -329,6 +333,7 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -337,6 +342,7 @@ export class Bookings {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -352,56 +358,52 @@ export class Bookings {
*
* @example
* await client.bookings.bulkRetrieveBookings({
- * bookingIds: ["booking_ids"]
+ * booking_ids: ["booking_ids"]
* })
*/
- public async bulkRetrieveBookings(
+ public bulkRetrieveBookings(
request: Square.BulkRetrieveBookingsRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__bulkRetrieveBookings(request, requestOptions));
+ }
+
+ private async __bulkRetrieveBookings(
+ request: Square.BulkRetrieveBookingsRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/bulk-retrieve",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.BulkRetrieveBookingsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BulkRetrieveBookingsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.BulkRetrieveBookingsResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -410,12 +412,14 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/bookings/bulk-retrieve.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -428,48 +432,47 @@ export class Bookings {
* @example
* await client.bookings.getBusinessProfile()
*/
- public async getBusinessProfile(
+ public getBusinessProfile(
requestOptions?: Bookings.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__getBusinessProfile(requestOptions));
+ }
+
+ private async __getBusinessProfile(
+ requestOptions?: Bookings.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/business-booking-profile",
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetBusinessBookingProfileResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.GetBusinessBookingProfileResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -478,6 +481,7 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -486,6 +490,7 @@ export class Bookings {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -498,53 +503,53 @@ export class Bookings {
*
* @example
* await client.bookings.retrieveLocationBookingProfile({
- * locationId: "location_id"
+ * location_id: "location_id"
* })
*/
- public async retrieveLocationBookingProfile(
+ public retrieveLocationBookingProfile(
+ request: Square.RetrieveLocationBookingProfileRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__retrieveLocationBookingProfile(request, requestOptions));
+ }
+
+ private async __retrieveLocationBookingProfile(
request: Square.RetrieveLocationBookingProfileRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
- const { locationId } = request;
+ ): Promise> {
+ const { location_id: locationId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/location-booking-profiles/${encodeURIComponent(locationId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.RetrieveLocationBookingProfileResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.RetrieveLocationBookingProfileResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -553,6 +558,7 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -561,6 +567,7 @@ export class Bookings {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -573,56 +580,57 @@ export class Bookings {
*
* @example
* await client.bookings.bulkRetrieveTeamMemberBookingProfiles({
- * teamMemberIds: ["team_member_ids"]
+ * team_member_ids: ["team_member_ids"]
* })
*/
- public async bulkRetrieveTeamMemberBookingProfiles(
+ public bulkRetrieveTeamMemberBookingProfiles(
+ request: Square.BulkRetrieveTeamMemberBookingProfilesRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(
+ this.__bulkRetrieveTeamMemberBookingProfiles(request, requestOptions),
+ );
+ }
+
+ private async __bulkRetrieveTeamMemberBookingProfiles(
request: Square.BulkRetrieveTeamMemberBookingProfilesRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/team-member-booking-profiles/bulk-retrieve",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.BulkRetrieveTeamMemberBookingProfilesRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BulkRetrieveTeamMemberBookingProfilesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.BulkRetrieveTeamMemberBookingProfilesResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -631,6 +639,7 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -639,6 +648,7 @@ export class Bookings {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -654,53 +664,50 @@ export class Bookings {
*
* @example
* await client.bookings.get({
- * bookingId: "booking_id"
+ * booking_id: "booking_id"
* })
*/
- public async get(
+ public get(
request: Square.GetBookingsRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
- const { bookingId } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
+ request: Square.GetBookingsRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): Promise> {
+ const { booking_id: bookingId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/${encodeURIComponent(bookingId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetBookingResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.GetBookingResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -709,12 +716,14 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/bookings/{booking_id}.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -733,58 +742,54 @@ export class Bookings {
*
* @example
* await client.bookings.update({
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* booking: {}
* })
*/
- public async update(
+ public update(
request: Square.UpdateBookingRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
- const { bookingId, ..._body } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
+ request: Square.UpdateBookingRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): Promise> {
+ const { booking_id: bookingId, ..._body } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/${encodeURIComponent(bookingId)}`,
),
method: "PUT",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.UpdateBookingRequest.jsonOrThrow(_body, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: _body,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateBookingResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.UpdateBookingResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -793,12 +798,14 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling PUT /v2/bookings/{booking_id}.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -817,57 +824,53 @@ export class Bookings {
*
* @example
* await client.bookings.cancel({
- * bookingId: "booking_id"
+ * booking_id: "booking_id"
* })
*/
- public async cancel(
+ public cancel(
+ request: Square.CancelBookingRequest,
+ requestOptions?: Bookings.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__cancel(request, requestOptions));
+ }
+
+ private async __cancel(
request: Square.CancelBookingRequest,
requestOptions?: Bookings.RequestOptions,
- ): Promise {
- const { bookingId, ..._body } = request;
+ ): Promise> {
+ const { booking_id: bookingId, ..._body } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/${encodeURIComponent(bookingId)}/cancel`,
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.CancelBookingRequest.jsonOrThrow(_body, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: _body,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.CancelBookingResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.CancelBookingResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -876,6 +879,7 @@ export class Bookings {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -884,6 +888,7 @@ export class Bookings {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/bookings/client/index.ts b/src/api/resources/bookings/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/bookings/client/index.ts
+++ b/src/api/resources/bookings/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/bookings/client/requests/BulkRetrieveBookingsRequest.ts b/src/api/resources/bookings/client/requests/BulkRetrieveBookingsRequest.ts
index fb06a42b6..780d6a3fe 100644
--- a/src/api/resources/bookings/client/requests/BulkRetrieveBookingsRequest.ts
+++ b/src/api/resources/bookings/client/requests/BulkRetrieveBookingsRequest.ts
@@ -5,10 +5,10 @@
/**
* @example
* {
- * bookingIds: ["booking_ids"]
+ * booking_ids: ["booking_ids"]
* }
*/
export interface BulkRetrieveBookingsRequest {
/** A non-empty list of [Booking](entity:Booking) IDs specifying bookings to retrieve. */
- bookingIds: string[];
+ booking_ids: string[];
}
diff --git a/src/api/resources/bookings/client/requests/BulkRetrieveTeamMemberBookingProfilesRequest.ts b/src/api/resources/bookings/client/requests/BulkRetrieveTeamMemberBookingProfilesRequest.ts
index f0d8d22fe..4b4d275d7 100644
--- a/src/api/resources/bookings/client/requests/BulkRetrieveTeamMemberBookingProfilesRequest.ts
+++ b/src/api/resources/bookings/client/requests/BulkRetrieveTeamMemberBookingProfilesRequest.ts
@@ -5,10 +5,10 @@
/**
* @example
* {
- * teamMemberIds: ["team_member_ids"]
+ * team_member_ids: ["team_member_ids"]
* }
*/
export interface BulkRetrieveTeamMemberBookingProfilesRequest {
/** A non-empty list of IDs of team members whose booking profiles you want to retrieve. */
- teamMemberIds: string[];
+ team_member_ids: string[];
}
diff --git a/src/api/resources/bookings/client/requests/CancelBookingRequest.ts b/src/api/resources/bookings/client/requests/CancelBookingRequest.ts
index df9e2f50c..bf576405e 100644
--- a/src/api/resources/bookings/client/requests/CancelBookingRequest.ts
+++ b/src/api/resources/bookings/client/requests/CancelBookingRequest.ts
@@ -5,16 +5,16 @@
/**
* @example
* {
- * bookingId: "booking_id"
+ * booking_id: "booking_id"
* }
*/
export interface CancelBookingRequest {
/**
* The ID of the [Booking](entity:Booking) object representing the to-be-cancelled booking.
*/
- bookingId: string;
+ booking_id: string;
/** A unique key to make this request an idempotent operation. */
- idempotencyKey?: string | null;
+ idempotency_key?: string | null;
/** The revision number for the booking used for optimistic concurrency. */
- bookingVersion?: number | null;
+ booking_version?: number | null;
}
diff --git a/src/api/resources/bookings/client/requests/CreateBookingRequest.ts b/src/api/resources/bookings/client/requests/CreateBookingRequest.ts
index f02b87e0c..3b06fd4e4 100644
--- a/src/api/resources/bookings/client/requests/CreateBookingRequest.ts
+++ b/src/api/resources/bookings/client/requests/CreateBookingRequest.ts
@@ -2,7 +2,7 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
@@ -12,7 +12,7 @@ import * as Square from "../../../../index";
*/
export interface CreateBookingRequest {
/** A unique key to make this request an idempotent operation. */
- idempotencyKey?: string;
+ idempotency_key?: string;
/** The details of the booking to be created. */
booking: Square.Booking;
}
diff --git a/src/api/resources/bookings/client/requests/GetBookingsRequest.ts b/src/api/resources/bookings/client/requests/GetBookingsRequest.ts
index f30022de8..f66697652 100644
--- a/src/api/resources/bookings/client/requests/GetBookingsRequest.ts
+++ b/src/api/resources/bookings/client/requests/GetBookingsRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * bookingId: "booking_id"
+ * booking_id: "booking_id"
* }
*/
export interface GetBookingsRequest {
/**
* The ID of the [Booking](entity:Booking) object representing the to-be-retrieved booking.
*/
- bookingId: string;
+ booking_id: string;
}
diff --git a/src/api/resources/bookings/client/requests/ListBookingsRequest.ts b/src/api/resources/bookings/client/requests/ListBookingsRequest.ts
index e57f99b22..1bb5af0b6 100644
--- a/src/api/resources/bookings/client/requests/ListBookingsRequest.ts
+++ b/src/api/resources/bookings/client/requests/ListBookingsRequest.ts
@@ -18,21 +18,21 @@ export interface ListBookingsRequest {
/**
* The [customer](entity:Customer) for whom to retrieve bookings. If this is not set, bookings for all customers are retrieved.
*/
- customerId?: string | null;
+ customer_id?: string | null;
/**
* The team member for whom to retrieve bookings. If this is not set, bookings of all members are retrieved.
*/
- teamMemberId?: string | null;
+ team_member_id?: string | null;
/**
* The location for which to retrieve bookings. If this is not set, all locations' bookings are retrieved.
*/
- locationId?: string | null;
+ location_id?: string | null;
/**
* The RFC 3339 timestamp specifying the earliest of the start time. If this is not set, the current time is used.
*/
- startAtMin?: string | null;
+ start_at_min?: string | null;
/**
* 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.
*/
- startAtMax?: string | null;
+ start_at_max?: string | null;
}
diff --git a/src/api/resources/bookings/client/requests/RetrieveLocationBookingProfileRequest.ts b/src/api/resources/bookings/client/requests/RetrieveLocationBookingProfileRequest.ts
index c53c91d78..7e992b6fa 100644
--- a/src/api/resources/bookings/client/requests/RetrieveLocationBookingProfileRequest.ts
+++ b/src/api/resources/bookings/client/requests/RetrieveLocationBookingProfileRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * locationId: "location_id"
+ * location_id: "location_id"
* }
*/
export interface RetrieveLocationBookingProfileRequest {
/**
* The ID of the location to retrieve the booking profile.
*/
- locationId: string;
+ location_id: string;
}
diff --git a/src/api/resources/bookings/client/requests/SearchAvailabilityRequest.ts b/src/api/resources/bookings/client/requests/SearchAvailabilityRequest.ts
index 50bc2efd8..cae76174f 100644
--- a/src/api/resources/bookings/client/requests/SearchAvailabilityRequest.ts
+++ b/src/api/resources/bookings/client/requests/SearchAvailabilityRequest.ts
@@ -2,14 +2,14 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
* query: {
* filter: {
- * startAtRange: {}
+ * start_at_range: {}
* }
* }
* }
diff --git a/src/api/resources/bookings/client/requests/UpdateBookingRequest.ts b/src/api/resources/bookings/client/requests/UpdateBookingRequest.ts
index 3ed17fbab..95400b439 100644
--- a/src/api/resources/bookings/client/requests/UpdateBookingRequest.ts
+++ b/src/api/resources/bookings/client/requests/UpdateBookingRequest.ts
@@ -2,12 +2,12 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* booking: {}
* }
*/
@@ -15,9 +15,9 @@ export interface UpdateBookingRequest {
/**
* The ID of the [Booking](entity:Booking) object representing the to-be-updated booking.
*/
- bookingId: string;
+ booking_id: string;
/** A unique key to make this request an idempotent operation. */
- idempotencyKey?: string | null;
+ idempotency_key?: string | null;
/** The booking to be updated. Individual attributes explicitly specified here override the corresponding values of the existing booking. */
booking: Square.Booking;
}
diff --git a/src/api/resources/bookings/client/requests/index.ts b/src/api/resources/bookings/client/requests/index.ts
index 3c416a42f..61a3bbb3c 100644
--- a/src/api/resources/bookings/client/requests/index.ts
+++ b/src/api/resources/bookings/client/requests/index.ts
@@ -1,9 +1,9 @@
-export { type ListBookingsRequest } from "./ListBookingsRequest";
-export { type CreateBookingRequest } from "./CreateBookingRequest";
-export { type SearchAvailabilityRequest } from "./SearchAvailabilityRequest";
-export { type BulkRetrieveBookingsRequest } from "./BulkRetrieveBookingsRequest";
-export { type RetrieveLocationBookingProfileRequest } from "./RetrieveLocationBookingProfileRequest";
-export { type BulkRetrieveTeamMemberBookingProfilesRequest } from "./BulkRetrieveTeamMemberBookingProfilesRequest";
-export { type GetBookingsRequest } from "./GetBookingsRequest";
-export { type UpdateBookingRequest } from "./UpdateBookingRequest";
-export { type CancelBookingRequest } from "./CancelBookingRequest";
+export { type ListBookingsRequest } from "./ListBookingsRequest.js";
+export { type CreateBookingRequest } from "./CreateBookingRequest.js";
+export { type SearchAvailabilityRequest } from "./SearchAvailabilityRequest.js";
+export { type BulkRetrieveBookingsRequest } from "./BulkRetrieveBookingsRequest.js";
+export { type RetrieveLocationBookingProfileRequest } from "./RetrieveLocationBookingProfileRequest.js";
+export { type BulkRetrieveTeamMemberBookingProfilesRequest } from "./BulkRetrieveTeamMemberBookingProfilesRequest.js";
+export { type GetBookingsRequest } from "./GetBookingsRequest.js";
+export { type UpdateBookingRequest } from "./UpdateBookingRequest.js";
+export { type CancelBookingRequest } from "./CancelBookingRequest.js";
diff --git a/src/api/resources/bookings/index.ts b/src/api/resources/bookings/index.ts
index 33a87f100..9eb1192dc 100644
--- a/src/api/resources/bookings/index.ts
+++ b/src/api/resources/bookings/index.ts
@@ -1,2 +1,2 @@
-export * from "./client";
-export * from "./resources";
+export * from "./client/index.js";
+export * from "./resources/index.js";
diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts
index 46ac33927..688f366c2 100644
--- a/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts
+++ b/src/api/resources/bookings/resources/customAttributeDefinitions/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../../../serialization/index";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace CustomAttributeDefinitions {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace CustomAttributeDefinitions {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace CustomAttributeDefinitions {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class CustomAttributeDefinitions {
- constructor(protected readonly _options: CustomAttributeDefinitions.Options = {}) {}
+ protected readonly _options: CustomAttributeDefinitions.Options;
+
+ constructor(_options: CustomAttributeDefinitions.Options = {}) {
+ this._options = _options;
+ }
/**
* Get all bookings custom attribute definitions.
@@ -53,81 +58,82 @@ export class CustomAttributeDefinitions {
request: Square.bookings.ListCustomAttributeDefinitionsRequest = {},
requestOptions?: CustomAttributeDefinitions.RequestOptions,
): Promise> {
- const list = async (
- request: Square.bookings.ListCustomAttributeDefinitionsRequest,
- ): Promise => {
- const { limit, cursor } = request;
- const _queryParams: Record = {};
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/bookings/custom-attribute-definitions",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.1",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListBookingCustomAttributeDefinitionsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.bookings.ListCustomAttributeDefinitionsRequest,
+ ): Promise> => {
+ const { limit, cursor } = request;
+ const _queryParams: Record = {};
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/bookings/custom-attribute-definitions",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListBookingCustomAttributeDefinitionsResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
- });
- case "timeout":
- throw new errors.SquareTimeoutError(
- "Timeout exceeded when calling GET /v2/bookings/custom-attribute-definitions.",
- );
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError(
+ "Timeout exceeded when calling GET /v2/bookings/custom-attribute-definitions.",
+ );
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable<
Square.ListBookingCustomAttributeDefinitionsResponse,
Square.CustomAttributeDefinition
>({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.customAttributeDefinitions ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.custom_attribute_definitions ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
@@ -148,56 +154,55 @@ export class CustomAttributeDefinitions {
*
* @example
* await client.bookings.customAttributeDefinitions.create({
- * customAttributeDefinition: {}
+ * custom_attribute_definition: {}
* })
*/
- public async create(
+ public create(
request: Square.bookings.CreateBookingCustomAttributeDefinitionRequest,
requestOptions?: CustomAttributeDefinitions.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Square.bookings.CreateBookingCustomAttributeDefinitionRequest,
+ requestOptions?: CustomAttributeDefinitions.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/custom-attribute-definitions",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.bookings.CreateBookingCustomAttributeDefinitionRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.CreateBookingCustomAttributeDefinitionResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.CreateBookingCustomAttributeDefinitionResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -206,6 +211,7 @@ export class CustomAttributeDefinitions {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -214,6 +220,7 @@ export class CustomAttributeDefinitions {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -232,10 +239,17 @@ export class CustomAttributeDefinitions {
* key: "key"
* })
*/
- public async get(
+ public get(
request: Square.bookings.GetCustomAttributeDefinitionsRequest,
requestOptions?: CustomAttributeDefinitions.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
+ request: Square.bookings.GetCustomAttributeDefinitionsRequest,
+ requestOptions?: CustomAttributeDefinitions.RequestOptions,
+ ): Promise> {
const { key, version } = request;
const _queryParams: Record = {};
if (version !== undefined) {
@@ -243,45 +257,38 @@ export class CustomAttributeDefinitions {
}
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/custom-attribute-definitions/${encodeURIComponent(key)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
queryParameters: _queryParams,
- requestType: "json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.RetrieveBookingCustomAttributeDefinitionResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.RetrieveBookingCustomAttributeDefinitionResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -290,6 +297,7 @@ export class CustomAttributeDefinitions {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -298,6 +306,7 @@ export class CustomAttributeDefinitions {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -317,57 +326,56 @@ export class CustomAttributeDefinitions {
* @example
* await client.bookings.customAttributeDefinitions.update({
* key: "key",
- * customAttributeDefinition: {}
+ * custom_attribute_definition: {}
* })
*/
- public async update(
+ public update(
+ request: Square.bookings.UpdateBookingCustomAttributeDefinitionRequest,
+ requestOptions?: CustomAttributeDefinitions.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
request: Square.bookings.UpdateBookingCustomAttributeDefinitionRequest,
requestOptions?: CustomAttributeDefinitions.RequestOptions,
- ): Promise {
+ ): Promise> {
const { key, ..._body } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/custom-attribute-definitions/${encodeURIComponent(key)}`,
),
method: "PUT",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.bookings.UpdateBookingCustomAttributeDefinitionRequest.jsonOrThrow(_body, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: _body,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateBookingCustomAttributeDefinitionResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.UpdateBookingCustomAttributeDefinitionResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -376,6 +384,7 @@ export class CustomAttributeDefinitions {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -384,6 +393,7 @@ export class CustomAttributeDefinitions {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -405,50 +415,50 @@ export class CustomAttributeDefinitions {
* key: "key"
* })
*/
- public async delete(
+ public delete(
+ request: Square.bookings.DeleteCustomAttributeDefinitionsRequest,
+ requestOptions?: CustomAttributeDefinitions.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
+ }
+
+ private async __delete(
request: Square.bookings.DeleteCustomAttributeDefinitionsRequest,
requestOptions?: CustomAttributeDefinitions.RequestOptions,
- ): Promise {
+ ): Promise> {
const { key } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/custom-attribute-definitions/${encodeURIComponent(key)}`,
),
method: "DELETE",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.DeleteBookingCustomAttributeDefinitionResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.DeleteBookingCustomAttributeDefinitionResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -457,6 +467,7 @@ export class CustomAttributeDefinitions {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -465,6 +476,7 @@ export class CustomAttributeDefinitions {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/client/index.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/bookings/resources/customAttributeDefinitions/client/index.ts
+++ b/src/api/resources/bookings/resources/customAttributeDefinitions/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/CreateBookingCustomAttributeDefinitionRequest.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/CreateBookingCustomAttributeDefinitionRequest.ts
index 9ca4428e5..ddfad27fe 100644
--- a/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/CreateBookingCustomAttributeDefinitionRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/CreateBookingCustomAttributeDefinitionRequest.ts
@@ -2,12 +2,12 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
- * customAttributeDefinition: {}
+ * custom_attribute_definition: {}
* }
*/
export interface CreateBookingCustomAttributeDefinitionRequest {
@@ -28,10 +28,10 @@ export interface CreateBookingCustomAttributeDefinitionRequest {
* simple URL to the JSON schema definition hosted on the Square CDN. For more information, see
* [Specifying the schema](https://developer.squareup.com/docs/booking-custom-attributes-api/custom-attribute-definitions#specify-schema).
*/
- customAttributeDefinition: Square.CustomAttributeDefinition;
+ custom_attribute_definition: Square.CustomAttributeDefinition;
/**
* A unique identifier for this request, used to ensure idempotency. For more information,
* see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
*/
- idempotencyKey?: string;
+ idempotency_key?: string;
}
diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/UpdateBookingCustomAttributeDefinitionRequest.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/UpdateBookingCustomAttributeDefinitionRequest.ts
index ec3f3cb5a..9ddd73482 100644
--- a/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/UpdateBookingCustomAttributeDefinitionRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/UpdateBookingCustomAttributeDefinitionRequest.ts
@@ -2,13 +2,13 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
* key: "key",
- * customAttributeDefinition: {}
+ * custom_attribute_definition: {}
* }
*/
export interface UpdateBookingCustomAttributeDefinitionRequest {
@@ -30,10 +30,10 @@ export interface UpdateBookingCustomAttributeDefinitionRequest {
* To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency)
* control, include the optional `version` field and specify the current version of the custom attribute definition.
*/
- customAttributeDefinition: Square.CustomAttributeDefinition;
+ custom_attribute_definition: Square.CustomAttributeDefinition;
/**
* A unique identifier for this request, used to ensure idempotency. For more information,
* see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
*/
- idempotencyKey?: string | null;
+ idempotency_key?: string | null;
}
diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/index.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/index.ts
index 0dd526820..4c0fd5bc1 100644
--- a/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/index.ts
+++ b/src/api/resources/bookings/resources/customAttributeDefinitions/client/requests/index.ts
@@ -1,5 +1,5 @@
-export { type ListCustomAttributeDefinitionsRequest } from "./ListCustomAttributeDefinitionsRequest";
-export { type CreateBookingCustomAttributeDefinitionRequest } from "./CreateBookingCustomAttributeDefinitionRequest";
-export { type GetCustomAttributeDefinitionsRequest } from "./GetCustomAttributeDefinitionsRequest";
-export { type UpdateBookingCustomAttributeDefinitionRequest } from "./UpdateBookingCustomAttributeDefinitionRequest";
-export { type DeleteCustomAttributeDefinitionsRequest } from "./DeleteCustomAttributeDefinitionsRequest";
+export { type ListCustomAttributeDefinitionsRequest } from "./ListCustomAttributeDefinitionsRequest.js";
+export { type CreateBookingCustomAttributeDefinitionRequest } from "./CreateBookingCustomAttributeDefinitionRequest.js";
+export { type GetCustomAttributeDefinitionsRequest } from "./GetCustomAttributeDefinitionsRequest.js";
+export { type UpdateBookingCustomAttributeDefinitionRequest } from "./UpdateBookingCustomAttributeDefinitionRequest.js";
+export { type DeleteCustomAttributeDefinitionsRequest } from "./DeleteCustomAttributeDefinitionsRequest.js";
diff --git a/src/api/resources/bookings/resources/customAttributeDefinitions/index.ts b/src/api/resources/bookings/resources/customAttributeDefinitions/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/bookings/resources/customAttributeDefinitions/index.ts
+++ b/src/api/resources/bookings/resources/customAttributeDefinitions/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/bookings/resources/customAttributes/client/Client.ts b/src/api/resources/bookings/resources/customAttributes/client/Client.ts
index 2bdad8288..ece21735c 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/Client.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import * as serializers from "../../../../../../serialization/index";
-import urlJoin from "url-join";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace CustomAttributes {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace CustomAttributes {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace CustomAttributes {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class CustomAttributes {
- constructor(protected readonly _options: CustomAttributes.Options = {}) {}
+ protected readonly _options: CustomAttributes.Options;
+
+ constructor(_options: CustomAttributes.Options = {}) {
+ this._options = _options;
+ }
/**
* Bulk deletes bookings custom attributes.
@@ -53,59 +58,58 @@ export class CustomAttributes {
* await client.bookings.customAttributes.batchDelete({
* values: {
* "key": {
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key"
* }
* }
* })
*/
- public async batchDelete(
+ public batchDelete(
request: Square.bookings.BulkDeleteBookingCustomAttributesRequest,
requestOptions?: CustomAttributes.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__batchDelete(request, requestOptions));
+ }
+
+ private async __batchDelete(
+ request: Square.bookings.BulkDeleteBookingCustomAttributesRequest,
+ requestOptions?: CustomAttributes.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/custom-attributes/bulk-delete",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.bookings.BulkDeleteBookingCustomAttributesRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BulkDeleteBookingCustomAttributesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.BulkDeleteBookingCustomAttributesResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -114,6 +118,7 @@ export class CustomAttributes {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -122,6 +127,7 @@ export class CustomAttributes {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -142,59 +148,58 @@ export class CustomAttributes {
* await client.bookings.customAttributes.batchUpsert({
* values: {
* "key": {
- * bookingId: "booking_id",
- * customAttribute: {}
+ * booking_id: "booking_id",
+ * custom_attribute: {}
* }
* }
* })
*/
- public async batchUpsert(
+ public batchUpsert(
+ request: Square.bookings.BulkUpsertBookingCustomAttributesRequest,
+ requestOptions?: CustomAttributes.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__batchUpsert(request, requestOptions));
+ }
+
+ private async __batchUpsert(
request: Square.bookings.BulkUpsertBookingCustomAttributesRequest,
requestOptions?: CustomAttributes.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/bookings/custom-attributes/bulk-upsert",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.bookings.BulkUpsertBookingCustomAttributesRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BulkUpsertBookingCustomAttributesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.BulkUpsertBookingCustomAttributesResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -203,6 +208,7 @@ export class CustomAttributes {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -211,6 +217,7 @@ export class CustomAttributes {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -226,88 +233,89 @@ export class CustomAttributes {
*
* @example
* await client.bookings.customAttributes.list({
- * bookingId: "booking_id"
+ * booking_id: "booking_id"
* })
*/
public async list(
request: Square.bookings.ListCustomAttributesRequest,
requestOptions?: CustomAttributes.RequestOptions,
): Promise> {
- const list = async (
- request: Square.bookings.ListCustomAttributesRequest,
- ): Promise => {
- const { bookingId, limit, cursor, withDefinitions } = request;
- const _queryParams: Record = {};
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- if (withDefinitions !== undefined) {
- _queryParams["with_definitions"] = withDefinitions?.toString() ?? null;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- `v2/bookings/${encodeURIComponent(bookingId)}/custom-attributes`,
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListBookingCustomAttributesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.bookings.ListCustomAttributesRequest,
+ ): Promise> => {
+ const { booking_id: bookingId, limit, cursor, with_definitions: withDefinitions } = request;
+ const _queryParams: Record = {};
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ if (withDefinitions !== undefined) {
+ _queryParams["with_definitions"] = withDefinitions?.toString() ?? null;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ `v2/bookings/${encodeURIComponent(bookingId)}/custom-attributes`,
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
- });
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListBookingCustomAttributesResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
- });
- case "timeout":
- throw new errors.SquareTimeoutError(
- "Timeout exceeded when calling GET /v2/bookings/{booking_id}/custom-attributes.",
- );
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError(
+ "Timeout exceeded when calling GET /v2/bookings/{booking_id}/custom-attributes.",
+ );
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.customAttributes ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.custom_attributes ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
@@ -325,15 +333,22 @@ export class CustomAttributes {
*
* @example
* await client.bookings.customAttributes.get({
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key"
* })
*/
- public async get(
+ public get(
+ request: Square.bookings.GetCustomAttributesRequest,
+ requestOptions?: CustomAttributes.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
request: Square.bookings.GetCustomAttributesRequest,
requestOptions?: CustomAttributes.RequestOptions,
- ): Promise {
- const { bookingId, key, withDefinition, version } = request;
+ ): Promise> {
+ const { booking_id: bookingId, key, with_definition: withDefinition, version } = request;
const _queryParams: Record = {};
if (withDefinition !== undefined) {
_queryParams["with_definition"] = withDefinition?.toString() ?? null;
@@ -344,45 +359,38 @@ export class CustomAttributes {
}
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/${encodeURIComponent(bookingId)}/custom-attributes/${encodeURIComponent(key)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
queryParameters: _queryParams,
- requestType: "json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.RetrieveBookingCustomAttributeResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.RetrieveBookingCustomAttributeResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -391,6 +399,7 @@ export class CustomAttributes {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -399,6 +408,7 @@ export class CustomAttributes {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -417,59 +427,58 @@ export class CustomAttributes {
*
* @example
* await client.bookings.customAttributes.upsert({
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key",
- * customAttribute: {}
+ * custom_attribute: {}
* })
*/
- public async upsert(
+ public upsert(
request: Square.bookings.UpsertBookingCustomAttributeRequest,
requestOptions?: CustomAttributes.RequestOptions,
- ): Promise {
- const { bookingId, key, ..._body } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__upsert(request, requestOptions));
+ }
+
+ private async __upsert(
+ request: Square.bookings.UpsertBookingCustomAttributeRequest,
+ requestOptions?: CustomAttributes.RequestOptions,
+ ): Promise> {
+ const { booking_id: bookingId, key, ..._body } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/${encodeURIComponent(bookingId)}/custom-attributes/${encodeURIComponent(key)}`,
),
method: "PUT",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.bookings.UpsertBookingCustomAttributeRequest.jsonOrThrow(_body, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: _body,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpsertBookingCustomAttributeResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.UpsertBookingCustomAttributeResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -478,6 +487,7 @@ export class CustomAttributes {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -486,6 +496,7 @@ export class CustomAttributes {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -504,54 +515,54 @@ export class CustomAttributes {
*
* @example
* await client.bookings.customAttributes.delete({
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key"
* })
*/
- public async delete(
+ public delete(
+ request: Square.bookings.DeleteCustomAttributesRequest,
+ requestOptions?: CustomAttributes.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
+ }
+
+ private async __delete(
request: Square.bookings.DeleteCustomAttributesRequest,
requestOptions?: CustomAttributes.RequestOptions,
- ): Promise {
- const { bookingId, key } = request;
+ ): Promise> {
+ const { booking_id: bookingId, key } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/${encodeURIComponent(bookingId)}/custom-attributes/${encodeURIComponent(key)}`,
),
method: "DELETE",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.DeleteBookingCustomAttributeResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.DeleteBookingCustomAttributeResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -560,6 +571,7 @@ export class CustomAttributes {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -568,6 +580,7 @@ export class CustomAttributes {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/bookings/resources/customAttributes/client/index.ts b/src/api/resources/bookings/resources/customAttributes/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/index.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/BulkDeleteBookingCustomAttributesRequest.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/BulkDeleteBookingCustomAttributesRequest.ts
index dd626b7a9..14a2c1b41 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/BulkDeleteBookingCustomAttributesRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/BulkDeleteBookingCustomAttributesRequest.ts
@@ -2,14 +2,14 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
* values: {
* "key": {
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key"
* }
* }
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/BulkUpsertBookingCustomAttributesRequest.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/BulkUpsertBookingCustomAttributesRequest.ts
index fca36bbb3..e47cf3566 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/BulkUpsertBookingCustomAttributesRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/BulkUpsertBookingCustomAttributesRequest.ts
@@ -2,15 +2,15 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
* values: {
* "key": {
- * bookingId: "booking_id",
- * customAttribute: {}
+ * booking_id: "booking_id",
+ * custom_attribute: {}
* }
* }
* }
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/DeleteCustomAttributesRequest.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/DeleteCustomAttributesRequest.ts
index 1e6be8d91..cd4907f04 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/DeleteCustomAttributesRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/DeleteCustomAttributesRequest.ts
@@ -5,7 +5,7 @@
/**
* @example
* {
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key"
* }
*/
@@ -13,7 +13,7 @@ export interface DeleteCustomAttributesRequest {
/**
* The ID of the target [booking](entity:Booking).
*/
- bookingId: string;
+ booking_id: string;
/**
* 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
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/GetCustomAttributesRequest.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/GetCustomAttributesRequest.ts
index 540eb8c10..f458ee7a0 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/GetCustomAttributesRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/GetCustomAttributesRequest.ts
@@ -5,7 +5,7 @@
/**
* @example
* {
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key"
* }
*/
@@ -13,7 +13,7 @@ export interface GetCustomAttributesRequest {
/**
* The ID of the target [booking](entity:Booking).
*/
- bookingId: string;
+ booking_id: string;
/**
* 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
@@ -25,7 +25,7 @@ export interface GetCustomAttributesRequest {
* 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`.
*/
- withDefinition?: boolean | null;
+ with_definition?: boolean | null;
/**
* 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
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/ListCustomAttributesRequest.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/ListCustomAttributesRequest.ts
index ec23db686..3096631d6 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/ListCustomAttributesRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/ListCustomAttributesRequest.ts
@@ -5,14 +5,14 @@
/**
* @example
* {
- * bookingId: "booking_id"
+ * booking_id: "booking_id"
* }
*/
export interface ListCustomAttributesRequest {
/**
* The ID of the target [booking](entity:Booking).
*/
- bookingId: string;
+ booking_id: string;
/**
* 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.
@@ -30,5 +30,5 @@ export interface ListCustomAttributesRequest {
* 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`.
*/
- withDefinitions?: boolean | null;
+ with_definitions?: boolean | null;
}
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/UpsertBookingCustomAttributeRequest.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/UpsertBookingCustomAttributeRequest.ts
index b65cfb25c..d42b642ec 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/UpsertBookingCustomAttributeRequest.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/UpsertBookingCustomAttributeRequest.ts
@@ -2,21 +2,21 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
- * bookingId: "booking_id",
+ * booking_id: "booking_id",
* key: "key",
- * customAttribute: {}
+ * custom_attribute: {}
* }
*/
export interface UpsertBookingCustomAttributeRequest {
/**
* The ID of the target [booking](entity:Booking).
*/
- bookingId: string;
+ booking_id: string;
/**
* 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
@@ -33,10 +33,10 @@ export interface UpsertBookingCustomAttributeRequest {
* control for an update operation, include this optional field and specify the current version
* of the custom attribute.
*/
- customAttribute: Square.CustomAttribute;
+ custom_attribute: Square.CustomAttribute;
/**
* A unique identifier for this request, used to ensure idempotency. For more information,
* see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
*/
- idempotencyKey?: string | null;
+ idempotency_key?: string | null;
}
diff --git a/src/api/resources/bookings/resources/customAttributes/client/requests/index.ts b/src/api/resources/bookings/resources/customAttributes/client/requests/index.ts
index 3e49e8cbc..20483005e 100644
--- a/src/api/resources/bookings/resources/customAttributes/client/requests/index.ts
+++ b/src/api/resources/bookings/resources/customAttributes/client/requests/index.ts
@@ -1,6 +1,6 @@
-export { type BulkDeleteBookingCustomAttributesRequest } from "./BulkDeleteBookingCustomAttributesRequest";
-export { type BulkUpsertBookingCustomAttributesRequest } from "./BulkUpsertBookingCustomAttributesRequest";
-export { type ListCustomAttributesRequest } from "./ListCustomAttributesRequest";
-export { type GetCustomAttributesRequest } from "./GetCustomAttributesRequest";
-export { type UpsertBookingCustomAttributeRequest } from "./UpsertBookingCustomAttributeRequest";
-export { type DeleteCustomAttributesRequest } from "./DeleteCustomAttributesRequest";
+export { type BulkDeleteBookingCustomAttributesRequest } from "./BulkDeleteBookingCustomAttributesRequest.js";
+export { type BulkUpsertBookingCustomAttributesRequest } from "./BulkUpsertBookingCustomAttributesRequest.js";
+export { type ListCustomAttributesRequest } from "./ListCustomAttributesRequest.js";
+export { type GetCustomAttributesRequest } from "./GetCustomAttributesRequest.js";
+export { type UpsertBookingCustomAttributeRequest } from "./UpsertBookingCustomAttributeRequest.js";
+export { type DeleteCustomAttributesRequest } from "./DeleteCustomAttributesRequest.js";
diff --git a/src/api/resources/bookings/resources/customAttributes/index.ts b/src/api/resources/bookings/resources/customAttributes/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/bookings/resources/customAttributes/index.ts
+++ b/src/api/resources/bookings/resources/customAttributes/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/bookings/resources/index.ts b/src/api/resources/bookings/resources/index.ts
index f4f82dee8..e3b708588 100644
--- a/src/api/resources/bookings/resources/index.ts
+++ b/src/api/resources/bookings/resources/index.ts
@@ -1,8 +1,8 @@
-export * as customAttributeDefinitions from "./customAttributeDefinitions";
-export * as customAttributes from "./customAttributes";
-export * as locationProfiles from "./locationProfiles";
-export * as teamMemberProfiles from "./teamMemberProfiles";
-export * from "./customAttributeDefinitions/client/requests";
-export * from "./customAttributes/client/requests";
-export * from "./locationProfiles/client/requests";
-export * from "./teamMemberProfiles/client/requests";
+export * as customAttributeDefinitions from "./customAttributeDefinitions/index.js";
+export * as customAttributes from "./customAttributes/index.js";
+export * as locationProfiles from "./locationProfiles/index.js";
+export * as teamMemberProfiles from "./teamMemberProfiles/index.js";
+export * from "./customAttributeDefinitions/client/requests/index.js";
+export * from "./customAttributes/client/requests/index.js";
+export * from "./locationProfiles/client/requests/index.js";
+export * from "./teamMemberProfiles/client/requests/index.js";
diff --git a/src/api/resources/bookings/resources/locationProfiles/client/Client.ts b/src/api/resources/bookings/resources/locationProfiles/client/Client.ts
index 4ec1fc95d..94ec90f40 100644
--- a/src/api/resources/bookings/resources/locationProfiles/client/Client.ts
+++ b/src/api/resources/bookings/resources/locationProfiles/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../../../serialization/index";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace LocationProfiles {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace LocationProfiles {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace LocationProfiles {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class LocationProfiles {
- constructor(protected readonly _options: LocationProfiles.Options = {}) {}
+ protected readonly _options: LocationProfiles.Options;
+
+ constructor(_options: LocationProfiles.Options = {}) {
+ this._options = _options;
+ }
/**
* Lists location booking profiles of a seller.
@@ -50,78 +55,79 @@ export class LocationProfiles {
request: Square.bookings.ListLocationProfilesRequest = {},
requestOptions?: LocationProfiles.RequestOptions,
): Promise> {
- const list = async (
- request: Square.bookings.ListLocationProfilesRequest,
- ): Promise => {
- const { limit, cursor } = request;
- const _queryParams: Record = {};
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/bookings/location-booking-profiles",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListLocationBookingProfilesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.bookings.ListLocationProfilesRequest,
+ ): Promise> => {
+ const { limit, cursor } = request;
+ const _queryParams: Record = {};
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/bookings/location-booking-profiles",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListLocationBookingProfilesResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- case "timeout":
- throw new errors.SquareTimeoutError(
- "Timeout exceeded when calling GET /v2/bookings/location-booking-profiles.",
- );
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
- });
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError(
+ "Timeout exceeded when calling GET /v2/bookings/location-booking-profiles.",
+ );
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.locationBookingProfiles ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.location_booking_profiles ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
diff --git a/src/api/resources/bookings/resources/locationProfiles/client/index.ts b/src/api/resources/bookings/resources/locationProfiles/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/bookings/resources/locationProfiles/client/index.ts
+++ b/src/api/resources/bookings/resources/locationProfiles/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/bookings/resources/locationProfiles/client/requests/index.ts b/src/api/resources/bookings/resources/locationProfiles/client/requests/index.ts
index f3f432a40..09a22ccc8 100644
--- a/src/api/resources/bookings/resources/locationProfiles/client/requests/index.ts
+++ b/src/api/resources/bookings/resources/locationProfiles/client/requests/index.ts
@@ -1 +1 @@
-export { type ListLocationProfilesRequest } from "./ListLocationProfilesRequest";
+export { type ListLocationProfilesRequest } from "./ListLocationProfilesRequest.js";
diff --git a/src/api/resources/bookings/resources/locationProfiles/index.ts b/src/api/resources/bookings/resources/locationProfiles/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/bookings/resources/locationProfiles/index.ts
+++ b/src/api/resources/bookings/resources/locationProfiles/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts b/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts
index b3dcd8fc4..2cc26de37 100644
--- a/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts
+++ b/src/api/resources/bookings/resources/teamMemberProfiles/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../../../serialization/index";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace TeamMemberProfiles {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace TeamMemberProfiles {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace TeamMemberProfiles {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class TeamMemberProfiles {
- constructor(protected readonly _options: TeamMemberProfiles.Options = {}) {}
+ protected readonly _options: TeamMemberProfiles.Options;
+
+ constructor(_options: TeamMemberProfiles.Options = {}) {
+ this._options = _options;
+ }
/**
* Lists booking profiles for team members.
@@ -50,84 +55,85 @@ export class TeamMemberProfiles {
request: Square.bookings.ListTeamMemberProfilesRequest = {},
requestOptions?: TeamMemberProfiles.RequestOptions,
): Promise> {
- const list = async (
- request: Square.bookings.ListTeamMemberProfilesRequest,
- ): Promise => {
- const { bookableOnly, limit, cursor, locationId } = request;
- const _queryParams: Record = {};
- if (bookableOnly !== undefined) {
- _queryParams["bookable_only"] = bookableOnly?.toString() ?? null;
- }
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- if (locationId !== undefined) {
- _queryParams["location_id"] = locationId;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/bookings/team-member-booking-profiles",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListTeamMemberBookingProfilesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.bookings.ListTeamMemberProfilesRequest,
+ ): Promise> => {
+ const { bookable_only: bookableOnly, limit, cursor, location_id: locationId } = request;
+ const _queryParams: Record = {};
+ if (bookableOnly !== undefined) {
+ _queryParams["bookable_only"] = bookableOnly?.toString() ?? null;
+ }
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ if (locationId !== undefined) {
+ _queryParams["location_id"] = locationId;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/bookings/team-member-booking-profiles",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
- });
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListTeamMemberBookingProfilesResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
- });
- case "timeout":
- throw new errors.SquareTimeoutError(
- "Timeout exceeded when calling GET /v2/bookings/team-member-booking-profiles.",
- );
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError(
+ "Timeout exceeded when calling GET /v2/bookings/team-member-booking-profiles.",
+ );
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.teamMemberBookingProfiles ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.team_member_booking_profiles ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
@@ -142,53 +148,53 @@ export class TeamMemberProfiles {
*
* @example
* await client.bookings.teamMemberProfiles.get({
- * teamMemberId: "team_member_id"
+ * team_member_id: "team_member_id"
* })
*/
- public async get(
+ public get(
+ request: Square.bookings.GetTeamMemberProfilesRequest,
+ requestOptions?: TeamMemberProfiles.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
request: Square.bookings.GetTeamMemberProfilesRequest,
requestOptions?: TeamMemberProfiles.RequestOptions,
- ): Promise {
- const { teamMemberId } = request;
+ ): Promise> {
+ const { team_member_id: teamMemberId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/bookings/team-member-booking-profiles/${encodeURIComponent(teamMemberId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetTeamMemberBookingProfileResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.GetTeamMemberBookingProfileResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -197,6 +203,7 @@ export class TeamMemberProfiles {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -205,6 +212,7 @@ export class TeamMemberProfiles {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/client/index.ts b/src/api/resources/bookings/resources/teamMemberProfiles/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/bookings/resources/teamMemberProfiles/client/index.ts
+++ b/src/api/resources/bookings/resources/teamMemberProfiles/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/GetTeamMemberProfilesRequest.ts b/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/GetTeamMemberProfilesRequest.ts
index 8c0e22128..827207556 100644
--- a/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/GetTeamMemberProfilesRequest.ts
+++ b/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/GetTeamMemberProfilesRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * teamMemberId: "team_member_id"
+ * team_member_id: "team_member_id"
* }
*/
export interface GetTeamMemberProfilesRequest {
/**
* The ID of the team member to retrieve.
*/
- teamMemberId: string;
+ team_member_id: string;
}
diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/ListTeamMemberProfilesRequest.ts b/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/ListTeamMemberProfilesRequest.ts
index 126643f74..381143564 100644
--- a/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/ListTeamMemberProfilesRequest.ts
+++ b/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/ListTeamMemberProfilesRequest.ts
@@ -10,7 +10,7 @@ export interface ListTeamMemberProfilesRequest {
/**
* Indicates whether to include only bookable team members in the returned result (`true`) or not (`false`).
*/
- bookableOnly?: boolean | null;
+ bookable_only?: boolean | null;
/**
* The maximum number of results to return in a paged response.
*/
@@ -22,5 +22,5 @@ export interface ListTeamMemberProfilesRequest {
/**
* Indicates whether to include only team members enabled at the given location in the returned result.
*/
- locationId?: string | null;
+ location_id?: string | null;
}
diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/index.ts b/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/index.ts
index 4a2788242..4be4475da 100644
--- a/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/index.ts
+++ b/src/api/resources/bookings/resources/teamMemberProfiles/client/requests/index.ts
@@ -1,2 +1,2 @@
-export { type ListTeamMemberProfilesRequest } from "./ListTeamMemberProfilesRequest";
-export { type GetTeamMemberProfilesRequest } from "./GetTeamMemberProfilesRequest";
+export { type ListTeamMemberProfilesRequest } from "./ListTeamMemberProfilesRequest.js";
+export { type GetTeamMemberProfilesRequest } from "./GetTeamMemberProfilesRequest.js";
diff --git a/src/api/resources/bookings/resources/teamMemberProfiles/index.ts b/src/api/resources/bookings/resources/teamMemberProfiles/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/bookings/resources/teamMemberProfiles/index.ts
+++ b/src/api/resources/bookings/resources/teamMemberProfiles/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/cards/client/Client.ts b/src/api/resources/cards/client/Client.ts
index f9f7ac900..85495185f 100644
--- a/src/api/resources/cards/client/Client.ts
+++ b/src/api/resources/cards/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import * as Square from "../../../index";
-import * as serializers from "../../../../serialization/index";
-import urlJoin from "url-join";
-import * as errors from "../../../../errors/index";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import * as Square from "../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as errors from "../../../../errors/index.js";
export declare namespace Cards {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace Cards {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace Cards {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Cards {
- constructor(protected readonly _options: Cards.Options = {}) {}
+ protected readonly _options: Cards.Options;
+
+ constructor(_options: Cards.Options = {}) {
+ this._options = _options;
+ }
/**
* Retrieves a list of cards owned by the account making the request.
@@ -51,85 +56,86 @@ export class Cards {
request: Square.ListCardsRequest = {},
requestOptions?: Cards.RequestOptions,
): Promise> {
- const list = async (request: Square.ListCardsRequest): Promise => {
- const { cursor, customerId, includeDisabled, referenceId, sortOrder } = request;
- const _queryParams: Record = {};
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- if (customerId !== undefined) {
- _queryParams["customer_id"] = customerId;
- }
- if (includeDisabled !== undefined) {
- _queryParams["include_disabled"] = includeDisabled?.toString() ?? null;
- }
- if (referenceId !== undefined) {
- _queryParams["reference_id"] = referenceId;
- }
- if (sortOrder !== undefined) {
- _queryParams["sort_order"] = serializers.SortOrder.jsonOrThrow(sortOrder, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- });
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/cards",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListCardsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Square.ListCardsRequest): Promise> => {
+ const {
+ cursor,
+ customer_id: customerId,
+ include_disabled: includeDisabled,
+ reference_id: referenceId,
+ sort_order: sortOrder,
+ } = request;
+ const _queryParams: Record = {};
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ if (customerId !== undefined) {
+ _queryParams["customer_id"] = customerId;
+ }
+ if (includeDisabled !== undefined) {
+ _queryParams["include_disabled"] = includeDisabled?.toString() ?? null;
+ }
+ if (referenceId !== undefined) {
+ _queryParams["reference_id"] = referenceId;
+ }
+ if (sortOrder !== undefined) {
+ _queryParams["sort_order"] = sortOrder;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/cards",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
- });
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return { data: _response.body as Square.ListCardsResponse, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
- });
- case "timeout":
- throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/cards.");
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/cards.");
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
getItems: (response) => response?.cards ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
@@ -145,70 +151,66 @@ export class Cards {
*
* @example
* await client.cards.create({
- * idempotencyKey: "4935a656-a929-4792-b97c-8848be85c27c",
- * sourceId: "cnon:uIbfJXhXETSP197M3GB",
+ * idempotency_key: "4935a656-a929-4792-b97c-8848be85c27c",
+ * source_id: "cnon:uIbfJXhXETSP197M3GB",
* card: {
- * cardholderName: "Amelia Earhart",
- * billingAddress: {
- * addressLine1: "500 Electric Ave",
- * addressLine2: "Suite 600",
+ * cardholder_name: "Amelia Earhart",
+ * billing_address: {
+ * address_line_1: "500 Electric Ave",
+ * address_line_2: "Suite 600",
* locality: "New York",
- * administrativeDistrictLevel1: "NY",
- * postalCode: "10003",
+ * administrative_district_level_1: "NY",
+ * postal_code: "10003",
* country: "US"
* },
- * customerId: "VDKXEEKPJN48QDG3BGGFAK05P8",
- * referenceId: "user-id-1"
+ * customer_id: "VDKXEEKPJN48QDG3BGGFAK05P8",
+ * reference_id: "user-id-1"
* }
* })
*/
- public async create(
+ public create(
+ request: Square.CreateCardRequest,
+ requestOptions?: Cards.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
request: Square.CreateCardRequest,
requestOptions?: Cards.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/cards",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.CreateCardRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.CreateCardResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.CreateCardResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -217,12 +219,14 @@ export class Cards {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/cards.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -235,53 +239,50 @@ export class Cards {
*
* @example
* await client.cards.get({
- * cardId: "card_id"
+ * card_id: "card_id"
* })
*/
- public async get(
+ public get(
request: Square.GetCardsRequest,
requestOptions?: Cards.RequestOptions,
- ): Promise {
- const { cardId } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
+ request: Square.GetCardsRequest,
+ requestOptions?: Cards.RequestOptions,
+ ): Promise> {
+ const { card_id: cardId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/cards/${encodeURIComponent(cardId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetCardResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.GetCardResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -290,12 +291,14 @@ export class Cards {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/cards/{card_id}.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -309,53 +312,50 @@ export class Cards {
*
* @example
* await client.cards.disable({
- * cardId: "card_id"
+ * card_id: "card_id"
* })
*/
- public async disable(
+ public disable(
request: Square.DisableCardsRequest,
requestOptions?: Cards.RequestOptions,
- ): Promise {
- const { cardId } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__disable(request, requestOptions));
+ }
+
+ private async __disable(
+ request: Square.DisableCardsRequest,
+ requestOptions?: Cards.RequestOptions,
+ ): Promise> {
+ const { card_id: cardId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/cards/${encodeURIComponent(cardId)}/disable`,
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.DisableCardResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.DisableCardResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -364,12 +364,14 @@ export class Cards {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/cards/{card_id}/disable.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/cards/client/index.ts b/src/api/resources/cards/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/cards/client/index.ts
+++ b/src/api/resources/cards/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/cards/client/requests/CreateCardRequest.ts b/src/api/resources/cards/client/requests/CreateCardRequest.ts
index 54ac6b9bf..81b326622 100644
--- a/src/api/resources/cards/client/requests/CreateCardRequest.ts
+++ b/src/api/resources/cards/client/requests/CreateCardRequest.ts
@@ -2,25 +2,25 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * idempotencyKey: "4935a656-a929-4792-b97c-8848be85c27c",
- * sourceId: "cnon:uIbfJXhXETSP197M3GB",
+ * idempotency_key: "4935a656-a929-4792-b97c-8848be85c27c",
+ * source_id: "cnon:uIbfJXhXETSP197M3GB",
* card: {
- * cardholderName: "Amelia Earhart",
- * billingAddress: {
- * addressLine1: "500 Electric Ave",
- * addressLine2: "Suite 600",
+ * cardholder_name: "Amelia Earhart",
+ * billing_address: {
+ * address_line_1: "500 Electric Ave",
+ * address_line_2: "Suite 600",
* locality: "New York",
- * administrativeDistrictLevel1: "NY",
- * postalCode: "10003",
+ * administrative_district_level_1: "NY",
+ * postal_code: "10003",
* country: "US"
* },
- * customerId: "VDKXEEKPJN48QDG3BGGFAK05P8",
- * referenceId: "user-id-1"
+ * customer_id: "VDKXEEKPJN48QDG3BGGFAK05P8",
+ * reference_id: "user-id-1"
* }
* }
*/
@@ -33,9 +33,9 @@ export interface CreateCardRequest {
*
* See [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information.
*/
- idempotencyKey: string;
+ idempotency_key: string;
/** The ID of the source which represents the card information to be stored. This can be a card nonce or a payment id. */
- sourceId: string;
+ source_id: string;
/**
* 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
@@ -43,7 +43,7 @@ export interface CreateCardRequest {
*
* See the [SCA Overview](https://developer.squareup.com/docs/sca-overview).
*/
- verificationToken?: string;
+ verification_token?: string;
/** Payment details associated with the card to be stored. */
card: Square.Card;
}
diff --git a/src/api/resources/cards/client/requests/DisableCardsRequest.ts b/src/api/resources/cards/client/requests/DisableCardsRequest.ts
index 7a96d92d9..17b7cde26 100644
--- a/src/api/resources/cards/client/requests/DisableCardsRequest.ts
+++ b/src/api/resources/cards/client/requests/DisableCardsRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * cardId: "card_id"
+ * card_id: "card_id"
* }
*/
export interface DisableCardsRequest {
/**
* Unique ID for the desired Card.
*/
- cardId: string;
+ card_id: string;
}
diff --git a/src/api/resources/cards/client/requests/GetCardsRequest.ts b/src/api/resources/cards/client/requests/GetCardsRequest.ts
index c5d067993..c2cfb0e49 100644
--- a/src/api/resources/cards/client/requests/GetCardsRequest.ts
+++ b/src/api/resources/cards/client/requests/GetCardsRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * cardId: "card_id"
+ * card_id: "card_id"
* }
*/
export interface GetCardsRequest {
/**
* Unique ID for the desired Card.
*/
- cardId: string;
+ card_id: string;
}
diff --git a/src/api/resources/cards/client/requests/ListCardsRequest.ts b/src/api/resources/cards/client/requests/ListCardsRequest.ts
index 44df40e49..e2328ad16 100644
--- a/src/api/resources/cards/client/requests/ListCardsRequest.ts
+++ b/src/api/resources/cards/client/requests/ListCardsRequest.ts
@@ -2,7 +2,7 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
@@ -20,19 +20,19 @@ export interface ListCardsRequest {
* Limit results to cards associated with the customer supplied.
* By default, all cards owned by the merchant are returned.
*/
- customerId?: string | null;
+ customer_id?: string | null;
/**
* Includes disabled cards.
* By default, all enabled cards owned by the merchant are returned.
*/
- includeDisabled?: boolean | null;
+ include_disabled?: boolean | null;
/**
* Limit results to cards associated with the reference_id supplied.
*/
- referenceId?: string | null;
+ reference_id?: string | null;
/**
* Sorts the returned list by when the card was created with the specified order.
* This field defaults to ASC.
*/
- sortOrder?: Square.SortOrder | null;
+ sort_order?: Square.SortOrder | null;
}
diff --git a/src/api/resources/cards/client/requests/index.ts b/src/api/resources/cards/client/requests/index.ts
index 5fb9592cd..bc18d5392 100644
--- a/src/api/resources/cards/client/requests/index.ts
+++ b/src/api/resources/cards/client/requests/index.ts
@@ -1,4 +1,4 @@
-export { type ListCardsRequest } from "./ListCardsRequest";
-export { type CreateCardRequest } from "./CreateCardRequest";
-export { type GetCardsRequest } from "./GetCardsRequest";
-export { type DisableCardsRequest } from "./DisableCardsRequest";
+export { type ListCardsRequest } from "./ListCardsRequest.js";
+export { type CreateCardRequest } from "./CreateCardRequest.js";
+export { type GetCardsRequest } from "./GetCardsRequest.js";
+export { type DisableCardsRequest } from "./DisableCardsRequest.js";
diff --git a/src/api/resources/cards/index.ts b/src/api/resources/cards/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/cards/index.ts
+++ b/src/api/resources/cards/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/cashDrawers/client/Client.ts b/src/api/resources/cashDrawers/client/Client.ts
index a549c4509..e3a992fee 100644
--- a/src/api/resources/cashDrawers/client/Client.ts
+++ b/src/api/resources/cashDrawers/client/Client.ts
@@ -2,9 +2,9 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import { Shifts } from "../resources/shifts/client/Client";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import { Shifts } from "../resources/shifts/client/Client.js";
export declare namespace CashDrawers {
export interface Options {
@@ -14,27 +14,19 @@ export declare namespace CashDrawers {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
-
- export interface RequestOptions {
- /** The maximum time to wait for a response in seconds. */
- timeoutInSeconds?: number;
- /** The number of times to retry the request. Defaults to 2. */
- maxRetries?: number;
- /** A hook to abort the request. */
- abortSignal?: AbortSignal;
- /** Override the Square-Version header */
- version?: "2025-07-16";
- /** Additional headers to include in the request. */
- headers?: Record;
- }
}
export class CashDrawers {
+ protected readonly _options: CashDrawers.Options;
protected _shifts: Shifts | undefined;
- constructor(protected readonly _options: CashDrawers.Options = {}) {}
+ constructor(_options: CashDrawers.Options = {}) {
+ this._options = _options;
+ }
public get shifts(): Shifts {
return (this._shifts ??= new Shifts(this._options));
diff --git a/src/api/resources/cashDrawers/index.ts b/src/api/resources/cashDrawers/index.ts
index 33a87f100..9eb1192dc 100644
--- a/src/api/resources/cashDrawers/index.ts
+++ b/src/api/resources/cashDrawers/index.ts
@@ -1,2 +1,2 @@
-export * from "./client";
-export * from "./resources";
+export * from "./client/index.js";
+export * from "./resources/index.js";
diff --git a/src/api/resources/cashDrawers/resources/index.ts b/src/api/resources/cashDrawers/resources/index.ts
index 1e7da9b44..b25892811 100644
--- a/src/api/resources/cashDrawers/resources/index.ts
+++ b/src/api/resources/cashDrawers/resources/index.ts
@@ -1,2 +1,2 @@
-export * as shifts from "./shifts";
-export * from "./shifts/client/requests";
+export * as shifts from "./shifts/index.js";
+export * from "./shifts/client/requests/index.js";
diff --git a/src/api/resources/cashDrawers/resources/shifts/client/Client.ts b/src/api/resources/cashDrawers/resources/shifts/client/Client.ts
index af2d438b4..404bff47c 100644
--- a/src/api/resources/cashDrawers/resources/shifts/client/Client.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import * as serializers from "../../../../../../serialization/index";
-import urlJoin from "url-join";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace Shifts {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace Shifts {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace Shifts {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Shifts {
- constructor(protected readonly _options: Shifts.Options = {}) {}
+ protected readonly _options: Shifts.Options;
+
+ constructor(_options: Shifts.Options = {}) {
+ this._options = _options;
+ }
/**
* Provides the details for all of the cash drawer shifts for a location
@@ -46,96 +51,103 @@ export class Shifts {
*
* @example
* await client.cashDrawers.shifts.list({
- * locationId: "location_id"
+ * location_id: "location_id"
* })
*/
public async list(
request: Square.cashDrawers.ListShiftsRequest,
requestOptions?: Shifts.RequestOptions,
): Promise> {
- const list = async (
- request: Square.cashDrawers.ListShiftsRequest,
- ): Promise => {
- const { locationId, sortOrder, beginTime, endTime, limit, cursor } = request;
- const _queryParams: Record = {};
- _queryParams["location_id"] = locationId;
- if (sortOrder !== undefined) {
- _queryParams["sort_order"] = serializers.SortOrder.jsonOrThrow(sortOrder, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- });
- }
- if (beginTime !== undefined) {
- _queryParams["begin_time"] = beginTime;
- }
- if (endTime !== undefined) {
- _queryParams["end_time"] = endTime;
- }
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/cash-drawers/shifts",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.1",
- "User-Agent": "square/43.0.1",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListCashDrawerShiftsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.cashDrawers.ListShiftsRequest,
+ ): Promise> => {
+ const {
+ location_id: locationId,
+ sort_order: sortOrder,
+ begin_time: beginTime,
+ end_time: endTime,
+ limit,
+ cursor,
+ } = request;
+ const _queryParams: Record = {};
+ _queryParams["location_id"] = locationId;
+ if (sortOrder !== undefined) {
+ _queryParams["sort_order"] = sortOrder;
+ }
+ if (beginTime !== undefined) {
+ _queryParams["begin_time"] = beginTime;
+ }
+ if (endTime !== undefined) {
+ _queryParams["end_time"] = endTime;
+ }
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/cash-drawers/shifts",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListCashDrawerShiftsResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
- });
- case "timeout":
- throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/cash-drawers/shifts.");
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError(
+ "Timeout exceeded when calling GET /v2/cash-drawers/shifts.",
+ );
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.cashDrawerShifts ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.cash_drawer_shifts ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
@@ -151,57 +163,54 @@ export class Shifts {
*
* @example
* await client.cashDrawers.shifts.get({
- * shiftId: "shift_id",
- * locationId: "location_id"
+ * shift_id: "shift_id",
+ * location_id: "location_id"
* })
*/
- public async get(
+ public get(
request: Square.cashDrawers.GetShiftsRequest,
requestOptions?: Shifts.RequestOptions,
- ): Promise {
- const { shiftId, locationId } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
+ request: Square.cashDrawers.GetShiftsRequest,
+ requestOptions?: Shifts.RequestOptions,
+ ): Promise> {
+ const { shift_id: shiftId, location_id: locationId } = request;
const _queryParams: Record = {};
_queryParams["location_id"] = locationId;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/cash-drawers/shifts/${encodeURIComponent(shiftId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
queryParameters: _queryParams,
- requestType: "json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetCashDrawerShiftResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.GetCashDrawerShiftResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -210,6 +219,7 @@ export class Shifts {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -218,6 +228,7 @@ export class Shifts {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -230,87 +241,88 @@ export class Shifts {
*
* @example
* await client.cashDrawers.shifts.listEvents({
- * shiftId: "shift_id",
- * locationId: "location_id"
+ * shift_id: "shift_id",
+ * location_id: "location_id"
* })
*/
public async listEvents(
request: Square.cashDrawers.ListEventsShiftsRequest,
requestOptions?: Shifts.RequestOptions,
): Promise> {
- const list = async (
- request: Square.cashDrawers.ListEventsShiftsRequest,
- ): Promise => {
- const { shiftId, locationId, limit, cursor } = request;
- const _queryParams: Record = {};
- _queryParams["location_id"] = locationId;
- if (limit !== undefined) {
- _queryParams["limit"] = limit?.toString() ?? null;
- }
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- `v2/cash-drawers/shifts/${encodeURIComponent(shiftId)}/events`,
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListCashDrawerShiftEventsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Square.cashDrawers.ListEventsShiftsRequest,
+ ): Promise> => {
+ const { shift_id: shiftId, location_id: locationId, limit, cursor } = request;
+ const _queryParams: Record = {};
+ _queryParams["location_id"] = locationId;
+ if (limit !== undefined) {
+ _queryParams["limit"] = limit?.toString() ?? null;
+ }
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ `v2/cash-drawers/shifts/${encodeURIComponent(shiftId)}/events`,
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
- });
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return {
+ data: _response.body as Square.ListCashDrawerShiftEventsResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- case "timeout":
- throw new errors.SquareTimeoutError(
- "Timeout exceeded when calling GET /v2/cash-drawers/shifts/{shift_id}/events.",
- );
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
- });
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError(
+ "Timeout exceeded when calling GET /v2/cash-drawers/shifts/{shift_id}/events.",
+ );
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
- getItems: (response) => response?.cashDrawerShiftEvents ?? [],
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
+ getItems: (response) => response?.cash_drawer_shift_events ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
},
diff --git a/src/api/resources/cashDrawers/resources/shifts/client/index.ts b/src/api/resources/cashDrawers/resources/shifts/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/cashDrawers/resources/shifts/client/index.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/cashDrawers/resources/shifts/client/requests/GetShiftsRequest.ts b/src/api/resources/cashDrawers/resources/shifts/client/requests/GetShiftsRequest.ts
index 3f84d4aac..8e194555e 100644
--- a/src/api/resources/cashDrawers/resources/shifts/client/requests/GetShiftsRequest.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/client/requests/GetShiftsRequest.ts
@@ -5,17 +5,17 @@
/**
* @example
* {
- * shiftId: "shift_id",
- * locationId: "location_id"
+ * shift_id: "shift_id",
+ * location_id: "location_id"
* }
*/
export interface GetShiftsRequest {
/**
* The shift ID.
*/
- shiftId: string;
+ shift_id: string;
/**
* The ID of the location to retrieve cash drawer shifts from.
*/
- locationId: string;
+ location_id: string;
}
diff --git a/src/api/resources/cashDrawers/resources/shifts/client/requests/ListEventsShiftsRequest.ts b/src/api/resources/cashDrawers/resources/shifts/client/requests/ListEventsShiftsRequest.ts
index 33d092715..04767719f 100644
--- a/src/api/resources/cashDrawers/resources/shifts/client/requests/ListEventsShiftsRequest.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/client/requests/ListEventsShiftsRequest.ts
@@ -5,19 +5,19 @@
/**
* @example
* {
- * shiftId: "shift_id",
- * locationId: "location_id"
+ * shift_id: "shift_id",
+ * location_id: "location_id"
* }
*/
export interface ListEventsShiftsRequest {
/**
* The shift ID.
*/
- shiftId: string;
+ shift_id: string;
/**
* The ID of the location to list cash drawer shifts for.
*/
- locationId: string;
+ location_id: string;
/**
* Number of resources to be returned in a page of results (200 by
* default, 1000 max).
diff --git a/src/api/resources/cashDrawers/resources/shifts/client/requests/ListShiftsRequest.ts b/src/api/resources/cashDrawers/resources/shifts/client/requests/ListShiftsRequest.ts
index a7ef994f1..f4d219867 100644
--- a/src/api/resources/cashDrawers/resources/shifts/client/requests/ListShiftsRequest.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/client/requests/ListShiftsRequest.ts
@@ -2,32 +2,32 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
- * locationId: "location_id"
+ * location_id: "location_id"
* }
*/
export interface ListShiftsRequest {
/**
* The ID of the location to query for a list of cash drawer shifts.
*/
- locationId: string;
+ location_id: string;
/**
* The order in which cash drawer shifts are listed in the response,
* based on their opened_at field. Default value: ASC
*/
- sortOrder?: Square.SortOrder | null;
+ sort_order?: Square.SortOrder | null;
/**
* The inclusive start time of the query on opened_at, in ISO 8601 format.
*/
- beginTime?: string | null;
+ begin_time?: string | null;
/**
* The exclusive end date of the query on opened_at, in ISO 8601 format.
*/
- endTime?: string | null;
+ end_time?: string | null;
/**
* Number of cash drawer shift events in a page of results (200 by
* default, 1000 max).
diff --git a/src/api/resources/cashDrawers/resources/shifts/client/requests/index.ts b/src/api/resources/cashDrawers/resources/shifts/client/requests/index.ts
index c69b4133d..97ce5aedb 100644
--- a/src/api/resources/cashDrawers/resources/shifts/client/requests/index.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/client/requests/index.ts
@@ -1,3 +1,3 @@
-export { type ListShiftsRequest } from "./ListShiftsRequest";
-export { type GetShiftsRequest } from "./GetShiftsRequest";
-export { type ListEventsShiftsRequest } from "./ListEventsShiftsRequest";
+export { type ListShiftsRequest } from "./ListShiftsRequest.js";
+export { type GetShiftsRequest } from "./GetShiftsRequest.js";
+export { type ListEventsShiftsRequest } from "./ListEventsShiftsRequest.js";
diff --git a/src/api/resources/cashDrawers/resources/shifts/index.ts b/src/api/resources/cashDrawers/resources/shifts/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/cashDrawers/resources/shifts/index.ts
+++ b/src/api/resources/cashDrawers/resources/shifts/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/catalog/client/Client.ts b/src/api/resources/catalog/client/Client.ts
index 986b1e086..2c13d3e9f 100644
--- a/src/api/resources/catalog/client/Client.ts
+++ b/src/api/resources/catalog/client/Client.ts
@@ -2,14 +2,13 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import * as Square from "../../../index";
-import * as serializers from "../../../../serialization/index";
-import urlJoin from "url-join";
-import * as errors from "../../../../errors/index";
-import { Images } from "../resources/images/client/Client";
-import { Object_ } from "../resources/object/client/Client";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import * as Square from "../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as errors from "../../../../errors/index.js";
+import { Images } from "../resources/images/client/Client.js";
+import { Object_ } from "../resources/object/client/Client.js";
export declare namespace Catalog {
export interface Options {
@@ -19,6 +18,8 @@ export declare namespace Catalog {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -32,15 +33,18 @@ export declare namespace Catalog {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Catalog {
+ protected readonly _options: Catalog.Options;
protected _images: Images | undefined;
protected _object: Object_ | undefined;
- constructor(protected readonly _options: Catalog.Options = {}) {}
+ constructor(_options: Catalog.Options = {}) {
+ this._options = _options;
+ }
public get images(): Images {
return (this._images ??= new Images(this._options));
@@ -71,56 +75,55 @@ export class Catalog {
*
* @example
* await client.catalog.batchDelete({
- * objectIds: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"]
+ * object_ids: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"]
* })
*/
- public async batchDelete(
+ public batchDelete(
+ request: Square.BatchDeleteCatalogObjectsRequest,
+ requestOptions?: Catalog.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__batchDelete(request, requestOptions));
+ }
+
+ private async __batchDelete(
request: Square.BatchDeleteCatalogObjectsRequest,
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/batch-delete",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.BatchDeleteCatalogObjectsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BatchDeleteCatalogObjectsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.BatchDeleteCatalogObjectsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -129,12 +132,14 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/catalog/batch-delete.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -152,57 +157,56 @@ export class Catalog {
*
* @example
* await client.catalog.batchGet({
- * objectIds: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
- * includeRelatedObjects: true
+ * object_ids: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
+ * include_related_objects: true
* })
*/
- public async batchGet(
+ public batchGet(
request: Square.BatchGetCatalogObjectsRequest,
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__batchGet(request, requestOptions));
+ }
+
+ private async __batchGet(
+ request: Square.BatchGetCatalogObjectsRequest,
+ requestOptions?: Catalog.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/batch-retrieve",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.BatchGetCatalogObjectsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BatchGetCatalogObjectsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.BatchGetCatalogObjectsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -211,12 +215,14 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/catalog/batch-retrieve.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -241,7 +247,7 @@ export class Catalog {
*
* @example
* await client.catalog.batchUpsert({
- * idempotencyKey: "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
+ * idempotency_key: "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
* batches: [{
* objects: [{
* type: "ITEM",
@@ -259,53 +265,52 @@ export class Catalog {
* }]
* })
*/
- public async batchUpsert(
+ public batchUpsert(
request: Square.BatchUpsertCatalogObjectsRequest,
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__batchUpsert(request, requestOptions));
+ }
+
+ private async __batchUpsert(
+ request: Square.BatchUpsertCatalogObjectsRequest,
+ requestOptions?: Catalog.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/batch-upsert",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.BatchUpsertCatalogObjectsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.BatchUpsertCatalogObjectsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.BatchUpsertCatalogObjectsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -314,12 +319,14 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/catalog/batch-upsert.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -333,46 +340,42 @@ export class Catalog {
* @example
* await client.catalog.info()
*/
- public async info(requestOptions?: Catalog.RequestOptions): Promise {
+ public info(requestOptions?: Catalog.RequestOptions): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__info(requestOptions));
+ }
+
+ private async __info(
+ requestOptions?: Catalog.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/info",
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.CatalogInfoResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.CatalogInfoResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -381,12 +384,14 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/catalog/info.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -411,76 +416,74 @@ export class Catalog {
request: Square.ListCatalogRequest = {},
requestOptions?: Catalog.RequestOptions,
): Promise> {
- const list = async (request: Square.ListCatalogRequest): Promise => {
- const { cursor, types, catalogVersion } = request;
- const _queryParams: Record = {};
- if (cursor !== undefined) {
- _queryParams["cursor"] = cursor;
- }
- if (types !== undefined) {
- _queryParams["types"] = types;
- }
- if (catalogVersion !== undefined) {
- _queryParams["catalog_version"] = catalogVersion?.toString() ?? null;
- }
- const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
- (await core.Supplier.get(this._options.baseUrl)) ??
- (await core.Supplier.get(this._options.environment)) ??
- environments.SquareEnvironment.Production,
- "v2/catalog/list",
- ),
- method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- queryParameters: _queryParams,
- requestType: "json",
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
- maxRetries: requestOptions?.maxRetries,
- abortSignal: requestOptions?.abortSignal,
- });
- if (_response.ok) {
- return serializers.ListCatalogResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
- }
- if (_response.error.reason === "status-code") {
- throw new errors.SquareError({
- statusCode: _response.error.statusCode,
- body: _response.error.body,
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Square.ListCatalogRequest): Promise> => {
+ const { cursor, types, catalog_version: catalogVersion } = request;
+ const _queryParams: Record = {};
+ if (cursor !== undefined) {
+ _queryParams["cursor"] = cursor;
+ }
+ if (types !== undefined) {
+ _queryParams["types"] = types;
+ }
+ if (catalogVersion !== undefined) {
+ _queryParams["catalog_version"] = catalogVersion?.toString() ?? null;
+ }
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.SquareEnvironment.Production,
+ "v2/catalog/list",
+ ),
+ method: "GET",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
+ queryParameters: _queryParams,
+ timeoutMs:
+ requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
+ maxRetries: requestOptions?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
});
- }
- switch (_response.error.reason) {
- case "non-json":
+ if (_response.ok) {
+ return { data: _response.body as Square.ListCatalogResponse, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
- body: _response.error.rawBody,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
- case "timeout":
- throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/catalog/list.");
- case "unknown":
- throw new errors.SquareError({
- message: _response.error.errorMessage,
- });
- }
- };
+ }
+ switch (_response.error.reason) {
+ case "non-json":
+ throw new errors.SquareError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
+ });
+ case "timeout":
+ throw new errors.SquareTimeoutError("Timeout exceeded when calling GET /v2/catalog/list.");
+ case "unknown":
+ throw new errors.SquareError({
+ message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
return new core.Pageable({
- response: await list(request),
- hasNextPage: (response) => response?.cursor != null,
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.cursor != null && !(typeof response?.cursor === "string" && response?.cursor === ""),
getItems: (response) => response?.objects ?? [],
loadPage: (response) => {
return list(core.setObjectProperty(request, "cursor", response?.cursor));
@@ -505,63 +508,59 @@ export class Catalog {
*
* @example
* await client.catalog.search({
- * objectTypes: ["ITEM"],
+ * object_types: ["ITEM"],
* query: {
- * prefixQuery: {
- * attributeName: "name",
- * attributePrefix: "tea"
+ * prefix_query: {
+ * attribute_name: "name",
+ * attribute_prefix: "tea"
* }
* },
* limit: 100
* })
*/
- public async search(
+ public search(
request: Square.SearchCatalogObjectsRequest = {},
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__search(request, requestOptions));
+ }
+
+ private async __search(
+ request: Square.SearchCatalogObjectsRequest = {},
+ requestOptions?: Catalog.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/search",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.SearchCatalogObjectsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.SearchCatalogObjectsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.SearchCatalogObjectsResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -570,12 +569,14 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/catalog/search.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -597,77 +598,73 @@ export class Catalog {
*
* @example
* await client.catalog.searchItems({
- * textFilter: "red",
- * categoryIds: ["WINE_CATEGORY_ID"],
- * stockLevels: ["OUT", "LOW"],
- * enabledLocationIds: ["ATL_LOCATION_ID"],
+ * text_filter: "red",
+ * category_ids: ["WINE_CATEGORY_ID"],
+ * stock_levels: ["OUT", "LOW"],
+ * enabled_location_ids: ["ATL_LOCATION_ID"],
* limit: 100,
- * sortOrder: "ASC",
- * productTypes: ["REGULAR"],
- * customAttributeFilters: [{
- * customAttributeDefinitionId: "VEGAN_DEFINITION_ID",
- * boolFilter: true
+ * sort_order: "ASC",
+ * product_types: ["REGULAR"],
+ * custom_attribute_filters: [{
+ * custom_attribute_definition_id: "VEGAN_DEFINITION_ID",
+ * bool_filter: true
* }, {
- * customAttributeDefinitionId: "BRAND_DEFINITION_ID",
- * stringFilter: "Dark Horse"
+ * custom_attribute_definition_id: "BRAND_DEFINITION_ID",
+ * string_filter: "Dark Horse"
* }, {
* key: "VINTAGE",
- * numberFilter: {
+ * number_filter: {
* min: "min",
* max: "max"
* }
* }, {
- * customAttributeDefinitionId: "VARIETAL_DEFINITION_ID"
+ * custom_attribute_definition_id: "VARIETAL_DEFINITION_ID"
* }]
* })
*/
- public async searchItems(
+ public searchItems(
request: Square.SearchCatalogItemsRequest = {},
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__searchItems(request, requestOptions));
+ }
+
+ private async __searchItems(
+ request: Square.SearchCatalogItemsRequest = {},
+ requestOptions?: Catalog.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/search-catalog-items",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.SearchCatalogItemsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.SearchCatalogItemsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.SearchCatalogItemsResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -676,6 +673,7 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -684,6 +682,7 @@ export class Catalog {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -698,58 +697,57 @@ export class Catalog {
*
* @example
* await client.catalog.updateItemModifierLists({
- * itemIds: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- * modifierListsToEnable: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- * modifierListsToDisable: ["7WRC16CJZDVLSNDQ35PP6YAD"]
+ * item_ids: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ * modifier_lists_to_enable: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ * modifier_lists_to_disable: ["7WRC16CJZDVLSNDQ35PP6YAD"]
* })
*/
- public async updateItemModifierLists(
+ public updateItemModifierLists(
request: Square.UpdateItemModifierListsRequest,
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__updateItemModifierLists(request, requestOptions));
+ }
+
+ private async __updateItemModifierLists(
+ request: Square.UpdateItemModifierListsRequest,
+ requestOptions?: Catalog.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/update-item-modifier-lists",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.UpdateItemModifierListsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateItemModifierListsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.UpdateItemModifierListsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -758,6 +756,7 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -766,6 +765,7 @@ export class Catalog {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -780,58 +780,54 @@ export class Catalog {
*
* @example
* await client.catalog.updateItemTaxes({
- * itemIds: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- * taxesToEnable: ["4WRCNHCJZDVLSNDQ35PP6YAD"],
- * taxesToDisable: ["AQCEGCEBBQONINDOHRGZISEX"]
+ * item_ids: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ * taxes_to_enable: ["4WRCNHCJZDVLSNDQ35PP6YAD"],
+ * taxes_to_disable: ["AQCEGCEBBQONINDOHRGZISEX"]
* })
*/
- public async updateItemTaxes(
+ public updateItemTaxes(
+ request: Square.UpdateItemTaxesRequest,
+ requestOptions?: Catalog.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__updateItemTaxes(request, requestOptions));
+ }
+
+ private async __updateItemTaxes(
request: Square.UpdateItemTaxesRequest,
requestOptions?: Catalog.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/update-item-taxes",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.UpdateItemTaxesRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateItemTaxesResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.UpdateItemTaxesResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -840,6 +836,7 @@ export class Catalog {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -848,6 +845,7 @@ export class Catalog {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/catalog/client/index.ts b/src/api/resources/catalog/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/catalog/client/index.ts
+++ b/src/api/resources/catalog/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/catalog/client/requests/BatchDeleteCatalogObjectsRequest.ts b/src/api/resources/catalog/client/requests/BatchDeleteCatalogObjectsRequest.ts
index 5928375f6..5ddbec808 100644
--- a/src/api/resources/catalog/client/requests/BatchDeleteCatalogObjectsRequest.ts
+++ b/src/api/resources/catalog/client/requests/BatchDeleteCatalogObjectsRequest.ts
@@ -5,7 +5,7 @@
/**
* @example
* {
- * objectIds: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"]
+ * object_ids: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"]
* }
*/
export interface BatchDeleteCatalogObjectsRequest {
@@ -14,5 +14,5 @@ export interface BatchDeleteCatalogObjectsRequest {
* in the graph that depend on that object will be deleted as well (for example, deleting a
* CatalogItem will delete its CatalogItemVariation.
*/
- objectIds: string[];
+ object_ids: string[];
}
diff --git a/src/api/resources/catalog/client/requests/BatchGetCatalogObjectsRequest.ts b/src/api/resources/catalog/client/requests/BatchGetCatalogObjectsRequest.ts
index be6a46943..768c28253 100644
--- a/src/api/resources/catalog/client/requests/BatchGetCatalogObjectsRequest.ts
+++ b/src/api/resources/catalog/client/requests/BatchGetCatalogObjectsRequest.ts
@@ -5,13 +5,13 @@
/**
* @example
* {
- * objectIds: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
- * includeRelatedObjects: true
+ * object_ids: ["W62UWFY35CWMYGVWK6TWJDNI", "AA27W3M2GGTF3H6AVPNB77CK"],
+ * include_related_objects: true
* }
*/
export interface BatchGetCatalogObjectsRequest {
/** The IDs of the CatalogObjects to be retrieved. */
- objectIds: string[];
+ object_ids: string[];
/**
* 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
@@ -28,21 +28,21 @@ export interface BatchGetCatalogObjectsRequest {
*
* Default value: `false`
*/
- includeRelatedObjects?: boolean | null;
+ include_related_objects?: boolean | null;
/**
* 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.
*/
- catalogVersion?: bigint | null;
+ catalog_version?: (number | bigint) | null;
/** Indicates whether to include (`true`) or not (`false`) in the response deleted objects, namely, those with the `is_deleted` attribute set to `true`. */
- includeDeletedObjects?: boolean | null;
+ include_deleted_objects?: boolean | null;
/**
* 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.
*/
- includeCategoryPathToRoot?: boolean | null;
+ include_category_path_to_root?: boolean | null;
}
diff --git a/src/api/resources/catalog/client/requests/BatchUpsertCatalogObjectsRequest.ts b/src/api/resources/catalog/client/requests/BatchUpsertCatalogObjectsRequest.ts
index 07bb27415..c25ac8606 100644
--- a/src/api/resources/catalog/client/requests/BatchUpsertCatalogObjectsRequest.ts
+++ b/src/api/resources/catalog/client/requests/BatchUpsertCatalogObjectsRequest.ts
@@ -2,12 +2,12 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * idempotencyKey: "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
+ * idempotency_key: "789ff020-f723-43a9-b4b5-43b5dc1fa3dc",
* batches: [{
* objects: [{
* type: "ITEM",
@@ -38,7 +38,7 @@ export interface BatchUpsertCatalogObjectsRequest {
*
* See [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information.
*/
- idempotencyKey: string;
+ idempotency_key: string;
/**
* 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
diff --git a/src/api/resources/catalog/client/requests/ListCatalogRequest.ts b/src/api/resources/catalog/client/requests/ListCatalogRequest.ts
index 5a2363cda..e01dbf3e1 100644
--- a/src/api/resources/catalog/client/requests/ListCatalogRequest.ts
+++ b/src/api/resources/catalog/client/requests/ListCatalogRequest.ts
@@ -36,5 +36,5 @@ export interface ListCatalogRequest {
* the [CatalogObject](entity:CatalogObject)s' `version` attribute. If not included, results will be from the
* current version of the catalog.
*/
- catalogVersion?: bigint | null;
+ catalog_version?: (number | bigint) | null;
}
diff --git a/src/api/resources/catalog/client/requests/SearchCatalogItemsRequest.ts b/src/api/resources/catalog/client/requests/SearchCatalogItemsRequest.ts
index 040e6a65f..09d32095e 100644
--- a/src/api/resources/catalog/client/requests/SearchCatalogItemsRequest.ts
+++ b/src/api/resources/catalog/client/requests/SearchCatalogItemsRequest.ts
@@ -2,32 +2,32 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * textFilter: "red",
- * categoryIds: ["WINE_CATEGORY_ID"],
- * stockLevels: ["OUT", "LOW"],
- * enabledLocationIds: ["ATL_LOCATION_ID"],
+ * text_filter: "red",
+ * category_ids: ["WINE_CATEGORY_ID"],
+ * stock_levels: ["OUT", "LOW"],
+ * enabled_location_ids: ["ATL_LOCATION_ID"],
* limit: 100,
- * sortOrder: "ASC",
- * productTypes: ["REGULAR"],
- * customAttributeFilters: [{
- * customAttributeDefinitionId: "VEGAN_DEFINITION_ID",
- * boolFilter: true
+ * sort_order: "ASC",
+ * product_types: ["REGULAR"],
+ * custom_attribute_filters: [{
+ * custom_attribute_definition_id: "VEGAN_DEFINITION_ID",
+ * bool_filter: true
* }, {
- * customAttributeDefinitionId: "BRAND_DEFINITION_ID",
- * stringFilter: "Dark Horse"
+ * custom_attribute_definition_id: "BRAND_DEFINITION_ID",
+ * string_filter: "Dark Horse"
* }, {
* key: "VINTAGE",
- * numberFilter: {
+ * number_filter: {
* min: "min",
* max: "max"
* }
* }, {
- * customAttributeDefinitionId: "VARIETAL_DEFINITION_ID"
+ * custom_attribute_definition_id: "VARIETAL_DEFINITION_ID"
* }]
* }
*/
@@ -37,16 +37,16 @@ export interface SearchCatalogItemsRequest {
* the `name`, `description`, or `abbreviation` attribute value of an item, or in
* the `name`, `sku`, or `upc` attribute value of an item variation.
*/
- textFilter?: string;
+ text_filter?: string;
/** The category id query expression to return items containing the specified category IDs. */
- categoryIds?: string[];
+ category_ids?: string[];
/**
* The stock-level query expression to return item variations with the specified stock levels.
* See [SearchCatalogItemsRequestStockLevel](#type-searchcatalogitemsrequeststocklevel) for possible values
*/
- stockLevels?: Square.SearchCatalogItemsRequestStockLevel[];
+ stock_levels?: Square.SearchCatalogItemsRequestStockLevel[];
/** The enabled-location query expression to return items and item variations having specified enabled locations. */
- enabledLocationIds?: string[];
+ enabled_location_ids?: string[];
/** The pagination token, returned in the previous response, used to fetch the next batch of pending results. */
cursor?: string;
/** The maximum number of results to return per page. The default value is 100. */
@@ -55,15 +55,15 @@ export interface SearchCatalogItemsRequest {
* The order to sort the results by item names. The default sort order is ascending (`ASC`).
* See [SortOrder](#type-sortorder) for possible values
*/
- sortOrder?: Square.SortOrder;
+ sort_order?: Square.SortOrder;
/** The product types query expression to return items or item variations having the specified product types. */
- productTypes?: Square.CatalogItemProductType[];
+ product_types?: Square.CatalogItemProductType[];
/**
* 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.
*/
- customAttributeFilters?: Square.CustomAttributeFilter[];
+ custom_attribute_filters?: Square.CustomAttributeFilter[];
/** The query filter to return not archived (`ARCHIVED_STATE_NOT_ARCHIVED`), archived (`ARCHIVED_STATE_ARCHIVED`), or either type (`ARCHIVED_STATE_ALL`) of items. */
- archivedState?: Square.ArchivedState;
+ archived_state?: Square.ArchivedState;
}
diff --git a/src/api/resources/catalog/client/requests/SearchCatalogObjectsRequest.ts b/src/api/resources/catalog/client/requests/SearchCatalogObjectsRequest.ts
index 93c4054a5..bc40e2bc5 100644
--- a/src/api/resources/catalog/client/requests/SearchCatalogObjectsRequest.ts
+++ b/src/api/resources/catalog/client/requests/SearchCatalogObjectsRequest.ts
@@ -2,16 +2,16 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * objectTypes: ["ITEM"],
+ * object_types: ["ITEM"],
* query: {
- * prefixQuery: {
- * attributeName: "name",
- * attributePrefix: "tea"
+ * prefix_query: {
+ * attribute_name: "name",
+ * attribute_prefix: "tea"
* }
* },
* limit: 100
@@ -39,9 +39,9 @@ export interface SearchCatalogObjectsRequest {
* ITEM_OPTION_VAL, ITEM_VARIATION, or MODIFIER), you must explicitly include all the types of interest
* in this field.
*/
- objectTypes?: Square.CatalogObjectType[];
+ object_types?: Square.CatalogObjectType[];
/** If `true`, deleted objects will be included in the results. Defaults to `false`. Deleted objects will have their `is_deleted` field set to `true`. If `include_deleted_objects` is `true`, then the `include_category_path_to_root` request parameter must be `false`. Both properties cannot be `true` at the same time. */
- includeDeletedObjects?: boolean;
+ include_deleted_objects?: boolean;
/**
* 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
@@ -58,13 +58,13 @@ export interface SearchCatalogObjectsRequest {
*
* Default value: `false`
*/
- includeRelatedObjects?: boolean;
+ include_related_objects?: boolean;
/**
* 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.
*/
- beginTime?: string;
+ begin_time?: string;
/** A query to be used to filter or sort the results. If no query is specified, the entire catalog will be returned. */
query?: Square.CatalogQuery;
/**
@@ -74,5 +74,5 @@ export interface SearchCatalogObjectsRequest {
*/
limit?: number;
/** Specifies whether or not to include the `path_to_root` list for each returned category instance. The `path_to_root` list consists of `CategoryPathToRootNode` objects and specifies the path that starts with the immediate parent category of the returned category and ends with its root category. If the returned category is a top-level category, the `path_to_root` list is empty and is not returned in the response payload. If `include_category_path_to_root` is `true`, then the `include_deleted_objects` request parameter must be `false`. Both properties cannot be `true` at the same time. */
- includeCategoryPathToRoot?: boolean;
+ include_category_path_to_root?: boolean;
}
diff --git a/src/api/resources/catalog/client/requests/UpdateItemModifierListsRequest.ts b/src/api/resources/catalog/client/requests/UpdateItemModifierListsRequest.ts
index 993504615..2ace2816f 100644
--- a/src/api/resources/catalog/client/requests/UpdateItemModifierListsRequest.ts
+++ b/src/api/resources/catalog/client/requests/UpdateItemModifierListsRequest.ts
@@ -5,22 +5,22 @@
/**
* @example
* {
- * itemIds: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- * modifierListsToEnable: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- * modifierListsToDisable: ["7WRC16CJZDVLSNDQ35PP6YAD"]
+ * item_ids: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ * modifier_lists_to_enable: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ * modifier_lists_to_disable: ["7WRC16CJZDVLSNDQ35PP6YAD"]
* }
*/
export interface UpdateItemModifierListsRequest {
/** The IDs of the catalog items associated with the CatalogModifierList objects being updated. */
- itemIds: string[];
+ item_ids: string[];
/**
* 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.
*/
- modifierListsToEnable?: string[] | null;
+ modifier_lists_to_enable?: string[] | null;
/**
* 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.
*/
- modifierListsToDisable?: string[] | null;
+ modifier_lists_to_disable?: string[] | null;
}
diff --git a/src/api/resources/catalog/client/requests/UpdateItemTaxesRequest.ts b/src/api/resources/catalog/client/requests/UpdateItemTaxesRequest.ts
index 45b6420c6..6c3e3d378 100644
--- a/src/api/resources/catalog/client/requests/UpdateItemTaxesRequest.ts
+++ b/src/api/resources/catalog/client/requests/UpdateItemTaxesRequest.ts
@@ -5,9 +5,9 @@
/**
* @example
* {
- * itemIds: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
- * taxesToEnable: ["4WRCNHCJZDVLSNDQ35PP6YAD"],
- * taxesToDisable: ["AQCEGCEBBQONINDOHRGZISEX"]
+ * item_ids: ["H42BRLUJ5KTZTTMPVSLFAACQ", "2JXOBJIHCWBQ4NZ3RIXQGJA6"],
+ * taxes_to_enable: ["4WRCNHCJZDVLSNDQ35PP6YAD"],
+ * taxes_to_disable: ["AQCEGCEBBQONINDOHRGZISEX"]
* }
*/
export interface UpdateItemTaxesRequest {
@@ -15,15 +15,15 @@ export interface UpdateItemTaxesRequest {
* IDs for the CatalogItems associated with the CatalogTax objects being updated.
* No more than 1,000 IDs may be provided.
*/
- itemIds: string[];
+ item_ids: string[];
/**
* IDs of the CatalogTax objects to enable.
* At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
*/
- taxesToEnable?: string[] | null;
+ taxes_to_enable?: string[] | null;
/**
* IDs of the CatalogTax objects to disable.
* At least one of `taxes_to_enable` or `taxes_to_disable` must be specified.
*/
- taxesToDisable?: string[] | null;
+ taxes_to_disable?: string[] | null;
}
diff --git a/src/api/resources/catalog/client/requests/index.ts b/src/api/resources/catalog/client/requests/index.ts
index 14d4621a0..8c050113c 100644
--- a/src/api/resources/catalog/client/requests/index.ts
+++ b/src/api/resources/catalog/client/requests/index.ts
@@ -1,8 +1,8 @@
-export { type BatchDeleteCatalogObjectsRequest } from "./BatchDeleteCatalogObjectsRequest";
-export { type BatchGetCatalogObjectsRequest } from "./BatchGetCatalogObjectsRequest";
-export { type BatchUpsertCatalogObjectsRequest } from "./BatchUpsertCatalogObjectsRequest";
-export { type ListCatalogRequest } from "./ListCatalogRequest";
-export { type SearchCatalogObjectsRequest } from "./SearchCatalogObjectsRequest";
-export { type SearchCatalogItemsRequest } from "./SearchCatalogItemsRequest";
-export { type UpdateItemModifierListsRequest } from "./UpdateItemModifierListsRequest";
-export { type UpdateItemTaxesRequest } from "./UpdateItemTaxesRequest";
+export { type BatchDeleteCatalogObjectsRequest } from "./BatchDeleteCatalogObjectsRequest.js";
+export { type BatchGetCatalogObjectsRequest } from "./BatchGetCatalogObjectsRequest.js";
+export { type BatchUpsertCatalogObjectsRequest } from "./BatchUpsertCatalogObjectsRequest.js";
+export { type ListCatalogRequest } from "./ListCatalogRequest.js";
+export { type SearchCatalogObjectsRequest } from "./SearchCatalogObjectsRequest.js";
+export { type SearchCatalogItemsRequest } from "./SearchCatalogItemsRequest.js";
+export { type UpdateItemModifierListsRequest } from "./UpdateItemModifierListsRequest.js";
+export { type UpdateItemTaxesRequest } from "./UpdateItemTaxesRequest.js";
diff --git a/src/api/resources/catalog/index.ts b/src/api/resources/catalog/index.ts
index 33a87f100..9eb1192dc 100644
--- a/src/api/resources/catalog/index.ts
+++ b/src/api/resources/catalog/index.ts
@@ -1,2 +1,2 @@
-export * from "./client";
-export * from "./resources";
+export * from "./client/index.js";
+export * from "./resources/index.js";
diff --git a/src/api/resources/catalog/resources/images/client/Client.ts b/src/api/resources/catalog/resources/images/client/Client.ts
index a27a056eb..3c762eb33 100644
--- a/src/api/resources/catalog/resources/images/client/Client.ts
+++ b/src/api/resources/catalog/resources/images/client/Client.ts
@@ -2,13 +2,12 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import * as serializers from "../../../../../../serialization/index";
-import { toJson } from "../../../../../../core/json";
-import urlJoin from "url-join";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { toJson } from "../../../../../../core/json.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace Images {
export interface Options {
@@ -18,6 +17,8 @@ export declare namespace Images {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -31,12 +32,16 @@ export declare namespace Images {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Images {
- constructor(protected readonly _options: Images.Options = {}) {}
+ protected readonly _options: Images.Options;
+
+ constructor(_options: Images.Options = {}) {
+ this._options = _options;
+ }
/**
* Uploads an image file to be represented by a [CatalogImage](entity:CatalogImage) object that can be linked to an existing
@@ -52,48 +57,44 @@ export class Images {
* @example
* await client.catalog.images.create({})
*/
- public async create(
+ public create(
request: Square.catalog.CreateImagesRequest,
requestOptions?: Images.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Square.catalog.CreateImagesRequest,
+ requestOptions?: Images.RequestOptions,
+ ): Promise> {
const _request = await core.newFormData();
if (request.request != null) {
- _request.append(
- "request",
- toJson(
- serializers.CreateCatalogImageRequest.jsonOrThrow(request.request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
- ),
- );
+ _request.append("request", toJson(request.request));
}
- if (request.imageFile != null) {
- await _request.appendFile("image_file", request.imageFile);
+ if (request.image_file != null) {
+ await _request.appendFile("image_file", request.image_file);
}
const _maybeEncodedRequest = await _request.getRequest();
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/images",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ..._maybeEncodedRequest.headers,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ ..._maybeEncodedRequest.headers,
+ }),
+ requestOptions?.headers,
+ ),
requestType: "file",
duplex: _maybeEncodedRequest.duplex,
body: _maybeEncodedRequest.body,
@@ -102,19 +103,14 @@ export class Images {
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.CreateCatalogImageResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.CreateCatalogImageResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -123,12 +119,14 @@ export class Images {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/catalog/images.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -144,51 +142,47 @@ export class Images {
*
* @example
* await client.catalog.images.update({
- * imageId: "image_id"
+ * image_id: "image_id"
* })
*/
- public async update(
+ public update(
request: Square.catalog.UpdateImagesRequest,
requestOptions?: Images.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
+ request: Square.catalog.UpdateImagesRequest,
+ requestOptions?: Images.RequestOptions,
+ ): Promise> {
const _request = await core.newFormData();
if (request.request != null) {
- _request.append(
- "request",
- toJson(
- serializers.UpdateCatalogImageRequest.jsonOrThrow(request.request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
- ),
- );
+ _request.append("request", toJson(request.request));
}
- if (request.imageFile != null) {
- await _request.appendFile("image_file", request.imageFile);
+ if (request.image_file != null) {
+ await _request.appendFile("image_file", request.image_file);
}
const _maybeEncodedRequest = await _request.getRequest();
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
- `v2/catalog/images/${encodeURIComponent(request.imageId)}`,
+ `v2/catalog/images/${encodeURIComponent(request.image_id)}`,
),
method: "PUT",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ..._maybeEncodedRequest.headers,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ ..._maybeEncodedRequest.headers,
+ }),
+ requestOptions?.headers,
+ ),
requestType: "file",
duplex: _maybeEncodedRequest.duplex,
body: _maybeEncodedRequest.body,
@@ -197,19 +191,14 @@ export class Images {
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateCatalogImageResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.UpdateCatalogImageResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -218,12 +207,14 @@ export class Images {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling PUT /v2/catalog/images/{image_id}.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/catalog/resources/images/client/index.ts b/src/api/resources/catalog/resources/images/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/catalog/resources/images/client/index.ts
+++ b/src/api/resources/catalog/resources/images/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/catalog/resources/images/client/requests/CreateImagesRequest.ts b/src/api/resources/catalog/resources/images/client/requests/CreateImagesRequest.ts
index 50d490319..cd0d4feea 100644
--- a/src/api/resources/catalog/resources/images/client/requests/CreateImagesRequest.ts
+++ b/src/api/resources/catalog/resources/images/client/requests/CreateImagesRequest.ts
@@ -2,8 +2,8 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
-import * as fs from "fs";
+import * as Square from "../../../../../../index.js";
+import * as core from "../../../../../../../core/index.js";
/**
* @example
@@ -11,5 +11,5 @@ import * as fs from "fs";
*/
export interface CreateImagesRequest {
request?: Square.CreateCatalogImageRequest;
- imageFile?: File | fs.ReadStream | Blob | undefined;
+ image_file?: core.FileLike | undefined;
}
diff --git a/src/api/resources/catalog/resources/images/client/requests/UpdateImagesRequest.ts b/src/api/resources/catalog/resources/images/client/requests/UpdateImagesRequest.ts
index ad56e6e59..46442d80b 100644
--- a/src/api/resources/catalog/resources/images/client/requests/UpdateImagesRequest.ts
+++ b/src/api/resources/catalog/resources/images/client/requests/UpdateImagesRequest.ts
@@ -2,20 +2,20 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
-import * as fs from "fs";
+import * as Square from "../../../../../../index.js";
+import * as core from "../../../../../../../core/index.js";
/**
* @example
* {
- * imageId: "image_id"
+ * image_id: "image_id"
* }
*/
export interface UpdateImagesRequest {
/**
* The ID of the `CatalogImage` object to update the encapsulated image file.
*/
- imageId: string;
+ image_id: string;
request?: Square.UpdateCatalogImageRequest;
- imageFile?: File | fs.ReadStream | Blob | undefined;
+ image_file?: core.FileLike | undefined;
}
diff --git a/src/api/resources/catalog/resources/images/client/requests/index.ts b/src/api/resources/catalog/resources/images/client/requests/index.ts
index ebbd407bb..e3a2f79d5 100644
--- a/src/api/resources/catalog/resources/images/client/requests/index.ts
+++ b/src/api/resources/catalog/resources/images/client/requests/index.ts
@@ -1,2 +1,2 @@
-export { type CreateImagesRequest } from "./CreateImagesRequest";
-export { type UpdateImagesRequest } from "./UpdateImagesRequest";
+export { type CreateImagesRequest } from "./CreateImagesRequest.js";
+export { type UpdateImagesRequest } from "./UpdateImagesRequest.js";
diff --git a/src/api/resources/catalog/resources/images/index.ts b/src/api/resources/catalog/resources/images/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/catalog/resources/images/index.ts
+++ b/src/api/resources/catalog/resources/images/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/catalog/resources/index.ts b/src/api/resources/catalog/resources/index.ts
index cbcd61155..c2a292860 100644
--- a/src/api/resources/catalog/resources/index.ts
+++ b/src/api/resources/catalog/resources/index.ts
@@ -1,4 +1,4 @@
-export * as images from "./images";
-export * as object from "./object";
-export * from "./images/client/requests";
-export * from "./object/client/requests";
+export * as images from "./images/index.js";
+export * as object from "./object/index.js";
+export * from "./images/client/requests/index.js";
+export * from "./object/client/requests/index.js";
diff --git a/src/api/resources/catalog/resources/object/client/Client.ts b/src/api/resources/catalog/resources/object/client/Client.ts
index 8b793b5b3..6fe55c90c 100644
--- a/src/api/resources/catalog/resources/object/client/Client.ts
+++ b/src/api/resources/catalog/resources/object/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import * as serializers from "../../../../../../serialization/index";
-import urlJoin from "url-join";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace Object_ {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace Object_ {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace Object_ {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Object_ {
- constructor(protected readonly _options: Object_.Options = {}) {}
+ protected readonly _options: Object_.Options;
+
+ constructor(_options: Object_.Options = {}) {
+ this._options = _options;
+ }
/**
* Creates a new or updates the specified [CatalogObject](entity:CatalogObject).
@@ -49,60 +54,56 @@ export class Object_ {
*
* @example
* await client.catalog.object.upsert({
- * idempotencyKey: "af3d1afc-7212-4300-b463-0bfc5314a5ae",
+ * idempotency_key: "af3d1afc-7212-4300-b463-0bfc5314a5ae",
* object: {
* type: "ITEM",
* id: "id"
* }
* })
*/
- public async upsert(
+ public upsert(
+ request: Square.catalog.UpsertCatalogObjectRequest,
+ requestOptions?: Object_.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__upsert(request, requestOptions));
+ }
+
+ private async __upsert(
request: Square.catalog.UpsertCatalogObjectRequest,
requestOptions?: Object_.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/catalog/object",
),
method: "POST",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.catalog.UpsertCatalogObjectRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpsertCatalogObjectResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.UpsertCatalogObjectResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -111,12 +112,14 @@ export class Object_ {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError("Timeout exceeded when calling POST /v2/catalog/object.");
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -135,14 +138,26 @@ export class Object_ {
*
* @example
* await client.catalog.object.get({
- * objectId: "object_id"
+ * object_id: "object_id"
* })
*/
- public async get(
+ public get(
+ request: Square.catalog.GetObjectRequest,
+ requestOptions?: Object_.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
+ }
+
+ private async __get(
request: Square.catalog.GetObjectRequest,
requestOptions?: Object_.RequestOptions,
- ): Promise {
- const { objectId, includeRelatedObjects, catalogVersion, includeCategoryPathToRoot } = request;
+ ): Promise> {
+ const {
+ object_id: objectId,
+ include_related_objects: includeRelatedObjects,
+ catalog_version: catalogVersion,
+ include_category_path_to_root: includeCategoryPathToRoot,
+ } = request;
const _queryParams: Record = {};
if (includeRelatedObjects !== undefined) {
_queryParams["include_related_objects"] = includeRelatedObjects?.toString() ?? null;
@@ -157,45 +172,35 @@ export class Object_ {
}
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/catalog/object/${encodeURIComponent(objectId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
queryParameters: _queryParams,
- requestType: "json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.GetCatalogObjectResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.GetCatalogObjectResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -204,6 +209,7 @@ export class Object_ {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -212,6 +218,7 @@ export class Object_ {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -233,53 +240,50 @@ export class Object_ {
*
* @example
* await client.catalog.object.delete({
- * objectId: "object_id"
+ * object_id: "object_id"
* })
*/
- public async delete(
+ public delete(
+ request: Square.catalog.DeleteObjectRequest,
+ requestOptions?: Object_.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
+ }
+
+ private async __delete(
request: Square.catalog.DeleteObjectRequest,
requestOptions?: Object_.RequestOptions,
- ): Promise {
- const { objectId } = request;
+ ): Promise> {
+ const { object_id: objectId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/catalog/object/${encodeURIComponent(objectId)}`,
),
method: "DELETE",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.DeleteCatalogObjectResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return { data: _response.body as Square.DeleteCatalogObjectResponse, rawResponse: _response.rawResponse };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -288,6 +292,7 @@ export class Object_ {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -296,6 +301,7 @@ export class Object_ {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/catalog/resources/object/client/index.ts b/src/api/resources/catalog/resources/object/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/catalog/resources/object/client/index.ts
+++ b/src/api/resources/catalog/resources/object/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/catalog/resources/object/client/requests/DeleteObjectRequest.ts b/src/api/resources/catalog/resources/object/client/requests/DeleteObjectRequest.ts
index 5553a8a35..d71ccb4ae 100644
--- a/src/api/resources/catalog/resources/object/client/requests/DeleteObjectRequest.ts
+++ b/src/api/resources/catalog/resources/object/client/requests/DeleteObjectRequest.ts
@@ -5,7 +5,7 @@
/**
* @example
* {
- * objectId: "object_id"
+ * object_id: "object_id"
* }
*/
export interface DeleteObjectRequest {
@@ -14,5 +14,5 @@ export interface DeleteObjectRequest {
* 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).
*/
- objectId: string;
+ object_id: string;
}
diff --git a/src/api/resources/catalog/resources/object/client/requests/GetObjectRequest.ts b/src/api/resources/catalog/resources/object/client/requests/GetObjectRequest.ts
index 0a008fb87..f01afff42 100644
--- a/src/api/resources/catalog/resources/object/client/requests/GetObjectRequest.ts
+++ b/src/api/resources/catalog/resources/object/client/requests/GetObjectRequest.ts
@@ -5,14 +5,14 @@
/**
* @example
* {
- * objectId: "object_id"
+ * object_id: "object_id"
* }
*/
export interface GetObjectRequest {
/**
* The object ID of any type of catalog objects to be retrieved.
*/
- objectId: string;
+ object_id: string;
/**
* 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
@@ -29,19 +29,19 @@ export interface GetObjectRequest {
*
* Default value: `false`
*/
- includeRelatedObjects?: boolean | null;
+ include_related_objects?: boolean | null;
/**
* 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.
*/
- catalogVersion?: bigint | null;
+ catalog_version?: (number | bigint) | null;
/**
* 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.
*/
- includeCategoryPathToRoot?: boolean | null;
+ include_category_path_to_root?: boolean | null;
}
diff --git a/src/api/resources/catalog/resources/object/client/requests/UpsertCatalogObjectRequest.ts b/src/api/resources/catalog/resources/object/client/requests/UpsertCatalogObjectRequest.ts
index 071efb170..109517a60 100644
--- a/src/api/resources/catalog/resources/object/client/requests/UpsertCatalogObjectRequest.ts
+++ b/src/api/resources/catalog/resources/object/client/requests/UpsertCatalogObjectRequest.ts
@@ -2,12 +2,12 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../../../index";
+import * as Square from "../../../../../../index.js";
/**
* @example
* {
- * idempotencyKey: "af3d1afc-7212-4300-b463-0bfc5314a5ae",
+ * idempotency_key: "af3d1afc-7212-4300-b463-0bfc5314a5ae",
* object: {
* type: "ITEM",
* id: "id"
@@ -27,7 +27,7 @@ export interface UpsertCatalogObjectRequest {
*
* See [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information.
*/
- idempotencyKey: string;
+ idempotency_key: string;
/**
* A CatalogObject to be created or updated.
*
diff --git a/src/api/resources/catalog/resources/object/client/requests/index.ts b/src/api/resources/catalog/resources/object/client/requests/index.ts
index a974f1464..602348e3f 100644
--- a/src/api/resources/catalog/resources/object/client/requests/index.ts
+++ b/src/api/resources/catalog/resources/object/client/requests/index.ts
@@ -1,3 +1,3 @@
-export { type UpsertCatalogObjectRequest } from "./UpsertCatalogObjectRequest";
-export { type GetObjectRequest } from "./GetObjectRequest";
-export { type DeleteObjectRequest } from "./DeleteObjectRequest";
+export { type UpsertCatalogObjectRequest } from "./UpsertCatalogObjectRequest.js";
+export { type GetObjectRequest } from "./GetObjectRequest.js";
+export { type DeleteObjectRequest } from "./DeleteObjectRequest.js";
diff --git a/src/api/resources/catalog/resources/object/index.ts b/src/api/resources/catalog/resources/object/index.ts
index 5ec76921e..914b8c3c7 100644
--- a/src/api/resources/catalog/resources/object/index.ts
+++ b/src/api/resources/catalog/resources/object/index.ts
@@ -1 +1 @@
-export * from "./client";
+export * from "./client/index.js";
diff --git a/src/api/resources/checkout/client/Client.ts b/src/api/resources/checkout/client/Client.ts
index a086a1357..efa15be93 100644
--- a/src/api/resources/checkout/client/Client.ts
+++ b/src/api/resources/checkout/client/Client.ts
@@ -2,13 +2,12 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../environments";
-import * as core from "../../../../core";
-import * as Square from "../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../serialization/index";
-import * as errors from "../../../../errors/index";
-import { PaymentLinks } from "../resources/paymentLinks/client/Client";
+import * as environments from "../../../../environments.js";
+import * as core from "../../../../core/index.js";
+import * as Square from "../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as errors from "../../../../errors/index.js";
+import { PaymentLinks } from "../resources/paymentLinks/client/Client.js";
export declare namespace Checkout {
export interface Options {
@@ -18,6 +17,8 @@ export declare namespace Checkout {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -31,14 +32,17 @@ export declare namespace Checkout {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record | undefined>;
}
}
export class Checkout {
+ protected readonly _options: Checkout.Options;
protected _paymentLinks: PaymentLinks | undefined;
- constructor(protected readonly _options: Checkout.Options = {}) {}
+ constructor(_options: Checkout.Options = {}) {
+ this._options = _options;
+ }
public get paymentLinks(): PaymentLinks {
return (this._paymentLinks ??= new PaymentLinks(this._options));
@@ -52,53 +56,53 @@ export class Checkout {
*
* @example
* await client.checkout.retrieveLocationSettings({
- * locationId: "location_id"
+ * location_id: "location_id"
* })
*/
- public async retrieveLocationSettings(
+ public retrieveLocationSettings(
request: Square.RetrieveLocationSettingsRequest,
requestOptions?: Checkout.RequestOptions,
- ): Promise {
- const { locationId } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__retrieveLocationSettings(request, requestOptions));
+ }
+
+ private async __retrieveLocationSettings(
+ request: Square.RetrieveLocationSettingsRequest,
+ requestOptions?: Checkout.RequestOptions,
+ ): Promise> {
+ const { location_id: locationId } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/online-checkout/location-settings/${encodeURIComponent(locationId)}`,
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.RetrieveLocationSettingsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.RetrieveLocationSettingsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -107,6 +111,7 @@ export class Checkout {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -115,6 +120,7 @@ export class Checkout {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -127,58 +133,57 @@ export class Checkout {
*
* @example
* await client.checkout.updateLocationSettings({
- * locationId: "location_id",
- * locationSettings: {}
+ * location_id: "location_id",
+ * location_settings: {}
* })
*/
- public async updateLocationSettings(
+ public updateLocationSettings(
request: Square.UpdateLocationSettingsRequest,
requestOptions?: Checkout.RequestOptions,
- ): Promise {
- const { locationId, ..._body } = request;
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__updateLocationSettings(request, requestOptions));
+ }
+
+ private async __updateLocationSettings(
+ request: Square.UpdateLocationSettingsRequest,
+ requestOptions?: Checkout.RequestOptions,
+ ): Promise> {
+ const { location_id: locationId, ..._body } = request;
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
`v2/online-checkout/location-settings/${encodeURIComponent(locationId)}`,
),
method: "PUT",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.UpdateLocationSettingsRequest.jsonOrThrow(_body, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: _body,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateLocationSettingsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.UpdateLocationSettingsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -187,6 +192,7 @@ export class Checkout {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -195,6 +201,7 @@ export class Checkout {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -207,48 +214,47 @@ export class Checkout {
* @example
* await client.checkout.retrieveMerchantSettings()
*/
- public async retrieveMerchantSettings(
+ public retrieveMerchantSettings(
+ requestOptions?: Checkout.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__retrieveMerchantSettings(requestOptions));
+ }
+
+ private async __retrieveMerchantSettings(
requestOptions?: Checkout.RequestOptions,
- ): Promise {
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/online-checkout/merchant-settings",
),
method: "GET",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
- contentType: "application/json",
- requestType: "json",
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.RetrieveMerchantSettingsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.RetrieveMerchantSettingsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -257,6 +263,7 @@ export class Checkout {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -265,6 +272,7 @@ export class Checkout {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
@@ -277,56 +285,55 @@ export class Checkout {
*
* @example
* await client.checkout.updateMerchantSettings({
- * merchantSettings: {}
+ * merchant_settings: {}
* })
*/
- public async updateMerchantSettings(
+ public updateMerchantSettings(
request: Square.UpdateMerchantSettingsRequest,
requestOptions?: Checkout.RequestOptions,
- ): Promise {
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__updateMerchantSettings(request, requestOptions));
+ }
+
+ private async __updateMerchantSettings(
+ request: Square.UpdateMerchantSettingsRequest,
+ requestOptions?: Checkout.RequestOptions,
+ ): Promise> {
const _response = await (this._options.fetcher ?? core.fetcher)({
- url: urlJoin(
+ url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
(await core.Supplier.get(this._options.environment)) ??
environments.SquareEnvironment.Production,
"v2/online-checkout/merchant-settings",
),
method: "PUT",
- headers: {
- Authorization: await this._getAuthorizationHeader(),
- "Square-Version": requestOptions?.version ?? this._options?.version ?? "2025-07-16",
- "X-Fern-Language": "JavaScript",
- "X-Fern-SDK-Name": "square",
- "X-Fern-SDK-Version": "43.0.0",
- "User-Agent": "square/43.0.0",
- "X-Fern-Runtime": core.RUNTIME.type,
- "X-Fern-Runtime-Version": core.RUNTIME.version,
- ...requestOptions?.headers,
- },
+ headers: mergeHeaders(
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Authorization: await this._getAuthorizationHeader(),
+ "Square-Version": requestOptions?.version ?? "2025-07-16",
+ }),
+ requestOptions?.headers,
+ ),
contentType: "application/json",
requestType: "json",
- body: serializers.UpdateMerchantSettingsRequest.jsonOrThrow(request, {
- unrecognizedObjectKeys: "strip",
- omitUndefined: true,
- }),
+ body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
- return serializers.UpdateMerchantSettingsResponse.parseOrThrow(_response.body, {
- unrecognizedObjectKeys: "passthrough",
- allowUnrecognizedUnionMembers: true,
- allowUnrecognizedEnumValues: true,
- skipValidation: true,
- breadcrumbsPrefix: ["response"],
- });
+ return {
+ data: _response.body as Square.UpdateMerchantSettingsResponse,
+ rawResponse: _response.rawResponse,
+ };
}
if (_response.error.reason === "status-code") {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.body,
+ rawResponse: _response.rawResponse,
});
}
@@ -335,6 +342,7 @@ export class Checkout {
throw new errors.SquareError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
+ rawResponse: _response.rawResponse,
});
case "timeout":
throw new errors.SquareTimeoutError(
@@ -343,6 +351,7 @@ export class Checkout {
case "unknown":
throw new errors.SquareError({
message: _response.error.errorMessage,
+ rawResponse: _response.rawResponse,
});
}
}
diff --git a/src/api/resources/checkout/client/index.ts b/src/api/resources/checkout/client/index.ts
index 415726b7f..82648c6ff 100644
--- a/src/api/resources/checkout/client/index.ts
+++ b/src/api/resources/checkout/client/index.ts
@@ -1 +1,2 @@
-export * from "./requests";
+export {};
+export * from "./requests/index.js";
diff --git a/src/api/resources/checkout/client/requests/RetrieveLocationSettingsRequest.ts b/src/api/resources/checkout/client/requests/RetrieveLocationSettingsRequest.ts
index 71ce84a90..71d9cec1b 100644
--- a/src/api/resources/checkout/client/requests/RetrieveLocationSettingsRequest.ts
+++ b/src/api/resources/checkout/client/requests/RetrieveLocationSettingsRequest.ts
@@ -5,12 +5,12 @@
/**
* @example
* {
- * locationId: "location_id"
+ * location_id: "location_id"
* }
*/
export interface RetrieveLocationSettingsRequest {
/**
* The ID of the location for which to retrieve settings.
*/
- locationId: string;
+ location_id: string;
}
diff --git a/src/api/resources/checkout/client/requests/UpdateLocationSettingsRequest.ts b/src/api/resources/checkout/client/requests/UpdateLocationSettingsRequest.ts
index e94cf5f0c..9e34e2906 100644
--- a/src/api/resources/checkout/client/requests/UpdateLocationSettingsRequest.ts
+++ b/src/api/resources/checkout/client/requests/UpdateLocationSettingsRequest.ts
@@ -2,20 +2,20 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * locationId: "location_id",
- * locationSettings: {}
+ * location_id: "location_id",
+ * location_settings: {}
* }
*/
export interface UpdateLocationSettingsRequest {
/**
* The ID of the location for which to retrieve settings.
*/
- locationId: string;
+ location_id: string;
/** Describe your updates using the `location_settings` object. Make sure it contains only the fields that have changed. */
- locationSettings: Square.CheckoutLocationSettings;
+ location_settings: Square.CheckoutLocationSettings;
}
diff --git a/src/api/resources/checkout/client/requests/UpdateMerchantSettingsRequest.ts b/src/api/resources/checkout/client/requests/UpdateMerchantSettingsRequest.ts
index d46b43bda..ef9fd8211 100644
--- a/src/api/resources/checkout/client/requests/UpdateMerchantSettingsRequest.ts
+++ b/src/api/resources/checkout/client/requests/UpdateMerchantSettingsRequest.ts
@@ -2,15 +2,15 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as Square from "../../../../index";
+import * as Square from "../../../../index.js";
/**
* @example
* {
- * merchantSettings: {}
+ * merchant_settings: {}
* }
*/
export interface UpdateMerchantSettingsRequest {
/** Describe your updates using the `merchant_settings` object. Make sure it contains only the fields that have changed. */
- merchantSettings: Square.CheckoutMerchantSettings;
+ merchant_settings: Square.CheckoutMerchantSettings;
}
diff --git a/src/api/resources/checkout/client/requests/index.ts b/src/api/resources/checkout/client/requests/index.ts
index ff86d69a5..e97196d8b 100644
--- a/src/api/resources/checkout/client/requests/index.ts
+++ b/src/api/resources/checkout/client/requests/index.ts
@@ -1,3 +1,3 @@
-export { type RetrieveLocationSettingsRequest } from "./RetrieveLocationSettingsRequest";
-export { type UpdateLocationSettingsRequest } from "./UpdateLocationSettingsRequest";
-export { type UpdateMerchantSettingsRequest } from "./UpdateMerchantSettingsRequest";
+export { type RetrieveLocationSettingsRequest } from "./RetrieveLocationSettingsRequest.js";
+export { type UpdateLocationSettingsRequest } from "./UpdateLocationSettingsRequest.js";
+export { type UpdateMerchantSettingsRequest } from "./UpdateMerchantSettingsRequest.js";
diff --git a/src/api/resources/checkout/index.ts b/src/api/resources/checkout/index.ts
index 33a87f100..9eb1192dc 100644
--- a/src/api/resources/checkout/index.ts
+++ b/src/api/resources/checkout/index.ts
@@ -1,2 +1,2 @@
-export * from "./client";
-export * from "./resources";
+export * from "./client/index.js";
+export * from "./resources/index.js";
diff --git a/src/api/resources/checkout/resources/index.ts b/src/api/resources/checkout/resources/index.ts
index 5f3efa0d0..3784c0dd1 100644
--- a/src/api/resources/checkout/resources/index.ts
+++ b/src/api/resources/checkout/resources/index.ts
@@ -1,2 +1,2 @@
-export * as paymentLinks from "./paymentLinks";
-export * from "./paymentLinks/client/requests";
+export * as paymentLinks from "./paymentLinks/index.js";
+export * from "./paymentLinks/client/requests/index.js";
diff --git a/src/api/resources/checkout/resources/paymentLinks/client/Client.ts b/src/api/resources/checkout/resources/paymentLinks/client/Client.ts
index 8d018551b..6918d26ed 100644
--- a/src/api/resources/checkout/resources/paymentLinks/client/Client.ts
+++ b/src/api/resources/checkout/resources/paymentLinks/client/Client.ts
@@ -2,12 +2,11 @@
* This file was auto-generated by Fern from our API Definition.
*/
-import * as environments from "../../../../../../environments";
-import * as core from "../../../../../../core";
-import * as Square from "../../../../../index";
-import urlJoin from "url-join";
-import * as serializers from "../../../../../../serialization/index";
-import * as errors from "../../../../../../errors/index";
+import * as environments from "../../../../../../environments.js";
+import * as core from "../../../../../../core/index.js";
+import * as Square from "../../../../../index.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
+import * as errors from "../../../../../../errors/index.js";
export declare namespace PaymentLinks {
export interface Options {
@@ -17,6 +16,8 @@ export declare namespace PaymentLinks {
token?: core.Supplier;
/** Override the Square-Version header */
version?: "2025-07-16";
+ /** Additional headers to include in requests. */
+ headers?: Record | undefined>;
fetcher?: core.FetchFunction;
}
@@ -30,12 +31,16 @@ export declare namespace PaymentLinks {
/** Override the Square-Version header */
version?: "2025-07-16";
/** Additional headers to include in the request. */
- headers?: Record;
+ headers?: Record