-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(settings): Adding a settings/entitlement service (#3)
* feat(settings): Adding a settings/entitlement service * feat(settings): Adding a settings/entitlement service * feat(settings): Adding a settings/entitlement service
- Loading branch information
Showing
3 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |