Skip to content

Commit

Permalink
Merge pull request amabnl#67 in FLIGHT/service.amadeus from feature/F…
Browse files Browse the repository at this point in the history
…A-3026 to master

* commit '5c6985293e6576a118907486eab76176b363befa':
  FA-3026: review comment
  FA-3026: remove +x from composer.lock
  FA-3026: fix tests, revert unwanted but commited changes
  FA-3026: modify remarks parsing to match remark strings with "-" in the value
  FA-3026: working on remarks to enable handling of more than one traveller
  • Loading branch information
Michael Mueller committed Jul 9, 2018
2 parents cee5822 + 5c69852 commit 7489b9d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
6 changes: 3 additions & 3 deletions docs/remarks/DELETE_request.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recordlocator": "LTEXQF",
"remarks": {
"TESTVALUE": "test2"
}
"remarks": [
"TESTVALUE-test2"
]
}
6 changes: 3 additions & 3 deletions docs/remarks/POST_request.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recordlocator": "LTEXQF",
"remarks": {
"TESTVALUE": "test"
}
"remarks": [
"TESTVALUE-test"
]
}
6 changes: 3 additions & 3 deletions docs/remarks/PUT_request.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recordlocator": "LTEXQF",
"remarks": {
"TESTVALUE": "test2"
}
"remarks": [
"TESTVALUE-test2"
]
}
13 changes: 10 additions & 3 deletions src/Remarks/Service/Remarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ public function remarksAdd($authHeader, $recordlocator, $body)
$this->requestValidator->validateRecordlocator($recordlocator);

$remarks = new ArrayCollection();
foreach ($body as $remarkName => $remarkValue) {
foreach ($body as $remarkString) {
// first item has the remarkName so we explode it out of the array to let the remarkValue rest in pieces
$remark = explode('-', $remarkString);
$remarkName = $remark[0];
unset($remark[0]);
$remarkValue = implode('-', $remark);
$remarks->add((new Remark())->setName($remarkName)->setValue($remarkValue));
}

Expand Down Expand Up @@ -178,8 +183,10 @@ public function remarksDelete($authHeader, $recordlocator, $body)
$remarksDeleteCollection = new ArrayCollection();
/** @var Remark $remark */
foreach ($remarksReadCollection->getRemarks() as $remark) {
foreach ($body as $remarkName => $remarkValue) {
if ($remarkName == $remark->getName()) {
foreach ($body as $remarkString) {
// first item has the remarkName so we explode it out of the array to let the remarkValue rest in pieces
$remarkData = explode('-', $remarkString);
if ($remarkData[0] == $remark->getName()) {
$remarksDeleteCollection->add($remark);
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/_data/fixtures/07-add_remarks_body.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"IBEPAXELIG-ADT": "P1.1",
"IBEBZIP": 6244
}
[
"IBEPAXELIG-ADT-P1.1",
"IBEBZIP-6244"
]
8 changes: 4 additions & 4 deletions tests/_data/fixtures/08-modify_remarks_body.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"IBEPAXELIG-ADT": "P1.2",
"IBEBZIP": 6243
}
[
"IBEPAXELIG-ADT-P1.2",
"IBEBZIP-6243"
]

0 comments on commit 7489b9d

Please sign in to comment.