UNPKG

square-connect

Version:

JavaScript client library for the Square Connect v2 API

993 lines (844 loc) 45 kB
/** * 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 V1CashDrawerShift = require('../model/V1CashDrawerShift'); var V1Employee = require('../model/V1Employee'); var V1EmployeeRole = require('../model/V1EmployeeRole'); var V1Timecard = require('../model/V1Timecard'); var V1TimecardEvent = require('../model/V1TimecardEvent'); /** * V1Employees service. * @module api/V1EmployeesApi */ /** * Constructs a new V1EmployeesApi. * @alias module:api/V1EmployeesApi * @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; /** * CreateEmployee * Use the CreateEmployee endpoint to add an employee to a Square account. Employees created with the Connect API have an initial status of &#x60;INACTIVE&#x60;. Inactive employees cannot sign in to Square Point of Sale until they are activated from the Square Dashboard. Employee status cannot be changed with the Connect API. Employee entities cannot be deleted. To disable employee profiles, set the employee&#39;s status to &lt;code&gt;INACTIVE&lt;/code&gt; * @param {module:model/V1Employee} 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/V1Employee} and HTTP response */ this.createEmployeeWithHttpInfo = 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 createEmployee"); } 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 = V1Employee; return this.apiClient.callApi( '/v1/me/employees', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CreateEmployee * Use the CreateEmployee endpoint to add an employee to a Square account. Employees created with the Connect API have an initial status of &#x60;INACTIVE&#x60;. Inactive employees cannot sign in to Square Point of Sale until they are activated from the Square Dashboard. Employee status cannot be changed with the Connect API. Employee entities cannot be deleted. To disable employee profiles, set the employee&#39;s status to &lt;code&gt;INACTIVE&lt;/code&gt; * @param {module:model/V1Employee} 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/V1Employee} */ this.createEmployee = function(body) { return this.createEmployeeWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } /** * CreateEmployeeRole * Creates an employee role you can then assign to employees. Square accounts can include any number of roles that can be assigned to employees. These roles define the actions and permissions granted to an employee with that role. For example, an employee with a \&quot;Shift Manager\&quot; role might be able to issue refunds in Square Point of Sale, whereas an employee with a \&quot;Clerk\&quot; role might not. Roles are assigned with the [V1UpdateEmployee](#endpoint-v1updateemployee) endpoint. An employee can have only one role at a time. If an employee has no role, they have none of the permissions associated with roles. All employees can accept payments with Square Point of Sale. * @param {module:model/V1EmployeeRole} employeeRole An EmployeeRole object with a name and permissions, and an optional owner flag. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/V1EmployeeRole} and HTTP response */ this.createEmployeeRoleWithHttpInfo = function(employeeRole) { var postBody = employeeRole; // verify the required parameter 'employeeRole' is set if (employeeRole === undefined || employeeRole === null) { throw new Error("Missing the required parameter 'employeeRole' when calling createEmployeeRole"); } 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 = V1EmployeeRole; return this.apiClient.callApi( '/v1/me/roles', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CreateEmployeeRole * Creates an employee role you can then assign to employees. Square accounts can include any number of roles that can be assigned to employees. These roles define the actions and permissions granted to an employee with that role. For example, an employee with a \&quot;Shift Manager\&quot; role might be able to issue refunds in Square Point of Sale, whereas an employee with a \&quot;Clerk\&quot; role might not. Roles are assigned with the [V1UpdateEmployee](#endpoint-v1updateemployee) endpoint. An employee can have only one role at a time. If an employee has no role, they have none of the permissions associated with roles. All employees can accept payments with Square Point of Sale. * @param {module:model/V1EmployeeRole} employeeRole An EmployeeRole object with a name and permissions, and an optional owner flag. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/V1EmployeeRole} */ this.createEmployeeRole = function(employeeRole) { return this.createEmployeeRoleWithHttpInfo(employeeRole) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * CreateTimecard * Creates a timecard for an employee and clocks them in with an &#x60;API_CREATE&#x60; event and a &#x60;clockin_time&#x60; set to the current time unless the request provides a different value. To import timecards from another system (rather than clocking someone in). Specify the &#x60;clockin_time&#x60; and* &#x60;clockout_time&#x60; in the request. Timecards correspond to exactly one shift for a given employee, bounded by the &#x60;clockin_time&#x60; and &#x60;clockout_time&#x60; fields. An employee is considered clocked in if they have a timecard that doesn&#39;t have a &#x60;clockout_time&#x60; set. An employee that is currently clocked in cannot be clocked in a second time. * @param {module:model/V1Timecard} 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/V1Timecard} and HTTP response */ this.createTimecardWithHttpInfo = function(body) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.createTimecard"); 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 createTimecard"); } 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 = V1Timecard; return this.apiClient.callApi( '/v1/me/timecards', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * CreateTimecard * Creates a timecard for an employee and clocks them in with an &#x60;API_CREATE&#x60; event and a &#x60;clockin_time&#x60; set to the current time unless the request provides a different value. To import timecards from another system (rather than clocking someone in). Specify the &#x60;clockin_time&#x60; and* &#x60;clockout_time&#x60; in the request. Timecards correspond to exactly one shift for a given employee, bounded by the &#x60;clockin_time&#x60; and &#x60;clockout_time&#x60; fields. An employee is considered clocked in if they have a timecard that doesn&#39;t have a &#x60;clockout_time&#x60; set. An employee that is currently clocked in cannot be clocked in a second time. * @param {module:model/V1Timecard} 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/V1Timecard} */ this.createTimecard = function(body) { return this.createTimecardWithHttpInfo(body) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * DeleteTimecard * Deletes a timecard. Timecards can also be deleted through the Square Dashboard. Deleted timecards are still accessible through Connect API endpoints, but cannot be modified. The &#x60;deleted&#x60; field of the &#x60;Timecard&#x60; object indicates whether the timecard has been deleted. __Note__: By default, deleted timecards appear alongside valid timecards in results returned by the [ListTimecards](#endpoint-v1employees-listtimecards) endpoint. To filter deleted timecards, include the &#x60;deleted&#x60; query parameter in the list request. Only approved accounts can manage their employees with Square. Unapproved accounts cannot use employee management features with the API. * @param {String} timecardId The ID of the timecard to delete. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response */ this.deleteTimecardWithHttpInfo = function(timecardId) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.deleteTimecard"); var postBody = null; // verify the required parameter 'timecardId' is set if (timecardId === undefined || timecardId === null) { throw new Error("Missing the required parameter 'timecardId' when calling deleteTimecard"); } var pathParams = { 'timecard_id': timecardId }; 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 = Object; return this.apiClient.callApi( '/v1/me/timecards/{timecard_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * DeleteTimecard * Deletes a timecard. Timecards can also be deleted through the Square Dashboard. Deleted timecards are still accessible through Connect API endpoints, but cannot be modified. The &#x60;deleted&#x60; field of the &#x60;Timecard&#x60; object indicates whether the timecard has been deleted. __Note__: By default, deleted timecards appear alongside valid timecards in results returned by the [ListTimecards](#endpoint-v1employees-listtimecards) endpoint. To filter deleted timecards, include the &#x60;deleted&#x60; query parameter in the list request. Only approved accounts can manage their employees with Square. Unapproved accounts cannot use employee management features with the API. * @param {String} timecardId The ID of the timecard to delete. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object} */ this.deleteTimecard = function(timecardId) { return this.deleteTimecardWithHttpInfo(timecardId) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * ListCashDrawerShifts * Provides the details for all of a location&#39;s cash drawer shifts during a date range. The date range you specify cannot exceed 90 days. * @param {String} locationId The ID of the location to list cash drawer shifts for. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which cash drawer shifts are listed in the response, based on their created_at field. Default value: ASC * @param {String} opts.beginTime The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time minus 90 days. * @param {String} opts.endTime The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/V1CashDrawerShift>} and HTTP response */ this.listCashDrawerShiftsWithHttpInfo = function(locationId, opts) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.listCashDrawerShifts"); opts = opts || {}; var postBody = null; // verify the required parameter 'locationId' is set if (locationId === undefined || locationId === null) { throw new Error("Missing the required parameter 'locationId' when calling listCashDrawerShifts"); } var pathParams = { 'location_id': locationId }; var queryParams = { 'order': opts['order'], 'begin_time': opts['beginTime'], 'end_time': opts['endTime'] }; var headerParams = { }; headerParams['Square-Version'] = '2020-12-16'; var formParams = { }; var authNames = ['oauth2']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [V1CashDrawerShift]; return this.apiClient.callApi( '/v1/{location_id}/cash-drawer-shifts', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * ListCashDrawerShifts * Provides the details for all of a location&#39;s cash drawer shifts during a date range. The date range you specify cannot exceed 90 days. * @param {String} locationId The ID of the location to list cash drawer shifts for. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which cash drawer shifts are listed in the response, based on their created_at field. Default value: ASC * @param {String} opts.beginTime The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time minus 90 days. * @param {String} opts.endTime The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/V1CashDrawerShift>} */ this.listCashDrawerShifts = function(locationId, opts) { return this.listCashDrawerShiftsWithHttpInfo(locationId, opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * ListEmployeeRoles * Provides summary information for all of a business&#39;s employee roles. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which employees are listed in the response, based on their created_at field.Default value: ASC * @param {Number} opts.limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. * @param {String} opts.batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/V1EmployeeRole>} and HTTP response */ this.listEmployeeRolesWithHttpInfo = function(opts) { opts = opts || {}; var postBody = null; var pathParams = { }; var queryParams = { 'order': opts['order'], 'limit': opts['limit'], 'batch_token': opts['batchToken'] }; var headerParams = { }; headerParams['Square-Version'] = '2020-12-16'; var formParams = { }; var authNames = ['oauth2']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [V1EmployeeRole]; return this.apiClient.callApi( '/v1/me/roles', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * ListEmployeeRoles * Provides summary information for all of a business&#39;s employee roles. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which employees are listed in the response, based on their created_at field.Default value: ASC * @param {Number} opts.limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. * @param {String} opts.batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/V1EmployeeRole>} */ this.listEmployeeRoles = function(opts) { return this.listEmployeeRolesWithHttpInfo(opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * ListEmployees * Provides summary information for all of a business&#39;s employees. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which employees are listed in the response, based on their created_at field. Default value: ASC * @param {String} opts.beginUpdatedAt If filtering results by their updated_at field, the beginning of the requested reporting period, in ISO 8601 format * @param {String} opts.endUpdatedAt If filtering results by there updated_at field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.beginCreatedAt If filtering results by their created_at field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endCreatedAt If filtering results by their created_at field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.status If provided, the endpoint returns only employee entities with the specified status (ACTIVE or INACTIVE). * @param {String} opts.externalId If provided, the endpoint returns only employee entities with the specified external_id. * @param {Number} opts.limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. * @param {String} opts.batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/V1Employee>} and HTTP response */ this.listEmployeesWithHttpInfo = function(opts) { opts = opts || {}; var postBody = null; var pathParams = { }; var queryParams = { 'order': opts['order'], 'begin_updated_at': opts['beginUpdatedAt'], 'end_updated_at': opts['endUpdatedAt'], 'begin_created_at': opts['beginCreatedAt'], 'end_created_at': opts['endCreatedAt'], 'status': opts['status'], 'external_id': opts['externalId'], 'limit': opts['limit'], 'batch_token': opts['batchToken'] }; var headerParams = { }; headerParams['Square-Version'] = '2020-12-16'; var formParams = { }; var authNames = ['oauth2']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [V1Employee]; return this.apiClient.callApi( '/v1/me/employees', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * ListEmployees * Provides summary information for all of a business&#39;s employees. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which employees are listed in the response, based on their created_at field. Default value: ASC * @param {String} opts.beginUpdatedAt If filtering results by their updated_at field, the beginning of the requested reporting period, in ISO 8601 format * @param {String} opts.endUpdatedAt If filtering results by there updated_at field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.beginCreatedAt If filtering results by their created_at field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endCreatedAt If filtering results by their created_at field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.status If provided, the endpoint returns only employee entities with the specified status (ACTIVE or INACTIVE). * @param {String} opts.externalId If provided, the endpoint returns only employee entities with the specified external_id. * @param {Number} opts.limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. * @param {String} opts.batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/V1Employee>} */ this.listEmployees = function(opts) { return this.listEmployeesWithHttpInfo(opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * ListTimecardEvents * Provides summary information for all events associated with a particular timecard. Only approved accounts can manage their employees with Square. Unapproved accounts cannot use employee management features with the API. * @param {String} timecardId The ID of the timecard to list events for. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/V1TimecardEvent>} and HTTP response */ this.listTimecardEventsWithHttpInfo = function(timecardId) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.listTimecardEvents"); var postBody = null; // verify the required parameter 'timecardId' is set if (timecardId === undefined || timecardId === null) { throw new Error("Missing the required parameter 'timecardId' when calling listTimecardEvents"); } var pathParams = { 'timecard_id': timecardId }; 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 = [V1TimecardEvent]; return this.apiClient.callApi( '/v1/me/timecards/{timecard_id}/events', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * ListTimecardEvents * Provides summary information for all events associated with a particular timecard. Only approved accounts can manage their employees with Square. Unapproved accounts cannot use employee management features with the API. * @param {String} timecardId The ID of the timecard to list events for. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/V1TimecardEvent>} */ this.listTimecardEvents = function(timecardId) { return this.listTimecardEventsWithHttpInfo(timecardId) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * ListTimecards * Provides summary information for all of a business&#39;s employee timecards. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which timecards are listed in the response, based on their created_at field. * @param {String} opts.employeeId If provided, the endpoint returns only timecards for the employee with the specified ID. * @param {String} opts.beginClockinTime If filtering results by their clockin_time field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endClockinTime If filtering results by their clockin_time field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.beginClockoutTime If filtering results by their clockout_time field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endClockoutTime If filtering results by their clockout_time field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.beginUpdatedAt If filtering results by their updated_at field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endUpdatedAt If filtering results by their updated_at field, the end of the requested reporting period, in ISO 8601 format. * @param {Boolean} opts.deleted If true, only deleted timecards are returned. If false, only valid timecards are returned.If you don&#39;t provide this parameter, both valid and deleted timecards are returned. * @param {Number} opts.limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. * @param {String} opts.batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/V1Timecard>} and HTTP response */ this.listTimecardsWithHttpInfo = function(opts) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.listTimecards"); opts = opts || {}; var postBody = null; var pathParams = { }; var queryParams = { 'order': opts['order'], 'employee_id': opts['employeeId'], 'begin_clockin_time': opts['beginClockinTime'], 'end_clockin_time': opts['endClockinTime'], 'begin_clockout_time': opts['beginClockoutTime'], 'end_clockout_time': opts['endClockoutTime'], 'begin_updated_at': opts['beginUpdatedAt'], 'end_updated_at': opts['endUpdatedAt'], 'deleted': opts['deleted'], 'limit': opts['limit'], 'batch_token': opts['batchToken'] }; var headerParams = { }; headerParams['Square-Version'] = '2020-12-16'; var formParams = { }; var authNames = ['oauth2']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [V1Timecard]; return this.apiClient.callApi( '/v1/me/timecards', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * ListTimecards * Provides summary information for all of a business&#39;s employee timecards. * @param {Object} opts Optional parameters * @param {String} opts.order The order in which timecards are listed in the response, based on their created_at field. * @param {String} opts.employeeId If provided, the endpoint returns only timecards for the employee with the specified ID. * @param {String} opts.beginClockinTime If filtering results by their clockin_time field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endClockinTime If filtering results by their clockin_time field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.beginClockoutTime If filtering results by their clockout_time field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endClockoutTime If filtering results by their clockout_time field, the end of the requested reporting period, in ISO 8601 format. * @param {String} opts.beginUpdatedAt If filtering results by their updated_at field, the beginning of the requested reporting period, in ISO 8601 format. * @param {String} opts.endUpdatedAt If filtering results by their updated_at field, the end of the requested reporting period, in ISO 8601 format. * @param {Boolean} opts.deleted If true, only deleted timecards are returned. If false, only valid timecards are returned.If you don&#39;t provide this parameter, both valid and deleted timecards are returned. * @param {Number} opts.limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. * @param {String} opts.batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/V1Timecard>} */ this.listTimecards = function(opts) { return this.listTimecardsWithHttpInfo(opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * RetrieveCashDrawerShift * Provides the details for a single cash drawer shift, including all events that occurred during the shift. * @param {String} locationId The ID of the location to list cash drawer shifts for. * @param {String} shiftId The shift&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/V1CashDrawerShift} and HTTP response */ this.retrieveCashDrawerShiftWithHttpInfo = function(locationId, shiftId) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.retrieveCashDrawerShift"); var postBody = null; // verify the required parameter 'locationId' is set if (locationId === undefined || locationId === null) { throw new Error("Missing the required parameter 'locationId' when calling retrieveCashDrawerShift"); } // verify the required parameter 'shiftId' is set if (shiftId === undefined || shiftId === null) { throw new Error("Missing the required parameter 'shiftId' when calling retrieveCashDrawerShift"); } var pathParams = { 'location_id': locationId, 'shift_id': shiftId }; 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 = V1CashDrawerShift; return this.apiClient.callApi( '/v1/{location_id}/cash-drawer-shifts/{shift_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * RetrieveCashDrawerShift * Provides the details for a single cash drawer shift, including all events that occurred during the shift. * @param {String} locationId The ID of the location to list cash drawer shifts for. * @param {String} shiftId The shift&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/V1CashDrawerShift} */ this.retrieveCashDrawerShift = function(locationId, shiftId) { return this.retrieveCashDrawerShiftWithHttpInfo(locationId, shiftId) .then(function(response_and_data) { return response_and_data.data; }); } /** * RetrieveEmployee * Provides the details for a single employee. * @param {String} employeeId The employee&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/V1Employee} and HTTP response */ this.retrieveEmployeeWithHttpInfo = function(employeeId) { var postBody = null; // verify the required parameter 'employeeId' is set if (employeeId === undefined || employeeId === null) { throw new Error("Missing the required parameter 'employeeId' when calling retrieveEmployee"); } var pathParams = { 'employee_id': employeeId }; 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 = V1Employee; return this.apiClient.callApi( '/v1/me/employees/{employee_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * RetrieveEmployee * Provides the details for a single employee. * @param {String} employeeId The employee&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/V1Employee} */ this.retrieveEmployee = function(employeeId) { return this.retrieveEmployeeWithHttpInfo(employeeId) .then(function(response_and_data) { return response_and_data.data; }); } /** * RetrieveEmployeeRole * Provides the details for a single employee role. * @param {String} roleId The role&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/V1EmployeeRole} and HTTP response */ this.retrieveEmployeeRoleWithHttpInfo = function(roleId) { var postBody = null; // verify the required parameter 'roleId' is set if (roleId === undefined || roleId === null) { throw new Error("Missing the required parameter 'roleId' when calling retrieveEmployeeRole"); } var pathParams = { 'role_id': roleId }; 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 = V1EmployeeRole; return this.apiClient.callApi( '/v1/me/roles/{role_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * RetrieveEmployeeRole * Provides the details for a single employee role. * @param {String} roleId The role&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/V1EmployeeRole} */ this.retrieveEmployeeRole = function(roleId) { return this.retrieveEmployeeRoleWithHttpInfo(roleId) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * RetrieveTimecard * Provides the details for a single timecard. &lt;aside&gt; Only approved accounts can manage their employees with Square. Unapproved accounts cannot use employee management features with the API. &lt;/aside&gt; * @param {String} timecardId The timecard&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/V1Timecard} and HTTP response */ this.retrieveTimecardWithHttpInfo = function(timecardId) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.retrieveTimecard"); var postBody = null; // verify the required parameter 'timecardId' is set if (timecardId === undefined || timecardId === null) { throw new Error("Missing the required parameter 'timecardId' when calling retrieveTimecard"); } var pathParams = { 'timecard_id': timecardId }; 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 = V1Timecard; return this.apiClient.callApi( '/v1/me/timecards/{timecard_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * RetrieveTimecard * Provides the details for a single timecard. &lt;aside&gt; Only approved accounts can manage their employees with Square. Unapproved accounts cannot use employee management features with the API. &lt;/aside&gt; * @param {String} timecardId The timecard&#39;s ID. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/V1Timecard} */ this.retrieveTimecard = function(timecardId) { return this.retrieveTimecardWithHttpInfo(timecardId) .then(function(response_and_data) { return response_and_data.data; }); } /** * UpdateEmployee * * @param {String} employeeId The ID of the role to modify. * @param {module:model/V1Employee} 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/V1Employee} and HTTP response */ this.updateEmployeeWithHttpInfo = function(employeeId, body) { var postBody = body; // verify the required parameter 'employeeId' is set if (employeeId === undefined || employeeId === null) { throw new Error("Missing the required parameter 'employeeId' when calling updateEmployee"); } // verify the required parameter 'body' is set if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updateEmployee"); } var pathParams = { 'employee_id': employeeId }; 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 = V1Employee; return this.apiClient.callApi( '/v1/me/employees/{employee_id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * UpdateEmployee * * @param {String} employeeId The ID of the role to modify. * @param {module:model/V1Employee} 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/V1Employee} */ this.updateEmployee = function(employeeId, body) { return this.updateEmployeeWithHttpInfo(employeeId, body) .then(function(response_and_data) { return response_and_data.data; }); } /** * UpdateEmployeeRole * Modifies the details of an employee role. * @param {String} roleId The ID of the role to modify. * @param {module:model/V1EmployeeRole} 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/V1EmployeeRole} and HTTP response */ this.updateEmployeeRoleWithHttpInfo = function(roleId, body) { var postBody = body; // verify the required parameter 'roleId' is set if (roleId === undefined || roleId === null) { throw new Error("Missing the required parameter 'roleId' when calling updateEmployeeRole"); } // verify the required parameter 'body' is set if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updateEmployeeRole"); } var pathParams = { 'role_id': roleId }; 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 = V1EmployeeRole; return this.apiClient.callApi( '/v1/me/roles/{role_id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * UpdateEmployeeRole * Modifies the details of an employee role. * @param {String} roleId The ID of the role to modify. * @param {module:model/V1EmployeeRole} 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/V1EmployeeRole} */ this.updateEmployeeRole = function(roleId, body) { return this.updateEmployeeRoleWithHttpInfo(roleId, body) .then(function(response_and_data) { return response_and_data.data; }); } /** * @deprecated * UpdateTimecard * Modifies the details of a timecard with an &#x60;API_EDIT&#x60; event for the timecard. Updating an active timecard with a &#x60;clockout_time&#x60; clocks the employee out. * @param {String} timecardId TThe ID of the timecard to modify. * @param {module:model/V1Timecard} 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/V1Timecard} and HTTP response */ this.updateTimecardWithHttpInfo = function(timecardId, body) { console.warn("\x1b[33m%s\x1b[0m","Calling deprecated API: V1EmployeesApi.updateTimecard"); var postBody = body; // verify the required parameter 'timecardId' is set if (timecardId === undefined || timecardId === null) { throw new Error("Missing the required parameter 'timecardId' when calling updateTimecard"); } // verify the required parameter 'body' is set if (body === undefined || body === null) { throw new Error("Missing the required parameter 'body' when calling updateTimecard"); } var pathParams = { 'timecard_id': timecardId }; 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 = V1Timecard; return this.apiClient.callApi( '/v1/me/timecards/{timecard_id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * UpdateTimecard * Modifies the details of a timecard with an &#x60;API_EDIT&#x60; event for the timecard. Updating an active timecard with a &#x60;clockout_time&#x60; clocks the employee out. * @param {String} timecardId TThe ID of the timecard to modify. * @param {module:model/V1Timecard} 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/V1Timecard} */ this.updateTimecard = function(timecardId, body) { return this.updateTimecardWithHttpInfo(timecardId, body) .then(function(response_and_data) { return response_and_data.data; }); } };