Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add applicant related operations #8

Merged
merged 1 commit into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion peoplehr/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
distribution = "2201.0.0"
org = "ballerinax"
name = "peoplehr"
version = "1.1.0"
version = "1.1.1"
authors = ["Ballerina"]
icon = "icon.png"
repository = "https://github.com/ballerina-platform/module-ballerinax-peoplehr"
Expand Down
42 changes: 42 additions & 0 deletions peoplehr/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,48 @@ public isolated client class Client {
return check self.HTTPClient->post(VACANCY, request);
}

# Creates New Applicant
#
# + payload - New applicant detail
# + return - Successful response or an error
@display{label: "Create New Applicant"}
isolated remote function createNewApplicant(@display{label: "New Applicant detail"} NewApplicant payload) returns
OperationStatus|error {
http:Request request = new;
json jsonBody = check payload.cloneWithType(json);
json authentication = {APIKey: self.config.apiKey, Action: "CreateNewApplicant"};
request.setJsonPayload(check jsonBody.mergeJson(authentication));
return check self.HTTPClient->post(APPLICANT, request);
}

# Upload applicant document
#
# + payload - Request detail on new document
# + return - Successful response or an error
@display{label: "Upload new applicant document"}
isolated remote function uploadApplicantDocument(@display{label: "New applicant document"} NewDocument payload)
returns OperationStatus|error {
http:Request request = new;
json jsonBody = check payload.cloneWithType(json);
json authentication = {APIKey: self.config.apiKey, Action: "uploadapplicantdocument"};
request.setJsonPayload(check jsonBody.mergeJson(authentication));
return check self.HTTPClient->post(APPLICANT, request);
}

# Checks duplicate applicant
#
# + payload - Request detail on an applicant
# + return - Successful response or an error
@display{label: "Check duplicate applicant"}
isolated remote function checkDuplicateApplicant(@display{label: "Applicant detail"} ApplicantInformation payload)
returns OperationStatus|error {
http:Request request = new;
json jsonBody = check payload.cloneWithType(json);
json authentication = {APIKey: self.config.apiKey, Action: "CheckDuplicateApplicant"};
request.setJsonPayload(check jsonBody.mergeJson(authentication));
return check self.HTTPClient->post(APPLICANT, request);
}

# Gets query result By query name details.
#
# + payload - Request detail on a query
Expand Down
1 change: 1 addition & 0 deletions peoplehr/constants.bal
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ const string EMPLOYEE = "/Employee";
const string VACANCY = "/Vacancy";
const string HOLIDAY = "/Holiday";
const string SALARY = "/Salary";
const string APPLICANT = "/Applicant";
85 changes: 67 additions & 18 deletions peoplehr/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ Client baseClient = check new ({apiKey: apiKey, baseURL: baseURL});
@test:Config {enable: true}
function checkAuthentication() returns error? {
log:printInfo("Check Authentication");
AuthenticationResponse response = check baseClient->checkAuthentication({EmailAddress: emailAddress,
Password: password});
AuthenticationResponse response = check baseClient->checkAuthentication({
EmailAddress: emailAddress,
Password: password
});
log:printInfo(response.toString());
}

Expand All @@ -43,15 +45,22 @@ function testGetQueryResultByQueryName() returns error? {
log:printInfo(response.Message);
}

@test:Config {enable: false, dependsOn: [testGetEmployeeDetailById, testMarkAsLeaverById, testMarkAsLeaverById,
testAddNewHoliday]}
@test:Config {
enable: false,
dependsOn: [
testGetEmployeeDetailById,
testMarkAsLeaverById,
testMarkAsLeaverById,
testAddNewHoliday
]
}
function testUpdateEmployeeId() returns error? {
log:printInfo("Update Employee Id");
EmployeeIdUpdateRequest EmployeeIdUpdateRequest = {
ReasonForChange: "Test only",
OldEmployeeId: employeeId,
NewEmployeeId: (check random:createIntInRange(100, 1000)).toString()
};
};
OperationStatus response = check baseClient->updateEmployeeId(EmployeeIdUpdateRequest);
log:printInfo(response.Message);
}
Expand All @@ -61,8 +70,8 @@ function testGetAllEmployeeDetail() returns error? {
log:printInfo("Get All Employee Detail");
AllEmployeesRequest AllEmployeesRequest = {
IncludeLeavers: false
};
EmployeesResponse response= check baseClient->getAllEmployees(AllEmployeesRequest);
};
EmployeesResponse response = check baseClient->getAllEmployees(AllEmployeesRequest);
log:printInfo(response.Message);
}

