public function call($method, $params = [])
    {
        if (null === $this->client) {
            $this->client = new Client([
                'base_uri' => static::API_URL,
                'content-type' => 'application/json',
            ]);
        }

        $requestParams = array_merge($this->defaultParams, [
            $method => [$params],
        ]);

        if ($this->sandbox) {
            $requestParams['apikey'] = self::SANDBOX_KEY;
        }

        $response = $this->client->post(null, ['body' => json_encode($requestParams)]);
        if ($response->getStatusCode() != 200) {
            throw new \Exception('Api http error: ' . $response->getStatusCode(), $response->getStatusCode());
        }

        $result = json_decode($response->getBody(), true);
        if (isset($result['error'])) {
            throw new \BadMethodCallException('Api error: ' . $result['error']['description'],
                $result['error']['code']);
        }

        return $result;
    }
public function call($method, $params = [])
    {
        if (null === $this->client) {
            $this->client = new Client([
                'base_uri' => static::API_URL,
                'content-type' => 'application/json',
            ]);
        }

        $requestParams = array_merge($this->defaultParams, [
            $method => [$params],
        ]);

        if ($this->sandbox) {
            $requestParams['apikey'] = self::SANDBOX_KEY;
        }

        $response = $this->client->post(null, ['body' => json_encode($requestParams)]);
        if ($response->getStatusCode() != 200) {
            throw new \Exception('Api http error: ' . $response->getStatusCode(), $response->getStatusCode());
        }

        $result = json_decode($response->getBody(), true);
        if (isset($result['error'])) {
            throw new \BadMethodCallException('Api error: ' . $result['error']['description'],
                $result['error']['code']);
        }

        return $result;
    }
public function call ( $ method , $ params = [ ] ) { if ( null === $ this -> client ) { $ this -> client = new Client ( [ 'base_uri' => static :: API_URL , 'content-type' => 'application/json' , ] ) ; } $ requestParams = array_merge ( $ this -> defaultParams , [ $ method => [ $ params ] , ] ) ; if ( $ this -> sandbox ) { $ requestParams [ 'apikey' ] = self :: SANDBOX_KEY ; } $ response = $ this -> client -> post ( null , [ 'body' => json_encode ( $ requestParams ) ] ) ; if ( $ response -> getStatusCode ( ) != 200 ) { throw new \ Exception ( 'Api http error: ' . $ response -> getStatusCode ( ) , $ response -> getStatusCode ( ) ) ; } $ result = json_decode ( $ response -> getBody ( ) , true ) ; if ( isset ( $ result [ 'error' ] ) ) { throw new \ BadMethodCallException ( 'Api error: ' . $ result [ 'error' ] [ 'description' ] , $ result [ 'error' ] [ 'code' ] ) ; } return $ result ; }
Makes api call

@param string $method
@param array $params
@return string
@throws \Exception
Makes api call