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

Commit d9f4062

Browse files
committed
feat(NotificationPreferences): added method to get a notification preference
1 parent 289c35f commit d9f4062

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,12 @@ try {
474474

475475
### Consulta
476476
```php
477-
477+
try {
478+
$notification = $this->moip->notifications()->get('NPR-N6QZE3223P98');
479+
print_r($notification);
480+
} catch (Exception $e) {
481+
printf($e->__toString());
482+
}
478483
```
479484

480485
### Exclusão

src/Resource/NotificationPreferences.php

+32-2
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,43 @@ public function setTarget($target)
6464
/**
6565
* Returns target.
6666
*
67-
* @return stdClass
67+
* @return string
6868
*/
6969
public function getTarget()
7070
{
7171
return $this->data->target;
7272
}
7373

74+
/**
75+
* Returns media.
76+
*
77+
* @return string
78+
*/
79+
public function getMedia()
80+
{
81+
return $this->data->media;
82+
}
83+
84+
/**
85+
* Returns token.
86+
*
87+
* @return string
88+
*/
89+
public function getToken()
90+
{
91+
return $this->data->token;
92+
}
93+
94+
/**
95+
* Returns events.
96+
*
97+
* @return array
98+
*/
99+
public function getEvents()
100+
{
101+
return $this->data->events;
102+
}
103+
74104
/**
75105
* Returns notification id.
76106
*
@@ -104,7 +134,7 @@ public function get($notification_id)
104134
}
105135

106136
/**
107-
* Create a new Orders list instance.
137+
* Create a new Notifications List instance.
108138
*
109139
* @return \Moip\Resource\NotificationPreferencesList
110140
*/

tests/Resource/NotificationPreferencesTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,16 @@ public function testShouldCreateNotificationPreference()
2222
$notification = $this->createNotification();
2323
$this->assertNotEmpty($notification->getId());
2424
}
25+
26+
public function testShouldGetNotificationPreference()
27+
{
28+
$this->mockHttpSession($this->body_notification_preference);
29+
30+
$notification = $this->moip->notifications()->get('NPR-N6QZE3223P98');
31+
$this->assertEquals('NPR-N6QZE3223P98', $notification->getId());
32+
$this->assertEquals('WEBHOOK', $notification->getMedia());
33+
$this->assertEquals('994e3ffae9214fbc806d01de2dd5d341', $notification->getToken());
34+
$this->assertEquals('http://requestb.in/1dhjesw1', $notification->getTarget());
35+
$this->assertEquals(["ORDER.*","PAYMENT.AUTHORIZED","PAYMENT.CANCELLED"], $notification->getEvents());
36+
}
2537
}

0 commit comments

Comments
 (0)