/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/koho-api-helper@3.1.0/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,s=1,o=arguments.length;s<o;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},__assign.apply(this,arguments)},__createBinding=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[s]}})}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.hasOwnProperty.call(e,s)&&__createBinding(t,e,s);return __setModuleDefault(t,e),t},__awaiter=this&&this.__awaiter||function(e,t,s,o){return new(s||(s=Promise))((function(r,i){function n(e){try{a(o.next(e))}catch(e){i(e)}}function h(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(n,h)}a((o=o.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var s,o,r,i,n={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:h(0),throw:h(1),return:h(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function h(i){return function(h){return function(i){if(s)throw new TypeError("Generator is already executing.");for(;n;)try{if(s=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return n.label++,{value:i[1],done:!1};case 5:n.label++,o=i[1],i=[0];continue;case 7:i=n.ops.pop(),n.trys.pop();continue;default:if(!(r=n.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){n=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){n.label=i[1];break}if(6===i[0]&&n.label<r[1]){n.label=r[1],r=i;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(i);break}r[2]&&n.ops.pop(),n.trys.pop();continue}i=t.call(e,n)}catch(e){i=[6,e],o=0}finally{s=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,h])}}},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.KohoApiHelper=void 0;var got_1=__importDefault(require("got")),customer_methods_1=require("./methods/customer.methods"),person_methods_1=require("./methods/person.methods"),invoice_methods_1=require("./methods/invoice.methods"),contract_methods_1=require("./methods/contract.methods"),employee_methods_1=require("./methods/employee.methods"),product_methods_1=require("./methods/product.methods"),project_methods_1=require("./methods/project.methods"),sale_methods_1=require("./methods/sale.methods"),notification_methods_1=require("./methods/notification.methods"),customer_category_methods_1=require("./methods/customer-category.methods"),customer_group_methods_1=require("./methods/customer-group.methods"),offer_methods_1=require("./methods/offer.methods"),product_catalog_methods_1=require("./methods/product-catalog.methods"),customer_financial_statement_methods_1=require("./methods/customer-financial-statement.methods"),employee_team_methods_1=require("./methods/employee-team.methods"),employee_profile_methods_1=require("./methods/employee-profile.methods"),accounting_target_methods_1=require("./methods/accounting-target.methods"),work_session_methods_1=require("./methods/work-session.methods"),work_session_assignment_methods_1=require("./methods/work-session-assignment.methods"),work_session_assignment_template_methods_1=require("./methods/work-session-assignment-template.methods"),work_session_shift_methods_1=require("./methods/work-session-shift.methods"),work_session_shift_types_method_1=require("./methods/work-session-shift-types.method"),custom_report_methods_1=require("./methods/custom-report.methods"),company_methods_1=require("./methods/company.methods"),accounting_assignment_methods_1=require("./methods/accounting-assignment.methods"),https=__importStar(require("https")),project_template_methods_1=require("./methods/project-template.methods"),delay=function(e){return new Promise((function(t){return setTimeout(t,e)}))},KohoApiHelper=function(){function e(e){if(this.keepAliveAgent=new https.Agent({keepAlive:!0}),this.options=e||{},!this.options.token)throw new Error("No API token specified");if(!this.options.companyId&&!this.options.enterpriseId)throw new Error("No Company ID or enterpriseId specified");this.options.timeout||(this.options.timeout=3e4),this.options.url||(this.options.url="https://suite.koho-online.com/api"),this.options.throttleOptions=__assign({maxRetries:3,delay:15e3,enabled:!0},e.throttleOptions),this.accountingTargets=new accounting_target_methods_1.AccountingTargetMethods(this),this.customers=new customer_methods_1.CustomerMethods(this),this.customersCategories=new customer_category_methods_1.CustomerCategoryMethods(this),this.customersGroups=new customer_group_methods_1.CustomerGroupMethods(this),this.persons=new person_methods_1.PersonMethods(this),this.invoices=new invoice_methods_1.InvoiceMethods(this),this.contracts=new contract_methods_1.ContractMethods(this),this.employees=new employee_methods_1.EmployeeMethods(this),this.employeesTeams=new employee_team_methods_1.EmployeeTeamMethods(this),this.employeesProfiles=new employee_profile_methods_1.EmployeeProfileMethods(this),this.products=new product_methods_1.ProductMethods(this),this.productsCatalogs=new product_catalog_methods_1.ProductCatalogMethods(this),this.projects=new project_methods_1.ProjectMethods(this),this.sales=new sale_methods_1.SaleMethods(this),this.notifications=new notification_methods_1.NotificationMethods(this),this.offers=new offer_methods_1.OfferMethods(this),this.customersFinancialStatements=new customer_financial_statement_methods_1.CustomerFinancialStatementMethods(this),this.workSessions=new work_session_methods_1.WorkSessionMethods(this),this.workSessionAssignments=new work_session_assignment_methods_1.WorkSessionAssignmentMethods(this),this.workSessionAssignmentTemplates=new work_session_assignment_template_methods_1.WorkSessionAssignmentTemplateMethods(this),this.workSessionShifts=new work_session_shift_methods_1.WorkSessionShiftMethods(this),this.workSessionShiftTypes=new work_session_shift_types_method_1.WorkSessionShiftTypeMethods(this),this.customReports=new custom_report_methods_1.CustomReportMethods(this),this.companies=new company_methods_1.CompanyMethods(this),this.accountingAssignments=new accounting_assignment_methods_1.AccountingAssignmentMethods(this),this.projectTemplates=new project_template_methods_1.ProjectTemplateMethods(this)}return e.prototype._setupRequest=function(e,t,s,o,r,i){var n,h;if(!e)throw new Error("Missing URL for request");var a=__assign({method:t||"GET",searchParams:__assign(__assign({},this._authParams),o)},r);return"GET"===a.method||(null==r?void 0:r.body)||(null==r?void 0:r.form)||(a.json=s),!0===(null===(n=this.options)||void 0===n?void 0:n.useKeepAliveAgent)&&(a.agent={https:this.keepAliveAgent}),!0!==(null===(h=this.options)||void 0===h?void 0:h.disableStreaming)&&!0!==i&&"GET"===a.method&&(a.searchParams.stream=!0),a.headers=a.headers||{},a.headers.token=this.options.token,a.retry||(a.retry=2),__assign(__assign({},a),this.overrideGotOptions)},e.prototype._retryRequestOnThrottle=function(e,t){return __awaiter(this,void 0,void 0,(function(){var s;return __generator(this,(function(o){switch(o.label){case 0:return[4,t()];case 1:return s=o.sent(),!0===this.options.throttleOptions.enabled&&!0===s.throttle&&e>0?[4,delay(this.options.throttleOptions.delay)]:[3,3];case 2:return o.sent(),[2,this._retryRequestOnThrottle(e-1,t)];case 3:return[2,s]}}))}))},e.prototype.request=function(e,t,s,o,r){return __awaiter(this,void 0,void 0,(function(){var i,n;return __generator(this,(function(h){switch(h.label){case 0:return i=this._setupRequest(e,t,s,o,r),[4,this._retryRequestOnThrottle(this.options.throttleOptions.maxRetries,(function(){return got_1.default(e,i).json()}))];case 1:if("error"===(null==(n=h.sent())?void 0:n.status))throw new Error(n.message);return[2,n]}}))}))},e.prototype.requestText=function(e,t,s,o,r){return __awaiter(this,void 0,void 0,(function(){var i;return __generator(this,(function(n){switch(n.label){case 0:return i=this._setupRequest(e,t,s,o,r),[4,got_1.default(e,i).text()];case 1:return[2,n.sent()]}}))}))},e.prototype.requestBuffer=function(e,t,s,o,r){return __awaiter(this,void 0,void 0,(function(){var i;return __generator(this,(function(n){switch(n.label){case 0:return i=this._setupRequest(e,t,s,o,r,!0),[4,got_1.default(e,i).buffer()];case 1:return[2,n.sent()]}}))}))},Object.defineProperty(e.prototype,"_authParams",{get:function(){var e={};return this.options.enterpriseId&&(e.enterprise_id=this.options.enterpriseId),this.options.companyId&&(e.company_id=this.options.companyId),e},enumerable:!1,configurable:!0}),e}();exports.KohoApiHelper=KohoApiHelper;
//# sourceMappingURL=/sm/c3df2b7f29f29c190f3c4f94b158485aa7124001eeada5405c9d951e7051c299.map