@@ 88-96 (lines=9) @@ | ||
85 | * |
|
86 | * @throws \InvalidArgumentException Thrown if $resource is empty or not a string. |
|
87 | */ |
|
88 | final public function search(string $resource, array $filters = []) |
|
89 | { |
|
90 | $response = $this->send($resource, null, $filters); |
|
91 | if ($response->getStatusCode() !== 200) { |
|
92 | return null; |
|
93 | } |
|
94 | ||
95 | return DataWrapper::fromJson((string)$response->getBody()); |
|
96 | } |
|
97 | ||
98 | /** |
|
99 | * Execute a GET request against the Marvel API for a single resource. |
|
@@ 106-114 (lines=9) @@ | ||
103 | * |
|
104 | * @return null|DataWrapper |
|
105 | */ |
|
106 | final public function get(string $resource, int $id) |
|
107 | { |
|
108 | $response = $this->send($resource, $id); |
|
109 | if ($response->getStatusCode() !== 200) { |
|
110 | return null; |
|
111 | } |
|
112 | ||
113 | return DataWrapper::fromJson((string)$response->getBody()); |
|
114 | } |
|
115 | ||
116 | /** |
|
117 | * Send the given API url request. |