Skip to content

Commit 386e519

Browse files
authored
Refactored Samsung API to accepted Summit registration feed metadata (#194)
* fix on job time out * AttendeeService::resynchAttendeesStatusBySummit refactor Change-Id: Ifbbb8243ebcf2617085e1902a0af8c656a40b934 * fix on job time out * AttendeeService::resynchAttendeesStatusBySummit refactor Change-Id: Ifbbb8243ebcf2617085e1902a0af8c656a40b934 * Refactored Samsung API to accepted Summit registration feed metadata Change-Id: I0d5f4d7cab35ff20f4abbf7558330830463f95ce * added registration feed metadata CRUD endpoints GET api/v1/summits/{id}/registration-feed-metadata filter key (@@,=@) value (@@,=@) order id, key POST api/v1/summits/{id}/registration-feed-metadata payload key (required|string) value (required|string) GET api/v1/summits/{id}/registration-feed-metadata/{metadata_id} DELETE api/v1/summits/{id}/registration-feed-metadata/{metadata_id} Change-Id: I20752f3a47b508656a59987d8c91a05964297737 * Registration feed tweaks for samsung Change-Id: I2a956d06e6212f353a4e32bf8a7dca9b8ede0549 * Fix and tweaks Change-Id: Ie734a3ba0d6c2de76984456e875f004d5c107e61 * updated endpoints Change-Id: If300a4f3bf397f3c234b4ac4a8e3c5261860ffc0 * Fix on Job * dont allow duplicate jobs Change-Id: If989d7a620b15e01d8f41905a4afc4c1938cbe3a
1 parent e1d7829 commit 386e519

30 files changed

+1244
-377
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?php namespace App\Http\Controllers;
2+
/**
3+
* Copyright 2020 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
use App\Models\Foundation\Summit\Repositories\ISummitRegistrationFeedMetadataRepository;
16+
use models\oauth2\IResourceServerContext;
17+
use models\summit\ISummitRepository;
18+
use models\summit\Summit;
19+
use models\utils\IBaseRepository;
20+
use models\utils\IEntity;
21+
use services\model\ISummitService;
22+
23+
/**
24+
* Class OAuth2SummitRegistrationFeedMetadataApiController
25+
* @package App\Http\Controllers
26+
*/
27+
class OAuth2SummitRegistrationFeedMetadataApiController
28+
extends OAuth2ProtectedController
29+
{
30+
/**
31+
* @var ISummitRepository
32+
*/
33+
private $summit_repository;
34+
35+
/**
36+
* @var ISummitService
37+
*/
38+
private $service;
39+
40+
/**
41+
* @param ISummitRegistrationFeedMetadataRepository $repository
42+
* @param ISummitRepository $summit_repository
43+
* @param ISummitService $service
44+
* @param IResourceServerContext $resource_server_context
45+
*/
46+
public function __construct
47+
(
48+
ISummitRegistrationFeedMetadataRepository $repository,
49+
ISummitRepository $summit_repository,
50+
ISummitService $service,
51+
IResourceServerContext $resource_server_context
52+
)
53+
{
54+
parent::__construct($resource_server_context);
55+
$this->repository = $repository;
56+
$this->summit_repository = $summit_repository;
57+
$this->service = $service;
58+
}
59+
60+
use GetAllBySummit;
61+
62+
use GetSummitChildElementById;
63+
64+
use AddSummitChildElement;
65+
66+
use UpdateSummitChildElement;
67+
68+
use DeleteSummitChildElement;
69+
70+
/**
71+
* @return array
72+
*/
73+
protected function getFilterRules():array
74+
{
75+
return [
76+
'key' => ['=@', '@@'],
77+
'value' => ['=@', '@@'],
78+
];
79+
}
80+
81+
/**
82+
* @return array
83+
*/
84+
protected function getFilterValidatorRules():array{
85+
return [
86+
'key' => 'sometimes|required|string',
87+
'value' => 'sometimes|required|string',
88+
];
89+
}
90+
/**
91+
* @return array
92+
*/
93+
protected function getOrderRules():array{
94+
return [
95+
'id',
96+
'key',
97+
];
98+
}
99+
100+
/**
101+
* @param array $payload
102+
* @return array
103+
*/
104+
function getAddValidationRules(array $payload): array
105+
{
106+
return [
107+
'key' => 'required|string',
108+
'value' => 'required|string',
109+
];
110+
}
111+
112+
function getUpdateValidationRules(array $payload): array
113+
{
114+
return [
115+
'key' => 'sometimes|string',
116+
'value' => 'sometimes|string',
117+
];
118+
}
119+
120+
function updateChild(Summit $summit, $child_id, array $payload): IEntity
121+
{
122+
return $this->service->updateRegistrationFeedMetadata($summit, intval($child_id), $payload);
123+
}
124+
125+
/**
126+
* @param Summit $summit
127+
* @param array $payload
128+
* @return IEntity
129+
*/
130+
protected function addChild(Summit $summit, array $payload): IEntity
131+
{
132+
return $this->service->addRegistrationFeedMetadata($summit, $payload);
133+
}
134+
135+
/**
136+
* @return ISummitRepository
137+
*/
138+
protected function getSummitRepository(): ISummitRepository
139+
{
140+
return $this->summit_repository;
141+
}
142+
143+
/**
144+
* @return IBaseRepository
145+
*/
146+
protected function getRepository(): IBaseRepository
147+
{
148+
return $this->repository;
149+
}
150+
151+
/**
152+
* @param Summit $summit
153+
* @param $child_id
154+
* @return void
155+
*/
156+
protected function deleteChild(Summit $summit, $child_id): void
157+
{
158+
$this->service->removeRegistrationFeedMetadata($summit, intval($child_id));
159+
}
160+
161+
/**
162+
* @param Summit $summit
163+
* @param $child_id
164+
* @return IEntity|null
165+
*/
166+
protected function getChildFromSummit(Summit $summit,$child_id): ?IEntity
167+
{
168+
return $summit->getRegistrationFeedMetadataById(intval($child_id));
169+
}
170+
}

app/Jobs/Emails/BookableRooms/AbstractBookableRoomReservationEmail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(SummitRoomReservation $reservation)
4545
$payload[IMailTemplatesConstants::reservation_end_datetime] = $reservation->getLocalEndDatetime()->format("F d, Y");
4646
$payload[IMailTemplatesConstants::reservation_created_datetime] = $reservation->getCreated()->format("F d, Y");
4747
$payload[IMailTemplatesConstants::reservation_amount] = FormatUtils::getNiceFloat($reservation->getAmount());
48-
$payload[IMailTemplatesConstants::reservation_currency] = FormatUtils::getNiceFloat($reservation->getCurrency());
48+
$payload[IMailTemplatesConstants::reservation_currency] = $reservation->getCurrency();
4949
$payload[IMailTemplatesConstants::reservation_id] = $reservation->getId();
5050
$payload[IMailTemplatesConstants::room_capacity] = $room->getCapacity();
5151
$payload[IMailTemplatesConstants::summit_name] = $summit->getName();

app/ModelSerializers/SerializerRegistry.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
use App\ModelSerializers\Summit\Registration\SponsorUserInfoGrantCSVSerializer;
8282
use App\ModelSerializers\Summit\Registration\SummitAttendeeCSVSerializer;
8383
use App\ModelSerializers\Summit\Registration\SummitAttendeeTicketCSVSerializer;
84+
use App\ModelSerializers\Summit\Registration\SummitRegistrationFeedMetadataSerializer;
8485
use App\ModelSerializers\Summit\RSVP\Templates\RSVPDropDownQuestionTemplateSerializer;
8586
use App\ModelSerializers\Summit\RSVP\Templates\RSVPLiteralContentQuestionTemplateSerializer;
8687
use App\ModelSerializers\Summit\RSVP\Templates\RSVPMultiValueQuestionTemplateSerializer;
@@ -395,7 +396,7 @@ private function __construct()
395396
$this->registry['SpeakersSummitRegistrationPromoCode'] = SpeakersSummitRegistrationPromoCodeSerializer::class;
396397
$this->registry['SpeakersRegistrationDiscountCode'] = SpeakersRegistrationDiscountCodeSerializer::class;
397398
$this->registry['AssignedPromoCodeSpeaker'] = AssignedPromoCodeSpeakerSerializer::class;
398-
399+
$this->registry['SummitRegistrationFeedMetadata'] = SummitRegistrationFeedMetadataSerializer::class;
399400
// submission invitations
400401
$this->registry['SummitSubmissionInvitation'] = [
401402
self::SerializerType_Public => SummitSubmissionInvitationSerializer::class,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php namespace App\ModelSerializers\Summit\Registration;
2+
/*
3+
* Copyright 2023 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
use ModelSerializers\SilverStripeSerializer;
16+
17+
/**
18+
* Class SummitRegistrationFeedMetadataSerializer
19+
* @package App\ModelSerializers\Summit\Registration
20+
*/
21+
final class SummitRegistrationFeedMetadataSerializer extends SilverStripeSerializer
22+
{
23+
protected static $array_mappings = [
24+
'Key' => 'key:json_string',
25+
'Value' => 'value:json_string',
26+
'SummitId' => 'summit_id:json_int',
27+
];
28+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php namespace App\Models\Foundation\Summit\Registration;
2+
/*
3+
* Copyright 2023 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
use models\summit\SummitOwned;
16+
use models\utils\SilverstripeBaseModel;
17+
use Doctrine\ORM\Mapping as ORM;
18+
19+
/**
20+
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitRegistrationFeedMetadataRepository")
21+
* @ORM\AssociationOverrides({
22+
* @ORM\AssociationOverride(
23+
* name="summit",
24+
* inversedBy="registration_feed_metadata"
25+
* )
26+
* })
27+
* @ORM\Table(name="SummitRegistrationFeedMetadata")
28+
* Class SummitRegistrationFeedMetadata
29+
* @package App\Models\Foundation\Summit\Registration
30+
*/
31+
class SummitRegistrationFeedMetadata extends SilverstripeBaseModel
32+
{
33+
/**
34+
* @param string $key
35+
*/
36+
public function setKey(string $key): void
37+
{
38+
$this->key = $key;
39+
}
40+
41+
/**
42+
* @param string $value
43+
*/
44+
public function setValue(string $value): void
45+
{
46+
$this->value = $value;
47+
}
48+
use SummitOwned;
49+
50+
/**
51+
* @ORM\Column(name="`Key`", type="string")
52+
* @var string
53+
*/
54+
private $key;
55+
56+
/**
57+
* @ORM\Column(name="Value", type="string")
58+
* @var string
59+
*/
60+
private $value;
61+
62+
/**
63+
* @param string $key
64+
* @param string $value
65+
*/
66+
public function __construct(string $key, string $value)
67+
{
68+
parent::__construct();
69+
$this->key = trim($key);
70+
$this->value = trim($value);
71+
}
72+
73+
/**
74+
* @return string
75+
*/
76+
public function getKey(): string
77+
{
78+
return $this->key;
79+
}
80+
81+
/**
82+
* @return string
83+
*/
84+
public function getValue(): string
85+
{
86+
return $this->value;
87+
}
88+
89+
90+
}

app/Models/Foundation/Summit/Registration/SummitTicketType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ public function getAudience(): string
630630
*/
631631
public function setAudience(string $audience)
632632
{
633+
if(!in_array($audience, self::AllowedAudience))
634+
throw new ValidationException(sprintf("audience %s is not allowed", $audience));
635+
633636
$this->audience = $audience;
634637
}
635638

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php namespace App\Models\Foundation\Summit\Repositories;
2+
/*
3+
* Copyright 2023 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
use models\utils\IBaseRepository;
16+
/**
17+
* Interface ISummitRegistrationFeedMetadataRepository
18+
* @package App\Models\Foundation\Summit\Repositories
19+
*/
20+
interface ISummitRegistrationFeedMetadataRepository
21+
extends IBaseRepository
22+
{
23+
24+
}

0 commit comments

Comments
 (0)