UNPKG

@mindkey/recruiting-api-client

Version:

The MindKey API Client allows easy access to your MindKey Recruiting data.

4 lines (2 loc) 6.54 kB
var V=Object.defineProperty,S=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(t,e,a)=>e in t?V(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,s=(t,e)=>{for(var a in e||={})F.call(e,a)&&x(t,a,e[a]);if(b)for(var a of b(e))w.call(e,a)&&x(t,a,e[a]);return t},p=(t,e)=>S(t,E(e));function l(t,e){return`${t}/${encodeURIComponent(e)}`}function o(t){return{"X-MindKey-User-Language":t}}var d=class extends Error{constructor(e,a){super(a),this.response=e}get status(){return this.response.status}};var c={async get(t,e){return await c.sendRequest(t,"GET",e)},async post(t,e,a){return await c.sendRequest(t,"POST",a,e)},async put(t,e,a){return await c.sendRequest(t,"GET",a,e)},async delete(t,e,a){return await c.sendRequest(t,"GET",a,e)},async sendRequest(t,e,a,r){let n=await fetch(t,{method:e,headers:a,body:f(r)}),i="";if(n.ok)i=await n.text();else{try{i=await n.text()}catch{i=`Http failure response for ${t}: ${n.status} ${n.statusText}`}throw new d(n,i)}return i||(i="{}"),JSON.parse(i)}};function f(t){if(t)return typeof Blob<"u"&&t instanceof Blob||typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer||typeof FormData<"u"&&t instanceof FormData||typeof URLSearchParams<"u"&&t instanceof URLSearchParams?t:JSON.stringify(t)}function k(){return{"Content-Type":"application/json"}}var m=class{constructor(e,a=c){this.basePath=e,this.backend=a}getJobAgentConfiguration(e,a){return this.backend.get(`${this.getBaseUrl(e)}/configuration`,s({},o(a)))}getJobAgentType(e,a,r){return this.backend.get(`${this.getBaseUrl(e)}/types/${encodeURIComponent(r)}`,s({},o(a)))}getJobAgent(e,a,r,n,i){return this.backend.post(`${this.getBaseUrl(e)}/${i}`,{jobAgentId:r,code:n},s({},this.getDefaultPostHeaders(a)))}createJobAgent(e,a,r,n){return this.backend.post(`${this.getBaseUrl(e)}/create/${n}`,r,s({},this.getDefaultPostHeaders(a)))}updateJobAgent(e,a,r,n){return this.backend.put(`${this.getBaseUrl(e)}/${n}`,r,s({},this.getDefaultPostHeaders(a)))}deleteJobAgent(e,a,r,n,i){return this.backend.delete(`${this.getBaseUrl(e)}/${i}`,{code:n,jobAgentId:r},s({},this.getDefaultPostHeaders(a)))}resendEmail(e,a,r,n){return this.backend.post(`${this.getBaseUrl(e)}/resend-email/${n}`,r,s({},this.getDefaultPostHeaders(a)))}activate(e,a,r,n){return this.backend.post(`${this.getBaseUrl(e)}/activate/${n}`,r,s({},this.getDefaultPostHeaders(a)))}getBaseUrl(e){return`${l(this.basePath,e)}/job-agents`}getDefaultPostHeaders(e){return s(s({},o(e)),k())}};var y=class{constructor(e,a=c){this.baseUrl=e,this.backend=a}getLookups(e,a){return this.backend.get(`${l(this.baseUrl,e)}/candidates/lookup`,s({},o(a)))}};var D=function(t){return t.Other="Other",t.Application="Application",t.Resume="Resume",t}(D||{});var $=function(t){return t.Show="Show",t.Hide="Hide",t.Sidebar="Sidebar",t}($||{});var g=function(t){return t.All="All",t.External="External",t.Internal="Internal",t}(g||{}),B=function(t){return t.Hide="Hide",t.Only="Only",t.Bottom="Bottom",t.Top="Top",t}(B||{});var U=function(t){return t.Description="Description",t.StartDate="StartDate",t.EndDate="EndDate",t.Priority="Priority",t}(U||{});var O=(t,e,a)=>{let r=a?a[e]:void 0;if(r===void 0)return;let n=String(e);switch(typeof r){case"boolean":t.set(n,r?"true":"false");break;case"string":t.set(n,r);break;default:throw new Error(`${typeof r} is not implemented yet.`)}},h=(t,e)=>{if(e)for(let a of Object.keys(e))O(t,a,e)};var P=class{constructor(e,a=c){this.baseUrl=e,this.backend=a}getApplicationFormType(e,a,r="Standard"){return this.backend.get(`${this.getApplicationFormTypePath(e)}/${encodeURIComponent(r)}`,s({},o(a)))}getVacancyListConfiguration(e,a){return this.backend.get(this.getVacancyListConfigurationPath(e),s({},o(a)))}async getVacancyList(e,a,r){let n=new URL(this.getVacancyListPath(e));return h(n.searchParams,this.setDefaultFilter(r)),(await this.backend.get(n.toString(),s({},o(a)))).map(u=>this.prepareVacancyDetailsModel(u))}async getSimpleVacancyList(e,a,r){let n=new URL(this.getSimpleVacancyListPath(e));return h(n.searchParams,this.setDefaultFilter(r)),(await this.backend.get(n.toString(),s({},o(a)))).map(u=>this.prepareSimpleVacancyDetailsModel(u))}getVacancyDetailsConfiguration(e,a){return this.backend.get(this.getVacancyDetailsConfigurationPath(e),s({},o(a)))}async getVacancyDetails(e,a,r,n){let i=new URL(`${this.getBasePath(e)}/${encodeURIComponent(a)}`);h(i.searchParams,n);let u=await this.backend.get(i.toString(),s({},o(r)));return this.prepareVacancyDetailsModel(u)}createCandidate(e,a,r,n,i){let u=new FormData;return n.forEach(L=>u.append("attachments",L)),i&&u.set("image",i),u.set("candidate",JSON.stringify(r)),this.backend.post(`${this.getCandidatePath(e)}`,u,s({},o(a)))}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??g.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`}};export{g as AccessType,D as AttachmentType,$ as DataPlacement,d as HttpError,m as JobAgentClient,y as LookupClient,U as SortFieldType,B as UnsolicitedType,P as VacancyClient,f as convertToBodyInit,c as fetchBackend}; //# sourceMappingURL=api-client.mjs.map