Skip to content

Commit

Permalink
Add owner property to IdeResponse. (#78)
Browse files Browse the repository at this point in the history
* Add owner property to IdeResponse.

* Update fixtures.

* Test new property.

* Add conditional.

* Fix indentation.

* PHPCS
  • Loading branch information
grasmash committed Jul 24, 2020
1 parent 3249226 commit 972997e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Response/IdeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class IdeResponse
public $uuid;
public $label;
public $links;
public $owner;

/**
* IdeResponse constructor.
Expand All @@ -23,5 +24,6 @@ public function __construct($ide)
$this->uuid = $ide->uuid;
$this->label = $ide->label;
$this->links = $ide->_links;
$this->owner = new MemberResponse($ide->_embedded->owner);
}
}
7 changes: 6 additions & 1 deletion src/Response/MemberResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public function __construct($member)
$this->uuid = $member->uuid;
$this->first_name = $member->first_name;
$this->last_name = $member->last_name;
$this->mail = $member->mail;

if (property_exists($member, 'mail')) {
$this->mail = $member->mail;
} elseif (property_exists($member, 'email')) {
$this->mail = $member->email;
}
$this->picture_url = $member->picture_url;
$this->username = $member->username;

Expand Down
3 changes: 2 additions & 1 deletion tests/Endpoints/IdesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class IdesTest extends CloudApiTestCase
public $properties = [
'uuid',
'label',
'links'
'links',
'owner',
];

public function testGetAllIdes()
Expand Down
14 changes: 13 additions & 1 deletion tests/Fixtures/Endpoints/Ides/getAllIdes.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@
"ide": {
"href": "https://215824ff-272a-4a8c-9027-df32ed1d68a9.ides.acquia.com"
}
},
"_embedded": {
"owner": {
"uuid": "10be1d3e-f2b4-4d34-855d-321df3938ffd",
"first_name": "First",
"last_name": "Last",
"last_login_at": "2019-01-31T10:53:11-05:00",
"created_at": "2016-08-14T17:38:59-04:00",
"email": "user.name@example.com",
"picture_url": "https://accounts.acquia.com/path/to/image.png",
"username": "user.name"
}
}
}
]
}
}
}
14 changes: 13 additions & 1 deletion tests/Fixtures/Endpoints/Ides/getIde.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,17 @@
"ide": {
"href": "https://215824ff-272a-4a8c-9027-df32ed1d68a9.ides.acquia.com"
}
},
"_embedded": {
"owner": {
"uuid": "10be1d3e-f2b4-4d34-855d-321df3938ffd",
"first_name": "First",
"last_name": "Last",
"last_login_at": "2019-01-31T10:53:11-05:00",
"created_at": "2016-08-14T17:38:59-04:00",
"email": "user.name@example.com",
"picture_url": "https://accounts.acquia.com/path/to/image.png",
"username": "user.name"
}
}
}
}

0 comments on commit 972997e

Please sign in to comment.