Expand All @@ -72,7 +81,7 @@ function testGetEmployeeDetailById() returns error? {
EmployeeRequest EmployeeRequest = {
EmployeeId: employeeId
};
EmployeeResponse response= check baseClient->getEmployeeById(EmployeeRequest);
EmployeeResponse response = check baseClient->getEmployeeById(EmployeeRequest);
log:printInfo(response.Message);
}

Expand All @@ -93,7 +102,6 @@ function testCreateNewEmployee() returns error? {
log:printInfo(response.Message);
}


@test:Config {enable: true}
function testUpdateEmployeeDetail() returns error? {
log:printInfo("Update Employee Detail");
Expand All @@ -102,7 +110,7 @@ function testUpdateEmployeeDetail() returns error? {
FirstName: "BallerinaUser",
ReasonForChange: "Test"
};
OperationStatus response= check baseClient->updateEmployee(employee);
OperationStatus response = check baseClient->updateEmployee(employee);
log:printInfo(response.Message);
}

Expand All @@ -119,7 +127,7 @@ function testMarkAsLeaverById() returns error? {
AdditionalComments: "Test",
SupportingComments: "supporting comments"
};
OperationStatus response= check baseClient->markAsLeaverById(employeeLeaverStatus);
OperationStatus response = check baseClient->markAsLeaverById(employeeLeaverStatus);
log:printInfo(response.Message);
}

Expand All @@ -130,7 +138,7 @@ function testGetSalaryDetail() returns error? {
EmployeeId: "PW2",
IsIncludeHistory: false
};
SalaryDetailGetResponse response= check baseClient->getSalaryDetail(salaryDetailRequest);
SalaryDetailGetResponse response = check baseClient->getSalaryDetail(salaryDetailRequest);
log:printInfo(response.toString());
}

Expand All @@ -145,7 +153,7 @@ function testAddNewHoliday() returns error? {
DurationInDays: "1",
DurationInMinutes: "450"
};
OperationStatus response= check baseClient->addNewHoliday(newHolidayRequest);
OperationStatus response = check baseClient->addNewHoliday(newHolidayRequest);
log:printInfo(response.toString());
}

Expand All @@ -155,7 +163,7 @@ function testGetHolidayDetail() returns error? {
HolidayDetail holidayDetail = {
EmployeeId: "PW2"
};
HolidayGetResponse response= check baseClient->getHolidayDetail(holidayDetail);
HolidayGetResponse response = check baseClient->getHolidayDetail(holidayDetail);
log:printInfo(response.toString());
}

Expand All @@ -167,7 +175,7 @@ function testDeleteHoliday() returns error? {
StartDate: "2023-07-27",
EndDate: "2023-07-27"
};
OperationStatus response= check baseClient->deleteHoliday(holidayDetail);
OperationStatus response = check baseClient->deleteHoliday(holidayDetail);
log:printInfo(response.Message);
}

Expand All @@ -177,13 +185,54 @@ function testGetVacancy() returns error? {
GetVacancyResultRequest vacancyDetail = {
VacancyReference: "VA1"
};
VacancyGetResponse response= check baseClient->getVacancy(vacancyDetail);
VacancyGetResponse response = check baseClient->getVacancy(vacancyDetail);
log:printInfo(response.Message);
}

@test:Config {enable: true}
function testGetAllVacancies() returns error? {
log:printInfo("Get All Vacancies");
AllVacancies response= check baseClient->getAllVacancies();
AllVacancies response = check baseClient->getAllVacancies();
log:printInfo(response.toString());
}

@test:Config {enable: true}
function testCreateNewApplicant() returns error? {
log:printInfo("Create new applicant");
NewApplicant newApplicant = {
FirstName: "Smith",
LastName: "Perera",
Email: "testapplicant@wso2.com",
Documents: [{DocumentName: "CV01", Url: "www.mycv.com"}],
Skills: "Programming",
VacancyReference: "VA100"
};
OperationStatus response = check baseClient->createNewApplicant(newApplicant);
log:printInfo(response.Message);
}

@test:Config {enable: true, dependsOn: [testCreateNewApplicant]}
function testUploadApplicantDocument() returns error? {
log:printInfo("Upload new document");
NewDocument newDocument = {
ApplicantId: "6604761",
Description: "Degree",
DocumentName: "transcript.txt",
File: "dGVzdCBmaWxlCg=="
};
OperationStatus response = check baseClient->uploadApplicantDocument(newDocument);
log:printInfo(response.toString());
}
}

