Skip to content

Commit 3f5b4e1

Browse files
authored
Merge pull request #130 from ker0x/hotfix/user-response
[n/a] remove methods isPaymentEnabled and getLastAdReferral from User…
2 parents f4c77fc + 1f1d14e commit 3f5b4e1

25 files changed

+32
-80
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
/phpunit.xml.dist export-ignore
99
/.scrutinizer.yml export-ignore
1010
/tests export-ignore
11-
/docs export-ignore

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ The Messenger library follows [SemVer](http://semver.org/).
44

55
## 3.x
66

7+
**Changelog** (since [`3.0.0`](https://github.com/ker0x/messenger/compare/3.0.0...3.1.0))
8+
9+
- 3.1.0 (2018-10)
10+
- Update API version to `v3.2`.
11+
- Fix type for properties *AppId in `\Kerox\Messenger\Model\Callback\PassThreadControl::class`, `\Kerox\Messenger\Model\Callback\RequestThreadControl::class` and `\Kerox\Messenger\Model\Callback\TakeThreadControl::class`. (Thanks to @dbknet)
12+
- Change method visibility from `public` to `protected` in `\Kerox\Messenger\Helper\ValidatorTrait::class`
13+
- Remove methods `isPaymentEnabled` and `getLastAdReferral` from `\Kerox\Messenger\Response\UserResponse::class` as there are been removed from the API (see [CHANGELOG](https://developers.facebook.com/docs/graph-api/changelog/version3.1#messenger-platform))
14+
715
**Changelog** (since [`2.1.1`](https://github.com/ker0x/messenger/compare/2.1.1...3.0.0))
816

917
Version `3.0.0` of the Messenger library is an enhancement of version `2.1.1` with major break changes.

src/Api/User.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ private function getAllowedFields(): array
5454
self::LOCALE,
5555
self::TIMEZONE,
5656
self::GENDER,
57-
self::IS_PAYMENT_ENABLED,
5857
];
5958
}
6059
}

src/Helper/ValidatorTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ protected function isValidTag(string $tag, Message $message = null): void
274274
/**
275275
* @return array
276276
*/
277-
public function getAllowedSenderAction(): array
277+
protected function getAllowedSenderAction(): array
278278
{
279279
return [
280280
SendInterface::SENDER_ACTION_TYPING_ON,
@@ -286,7 +286,7 @@ public function getAllowedSenderAction(): array
286286
/**
287287
* @return array
288288
*/
289-
public function getAllowedNotificationType(): array
289+
protected function getAllowedNotificationType(): array
290290
{
291291
return [
292292
SendInterface::NOTIFICATION_TYPE_REGULAR,
@@ -298,7 +298,7 @@ public function getAllowedNotificationType(): array
298298
/**
299299
* @return array
300300
*/
301-
public function getAllowedTag(): array
301+
protected function getAllowedTag(): array
302302
{
303303
return [
304304
SendInterface::TAG_BUSINESS_PRODUCTIVITY,
@@ -324,7 +324,7 @@ public function getAllowedTag(): array
324324
/**
325325
* @return array
326326
*/
327-
public function getAllowedCurrency(): array
327+
protected function getAllowedCurrency(): array
328328
{
329329
return [
330330
'SGD',

src/Messenger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class Messenger
2323
{
2424
public const API_URL = 'https://graph.facebook.com/';
25-
public const API_VERSION = 'v3.1';
25+
public const API_VERSION = 'v3.2';
2626

2727
/**
2828
* @var string

src/Model/Callback/RequestThreadControl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class RequestThreadControl
88
{
99
/**
10-
* @var string
10+
* @var int
1111
*/
1212
protected $requestedOwnerAppId;
1313

src/Response/UserResponse.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Kerox\Messenger\Response;
66

7-
use Kerox\Messenger\Model\Referral;
87
use Kerox\Messenger\UserInterface;
98

109
class UserResponse extends AbstractResponse implements UserInterface
@@ -39,16 +38,6 @@ class UserResponse extends AbstractResponse implements UserInterface
3938
*/
4039
protected $gender;
4140

42-
/**
43-
* @var null|bool
44-
*/
45-
protected $paymentEnabled;
46-
47-
/**
48-
* @var null|\Kerox\Messenger\Model\Referral
49-
*/
50-
protected $lastAdReferral;
51-
5241
/**
5342
* @param array $response
5443
*/
@@ -60,9 +49,6 @@ protected function parseResponse(array $response): void
6049
$this->locale = $response[UserInterface::LOCALE] ?? null;
6150
$this->timezone = $response[UserInterface::TIMEZONE] ?? null;
6251
$this->gender = $response[UserInterface::GENDER] ?? null;
63-
$this->paymentEnabled = $response[UserInterface::IS_PAYMENT_ENABLED] ?? null;
64-
65-
$this->setLastAdReferral($response);
6652
}
6753

6854
/**
@@ -112,30 +98,4 @@ public function getGender(): ?string
11298
{
11399
return $this->gender;
114100
}
115-
116-
/**
117-
* @return null|bool
118-
*/
119-
public function isPaymentEnabled(): ?bool
120-
{
121-
return $this->paymentEnabled;
122-
}
123-
124-
/**
125-
* @return null|\Kerox\Messenger\Model\Referral
126-
*/
127-
public function getLastAdReferral(): ?Referral
128-
{
129-
return $this->lastAdReferral;
130-
}
131-
132-
/**
133-
* @param array $response
134-
*/
135-
private function setLastAdReferral(array $response): void
136-
{
137-
if (isset($response[UserInterface::LAST_AD_REFERRAL])) {
138-
$this->lastAdReferral = Referral::create($response[UserInterface::LAST_AD_REFERRAL]);
139-
}
140-
}
141101
}

src/UserInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ interface UserInterface
1212
public const LOCALE = 'locale';
1313
public const TIMEZONE = 'timezone';
1414
public const GENDER = 'gender';
15-
public const IS_PAYMENT_ENABLED = 'is_payment_enabled';
16-
public const LAST_AD_REFERRAL = 'last_ad_referral';
1715
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"broadcast_id": "0123456789"
3-
}
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"message_creative_id": "0123456789"
3-
}
3+
}

tests/Mocks/Response/Code/code.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"uri": "https://scontent.xx.fbcdn.net/v/t39.8917-6/16685555_1672240442792330_5569294125766803456_n.png?oh=eb8cf65a7a7a5808b24e55527b366dd0&oe=592BBFCC"
3-
}
3+
}

tests/Mocks/Response/Insights/insights.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
"id": "1234567/insights/page_messages_active_threads_unique/day"
5252
}
5353
]
54-
}
54+
}

tests/Mocks/Response/Nlp/success.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"success": true
3-
}
3+
}

