| @@ 22-35 (lines=14) @@ | ||
| 19 | $this->client = $client; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function post(Url $url, Header $header, Body $body): Promise |
|
| 23 | { |
|
| 24 | $request = (new Request) |
|
| 25 | ->setMethod('POST') |
|
| 26 | ->setUri($url->getUrl()) |
|
| 27 | ->setAllHeaders([ |
|
| 28 | 'Authorization' => $header->getHeader(), |
|
| 29 | 'Content-Type' => 'application/x-www-form-urlencoded', |
|
| 30 | ]) |
|
| 31 | ->setBody($this->getBodyString($body)) |
|
| 32 | ; |
|
| 33 | ||
| 34 | return $this->client->request($request); |
|
| 35 | } |
|
| 36 | ||
| 37 | private function getBodyString(Body $body): string |
|
| 38 | { |
|
| @@ 51-60 (lines=10) @@ | ||
| 48 | return $bodyString; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function get(Url $url, Header $header, Parameter ...$parameters): Promise |
|
| 52 | { |
|
| 53 | $request = (new Request) |
|
| 54 | ->setMethod('GET') |
|
| 55 | ->setUri($url->getUrl() . $this->buildQueryString(...$parameters)) |
|
| 56 | ->setAllHeaders(['Authorization' => $header->getHeader()]) |
|
| 57 | ; |
|
| 58 | ||
| 59 | return $this->client->request($request); |
|
| 60 | } |
|
| 61 | ||
| 62 | private function buildQueryString(Parameter ...$parameters): string |
|
| 63 | { |
|