Fixes on attendes endpoint
* shared_contact_info was not saving * error on delete RSVP * added member get affiliations endpoint Change-Id: Id4b8c1d8fec5b8601dde6815840e282a0bc46359
This commit is contained in:
parent
70ba1978b3
commit
91358d8b72
@ -26,6 +26,8 @@ use utils\OrderParser;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Class OAuth2MembersApiController
|
||||
* @package App\Http\Controllers
|
||||
@ -172,6 +174,48 @@ final class OAuth2MembersApiController extends OAuth2ProtectedController
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $member_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMemberAffiliations($member_id){
|
||||
try {
|
||||
|
||||
$member = $this->repository->getById($member_id);
|
||||
if(is_null($member)) return $this->error404();
|
||||
$affiliations = $member->getAffiliations()->toArray();
|
||||
|
||||
$response = new PagingResponse
|
||||
(
|
||||
count($affiliations),
|
||||
count($affiliations),
|
||||
1,
|
||||
1,
|
||||
$affiliations
|
||||
);
|
||||
|
||||
return $this->ok($response->toArray($expand = Input::get('expand','')));
|
||||
|
||||
}
|
||||
catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch(FilterParserException $ex3){
|
||||
Log::warning($ex3);
|
||||
return $this->error412($ex3->getMessages());
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $member_id
|
||||
* @param int $affiliation_id
|
||||
|
@ -449,7 +449,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
|
||||
$rules = [
|
||||
|
||||
'member_id' => 'required|integer',
|
||||
'share_contact_info' => 'sometimes|boolean',
|
||||
'shared_contact_info' => 'sometimes|boolean',
|
||||
'summit_hall_checked_in' => 'sometimes|boolean',
|
||||
'summit_hall_checked_in_date' => 'sometimes|date_format:U',
|
||||
];
|
||||
@ -533,7 +533,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
|
||||
|
||||
$rules = [
|
||||
'member_id' => 'required|integer',
|
||||
'share_contact_info' => 'sometimes|boolean',
|
||||
'shared_contact_info' => 'sometimes|boolean',
|
||||
'summit_hall_checked_in' => 'sometimes|boolean',
|
||||
'summit_hall_checked_in_date' => 'sometimes|date_format:U',
|
||||
];
|
||||
|
@ -102,7 +102,7 @@ Route::group([
|
||||
Route::group(['prefix'=>'{member_id}'], function(){
|
||||
|
||||
Route::group(['prefix' => 'affiliations'], function(){
|
||||
|
||||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2MembersApiController@getMemberAffiliations']);
|
||||
Route::group(['prefix' => '{affiliation_id}'], function(){
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2MembersApiController@updateAffiliation']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2MembersApiController@deleteAffiliation']);
|
||||
|
@ -41,8 +41,8 @@ final class SummitAttendeeFactory
|
||||
$attendee->setMember($member);
|
||||
$attendee->setSummit($summit);
|
||||
|
||||
if(isset($data['share_contact_info']))
|
||||
$attendee->setShareContactInfo($data['share_contact_info']);
|
||||
if(isset($data['shared_contact_info']))
|
||||
$attendee->setShareContactInfo($data['shared_contact_info']);
|
||||
|
||||
if(isset($data['summit_hall_checked_in']))
|
||||
$attendee->setSummitHallCheckedIn($data['summit_hall_checked_in']);
|
||||
|
@ -120,11 +120,11 @@ final class MemberService implements IMemberService
|
||||
public function deleteRSVP(Member $member, $rsvp_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($member, $rsvp_id){
|
||||
$affiliation = $member->getRsvpById($rsvp_id);
|
||||
if(is_null($affiliation))
|
||||
$rsvp = $member->getRsvpById($rsvp_id);
|
||||
if(is_null($rsvp))
|
||||
throw new EntityNotFoundException(sprintf("rsvp id %s does not belongs to member id %s", $rsvp_id, $member->getId()));
|
||||
|
||||
$member->removeAffiliation($affiliation);
|
||||
$member->removeRsvp($rsvp);
|
||||
});
|
||||
}
|
||||
}
|
@ -705,6 +705,12 @@ class ApiEndpointsSeeder extends Seeder
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [sprintf('%s/members/read/me', $current_realm)],
|
||||
],
|
||||
[
|
||||
'name' => 'get-member-affiliations',
|
||||
'route' => '/api/v1/members/{member_id}/affiliations',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [sprintf('%s/members/read', $current_realm)],
|
||||
],
|
||||
[
|
||||
'name' => 'update-member-affiliation',
|
||||
'route' => '/api/v1/members/{member_id}/affiliations/{affiliation_id}',
|
||||
|
@ -171,4 +171,30 @@ final class OAuth2MembersApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($affiliation));
|
||||
return $affiliation;
|
||||
}
|
||||
|
||||
public function testGetMemberAffiliation($member_id = 11624)
|
||||
{
|
||||
|
||||
$params = [
|
||||
//AND FILTER
|
||||
'member_id' => $member_id
|
||||
];
|
||||
|
||||
$headers = ["HTTP_Authorization" => " Bearer " . $this->access_token];
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2MembersApiController@getMemberAffiliations",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$affiliations = json_decode($content);
|
||||
$this->assertTrue(!is_null($affiliations));
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user