Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit fe2c4d6

Browse files
committed
feat(account): adds getPasswordLink()
1 parent 1c297d1 commit fe2c4d6

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/Resource/Account.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@ public function getCreatedAt()
383383
return $this->getIfSet('createdAt', $this->data);
384384
}
385385

386+
/**
387+
* Get link to set the password of created account.
388+
*
389+
* @return string
390+
*/
391+
public function getPasswordLink()
392+
{
393+
return $this->getIfSet('href', $this->data->_links->setPassword);
394+
}
395+
386396
/**
387397
* Mount the seller structure from account.
388398
*
@@ -435,7 +445,14 @@ protected function populate(stdClass $response)
435445
$account->data->person->alternativePhones = $this->getIfSet('alternativePhones', $person);
436446

437447
$account->data->company = $this->getIfSet('company', $response);
438-
$account->data->_links = $this->getIfSet('_links', $response);
448+
$account->data->_links = new stdClass();
449+
450+
$_links = $this->getIfSet('_links', $response);
451+
$account->data->_links->setPassword = new stdClass();
452+
453+
$setPassword = $this->getIfSet('setPassword', $_links);
454+
$account->data->_links->setPassword->href = $this->getIfSet('href', $setPassword);
455+
439456
$account->data->type = $this->getIfSet('type', $response);
440457
$account->data->id = $this->getIfSet('id', $response);
441458
$account->data->accessToken = $this->getIfSet('accessToken', $response);

tests/Resource/AccountTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function testShouldCreateAccount()
3535
$this->assertEquals('SSP', $account->getIdentityDocumentIssuer());
3636
$this->assertEquals('2017-10-25', $account->getIdentityDocumentIssueDate());
3737
$this->assertEquals('RG', $account->getIdentityDocumentType());
38+
$this->assertEquals('https://desenvolvedor.moip.com.br/sandbox/AskForNewPassword.do?method=confirm&email=dev.moip%40labs.moip.com.br&code=8e3b306d59907f4a47508913956c96ba', $account->getPasswordLink());
3839
}
3940

4041
public function testShouldCreateAccountWithCompany()

tests/jsons/account/create.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"id":"MPA-61B1FE0940A2","login":"fortestsminecustomercompany@mailinator.com","accessToken":"dbb1cee101444f7a9f74c576854b9103_v2","channelId":"APP-QGAGZRIX1CUF","type":"MERCHANT","transparentAccount":false,"email":{"address":"fortestsminecustomercompany@mailinator.com","confirmed":false},"person":{"name":"For tests","lastName":"Mine Customer Company","birthDate":"1990-01-01","taxDocument":{"type":"CPF","number":"028.229.218-73"},"address":{"street":"Av. Brigadeiro Faria Lima","streetNumber":"2927","district":"Itaim","zipcode":"01234000","zipCode":"01234000","city":"São Paulo","state":"SP","country":"BRA","complement":"Ap. X"},"phone":{"countryCode":"55","areaCode":"11","number":"965213244","verified":false,"phoneType":"not_informed"},"nationality":"BRA","identityDocument":{"number":"144563480","issuer":"SSP","issueDate":"2017-10-25","type":"RG"},"alternativePhones":[{"countryCode":"55","areaCode":"11","number":"912345678","verified":false,"phoneType":"not_informed"}],"birthPlace":"São Paulo","parentsName":{"father":"Father of Mine Customer","mother":"Mother of Mine Customer"}},"company":{"name":"Mine Customer Company","businessName":"Company Business","taxDocument":{"type":"CNPJ","number":"64.893.609/0001-10"},"address":{"street":"R. Company","streetNumber":"321","district":"Bairro Company","zipcode":"12345678","zipCode":"12345678","city":"São Paulo","state":"SP","country":"BRA","complement":"Ap. Y"},"phone":{"countryCode":"55","areaCode":"11","number":"987654321","verified":false,"phoneType":"not_informed"},"openingDate":"2017-10-20"},"businessSegment":{"id":33,"name":"Jogos online","mcc":null},"site":"https://www.meusite.com","createdAt":"2017-10-25T14:05:46.050Z","_links":{"self":{"href":"https://sandbox.moip.com.br/moipaccounts/MPA-61B1FE0940A2","title":null}}}
1+
{"id":"MPA-61B1FE0940A2","login":"fortestsminecustomercompany@mailinator.com","accessToken":"dbb1cee101444f7a9f74c576854b9103_v2","channelId":"APP-QGAGZRIX1CUF","type":"MERCHANT","transparentAccount":false,"email":{"address":"fortestsminecustomercompany@mailinator.com","confirmed":false},"person":{"name":"For tests","lastName":"Mine Customer Company","birthDate":"1990-01-01","taxDocument":{"type":"CPF","number":"028.229.218-73"},"address":{"street":"Av. Brigadeiro Faria Lima","streetNumber":"2927","district":"Itaim","zipcode":"01234000","zipCode":"01234000","city":"São Paulo","state":"SP","country":"BRA","complement":"Ap. X"},"phone":{"countryCode":"55","areaCode":"11","number":"965213244","verified":false,"phoneType":"not_informed"},"nationality":"BRA","identityDocument":{"number":"144563480","issuer":"SSP","issueDate":"2017-10-25","type":"RG"},"alternativePhones":[{"countryCode":"55","areaCode":"11","number":"912345678","verified":false,"phoneType":"not_informed"}],"birthPlace":"São Paulo","parentsName":{"father":"Father of Mine Customer","mother":"Mother of Mine Customer"}},"company":{"name":"Mine Customer Company","businessName":"Company Business","taxDocument":{"type":"CNPJ","number":"64.893.609/0001-10"},"address":{"street":"R. Company","streetNumber":"321","district":"Bairro Company","zipcode":"12345678","zipCode":"12345678","city":"São Paulo","state":"SP","country":"BRA","complement":"Ap. Y"},"phone":{"countryCode":"55","areaCode":"11","number":"987654321","verified":false,"phoneType":"not_informed"},"openingDate":"2017-10-20"},"businessSegment":{"id":33,"name":"Jogos online","mcc":null},"site":"https://www.meusite.com","createdAt":"2017-10-25T14:05:46.050Z","_links":{"self":{"href":"https://sandbox.moip.com.br/moipaccounts/MPA-61B1FE0940A2","title":null},"setPassword":{"href":"https://desenvolvedor.moip.com.br/sandbox/AskForNewPassword.do?method=confirm&email=dev.moip%40labs.moip.com.br&code=8e3b306d59907f4a47508913956c96ba"}}}

0 commit comments

Comments
 (0)