1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\Facebook\Exceptions; |
4
|
|
|
|
5
|
|
|
class CouldNotCreateMessage extends \Exception |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Thrown when the message text is not provided. |
9
|
|
|
* |
10
|
|
|
* @return static |
11
|
|
|
*/ |
12
|
|
|
public static function textTooLong() |
13
|
|
|
{ |
14
|
|
|
return new static('Message text is too long, A 320 character limited string should be provided.'); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Thrown when invalid notification type provided. |
19
|
|
|
* |
20
|
|
|
* @return static |
21
|
|
|
*/ |
22
|
|
|
public static function invalidNotificationType() |
23
|
|
|
{ |
24
|
|
|
return new static('Notification Type provided is invalid.'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Thrown when invalid attachment type provided. |
29
|
|
|
* |
30
|
|
|
* @return static |
31
|
|
|
*/ |
32
|
|
|
public static function invalidAttachmentType() |
33
|
|
|
{ |
34
|
|
|
return new static('Attachment Type provided is invalid.'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Thrown when a URl should be provided for an attachment. |
39
|
|
|
* |
40
|
|
|
* @return static |
41
|
|
|
*/ |
42
|
|
|
public static function urlNotProvided() |
43
|
|
|
{ |
44
|
|
|
return new static('You have not provided a Url for an attachment'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Thrown when a attachment type is not provided. |
49
|
|
|
* |
50
|
|
|
* @return static |
51
|
|
|
*/ |
52
|
|
|
public static function attachmentTypeNotProvided() |
53
|
|
|
{ |
54
|
|
|
return new static('You have not provided a type for an attachment'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Thrown when the button type is "postback" or "phone_number", |
59
|
|
|
* but the data value is not provided for the payload. |
60
|
|
|
* |
61
|
|
|
* @return static |
62
|
|
|
*/ |
63
|
|
|
public static function dataNotProvided() |
64
|
|
|
{ |
65
|
|
|
return new static("Your message was missing critical information"); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Thrown when the title characters limit is exceeded. |
70
|
|
|
* |
71
|
|
|
* @return static |
72
|
|
|
*/ |
73
|
|
|
public static function titleLimitExceeded($title) |
74
|
|
|
{ |
75
|
|
|
$count = mb_strlen($title); |
76
|
|
|
|
77
|
|
|
return new static( |
78
|
|
|
"Your title was {$count} characters long, which exceeds the 20 character limit. Please check the button template docs for more information." |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Thrown when the payload characters limit is exceeded. |
84
|
|
|
* |
85
|
|
|
* @param mixed $data |
86
|
|
|
* |
87
|
|
|
* @return static |
88
|
|
|
*/ |
89
|
|
|
public static function payloadLimitExceeded($data) |
90
|
|
|
{ |
91
|
|
|
$count = mb_strlen($data); |
92
|
|
|
|
93
|
|
|
return new static( |
94
|
|
|
"Your payload was {$count} characters long, which exceeds the 1000 character limit. Please check the button template docs for more information." |
95
|
|
|
); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Thrown when number of buttons in message exceeds. |
100
|
|
|
* |
101
|
|
|
* @return static |
102
|
|
|
*/ |
103
|
|
|
public static function messageButtonsLimitExceeded() |
104
|
|
|
{ |
105
|
|
|
return new static('You cannot add more than 3 buttons in 1 notification message.'); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Thrown when number of cards in message exceeds. |
110
|
|
|
* |
111
|
|
|
* @return static |
112
|
|
|
*/ |
113
|
|
|
public static function messageCardsLimitExceeded() |
114
|
|
|
{ |
115
|
|
|
return new static('You cannot add more than 10 cards in 1 notification message.'); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Thrown when there is no user id or phone number provided. |
120
|
|
|
* |
121
|
|
|
* @return static |
122
|
|
|
*/ |
123
|
|
|
public static function recipientNotProvided() |
124
|
|
|
{ |
125
|
|
|
return new static('Facebook notification recipient ID or Phone Number was not provided. Please refer usage docs.'); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|