square-connect
Version:
JavaScript client library for the Square Connect v2 API
487 lines (411 loc) • 17.8 kB
JavaScript
/**
* Square Connect API
* Client library for accessing the Square Connect APIs
*
* OpenAPI spec version: 2.0
* Contact: developers@squareup.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.3.0-SNAPSHOT
*
*/
var ApiClient = require('../ApiClient');
var CancelBookingRequest = require('../model/CancelBookingRequest');
var CancelBookingResponse = require('../model/CancelBookingResponse');
var CreateBookingRequest = require('../model/CreateBookingRequest');
var CreateBookingResponse = require('../model/CreateBookingResponse');
var ListTeamMemberBookingProfilesResponse = require('../model/ListTeamMemberBookingProfilesResponse');
var RetrieveBookingResponse = require('../model/RetrieveBookingResponse');
var RetrieveBusinessBookingProfileResponse = require('../model/RetrieveBusinessBookingProfileResponse');
var RetrieveTeamMemberBookingProfileResponse = require('../model/RetrieveTeamMemberBookingProfileResponse');
var SearchAvailabilityRequest = require('../model/SearchAvailabilityRequest');
var SearchAvailabilityResponse = require('../model/SearchAvailabilityResponse');
var UpdateBookingRequest = require('../model/UpdateBookingRequest');
var UpdateBookingResponse = require('../model/UpdateBookingResponse');
/**
* Bookings service.
* @module api/BookingsApi
*/
/**
* Constructs a new BookingsApi.
* @alias module:api/BookingsApi
* @class
* @param {module:ApiClient} apiClient Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
module.exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* CancelBooking
* Note: This endpoint is in beta.
* Cancels an existing booking.
* @param {String} bookingId The ID of the `Booking` object representing the to-be-cancelled booking.
* @param {module:model/CancelBookingRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CancelBookingResponse} and HTTP response
*/
this.cancelBookingWithHttpInfo = function(bookingId, body) {
var postBody = body;
// verify the required parameter 'bookingId' is set
if (bookingId === undefined || bookingId === null) {
throw new Error("Missing the required parameter 'bookingId' when calling cancelBooking");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling cancelBooking");
}
var pathParams = {
'booking_id': bookingId
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = CancelBookingResponse;
return this.apiClient.callApi(
'/v2/bookings/{booking_id}/cancel', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* CancelBooking
* Cancels an existing booking.
* @param {String} bookingId The ID of the `Booking` object representing the to-be-cancelled booking.
* @param {module:model/CancelBookingRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CancelBookingResponse}
*/
this.cancelBooking = function(bookingId, body) {
return this.cancelBookingWithHttpInfo(bookingId, body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* CreateBooking
* Note: This endpoint is in beta.
* Creates a booking.
* @param {module:model/CreateBookingRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CreateBookingResponse} and HTTP response
*/
this.createBookingWithHttpInfo = function(body) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling createBooking");
}
var pathParams = {
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = CreateBookingResponse;
return this.apiClient.callApi(
'/v2/bookings', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* CreateBooking
* Creates a booking.
* @param {module:model/CreateBookingRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CreateBookingResponse}
*/
this.createBooking = function(body) {
return this.createBookingWithHttpInfo(body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* ListTeamMemberBookingProfiles
* Note: This endpoint is in beta.
* Lists booking profiles for team members.
* @param {Object} opts Optional parameters
* @param {Boolean} opts.bookableOnly Indicates whether to include only bookable team members in the returned result (`true`) or not (`false`).
* @param {Number} opts.limit The maximum number of results to return.
* @param {String} opts.cursor The cursor for paginating through the results.
* @param {String} opts.locationId Indicates whether to include only team members enabled at the given location in the returned result.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListTeamMemberBookingProfilesResponse} and HTTP response
*/
this.listTeamMemberBookingProfilesWithHttpInfo = function(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'bookable_only': opts['bookableOnly'],
'limit': opts['limit'],
'cursor': opts['cursor'],
'location_id': opts['locationId']
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = ListTeamMemberBookingProfilesResponse;
return this.apiClient.callApi(
'/v2/bookings/team-member-booking-profiles', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* ListTeamMemberBookingProfiles
* Lists booking profiles for team members.
* @param {Object} opts Optional parameters
* @param {Boolean} opts.bookableOnly Indicates whether to include only bookable team members in the returned result (`true`) or not (`false`).
* @param {Number} opts.limit The maximum number of results to return.
* @param {String} opts.cursor The cursor for paginating through the results.
* @param {String} opts.locationId Indicates whether to include only team members enabled at the given location in the returned result.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListTeamMemberBookingProfilesResponse}
*/
this.listTeamMemberBookingProfiles = function(opts) {
return this.listTeamMemberBookingProfilesWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* RetrieveBooking
* Note: This endpoint is in beta.
* Retrieves a booking.
* @param {String} bookingId The ID of the `Booking` object representing the to-be-retrieved booking.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/RetrieveBookingResponse} and HTTP response
*/
this.retrieveBookingWithHttpInfo = function(bookingId) {
var postBody = null;
// verify the required parameter 'bookingId' is set
if (bookingId === undefined || bookingId === null) {
throw new Error("Missing the required parameter 'bookingId' when calling retrieveBooking");
}
var pathParams = {
'booking_id': bookingId
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = RetrieveBookingResponse;
return this.apiClient.callApi(
'/v2/bookings/{booking_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* RetrieveBooking
* Retrieves a booking.
* @param {String} bookingId The ID of the `Booking` object representing the to-be-retrieved booking.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/RetrieveBookingResponse}
*/
this.retrieveBooking = function(bookingId) {
return this.retrieveBookingWithHttpInfo(bookingId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* RetrieveBusinessBookingProfile
* Note: This endpoint is in beta.
* Retrieves a seller's booking profile.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/RetrieveBusinessBookingProfileResponse} and HTTP response
*/
this.retrieveBusinessBookingProfileWithHttpInfo = function() {
var postBody = null;
var pathParams = {
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = RetrieveBusinessBookingProfileResponse;
return this.apiClient.callApi(
'/v2/bookings/business-booking-profile', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* RetrieveBusinessBookingProfile
* Retrieves a seller's booking profile.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/RetrieveBusinessBookingProfileResponse}
*/
this.retrieveBusinessBookingProfile = function() {
return this.retrieveBusinessBookingProfileWithHttpInfo()
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* RetrieveTeamMemberBookingProfile
* Note: This endpoint is in beta.
* Retrieves a team member's booking profile.
* @param {String} teamMemberId The ID of the team member to retrieve.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/RetrieveTeamMemberBookingProfileResponse} and HTTP response
*/
this.retrieveTeamMemberBookingProfileWithHttpInfo = function(teamMemberId) {
var postBody = null;
// verify the required parameter 'teamMemberId' is set
if (teamMemberId === undefined || teamMemberId === null) {
throw new Error("Missing the required parameter 'teamMemberId' when calling retrieveTeamMemberBookingProfile");
}
var pathParams = {
'team_member_id': teamMemberId
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = RetrieveTeamMemberBookingProfileResponse;
return this.apiClient.callApi(
'/v2/bookings/team-member-booking-profiles/{team_member_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* RetrieveTeamMemberBookingProfile
* Retrieves a team member's booking profile.
* @param {String} teamMemberId The ID of the team member to retrieve.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/RetrieveTeamMemberBookingProfileResponse}
*/
this.retrieveTeamMemberBookingProfile = function(teamMemberId) {
return this.retrieveTeamMemberBookingProfileWithHttpInfo(teamMemberId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* SearchAvailability
* Note: This endpoint is in beta.
* Searches for availabilities for booking.
* @param {module:model/SearchAvailabilityRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SearchAvailabilityResponse} and HTTP response
*/
this.searchAvailabilityWithHttpInfo = function(body) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling searchAvailability");
}
var pathParams = {
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = SearchAvailabilityResponse;
return this.apiClient.callApi(
'/v2/bookings/availability/search', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* SearchAvailability
* Searches for availabilities for booking.
* @param {module:model/SearchAvailabilityRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SearchAvailabilityResponse}
*/
this.searchAvailability = function(body) {
return this.searchAvailabilityWithHttpInfo(body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* UpdateBooking
* Note: This endpoint is in beta.
* Updates a booking.
* @param {String} bookingId The ID of the `Booking` object representing the to-be-updated booking.
* @param {module:model/UpdateBookingRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/UpdateBookingResponse} and HTTP response
*/
this.updateBookingWithHttpInfo = function(bookingId, body) {
var postBody = body;
// verify the required parameter 'bookingId' is set
if (bookingId === undefined || bookingId === null) {
throw new Error("Missing the required parameter 'bookingId' when calling updateBooking");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateBooking");
}
var pathParams = {
'booking_id': bookingId
};
var queryParams = {
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = UpdateBookingResponse;
return this.apiClient.callApi(
'/v2/bookings/{booking_id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* UpdateBooking
* Updates a booking.
* @param {String} bookingId The ID of the `Booking` object representing the to-be-updated booking.
* @param {module:model/UpdateBookingRequest} body An object containing the fields to POST for the request. See the corresponding object definition for field details.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/UpdateBookingResponse}
*/
this.updateBooking = function(bookingId, body) {
return this.updateBookingWithHttpInfo(bookingId, body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
};