@@ 42-59 (lines=18) @@ | ||
39 | * @return mixed |
|
40 | * @throws \Gbowo\Exception\InvalidHttpResponseException if the response code is not 200 |
|
41 | */ |
|
42 | public function handle($planIdentifier) |
|
43 | { |
|
44 | $link = $this->baseUrl."?PlanId={$planIdentifier}"; |
|
45 | ||
46 | /** |
|
47 | * @var ResponseInterface $response |
|
48 | */ |
|
49 | $response = $this->adapter->getHttpClient() |
|
50 | ->get($link); |
|
51 | ||
52 | if (200 !== $response->getStatusCode()) { |
|
53 | throw new InvalidHttpResponseException( |
|
54 | "Expected 200. Got {$response->getStatusCode()}" |
|
55 | ); |
|
56 | } |
|
57 | ||
58 | return json_decode($response->getBody(), true); |
|
59 | } |
|
60 | } |
|
61 |
@@ 39-56 (lines=18) @@ | ||
36 | * @return mixed |
|
37 | * @throws \Gbowo\Exception\InvalidHttpResponseException if ann http response of 200 isn't returned |
|
38 | */ |
|
39 | public function handle(string $planIdentifier) |
|
40 | { |
|
41 | $link = $this->baseUrl . str_replace(":identifier", $planIdentifier, self::FETCH_PLAN_LINK); |
|
42 | ||
43 | /** |
|
44 | * @var ResponseInterface $response |
|
45 | */ |
|
46 | $response = $this->adapter->getHttpClient() |
|
47 | ->get($link); |
|
48 | ||
49 | if (200 !== $response->getStatusCode()) { |
|
50 | throw new InvalidHttpResponseException( |
|
51 | "Expected 200. Got {$response->getStatusCode()} instead" |
|
52 | ); |
|
53 | } |
|
54 | ||
55 | return json_decode($response->getBody(), true)['data']; |
|
56 | } |
|
57 | } |
|
58 |