square-connect
Version:
JavaScript client library for the Square Connect v2 API
937 lines (790 loc) • 37.3 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 CreateBreakTypeRequest = require('../model/CreateBreakTypeRequest');
var CreateBreakTypeResponse = require('../model/CreateBreakTypeResponse');
var CreateShiftRequest = require('../model/CreateShiftRequest');
var CreateShiftResponse = require('../model/CreateShiftResponse');
var DeleteBreakTypeResponse = require('../model/DeleteBreakTypeResponse');
var DeleteShiftResponse = require('../model/DeleteShiftResponse');
var GetBreakTypeResponse = require('../model/GetBreakTypeResponse');
var GetEmployeeWageResponse = require('../model/GetEmployeeWageResponse');
var GetShiftResponse = require('../model/GetShiftResponse');
var GetTeamMemberWageResponse = require('../model/GetTeamMemberWageResponse');
var ListBreakTypesResponse = require('../model/ListBreakTypesResponse');
var ListEmployeeWagesResponse = require('../model/ListEmployeeWagesResponse');
var ListTeamMemberWagesResponse = require('../model/ListTeamMemberWagesResponse');
var ListWorkweekConfigsResponse = require('../model/ListWorkweekConfigsResponse');
var SearchShiftsRequest = require('../model/SearchShiftsRequest');
var SearchShiftsResponse = require('../model/SearchShiftsResponse');
var UpdateBreakTypeRequest = require('../model/UpdateBreakTypeRequest');
var UpdateBreakTypeResponse = require('../model/UpdateBreakTypeResponse');
var UpdateShiftRequest = require('../model/UpdateShiftRequest');
var UpdateShiftResponse = require('../model/UpdateShiftResponse');
var UpdateWorkweekConfigRequest = require('../model/UpdateWorkweekConfigRequest');
var UpdateWorkweekConfigResponse = require('../model/UpdateWorkweekConfigResponse');
/**
* Labor service.
* @module api/LaborApi
*/
/**
* Constructs a new LaborApi.
* @alias module:api/LaborApi
* @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;
/**
* CreateBreakType
* Creates a new `BreakType`. A `BreakType` is a template for creating `Break` objects. You must provide the following values in your request to this endpoint: - `location_id` - `break_name` - `expected_duration` - `is_paid` You can only have 3 `BreakType` instances per location. If you attempt to add a 4th `BreakType` for a location, an `INVALID_REQUEST_ERROR` \"Exceeded limit of 3 breaks per location.\" is returned.
* @param {module:model/CreateBreakTypeRequest} 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/CreateBreakTypeResponse} and HTTP response
*/
this.createBreakTypeWithHttpInfo = 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 createBreakType");
}
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 = CreateBreakTypeResponse;
return this.apiClient.callApi(
'/v2/labor/break-types', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* CreateBreakType
* Creates a new `BreakType`. A `BreakType` is a template for creating `Break` objects. You must provide the following values in your request to this endpoint: - `location_id` - `break_name` - `expected_duration` - `is_paid` You can only have 3 `BreakType` instances per location. If you attempt to add a 4th `BreakType` for a location, an `INVALID_REQUEST_ERROR` \"Exceeded limit of 3 breaks per location.\" is returned.
* @param {module:model/CreateBreakTypeRequest} 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/CreateBreakTypeResponse}
*/
this.createBreakType = function(body) {
return this.createBreakTypeWithHttpInfo(body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* CreateShift
* Creates a new `Shift`. A `Shift` represents a complete work day for a single employee. You must provide the following values in your request to this endpoint: - `location_id` - `employee_id` - `start_at` An attempt to create a new `Shift` can result in a `BAD_REQUEST` error when: - The `status` of the new `Shift` is `OPEN` and the employee has another shift with an `OPEN` status. - The `start_at` date is in the future - the `start_at` or `end_at` overlaps another shift for the same employee - If `Break`s are set in the request, a break `start_at` must not be before the `Shift.start_at`. A break `end_at` must not be after the `Shift.end_at`
* @param {module:model/CreateShiftRequest} 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/CreateShiftResponse} and HTTP response
*/
this.createShiftWithHttpInfo = 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 createShift");
}
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 = CreateShiftResponse;
return this.apiClient.callApi(
'/v2/labor/shifts', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* CreateShift
* Creates a new `Shift`. A `Shift` represents a complete work day for a single employee. You must provide the following values in your request to this endpoint: - `location_id` - `employee_id` - `start_at` An attempt to create a new `Shift` can result in a `BAD_REQUEST` error when: - The `status` of the new `Shift` is `OPEN` and the employee has another shift with an `OPEN` status. - The `start_at` date is in the future - the `start_at` or `end_at` overlaps another shift for the same employee - If `Break`s are set in the request, a break `start_at` must not be before the `Shift.start_at`. A break `end_at` must not be after the `Shift.end_at`
* @param {module:model/CreateShiftRequest} 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/CreateShiftResponse}
*/
this.createShift = function(body) {
return this.createShiftWithHttpInfo(body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* DeleteBreakType
* Deletes an existing `BreakType`. A `BreakType` can be deleted even if it is referenced from a `Shift`.
* @param {String} id UUID for the `BreakType` being deleted.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/DeleteBreakTypeResponse} and HTTP response
*/
this.deleteBreakTypeWithHttpInfo = function(id) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling deleteBreakType");
}
var pathParams = {
'id': id
};
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 = DeleteBreakTypeResponse;
return this.apiClient.callApi(
'/v2/labor/break-types/{id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* DeleteBreakType
* Deletes an existing `BreakType`. A `BreakType` can be deleted even if it is referenced from a `Shift`.
* @param {String} id UUID for the `BreakType` being deleted.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/DeleteBreakTypeResponse}
*/
this.deleteBreakType = function(id) {
return this.deleteBreakTypeWithHttpInfo(id)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* DeleteShift
* Deletes a `Shift`.
* @param {String} id UUID for the `Shift` being deleted.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/DeleteShiftResponse} and HTTP response
*/
this.deleteShiftWithHttpInfo = function(id) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling deleteShift");
}
var pathParams = {
'id': id
};
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 = DeleteShiftResponse;
return this.apiClient.callApi(
'/v2/labor/shifts/{id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* DeleteShift
* Deletes a `Shift`.
* @param {String} id UUID for the `Shift` being deleted.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/DeleteShiftResponse}
*/
this.deleteShift = function(id) {
return this.deleteShiftWithHttpInfo(id)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* GetBreakType
* Returns a single `BreakType` specified by id.
* @param {String} id UUID for the `BreakType` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetBreakTypeResponse} and HTTP response
*/
this.getBreakTypeWithHttpInfo = function(id) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling getBreakType");
}
var pathParams = {
'id': id
};
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 = GetBreakTypeResponse;
return this.apiClient.callApi(
'/v2/labor/break-types/{id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* GetBreakType
* Returns a single `BreakType` specified by id.
* @param {String} id UUID for the `BreakType` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetBreakTypeResponse}
*/
this.getBreakType = function(id) {
return this.getBreakTypeWithHttpInfo(id)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* @deprecated
* GetEmployeeWage
* Returns a single `EmployeeWage` specified by id.
* @param {String} id UUID for the `EmployeeWage` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetEmployeeWageResponse} and HTTP response
*/
this.getEmployeeWageWithHttpInfo = function(id) {
console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: LaborApi.getEmployeeWage");
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling getEmployeeWage");
}
var pathParams = {
'id': id
};
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 = GetEmployeeWageResponse;
return this.apiClient.callApi(
'/v2/labor/employee-wages/{id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* GetEmployeeWage
* Returns a single `EmployeeWage` specified by id.
* @param {String} id UUID for the `EmployeeWage` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetEmployeeWageResponse}
*/
this.getEmployeeWage = function(id) {
return this.getEmployeeWageWithHttpInfo(id)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* GetShift
* Returns a single `Shift` specified by id.
* @param {String} id UUID for the `Shift` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetShiftResponse} and HTTP response
*/
this.getShiftWithHttpInfo = function(id) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling getShift");
}
var pathParams = {
'id': id
};
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 = GetShiftResponse;
return this.apiClient.callApi(
'/v2/labor/shifts/{id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* GetShift
* Returns a single `Shift` specified by id.
* @param {String} id UUID for the `Shift` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetShiftResponse}
*/
this.getShift = function(id) {
return this.getShiftWithHttpInfo(id)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* GetTeamMemberWage
* Returns a single `TeamMemberWage` specified by id.
* @param {String} id UUID for the `TeamMemberWage` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetTeamMemberWageResponse} and HTTP response
*/
this.getTeamMemberWageWithHttpInfo = function(id) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling getTeamMemberWage");
}
var pathParams = {
'id': id
};
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 = GetTeamMemberWageResponse;
return this.apiClient.callApi(
'/v2/labor/team-member-wages/{id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* GetTeamMemberWage
* Returns a single `TeamMemberWage` specified by id.
* @param {String} id UUID for the `TeamMemberWage` being retrieved.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetTeamMemberWageResponse}
*/
this.getTeamMemberWage = function(id) {
return this.getTeamMemberWageWithHttpInfo(id)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* ListBreakTypes
* Returns a paginated list of `BreakType` instances for a business.
* @param {Object} opts Optional parameters
* @param {String} opts.locationId Filter Break Types returned to only those that are associated with the specified location.
* @param {Number} opts.limit Maximum number of Break Types to return per page. Can range between 1 and 200. The default is the maximum at 200.
* @param {String} opts.cursor Pointer to the next page of Break Type results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListBreakTypesResponse} and HTTP response
*/
this.listBreakTypesWithHttpInfo = function(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'location_id': opts['locationId'],
'limit': opts['limit'],
'cursor': opts['cursor']
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = ListBreakTypesResponse;
return this.apiClient.callApi(
'/v2/labor/break-types', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* ListBreakTypes
* Returns a paginated list of `BreakType` instances for a business.
* @param {Object} opts Optional parameters
* @param {String} opts.locationId Filter Break Types returned to only those that are associated with the specified location.
* @param {Number} opts.limit Maximum number of Break Types to return per page. Can range between 1 and 200. The default is the maximum at 200.
* @param {String} opts.cursor Pointer to the next page of Break Type results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListBreakTypesResponse}
*/
this.listBreakTypes = function(opts) {
return this.listBreakTypesWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* @deprecated
* ListEmployeeWages
* Returns a paginated list of `EmployeeWage` instances for a business.
* @param {Object} opts Optional parameters
* @param {String} opts.employeeId Filter wages returned to only those that are associated with the specified employee.
* @param {Number} opts.limit Maximum number of Employee Wages to return per page. Can range between 1 and 200. The default is the maximum at 200.
* @param {String} opts.cursor Pointer to the next page of Employee Wage results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListEmployeeWagesResponse} and HTTP response
*/
this.listEmployeeWagesWithHttpInfo = function(opts) {
console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: LaborApi.listEmployeeWages");
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'employee_id': opts['employeeId'],
'limit': opts['limit'],
'cursor': opts['cursor']
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = ListEmployeeWagesResponse;
return this.apiClient.callApi(
'/v2/labor/employee-wages', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* ListEmployeeWages
* Returns a paginated list of `EmployeeWage` instances for a business.
* @param {Object} opts Optional parameters
* @param {String} opts.employeeId Filter wages returned to only those that are associated with the specified employee.
* @param {Number} opts.limit Maximum number of Employee Wages to return per page. Can range between 1 and 200. The default is the maximum at 200.
* @param {String} opts.cursor Pointer to the next page of Employee Wage results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListEmployeeWagesResponse}
*/
this.listEmployeeWages = function(opts) {
return this.listEmployeeWagesWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* ListTeamMemberWages
* Returns a paginated list of `TeamMemberWage` instances for a business.
* @param {Object} opts Optional parameters
* @param {String} opts.teamMemberId Filter wages returned to only those that are associated with the specified team member.
* @param {Number} opts.limit Maximum number of Team Member Wages to return per page. Can range between 1 and 200. The default is the maximum at 200.
* @param {String} opts.cursor Pointer to the next page of Employee Wage results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListTeamMemberWagesResponse} and HTTP response
*/
this.listTeamMemberWagesWithHttpInfo = function(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'team_member_id': opts['teamMemberId'],
'limit': opts['limit'],
'cursor': opts['cursor']
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = ListTeamMemberWagesResponse;
return this.apiClient.callApi(
'/v2/labor/team-member-wages', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* ListTeamMemberWages
* Returns a paginated list of `TeamMemberWage` instances for a business.
* @param {Object} opts Optional parameters
* @param {String} opts.teamMemberId Filter wages returned to only those that are associated with the specified team member.
* @param {Number} opts.limit Maximum number of Team Member Wages to return per page. Can range between 1 and 200. The default is the maximum at 200.
* @param {String} opts.cursor Pointer to the next page of Employee Wage results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListTeamMemberWagesResponse}
*/
this.listTeamMemberWages = function(opts) {
return this.listTeamMemberWagesWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* ListWorkweekConfigs
* Returns a list of `WorkweekConfig` instances for a business.
* @param {Object} opts Optional parameters
* @param {Number} opts.limit Maximum number of Workweek Configs to return per page.
* @param {String} opts.cursor Pointer to the next page of Workweek Config results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListWorkweekConfigsResponse} and HTTP response
*/
this.listWorkweekConfigsWithHttpInfo = function(opts) {
opts = opts || {};
var postBody = null;
var pathParams = {
};
var queryParams = {
'limit': opts['limit'],
'cursor': opts['cursor']
};
var headerParams = {
};
headerParams['Square-Version'] = '2020-12-16';
var formParams = {
};
var authNames = ['oauth2'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = ListWorkweekConfigsResponse;
return this.apiClient.callApi(
'/v2/labor/workweek-configs', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* ListWorkweekConfigs
* Returns a list of `WorkweekConfig` instances for a business.
* @param {Object} opts Optional parameters
* @param {Number} opts.limit Maximum number of Workweek Configs to return per page.
* @param {String} opts.cursor Pointer to the next page of Workweek Config results to fetch.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListWorkweekConfigsResponse}
*/
this.listWorkweekConfigs = function(opts) {
return this.listWorkweekConfigsWithHttpInfo(opts)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* SearchShifts
* Returns a paginated list of `Shift` records for a business. The list to be returned can be filtered by: - Location IDs **and** - employee IDs **and** - shift status (`OPEN`, `CLOSED`) **and** - shift start **and** - shift end **and** - work day details The list can be sorted by: - `start_at` - `end_at` - `created_at` - `updated_at`
* @param {module:model/SearchShiftsRequest} 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/SearchShiftsResponse} and HTTP response
*/
this.searchShiftsWithHttpInfo = 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 searchShifts");
}
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 = SearchShiftsResponse;
return this.apiClient.callApi(
'/v2/labor/shifts/search', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* SearchShifts
* Returns a paginated list of `Shift` records for a business. The list to be returned can be filtered by: - Location IDs **and** - employee IDs **and** - shift status (`OPEN`, `CLOSED`) **and** - shift start **and** - shift end **and** - work day details The list can be sorted by: - `start_at` - `end_at` - `created_at` - `updated_at`
* @param {module:model/SearchShiftsRequest} 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/SearchShiftsResponse}
*/
this.searchShifts = function(body) {
return this.searchShiftsWithHttpInfo(body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* UpdateBreakType
* Updates an existing `BreakType`.
* @param {String} id UUID for the `BreakType` being updated.
* @param {module:model/UpdateBreakTypeRequest} 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/UpdateBreakTypeResponse} and HTTP response
*/
this.updateBreakTypeWithHttpInfo = function(id, body) {
var postBody = body;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling updateBreakType");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateBreakType");
}
var pathParams = {
'id': id
};
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 = UpdateBreakTypeResponse;
return this.apiClient.callApi(
'/v2/labor/break-types/{id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* UpdateBreakType
* Updates an existing `BreakType`.
* @param {String} id UUID for the `BreakType` being updated.
* @param {module:model/UpdateBreakTypeRequest} 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/UpdateBreakTypeResponse}
*/
this.updateBreakType = function(id, body) {
return this.updateBreakTypeWithHttpInfo(id, body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* UpdateShift
* Updates an existing `Shift`. When adding a `Break` to a `Shift`, any earlier `Breaks` in the `Shift` have the `end_at` property set to a valid RFC-3339 datetime string. When closing a `Shift`, all `Break` instances in the shift must be complete with `end_at` set on each `Break`.
* @param {String} id ID of the object being updated.
* @param {module:model/UpdateShiftRequest} 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/UpdateShiftResponse} and HTTP response
*/
this.updateShiftWithHttpInfo = function(id, body) {
var postBody = body;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling updateShift");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateShift");
}
var pathParams = {
'id': id
};
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 = UpdateShiftResponse;
return this.apiClient.callApi(
'/v2/labor/shifts/{id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* UpdateShift
* Updates an existing `Shift`. When adding a `Break` to a `Shift`, any earlier `Breaks` in the `Shift` have the `end_at` property set to a valid RFC-3339 datetime string. When closing a `Shift`, all `Break` instances in the shift must be complete with `end_at` set on each `Break`.
* @param {String} id ID of the object being updated.
* @param {module:model/UpdateShiftRequest} 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/UpdateShiftResponse}
*/
this.updateShift = function(id, body) {
return this.updateShiftWithHttpInfo(id, body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* UpdateWorkweekConfig
* Updates a `WorkweekConfig`.
* @param {String} id UUID for the `WorkweekConfig` object being updated.
* @param {module:model/UpdateWorkweekConfigRequest} 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/UpdateWorkweekConfigResponse} and HTTP response
*/
this.updateWorkweekConfigWithHttpInfo = function(id, body) {
var postBody = body;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling updateWorkweekConfig");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateWorkweekConfig");
}
var pathParams = {
'id': id
};
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 = UpdateWorkweekConfigResponse;
return this.apiClient.callApi(
'/v2/labor/workweek-configs/{id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType
);
}
/**
* UpdateWorkweekConfig
* Updates a `WorkweekConfig`.
* @param {String} id UUID for the `WorkweekConfig` object being updated.
* @param {module:model/UpdateWorkweekConfigRequest} 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/UpdateWorkweekConfigResponse}
*/
this.updateWorkweekConfig = function(id, body) {
return this.updateWorkweekConfigWithHttpInfo(id, body)
.then(function(response_and_data) {
return response_and_data.data;
});
}
};