Skip to content

Commit

Permalink
Subaccount e-mail address can be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Jul 25, 2018
1 parent 4000dce commit 276f16b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Subaccounts/Subaccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,15 @@ private function doCreate($email = null, $name = null)
* @var $name string
* @return void
*/
public function update($id, $name)
public function update($id, $name = null, $email = null)
{
$request = new \stdClass();
$request->name = $name;
if ($name != null) {
$request->name = $name;
}
if ($email != null) {
$request->email = $email;
}
$this->client->post('/subaccounts/' . $id, ['json' => $request]);
}

Expand Down
26 changes: 26 additions & 0 deletions tests/Subacounts/UpdateSubaccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,36 @@ class UpdateSubaccountTest extends SeatsioClientTest
public function test()
{
$subaccount = $this->seatsioClient->subaccounts->create('joske');
$email = $this->randomEmail();

$this->seatsioClient->subaccounts->update($subaccount->id, 'jefke', $email);

$retrievedSubaccount = $this->seatsioClient->subaccounts->retrieve($subaccount->id);
self::assertEquals('jefke', $retrievedSubaccount->name);
self::assertEquals($email, $retrievedSubaccount->email);
}

public function emailIsOptional()
{
$email = $this->randomEmail();
$subaccount = $this->seatsioClient->subaccounts->createWithEmail('joske', $email);

$this->seatsioClient->subaccounts->update($subaccount->id, 'jefke');

$retrievedSubaccount = $this->seatsioClient->subaccounts->retrieve($subaccount->id);
self::assertEquals('jefke', $retrievedSubaccount->name);
self::assertEquals($email, $retrievedSubaccount->email);
}

public function nameIsOptional()
{
$email = $this->randomEmail();
$subaccount = $this->seatsioClient->subaccounts->createWithEmail('joske');

$this->seatsioClient->subaccounts->update($subaccount->id, null, $email);

$retrievedSubaccount = $this->seatsioClient->subaccounts->retrieve($subaccount->id);
self::assertEquals('joske', $retrievedSubaccount->name);
self::assertEquals($email, $retrievedSubaccount->email);
}
}

0 comments on commit 276f16b

Please sign in to comment.