Skip to content

Latest commit

 

History

History
579 lines (428 loc) · 22.6 KB

booking-custom-attributes.md

File metadata and controls

579 lines (428 loc) · 22.6 KB

Booking Custom Attributes

const bookingCustomAttributesApi = client.bookingCustomAttributesApi;

Class Name

BookingCustomAttributesApi

Methods

List Booking Custom Attribute Definitions

Get all bookings custom attribute definitions.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_READ for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_READ and APPOINTMENTS_READ for the OAuth scope.

async listBookingCustomAttributeDefinitions(  limit?: number,
  cursor?: string,
requestOptions?: RequestOptions): Promise<ApiResponse<ListBookingCustomAttributeDefinitionsResponse>>

Parameters

Parameter Type Tags Description
limit number | undefined Query, Optional The maximum number of results to return in a single paged response. This limit is advisory.
The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100.
The default value is 20. For more information, see Pagination.
cursor string | undefined Query, Optional The cursor returned in the paged response from the previous call to this endpoint.
Provide this cursor to retrieve the next page of results for your original request.
For more information, see Pagination.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

ListBookingCustomAttributeDefinitionsResponse

Example Usage

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.listBookingCustomAttributeDefinitions();
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Create Booking Custom Attribute Definition

Creates a bookings custom attribute definition.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async createBookingCustomAttributeDefinition(  body: CreateBookingCustomAttributeDefinitionRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<CreateBookingCustomAttributeDefinitionResponse>>

Parameters

Parameter Type Tags Description
body CreateBookingCustomAttributeDefinitionRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

CreateBookingCustomAttributeDefinitionResponse

Example Usage

const body: CreateBookingCustomAttributeDefinitionRequest = {
  customAttributeDefinition: {},
};

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.createBookingCustomAttributeDefinition(body);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Delete Booking Custom Attribute Definition

Deletes a bookings custom attribute definition.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async deleteBookingCustomAttributeDefinition(  key: string,
requestOptions?: RequestOptions): Promise<ApiResponse<DeleteBookingCustomAttributeDefinitionResponse>>

Parameters

Parameter Type Tags Description
key string Template, Required The key of the custom attribute definition to delete.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

DeleteBookingCustomAttributeDefinitionResponse

Example Usage

const key = 'key0';

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.deleteBookingCustomAttributeDefinition(key);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Retrieve Booking Custom Attribute Definition

Retrieves a bookings custom attribute definition.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_READ for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_READ and APPOINTMENTS_READ for the OAuth scope.

async retrieveBookingCustomAttributeDefinition(  key: string,
  version?: number,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveBookingCustomAttributeDefinitionResponse>>

Parameters

Parameter Type Tags Description
key string Template, Required The key of the custom attribute definition to retrieve. If the requesting application
is not the definition owner, you must use the qualified key.
version number | undefined Query, Optional The current version of the custom attribute definition, which is used for strongly consistent
reads to guarantee that you receive the most up-to-date data. When included in the request,
Square returns the specified version or a higher version if one exists. If the specified version
is higher than the current version, Square returns a BAD_REQUEST error.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

RetrieveBookingCustomAttributeDefinitionResponse

Example Usage

const key = 'key0';

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.retrieveBookingCustomAttributeDefinition(key);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Update Booking Custom Attribute Definition

Updates a bookings custom attribute definition.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async updateBookingCustomAttributeDefinition(  key: string,
  body: UpdateBookingCustomAttributeDefinitionRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<UpdateBookingCustomAttributeDefinitionResponse>>

Parameters

Parameter Type Tags Description
key string Template, Required The key of the custom attribute definition to update.
body UpdateBookingCustomAttributeDefinitionRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

UpdateBookingCustomAttributeDefinitionResponse

Example Usage

const key = 'key0';

const body: UpdateBookingCustomAttributeDefinitionRequest = {
  customAttributeDefinition: {},
};

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.updateBookingCustomAttributeDefinition(
  key,
  body
);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Bulk Delete Booking Custom Attributes

Bulk deletes bookings custom attributes.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async bulkDeleteBookingCustomAttributes(  body: BulkDeleteBookingCustomAttributesRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<BulkDeleteBookingCustomAttributesResponse>>

Parameters

Parameter Type Tags Description
body BulkDeleteBookingCustomAttributesRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

BulkDeleteBookingCustomAttributesResponse

Example Usage

const body: BulkDeleteBookingCustomAttributesRequest = {
  values: {
    'key0': {
      bookingId: 'booking_id4',
      key: 'key0',
    },
    'key1': {
      bookingId: 'booking_id4',
      key: 'key0',
    }
  },
};

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.bulkDeleteBookingCustomAttributes(body);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Bulk Upsert Booking Custom Attributes

Bulk upserts bookings custom attributes.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async bulkUpsertBookingCustomAttributes(  body: BulkUpsertBookingCustomAttributesRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<BulkUpsertBookingCustomAttributesResponse>>

Parameters

Parameter Type Tags Description
body BulkUpsertBookingCustomAttributesRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

BulkUpsertBookingCustomAttributesResponse

Example Usage

const body: BulkUpsertBookingCustomAttributesRequest = {
  values: {
    'key0': {
      bookingId: 'booking_id4',
      customAttribute: {},
    },
    'key1': {
      bookingId: 'booking_id4',
      customAttribute: {},
    }
  },
};

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.bulkUpsertBookingCustomAttributes(body);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

List Booking Custom Attributes

Lists a booking's custom attributes.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_READ for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_READ and APPOINTMENTS_READ for the OAuth scope.

async listBookingCustomAttributes(  bookingId: string,
  limit?: number,
  cursor?: string,
  withDefinitions?: boolean,
requestOptions?: RequestOptions): Promise<ApiResponse<ListBookingCustomAttributesResponse>>

Parameters

Parameter Type Tags Description
bookingId string Template, Required The ID of the target booking.
limit number | undefined Query, Optional The maximum number of results to return in a single paged response. This limit is advisory.
The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100.
The default value is 20. For more information, see Pagination.
cursor string | undefined Query, Optional The cursor returned in the paged response from the previous call to this endpoint.
Provide this cursor to retrieve the next page of results for your original request. For more
information, see Pagination.
withDefinitions boolean | undefined Query, Optional Indicates whether to return the custom attribute definition in the definition field of each
custom attribute. Set this parameter to true to get the name and description of each custom
attribute, information about the data type, or other definition details. The default value is false.
Default: false
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

ListBookingCustomAttributesResponse

Example Usage

const bookingId = 'booking_id4';

const withDefinitions = false;

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.listBookingCustomAttributes(
  bookingId,
  undefined,
  undefined,
  withDefinitions
);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Delete Booking Custom Attribute

Deletes a bookings custom attribute.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async deleteBookingCustomAttribute(  bookingId: string,
  key: string,
requestOptions?: RequestOptions): Promise<ApiResponse<DeleteBookingCustomAttributeResponse>>

Parameters

Parameter Type Tags Description
bookingId string Template, Required The ID of the target booking.
key string Template, Required The key of the custom attribute to delete. This key must match the key of a custom
attribute definition in the Square seller account. If the requesting application is not the
definition owner, you must use the qualified key.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

DeleteBookingCustomAttributeResponse

Example Usage

const bookingId = 'booking_id4';

const key = 'key0';

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.deleteBookingCustomAttribute(
  bookingId,
  key
);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Retrieve Booking Custom Attribute

Retrieves a bookings custom attribute.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_READ for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_READ and APPOINTMENTS_READ for the OAuth scope.

async retrieveBookingCustomAttribute(  bookingId: string,
  key: string,
  withDefinition?: boolean,
  version?: number,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveBookingCustomAttributeResponse>>

Parameters

Parameter Type Tags Description
bookingId string Template, Required The ID of the target booking.
key string Template, Required The key of the custom attribute to retrieve. This key must match the key of a custom
attribute definition in the Square seller account. If the requesting application is not the
definition owner, you must use the qualified key.
withDefinition boolean | undefined Query, Optional Indicates whether to return the custom attribute definition in the definition field of
the custom attribute. Set this parameter to true to get the name and description of the custom
attribute, information about the data type, or other definition details. The default value is false.
Default: false
version number | undefined Query, Optional The current version of the custom attribute, which is used for strongly consistent reads to
guarantee that you receive the most up-to-date data. When included in the request, Square
returns the specified version or a higher version if one exists. If the specified version is
higher than the current version, Square returns a BAD_REQUEST error.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

RetrieveBookingCustomAttributeResponse

Example Usage

const bookingId = 'booking_id4';

const key = 'key0';

const withDefinition = false;

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.retrieveBookingCustomAttribute(
  bookingId,
  key,
  withDefinition
);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Upsert Booking Custom Attribute

Upserts a bookings custom attribute.

To call this endpoint with buyer-level permissions, set APPOINTMENTS_WRITE for the OAuth scope. To call this endpoint with seller-level permissions, set APPOINTMENTS_ALL_WRITE and APPOINTMENTS_WRITE for the OAuth scope.

For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to Appointments Plus or Appointments Premium.

async upsertBookingCustomAttribute(  bookingId: string,
  key: string,
  body: UpsertBookingCustomAttributeRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<UpsertBookingCustomAttributeResponse>>

Parameters

Parameter Type Tags Description
bookingId string Template, Required The ID of the target booking.
key string Template, Required The key of the custom attribute to create or update. This key must match the key of a
custom attribute definition in the Square seller account. If the requesting application is not
the definition owner, you must use the qualified key.
body UpsertBookingCustomAttributeRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

UpsertBookingCustomAttributeResponse

Example Usage

const bookingId = 'booking_id4';

const key = 'key0';

const body: UpsertBookingCustomAttributeRequest = {
  customAttribute: {},
};

try {
  const { result, ...httpResponse } = await bookingCustomAttributesApi.upsertBookingCustomAttribute(
  bookingId,
  key,
  body
);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch (error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}