File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,15 @@ public static function keysToCamelCase($input)
1111 }
1212
1313 if (is_object ($ input )) {
14- $ className = get_class ($ input );
15- $ obj = new $ className ;
14+ // If the input object is not an instance of any SDK model then use the JsonSerializer class
15+ // so that json_encode() would use snake_case keys from the raw response.
16+ // Otherwise, use the mapped model class where the snake_case keys are assigned by generated code.
17+ if ($ input instanceof \stdClass) {
18+ $ obj = new JsonSerializer ($ input );
19+ } else {
20+ $ className = get_class ($ input );
21+ $ obj = new $ className ;
22+ }
1623 }
1724
1825 $ arr = [];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Pipedrive \Utils ;
4+
5+ use JsonSerializable ;
6+
7+ class JsonSerializer implements JsonSerializable
8+ {
9+ private $ args ;
10+
11+ public function __construct ($ input )
12+ {
13+ $ this ->args = $ input ;
14+ }
15+
16+ /**
17+ * Encode this object to JSON
18+ */
19+ public function jsonSerialize ()
20+ {
21+ return $ this ->args ;
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments