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

Commit

Permalink
feat(NotificationPreferences): added method to get a notification pre…
Browse files Browse the repository at this point in the history
…ference
  • Loading branch information
caiogaspar committed Sep 28, 2017
1 parent 289c35f commit d9f4062
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,12 @@ try {

### Consulta
```php

try {
$notification = $this->moip->notifications()->get('NPR-N6QZE3223P98');
print_r($notification);
} catch (Exception $e) {
printf($e->__toString());
}
```

### Exclusão
Expand Down
34 changes: 32 additions & 2 deletions src/Resource/NotificationPreferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,43 @@ public function setTarget($target)
/**
* Returns target.
*
* @return stdClass
* @return string
*/
public function getTarget()
{
return $this->data->target;
}

/**
* Returns media.
*
* @return string
*/
public function getMedia()
{
return $this->data->media;
}

/**
* Returns token.
*
* @return string
*/
public function getToken()
{
return $this->data->token;
}

/**
* Returns events.
*
* @return array
*/
public function getEvents()
{
return $this->data->events;
}

/**
* Returns notification id.
*
Expand Down Expand Up @@ -104,7 +134,7 @@ public function get($notification_id)
}

/**
* Create a new Orders list instance.
* Create a new Notifications List instance.
*
* @return \Moip\Resource\NotificationPreferencesList
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/Resource/NotificationPreferencesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@ public function testShouldCreateNotificationPreference()
$notification = $this->createNotification();
$this->assertNotEmpty($notification->getId());
}

public function testShouldGetNotificationPreference()
{
$this->mockHttpSession($this->body_notification_preference);

$notification = $this->moip->notifications()->get('NPR-N6QZE3223P98');
$this->assertEquals('NPR-N6QZE3223P98', $notification->getId());
$this->assertEquals('WEBHOOK', $notification->getMedia());
$this->assertEquals('994e3ffae9214fbc806d01de2dd5d341', $notification->getToken());
$this->assertEquals('http://requestb.in/1dhjesw1', $notification->getTarget());
$this->assertEquals(["ORDER.*","PAYMENT.AUTHORIZED","PAYMENT.CANCELLED"], $notification->getEvents());
}
}

0 comments on commit d9f4062

Please sign in to comment.