@test:Config {enable: true, dependsOn: [testCreateNewApplicant]}
function testCheckDuplicateApplicant() returns error? {
log:printInfo("Check duplicate applicant");
ApplicantInformation applicantInformation = {
FirstName: "Smith",
LastName: "Perera",
Email: "testapplicant@wso2.com",
VacancyReference: "VA3"
};
OperationStatus response = check baseClient->checkDuplicateApplicant(applicantInformation);
log:printInfo(response.toString());
}
99 changes: 96 additions & 3 deletions peoplehr/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public type EmployeeVerification record {
string EmployeeId?;
};

# Represents the response type of `UpdateEmployeeId` operation
# Represents the response type of an operation
#
# + Result - The response of the operation
public type OperationStatus record {
Expand Down Expand Up @@ -177,7 +177,7 @@ public type AllVacancies record {|
# + AdditionalQuestions - Additional questions
# + InternalQuestions - Internal questions on the vacancy
public type Vacancy record {
string? VacancyName?;
string VacancyName?;
string? VacancyDescription?;
string? Company?;
string? Location?;
Expand Down Expand Up @@ -790,7 +790,6 @@ public type HolidayUpdateRequest record {|
# + LastActionDateTime - The last action date time
# + IsToilHoliday - indicates whether isToil Holiday
public type Holiday record {|
*Authentication;
string StartDate?;
string EndDate?;
int DurationType?;
Expand All @@ -805,6 +804,7 @@ public type Holiday record {|
string Status?;
string LastActionDateTime?;
boolean IsToilHoliday?;
*Authentication;
|};

# Represents holiday detail
Expand All @@ -818,3 +818,96 @@ public type HolidayDetail record {|
string EndDate?;
*Authentication;
|};

# Represents additional question
#
# + QuestionId - Question ID
# + Value - Value default value
public type AdditionalQuestion record {
string QuestionId;
string Value;
};

# Internal questions for create new applicant
#
public type InternalQuestion record {
*AdditionalQuestion;
};

# Represents Document detail
#
# + DocumentName - Document name
# + Url - URL for the document
public type Document record {
string DocumentName;
string Url;
};

# Represents new applicant
#
# + VacancyReference - Vacancy reference for create new applicant
# + FirstName - First name for create new applicant
# + LastName - Last name for create new applicant
# + Email - Email for create new applicant
# + Gender - Gender for create new applicant
# + DateOfBirth - Date of birth for create new applicant
# + PostCode - Post code for create new applicant
# + Address - Address for create new applicant
# + PhoneNumber - PhoneNumber for create new applicant
# + OtherContactDetails - Other contact details for create new applicant
# + Source - Source for create new applicant
# + AdditionalQuestions - Source for create new applicant
# + InternalQuestions - Internal questions for create new applicant
# + Documents - Documents for create new applicant
# + Skills - Skills for create new applicant
# + RecruitmentCost - Recruitment cost for create new applicant
# + DateLastContacted - Date last contacted for create new applicant
public type NewApplicant record {|
string VacancyReference?;
string FirstName;
string LastName;
string Email?;
string Gender?;
string DateOfBirth?;
string PostCode?;
string Address?;
string PhoneNumber?;
string OtherContactDetails?;
string Source?;
AdditionalQuestion[] AdditionalQuestions?;
InternalQuestion[] InternalQuestions?;
Document[] Documents;
string Skills;
string RecruitmentCost?;
string DateLastContacted?;
*Authentication;
json...;
|};

# Represents document detail
#
# + ApplicantId - ApplicantId for upload applicant document
# + DocumentName - Document name for upload applicant document(<= 100 characters)
# + Description - Description for upload applicant document(<= 256 characters)
# + File - File for upload applicant document
public type NewDocument record {|
string ApplicantId;
string DocumentName;
string Description;
string File;
*Authentication;
|};

# Applicant information for duplicate checking
#
# + VacancyReference - Vacancy reference for check duplicate applicant
# + FirstName - First name for check duplicate applicant(<= 50 characters)
# + LastName - Last name for check duplicate applicant(<= 50 characters)
# + Email - Email for check duplicate applicant
public type ApplicantInformation record {|
string FirstName;
string LastName;
string VacancyReference;
string Email?;
*Authentication;
|};