tests/Mocks/Response/Persona/add.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
22
"id": "<PERSONA_ID>"
33
}
4+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"success": true
3-
}
3+
}

tests/Mocks/Response/Profile/add.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"result": "success"
3-
}
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"attachment_id":"1854626884821032"
3-
}
3+
}

tests/Mocks/Response/Send/attachment_to_user.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"recipient_id": "1008372609250235",
33
"message_id": "mid.1456970487936:c34767dfe57ee6e339",
44
"attachment_id": "1745504518999123"
5-
}
5+
}

tests/Mocks/Response/Send/basic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"recipient_id": "1008372609250235",
33
"message_id": "mid.1456970487936:c34767dfe57ee6e339"
4-
}
4+
}

tests/Mocks/Response/Send/error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"error_subcode": 1234567,
77
"fbtrace_id": "BLBz/WZt8dN"
88
}
9-
}
9+
}

tests/Mocks/Response/Tag/tag.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
"description": "The ticket_update tag may only be used to provide updates pertaining to an event for which a person already has a ticket. For example, when there is a change in time, a location update or a cancellation (such as when a concert is canceled, the venue has changed or a refund opportunity is available). This tag cannot be used for use cases beyond those listed above or for promotional content (ex: daily deals, coupons and discounts, or sale announcements)."
3434
}
3535
]
36-
}
36+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"success": true
3-
}
3+
}

tests/Mocks/Response/User/user.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@
44
"profile_pic": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p200x200/13055603_10105219398495383_8237637584159975445_n.jpg?oh=1d241d4b6d4dac50eaf9bb73288ea192&oe=57AF5C03&__gda__=1470213755_ab17c8c8e3a0a447fed3f272fa2179ce",
55
"locale": "en_US",
66
"timezone": -7,
7-
"gender": "male",
8-
"is_payment_enabled": true,
9-
"last_ad_referral": {
10-
"source": "ADS",
11-
"type": "OPEN_THREAD",
12-
"ad_id": "6045246247433",
13-
"ref": "myparam"
14-
}
15-
}
7+
"gender": "male"
8+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"success": true
3-
}
3+
}

tests/TestCase/Api/UserTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,12 @@ public function testGetProfile(): void
4545
$this->assertSame('en_US', $response->getLocale());
4646
$this->assertSame(-7., $response->getTimezone());
4747
$this->assertSame('male', $response->getGender());
48-
$this->assertTrue($response->isPaymentEnabled());
49-
$this->assertInstanceOf(Referral::class, $response->getLastAdReferral());
50-
$this->assertSame('ADS', $response->getLastAdReferral()->getSource());
51-
$this->assertSame('OPEN_THREAD', $response->getLastAdReferral()->getType());
52-
$this->assertSame('6045246247433', $response->getLastAdReferral()->getAdId());
53-
$this->assertSame('myparam', $response->getLastAdReferral()->getRef());
5448
}
5549

5650
public function testGetProfileWithBadField(): void
5751
{
5852
$this->expectException(MessengerException::class);
59-
$this->expectExceptionMessage('username is not a valid value. fields must only contain "first_name, last_name, profile_pic, locale, timezone, gender, is_payment_enabled".');
53+
$this->expectExceptionMessage('username is not a valid value. fields must only contain "first_name, last_name, profile_pic, locale, timezone, gender".');
6054
$response = $this->userApi->profile('1234abcd', ['username']);
6155
}
6256
}

0 commit comments

Comments
 (0)