Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Finish api for PayrollPaymentSchedule module with tests
- Loading branch information
Showing
12 changed files
with
541 additions
and
0 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,48 @@ | ||
<?php | ||
|
||
namespace Ianriizky\TalentaApi\Services\Api; | ||
|
||
use Illuminate\Http\Client\Response; | ||
|
||
/** | ||
* @property \Illuminate\Http\Client\PendingRequest $request | ||
* | ||
* @see https://documenter.getpostman.com/view/12246328/TWDZHvj1#561cc8c8-403f-46c7-b12f-6f3e3922a47c | ||
*/ | ||
trait PayrollPaymentSchedule | ||
{ | ||
/** | ||
* Create "/company/me/payroll-payment-schedule" GET request to the Talenta api. | ||
* | ||
* Get company payroll payment schedule. This endpoint will allow user to: | ||
* - get company payroll payment schedule master data | ||
* - get company payroll payment schedule transaction data with additonal year, month, status parameters | ||
* | ||
* @param array|string|null $query | ||
* @return \Illuminate\Http\Client\Response | ||
* | ||
* @see https://documenter.getpostman.com/view/12246328/TWDZHvj1#52ffb3a7-5ea9-401f-a3db-a488e6546eb4 | ||
*/ | ||
protected function getCompanyPayrollPaymentSchedule($query = null): Response | ||
{ | ||
return $this->request->get('/company/me/payroll-payment-schedule', $query); | ||
} | ||
|
||
/** | ||
* Create "/payroll-payment-schedule/:company_id/history" GET request to the Talenta api. | ||
* | ||
* Get company payroll payment schedule. This endpoint will allow user to | ||
* - get company payroll payment schedule master data | ||
* - get company payroll payment schedule transaction data with additonal year, month, status parameters | ||
* | ||
* @param string $company_id | ||
* @param array|string|null $query | ||
* @return \Illuminate\Http\Client\Response | ||
* | ||
* @see https://documenter.getpostman.com/view/12246328/TWDZHvj1#0835590c-7454-4377-9419-7dacdd2073ef | ||
*/ | ||
protected function getPayrollPaymentScheduleHistory(string $company_id, $query = null): Response | ||
{ | ||
return $this->request->get('/payroll-payment-schedule/'.$company_id.'/history', $query); | ||
} | ||
} |
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
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,201 @@ | ||
<?php | ||
|
||
namespace Ianriizky\TalentaApi\Tests\Api; | ||
|
||
use Ianriizky\TalentaApi\Support\Facades\TalentaApi; | ||
use Ianriizky\TalentaApi\Tests\ApiTestCase; | ||
use Illuminate\Http\Client\RequestException; | ||
use Illuminate\Http\Client\Response; | ||
use Illuminate\Http\Response as HttpResponse; | ||
|
||
/** | ||
* @see \Ianriizky\TalentaApi\Services\Api\PayrollPaymentSchedule | ||
*/ | ||
class PayrollPaymentScheduleTest extends ApiTestCase | ||
{ | ||
public function test_getCompanyPayrollPaymentSchedule_response_200_master_data_payroll_payment_schedule() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getCompanyPayrollPaymentSchedule/200_master_data_payroll_payment_schedule.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath); | ||
|
||
tap(TalentaApi::getCompanyPayrollPaymentSchedule([ | ||
// 'limit' => 'x', | ||
// 'page' => '1x', | ||
'user_id' => '8002', | ||
// 'year' => '2021', | ||
// 'month' => 'x', | ||
// 'status' => 'pending', | ||
]), function ($response) use ($jsonPath) { | ||
$this->assertInstanceOf(Response::class, $response); | ||
|
||
$response->assertSameWithJsonPath($jsonPath); | ||
}); | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getCompanyPayrollPaymentSchedule_response_200_payroll_payment_schedule_transaction() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getCompanyPayrollPaymentSchedule/200_payroll_payment_schedule_transaction.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath); | ||
|
||
tap(TalentaApi::getCompanyPayrollPaymentSchedule([ | ||
// 'limit' => 'x', | ||
// 'page' => '1x', | ||
'user_id' => '8002', | ||
'year' => '2021', | ||
// 'month' => 'x', | ||
// 'status' => '', | ||
]), function ($response) use ($jsonPath) { | ||
$this->assertInstanceOf(Response::class, $response); | ||
|
||
$response->assertSameWithJsonPath($jsonPath); | ||
}); | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getCompanyPayrollPaymentSchedule_response_200_empty_response() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getCompanyPayrollPaymentSchedule/200_empty_response.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath); | ||
|
||
tap(TalentaApi::getCompanyPayrollPaymentSchedule([ | ||
// 'limit' => 'x', | ||
// 'page' => '1x', | ||
'user_id' => '935848', | ||
// 'year' => 'x', | ||
// 'month' => 'x', | ||
]), function ($response) use ($jsonPath) { | ||
$this->assertInstanceOf(Response::class, $response); | ||
|
||
$response->assertSameWithJsonPath($jsonPath); | ||
}); | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getCompanyPayrollPaymentSchedule_response_401() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getCompanyPayrollPaymentSchedule/401.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath, HttpResponse::HTTP_UNAUTHORIZED); | ||
|
||
$this->expectException(RequestException::class); | ||
$this->expectExceptionCode(HttpResponse::HTTP_UNAUTHORIZED); | ||
|
||
try { | ||
TalentaApi::getCompanyPayrollPaymentSchedule([ | ||
// 'limit' => '3', | ||
// 'page' => '1', | ||
'user_id' => '935848', | ||
// 'year' => '', | ||
// 'month' => '', | ||
]); | ||
} catch (RequestException $th) { | ||
$th->response->assertSameWithJsonPath($jsonPath); | ||
|
||
throw $th; | ||
} | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getCompanyPayrollPaymentSchedule_response_400() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getCompanyPayrollPaymentSchedule/400.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath, HttpResponse::HTTP_BAD_REQUEST); | ||
|
||
$this->expectException(RequestException::class); | ||
$this->expectExceptionCode(HttpResponse::HTTP_BAD_REQUEST); | ||
|
||
try { | ||
TalentaApi::getCompanyPayrollPaymentSchedule([ | ||
'limit' => 'x', | ||
'page' => '1x', | ||
'user_id' => '-8002', | ||
'year' => '2021x', | ||
'month' => 'x', | ||
'status' => 'pending', | ||
]); | ||
} catch (RequestException $th) { | ||
$th->response->assertSameWithJsonPath($jsonPath); | ||
|
||
throw $th; | ||
} | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getPayrollPaymentScheduleHistory_response_200() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getPayrollPaymentScheduleHistory/200.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath); | ||
|
||
tap(TalentaApi::getPayrollPaymentScheduleHistory('me', [ | ||
'limit' => '20', | ||
'page' => '1', | ||
'user_id' => '935848', | ||
// 'month' => '4', | ||
'year' => '2022', | ||
]), function ($response) use ($jsonPath) { | ||
$this->assertInstanceOf(Response::class, $response); | ||
|
||
$response->assertSameWithJsonPath($jsonPath); | ||
}); | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getPayrollPaymentScheduleHistory_response_200_empty_data() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getPayrollPaymentScheduleHistory/200_empty_data.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath); | ||
|
||
tap(TalentaApi::getPayrollPaymentScheduleHistory('me', [ | ||
'limit' => '20', | ||
'page' => '1', | ||
'user_id' => '935848', | ||
'month' => '12', | ||
'year' => '2022', | ||
]), function ($response) use ($jsonPath) { | ||
$this->assertInstanceOf(Response::class, $response); | ||
|
||
$response->assertSameWithJsonPath($jsonPath); | ||
}); | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
|
||
public function test_getPayrollPaymentScheduleHistory_response_400() | ||
{ | ||
$jsonPath = 'payroll_payment_schedule/getPayrollPaymentScheduleHistory/400.json'; | ||
|
||
$this->factory->fakeUsingJsonPath($jsonPath, HttpResponse::HTTP_BAD_REQUEST); | ||
|
||
$this->expectException(RequestException::class); | ||
$this->expectExceptionCode(HttpResponse::HTTP_BAD_REQUEST); | ||
|
||
try { | ||
TalentaApi::getPayrollPaymentScheduleHistory('me', [ | ||
'limit' => '200', | ||
'page' => '1x', | ||
'user_id' => '935848', | ||
'month' => '12x', | ||
'year' => '2022x', | ||
]); | ||
} catch (RequestException $th) { | ||
$th->response->assertSameWithJsonPath($jsonPath); | ||
|
||
throw $th; | ||
} | ||
|
||
$this->factory->assertSentCount(1); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...sponses/payroll_payment_schedule/getCompanyPayrollPaymentSchedule/200_empty_response.json
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,7 @@ | ||
{ | ||
"message": "payroll payment schedule not found for company id 3053", | ||
"data": { | ||
"payroll_payment_schedule": null, | ||
"total": 0 | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...t_schedule/getCompanyPayrollPaymentSchedule/200_master_data_payroll_payment_schedule.json
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,100 @@ | ||
{ | ||
"message": "get company payroll payment schedule successfully", | ||
"data": { | ||
"payroll_payment_schedule": [ | ||
{ | ||
"id": 2400, | ||
"name": "MAHECUSTOM", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-12-16 11:13:05" | ||
}, | ||
{ | ||
"id": 2262, | ||
"name": "RF", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-11-22 10:29:01" | ||
}, | ||
{ | ||
"id": 2004, | ||
"name": "WAREHOUSEWEEKLY", | ||
"payment_schedule_date": "", | ||
"type": "weekly", | ||
"status": -1, | ||
"created_date": "2021-09-13 17:30:22" | ||
}, | ||
{ | ||
"id": 1782, | ||
"name": "NADIA", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-07-29 15:15:37" | ||
}, | ||
{ | ||
"id": 1702, | ||
"name": "ASASSA", | ||
"payment_schedule_date": "", | ||
"type": "weekly", | ||
"status": -1, | ||
"created_date": "2021-07-09 12:18:42" | ||
}, | ||
{ | ||
"id": 1701, | ||
"name": "TEST", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-07-09 12:15:30" | ||
}, | ||
{ | ||
"id": 1496, | ||
"name": "ALLOWANCE", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-05-11 16:31:38" | ||
}, | ||
{ | ||
"id": 1291, | ||
"name": "GAJIB", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-03-09 18:22:49" | ||
}, | ||
{ | ||
"id": 1290, | ||
"name": "GAJIA", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-03-09 18:22:24" | ||
}, | ||
{ | ||
"id": 1281, | ||
"name": "TES1", | ||
"payment_schedule_date": "", | ||
"type": "monthly", | ||
"status": -1, | ||
"created_date": "2021-03-05 10:25:19" | ||
} | ||
], | ||
"total": 27, | ||
"pagination": { | ||
"current_page": 1, | ||
"first_page_url": "/v2/payroll-payment-schedule/679?user_id=8002&page=1&per-page=10", | ||
"from": 1, | ||
"last_page": 3, | ||
"last_page_url": "/v2/payroll-payment-schedule/679?user_id=8002&page=3&per-page=10", | ||
"next_page_url": "/v2/payroll-payment-schedule/679?user_id=8002&page=2&per-page=10", | ||
"path": "/v2/payroll-payment-schedule/679", | ||
"per_page": 10, | ||
"to": 10, | ||
"total": 27 | ||
} | ||
} | ||
} |
Oops, something went wrong.