@mindkey/recruiting-api-client
Version:
The MindKey API Client allows easy access to your MindKey Recruiting data.
3 lines (1 loc) • 6.13 kB
JavaScript
var $=Object.defineProperty,x=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var P=(a,e,t)=>e in a?$(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,s=(a,e)=>{for(var t in e||={})B.call(e,t)&&P(a,t,e[t]);if(k)for(var t of k(e))C.call(e,t)&&P(a,t,e[t]);return a},p=(a,e)=>x(a,U(e));var d=class extends Error{constructor(e,t){super(t),this.response=e}get status(){return this.response.status}};function l(a,e){return`${a}/${encodeURIComponent(e)}`}function o(a){return{"X-MindKey-User-Language":a}}var c={async get(a,e){return await c.sendRequest(a,"GET",e)},async post(a,e,t){return await c.sendRequest(a,"POST",t,e)},async put(a,e,t){return await c.sendRequest(a,"GET",t,e)},async delete(a,e,t){return await c.sendRequest(a,"GET",t,e)},async sendRequest(a,e,t,r){let n=await fetch(a,{method:e,headers:t,body:b(r)}),i="";if(n.ok)i=await n.text();else{try{i=await n.text()}catch{i=`Http failure response for ${a}: ${n.status} ${n.statusText}`}throw new d(n,i)}return i||(i="{}"),JSON.parse(i)}};function b(a){if(a)return typeof Blob<"u"&&a instanceof Blob||typeof ArrayBuffer<"u"&&a instanceof ArrayBuffer||typeof FormData<"u"&&a instanceof FormData||typeof URLSearchParams<"u"&&a instanceof URLSearchParams?a:JSON.stringify(a)}function w(){return{"Content-Type":"application/json"}}var g=class{constructor(e,t=c){this.basePath=e,this.backend=t}getJobAgentConfiguration(e,t){return this.backend.get(`${this.getBaseUrl(e)}/configuration`,s({},o(t)))}getJobAgentType(e,t,r){return this.backend.get(`${this.getBaseUrl(e)}/types/${encodeURIComponent(r)}`,s({},o(t)))}getJobAgent(e,t,r,n,i){return this.backend.post(`${this.getBaseUrl(e)}/${i}`,{jobAgentId:r,code:n},s({},this.getDefaultPostHeaders(t)))}createJobAgent(e,t,r,n){return this.backend.post(`${this.getBaseUrl(e)}/create/${n}`,r,s({},this.getDefaultPostHeaders(t)))}updateJobAgent(e,t,r,n){return this.backend.put(`${this.getBaseUrl(e)}/${n}`,r,s({},this.getDefaultPostHeaders(t)))}deleteJobAgent(e,t,r,n,i){return this.backend.delete(`${this.getBaseUrl(e)}/${i}`,{code:n,jobAgentId:r},s({},this.getDefaultPostHeaders(t)))}resendEmail(e,t,r,n){return this.backend.post(`${this.getBaseUrl(e)}/resend-email/${n}`,r,s({},this.getDefaultPostHeaders(t)))}activate(e,t,r,n){return this.backend.post(`${this.getBaseUrl(e)}/activate/${n}`,r,s({},this.getDefaultPostHeaders(t)))}getBaseUrl(e){return`${l(this.basePath,e)}/job-agents`}getDefaultPostHeaders(e){return s(s({},o(e)),w())}};var h=class{constructor(e,t=c){this.baseUrl=e,this.backend=t}getLookups(e,t){return this.backend.get(`${l(this.baseUrl,e)}/candidates/lookup`,s({},o(t)))}};var m=function(a){return a.All="All",a.External="External",a.Internal="Internal",a}(m||{});var L=(a,e,t)=>{let r=t?t[e]:void 0;if(r===void 0)return;let n=String(e);switch(typeof r){case"boolean":a.set(n,r?"true":"false");break;case"string":a.set(n,r);break;default:throw new Error(`${typeof r} is not implemented yet.`)}},y=(a,e)=>{if(e)for(let t of Object.keys(e))L(a,t,e)};var f=class{constructor(e,t=c){this.baseUrl=e,this.backend=t}getApplicationFormType(e,t,r="Standard"){return this.backend.get(`${this.getApplicationFormTypePath(e)}/${encodeURIComponent(r)}`,s({},o(t)))}getVacancyListConfiguration(e,t){return this.backend.get(this.getVacancyListConfigurationPath(e),s({},o(t)))}async getVacancyList(e,t,r){let n=new URL(this.getVacancyListPath(e));return y(n.searchParams,this.setDefaultFilter(r)),(await this.backend.get(n.toString(),s({},o(t)))).map(u=>this.prepareVacancyDetailsModel(u))}async getSimpleVacancyList(e,t,r){let n=new URL(this.getSimpleVacancyListPath(e));return y(n.searchParams,this.setDefaultFilter(r)),(await this.backend.get(n.toString(),s({},o(t)))).map(u=>this.prepareSimpleVacancyDetailsModel(u))}getVacancyDetailsConfiguration(e,t){return this.backend.get(this.getVacancyDetailsConfigurationPath(e),s({},o(t)))}async getVacancyDetails(e,t,r,n){let i=new URL(`${this.getBasePath(e)}/${encodeURIComponent(t)}`);y(i.searchParams,n);let u=await this.backend.get(i.toString(),s({},o(r)));return this.prepareVacancyDetailsModel(u)}createCandidate(e,t,r,n,i){let u=new FormData;return n.forEach(D=>u.append("attachments",D)),i&&u.set("image",i),u.set("candidate",JSON.stringify(r)),this.backend.post(`${this.getCandidatePath(e)}`,u,s({},o(t)))}prepareVacancyDetailsModel(e){return this.assignEmptyArraysOnNullOrUndefinedListFieldsForVacancyDetailsModel(this.mapDeprecatedVacancyDetailsFields(e))}prepareSimpleVacancyDetailsModel(e){return this.assignEmptyArraysOnNullOrUndefinedListFieldsForSimpleVacancyDetailsModel(e)}mapDeprecatedVacancyDetailsFields(e){return p(s({},e),{contactEmployeeWorkPhoneNumber:e.contactEmployeeWorkPhoneNumber??e.contactEmployeWorkPhoneNumber})}assignEmptyArraysOnNullOrUndefinedListFieldsForSimpleVacancyDetailsModel(e){return p(s({},e),{areas:e.areas??[],fieldsOfWork:e.fieldsOfWork??[],locations:e.locations??[],regions:e.regions??[]})}assignEmptyArraysOnNullOrUndefinedListFieldsForVacancyDetailsModel(e){return p(s(s({},e),this.assignEmptyArraysOnNullOrUndefinedListFieldsForSimpleVacancyDetailsModel(e)),{medias:e.medias??[],vacancyElements:e.vacancyElements??[]})}setDefaultFilter(e){return p(s({},e),{access:e?.access??m.External})}getBasePath(e){return`${l(this.baseUrl,e)}/vacancies`}getApplicationFormTypePath(e){return`${l(this.baseUrl,e)}/candidates/types`}getCandidatePath(e){return`${l(this.baseUrl,e)}/candidates`}getVacancyListPath(e){return`${this.getBasePath(e)}/detailed`}getSimpleVacancyListPath(e){return`${this.getBasePath(e)}/simple`}getConfigurationPath(e){return`${this.getBasePath(e)}/configuration`}getVacancyListConfigurationPath(e){return`${this.getConfigurationPath(e)}/list`}getVacancyDetailsConfigurationPath(e){return`${this.getConfigurationPath(e)}/details`}};window.mindkey=window.mindkey||{};window.mindkey.apiClient=window.mindkey.apiClient||{};window.mindkey.apiClient.HttpError=d;window.mindkey.apiClient.JobAgentClient=g;window.mindkey.apiClient.VacancyClient=f;window.mindkey.apiClient.LookupClient=h;