@@ -77,17 +77,26 @@ private function getRemainingRequests(ResponseInterface $response): int
77
77
78
78
private function check (ResponseInterface $ response )
79
79
{
80
+ $ response ->getBody ()->rewind ();
81
+ $ json = json_decode ($ response ->getBody ()->getContents (), true );
82
+
80
83
if ($ response ->getStatusCode () === 401 ) {
81
- $ response ->getBody ()->rewind ();
82
- $ json = json_decode ($ response ->getBody ()->getContents (), true );
84
+ return new CallResult (
85
+ false ,
86
+ false ,
87
+ $ this ->getRemainingRequests ($ response ),
88
+ $ this ->getMaxRequests ($ response ),
89
+ [$ json ["message " ]]
90
+ );
91
+ }
83
92
93
+ if ($ response ->getStatusCode () === 403 ) {
84
94
return new CallResult (
85
95
false ,
86
96
false ,
87
97
$ this ->getRemainingRequests ($ response ),
88
98
$ this ->getMaxRequests ($ response ),
89
- [$ json ["message " ]],
90
- null
99
+ [$ json ["message " ]]
91
100
);
92
101
}
93
102
@@ -107,8 +116,7 @@ private function check(ResponseInterface $response)
107
116
true ,
108
117
$ this ->getRemainingRequests ($ response ),
109
118
$ this ->getMaxRequests ($ response ),
110
- ["rate limited " ],
111
- null
119
+ [$ json ["message " ]]
112
120
);
113
121
}
114
122
}
@@ -329,7 +337,7 @@ public function link(array $arguments): CallResult
329
337
"deviceId " => $ arguments ["deviceId " ],
330
338
"identification " => $ this ->userIdentifiersToArray (
331
339
new UserIdentified (
332
- isset ($ arguments ["userId " ]) ? (string ) $ arguments ["userId " ] : null ,
340
+ isset ($ arguments ["userId " ]) ? (string ) $ arguments ["userId " ] : null ,
333
341
isset ($ arguments ["email " ]) ? (string ) $ arguments ["email " ] : null
334
342
)
335
343
),
@@ -405,7 +413,14 @@ private function formatProperties(array $properties): array
405
413
$ formatted = array ();
406
414
407
415
foreach ($ properties as $ name => $ value ) {
408
- if (is_int ($ value ) || is_float ($ value ) || is_string ($ value ) || is_bool ($ value )) {
416
+ if (
417
+ is_int ($ value ) ||
418
+ is_float ($ value ) ||
419
+ is_string ($ value ) ||
420
+ is_bool ($ value ) ||
421
+ is_array ($ value ) ||
422
+ is_null ($ value )
423
+ ) {
409
424
$ formatted [$ name ] = $ value ;
410
425
continue ;
411
426
}
@@ -426,7 +441,7 @@ public function upsertUser(array $user): CallResult
426
441
$ payload = [
427
442
"identification " => $ this ->userIdentifiersToArray (
428
443
new UserIdentified (
429
- isset ($ user ["userId " ]) ? (string ) $ user ["userId " ] : null ,
444
+ isset ($ user ["userId " ]) ? (string ) $ user ["userId " ] : null ,
430
445
isset ($ user ["email " ]) ? (string ) $ user ["email " ] : null
431
446
)
432
447
),
@@ -485,7 +500,7 @@ public function upsertAccount(array $account): CallResult
485
500
$ payload = [
486
501
"identification " => $ this ->accountIdentifiersToArray (
487
502
new AccountIdentified (
488
- isset ($ account ["accountId " ]) ? (string ) $ account ["accountId " ] : null ,
503
+ isset ($ account ["accountId " ]) ? (string ) $ account ["accountId " ] : null ,
489
504
isset ($ account ["domain " ]) ? (string ) $ account ["domain " ] : null
490
505
)
491
506
),
@@ -501,7 +516,7 @@ function (array $user) {
501
516
return [
502
517
"identification " => $ this ->userIdentifiersToArray (
503
518
new UserIdentified (
504
- isset ($ user ["userId " ]) ? (string ) $ user ["userId " ] : null ,
519
+ isset ($ user ["userId " ]) ? (string ) $ user ["userId " ] : null ,
505
520
isset ($ user ["email " ]) ? (string ) $ user ["email " ] : null
506
521
)
507
522
),
0 commit comments