lib/Shipmile/HttpClient/HttpClient.php
public function request($path, $body = null, $httpMethod = 'GET', array $options = array())
    {
        $headers = array();

        $options = array_merge($this->options, $options);

        if (isset($options['headers'])) {
            $headers = $options['headers'];
            unset($options['headers']);
        }

        $headers = array_merge($this->headers, array_change_key_case($headers));

        unset($options['body']);

        unset($options['base']);
        unset($options['user_agent']);

        $request = $this->createRequest($httpMethod, $path, null, $headers, $options);

        if ($httpMethod != 'GET') {
            $request = $this->setBody($request, $body, $options);
        }

        try {
            $response = $this->client->send($request);
        } catch (\LogicException $e) {
            throw new \ErrorException($e->getMessage());
        } catch (\RuntimeException $e) {
            throw new \RuntimeException($e->getMessage());
        }

        return new Response($this->getBody($response), $response->getStatusCode(), $response->getHeaders());
    }
public function request($path, $body = null, $httpMethod = 'GET', array $options = array())
    {
        $headers = array();

        $options = array_merge($this->options, $options);

        if (isset($options['headers'])) {
            $headers = $options['headers'];
            unset($options['headers']);
        }

        $headers = array_merge($this->headers, array_change_key_case($headers));

        unset($options['body']);

        unset($options['base']);
        unset($options['user_agent']);

        $request = $this->createRequest($httpMethod, $path, null, $headers, $options);

        if ($httpMethod != 'GET') {
            $request = $this->setBody($request, $body, $options);
        }

        try {
            $response = $this->client->send($request);
        } catch (\LogicException $e) {
            throw new \ErrorException($e->getMessage());
        } catch (\RuntimeException $e) {
            throw new \RuntimeException($e->getMessage());
        }

        return new Response($this->getBody($response), $response->getStatusCode(), $response->getHeaders());
    }
public function request ( $ path , $ body = null , $ httpMethod = 'GET' , array $ options = array ( ) ) { $ headers = array ( ) ; $ options = array_merge ( $ this -> options , $ options ) ; if ( isset ( $ options [ 'headers' ] ) ) { $ headers = $ options [ 'headers' ] ; unset ( $ options [ 'headers' ] ) ; } $ headers = array_merge ( $ this -> headers , array_change_key_case ( $ headers ) ) ; unset ( $ options [ 'body' ] ) ; unset ( $ options [ 'base' ] ) ; unset ( $ options [ 'user_agent' ] ) ; $ request = $ this -> createRequest ( $ httpMethod , $ path , null , $ headers , $ options ) ; if ( $ httpMethod != 'GET' ) { $ request = $ this -> setBody ( $ request , $ body , $ options ) ; } try { $ response = $ this -> client -> send ( $ request ) ; } catch ( \ LogicException $ e ) { throw new \ ErrorException ( $ e -> getMessage ( ) ) ; } catch ( \ RuntimeException $ e ) { throw new \ RuntimeException ( $ e -> getMessage ( ) ) ; } return new Response ( $ this -> getBody ( $ response ) , $ response -> getStatusCode ( ) , $ response -> getHeaders ( ) ) ; }
Intermediate function which does three main things

- Transforms the body of request into correct format
- Creates the requests with give parameters
- Returns response body after parsing it into correct format
Intermediate function which does three main things