@@ -37,6 +37,7 @@ private function request($arguments)
37
37
$ method = $ this ->methods [$ arguments ['method ' ]];
38
38
$ args = $ arguments ['args ' ];
39
39
$ params = $ this ->prepareParameters ($ args ['params ' ]);
40
+ $ data = @$ this ->prepareData ($ args ['data ' ]);
40
41
41
42
$ uri = preg_replace_callback ('@:(.+?)(\/|$)@ ' , function ($ matches ) use ($ args ) {
42
43
return $ args ["params " ][$ matches [1 ]].$ matches [2 ];
@@ -56,7 +57,7 @@ private function request($arguments)
56
57
$ uri .= "? " . http_build_query ($ params );
57
58
}
58
59
59
- return $ this ->validateResponse ( $ args , $ this ->client ->request ($ uri , @ $ args [ ' data ' ] , $ method ['http_method ' ], $ this ->returnJson ) );
60
+ return $ this ->validateResponse ( $ args , $ this ->client ->request ($ uri , $ data , $ method ['http_method ' ], $ this ->returnJson ) );
60
61
}
61
62
62
63
protected function validateResponse ($ request_args , $ response )
@@ -92,6 +93,21 @@ protected function validateResponse($request_args, $response)
92
93
return $ response ;
93
94
}
94
95
96
+ private function prepareData ($ data ) {
97
+ $ result = array ();
98
+ foreach ($ data as $ key => $ value ) {
99
+ $ type = gettype ($ value );
100
+ if ($ type !== 'boolean ' ) {
101
+ $ result [$ key ] = $ value ;
102
+ continue ;
103
+ }
104
+
105
+ $ result [$ key ] = $ value ? 1 : 0 ;
106
+ }
107
+
108
+ return $ result ;
109
+ }
110
+
95
111
private function prepareParameters ($ params ) {
96
112
$ query_pairs = array ();
97
113
$ allowed = array ("limit " , "offset " , "page " , "sort_on " , "sort_order " , "include_private " , "language " );
0 commit comments