Skip to content

Commit

Permalink
feat(settings): Adding a settings/entitlement service (#3)
Browse files Browse the repository at this point in the history
* feat(settings): Adding a settings/entitlement service

* feat(settings): Adding a settings/entitlement service

* feat(settings): Adding a settings/entitlement service
  • Loading branch information
jgodi authored and bvkimball committed May 15, 2018
1 parent 75ee429 commit ba14393
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 25 deletions.
33 changes: 33 additions & 0 deletions src/services/SettingService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { AxiosInstance, AxiosResponse } from 'axios';
import { BullhornAllSettingsAndEntitlementsResponse } from '../types';
import { Staffing } from './Staffing';

/**
* A Class that defines a service to grab settings from Bullhorn
*/
export class SettingService {
http: AxiosInstance;

constructor() {
this.http = Staffing.http();
}

async getSettings(settings: string[]): Promise<{ [key: string]: any }> {
const response: AxiosResponse = await this.http.get(`settings/${settings.join()}`);
return response.data;
}

async getEntitlements(entity: string): Promise<string[]> {
const response: AxiosResponse = await this.http.get(`entitlements/${entity}`);
return response.data;
}

async getAllSettingsAndEntitlements(): Promise<BullhornAllSettingsAndEntitlementsResponse> {
const response: AxiosResponse = await this.http.get('services/Settings/allEntitlementsAndSettings');
const result: BullhornAllSettingsAndEntitlementsResponse = response.data;
if (result && result.dashboardEntitlements && result.entitlements) {
result.entitlements.DASHBOARD = result.dashboardEntitlements;
}
return result;
}
}
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './EntityService';
export * from './MetaService';
export * from './QueryService';
export * from './SearchService';
export * from './SettingService';
export * from './Staffing';
export * from './StaffingAuthProvider';
export * from './Where';
85 changes: 60 additions & 25 deletions src/types/Responses.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,79 @@
import { Field } from './Field';

export interface BullhornAllSettingsAndEntitlementsResponse {
settings: { [key: string]: any };
dashboardEntitlements: string[];
entitlements: { [key: string]: string[] };
userData: {
id: number;
masterUserID: number;
userType: {
id: number;
name: string;
};
firstName: string;
lastName: string;
phone: string;
mobile: string;
useDefaultMailClient: boolean;
email: string;
address: {
address1: string;
address2: string;
city: string;
state: string;
zip: string;
countryID: string;
countryName: string;
countryCode: string;
};
departments: {
total: number;
data: { id: number; name: string }[];
};
srelease: boolean;
};
}

export interface BullhornMessage {
detailMessage: string;
severity: string;
type: string;
detailMessage: string;
severity: string;
type: string;
}

export interface BullhornErrorMessage {
errorMessage: string;
errorMessageKey: string;
errorCode: number;
errorMessage: string;
errorMessageKey: string;
errorCode: number;
}

export interface BullhornMetaResponse {
entity: string;
entityMetaUrl: string;
label: string;
dateLastModified: number;
fields: Field[];
entity: string;
entityMetaUrl: string;
label: string;
dateLastModified: number;
fields: Field[];
}

export interface BullhornListResponse<T> {
total?: number;
start: string;
count: string;
data: T[];
messages?: BullhornMessage[];
meta?: BullhornMetaResponse;
total?: number;
start: string;
count: string;
data: T[];
messages?: BullhornMessage[];
meta?: BullhornMetaResponse;
}

export interface BullhornEntityResponse<T> {
data: T[];
messages?: BullhornMessage[];
meta?: BullhornMetaResponse;
data: T[];
messages?: BullhornMessage[];
meta?: BullhornMetaResponse;
}

export interface BullhornSavedEntityResponse<T> {
changedEntityType: string;
changedEntityId: number;
changeType: 'INSERT' | 'UPDATE';
messages: string[];
data: T;
changedEntityType: string;
changedEntityId: number;
changeType: 'INSERT' | 'UPDATE';
messages: string[];
data: T;
}

0 comments on commit ba14393

Please sign in to comment.