@@ 31-49 (lines=19) @@ | ||
28 | * @return mixed |
|
29 | * @throws \Gbowo\Exception\InvalidHttpResponseException if the response code is not 200 |
|
30 | */ |
|
31 | public function handle(...$args) |
|
32 | { |
|
33 | ||
34 | $link = $this->baseUrl.self::FETCH_PLAN_RELATIVE_LINK."?PlanId={$args[0]}"; |
|
35 | ||
36 | /** |
|
37 | * @var ResponseInterface $response |
|
38 | */ |
|
39 | $response = $this->adapter->getHttpClient() |
|
40 | ->get($link); |
|
41 | ||
42 | if (200 !== $response->getStatusCode()) { |
|
43 | throw new InvalidHttpResponseException( |
|
44 | "Expected 200. Got {$response->getStatusCode()}" |
|
45 | ); |
|
46 | } |
|
47 | ||
48 | return json_decode($response->getBody(), true); |
|
49 | } |
|
50 | } |
|
51 |
@@ 31-49 (lines=19) @@ | ||
28 | * @return mixed |
|
29 | * @throws \Gbowo\Exception\InvalidHttpResponseException if ann http response of 200 isn't returned |
|
30 | */ |
|
31 | public function handle(...$args) |
|
32 | { |
|
33 | ||
34 | $link = $this->baseUrl . str_replace(":identifier", $args[0], self::FETCH_PLAN_LINK); |
|
35 | ||
36 | /** |
|
37 | * @var ResponseInterface $response |
|
38 | */ |
|
39 | $response = $this->adapter->getHttpClient() |
|
40 | ->get($link); |
|
41 | ||
42 | if (200 !== $response->getStatusCode()) { |
|
43 | throw new InvalidHttpResponseException( |
|
44 | "Expected 200. Got {$response->getStatusCode()} instead" |
|
45 | ); |
|
46 | } |
|
47 | ||
48 | return json_decode($response->getBody(), true)['data']; |
|
49 | } |
|
50 | } |
|
51 |