src/Iadvize/ApiRestClient/Client.php
public function proceed()
    {
        // Get request
        $request = $this->getLastRequest();

        // Build parameters
        $parameters = [];
        if ($request->getFullResults()) {
            $parameters['full'] = true;
        }
        if ($request->getFilters()) {
            $parameters['filters'] = $request->getFilters();
        }
        if ($request->getFields()) {
            $parameters['fields'] = $request->getFields();
        }
        if ($request->getCurrentPage()) {
            $parameters['page'] = $request->getCurrentPage();
        }
        if ($request->getPaginationLimit()) {
            $parameters['limit'] = $request->getPaginationLimit();
        }

        // Create browser
        $browser = $this->getBrowser();
        $headers = ['X-API-Key' => $this->getAuthenticationKey()];
        $url     = $this->getBaseUri() . $request->getResourceName();
        if ($request->getIdentifier()) {
            $url .= '/' . $request->getIdentifier();
        }
        if ($parameters) {
            $url .= '?' . http_build_query($parameters);
        }

        $content = http_build_query($request->getFields());

        switch ($request->getMode()) {
            default:
            case Request::MODE_READ:
                $response = $browser->get($url, $headers);
                break;
            case Request::MODE_CREATE:
                $response = $browser->post($url, $headers, $content);
                break;
            case Request::MODE_UPDATE:
                $response = $browser->put($url, $headers, $content);
                break;
            case Request::MODE_DELETE:
                $response = $browser->delete($url, $headers);
                break;
        }

        // Content
        $content = $response->getContent();
        $content = json_decode($content, true);

        // Create meta
        $meta = new Response\Meta;
        if (!empty($content['meta'])) {
            if (isset($content['meta']['status'])) {
                $meta->setStatus($content['meta']['status']);
            }
            if (isset($content['meta']['message'])) {
                $meta->setMessage($content['meta']['message']);
            }
            if (isset($content['meta']['filters'])) {
                $meta->setFilters($content['meta']['filters']);
            }
        }

        // Create data
        $data = new Response\Data;
        if (!empty($content['data'])) {
            $data->setData($content['data']);
        }

        // Create pagination
        $pagination = new Response\Pagination;
        if (!empty($content['pagination'])) {

            if (!empty($content['pagination']['page'])) {
                $pagination->setPage($content['pagination']['page']);
            }
            if (!empty($content['pagination']['pages'])) {
                $pagination->setPages($content['pagination']['pages']);
            }
            if (!empty($content['pagination']['limit'])) {
                $pagination->setLimit($content['pagination']['limit']);
            }
            if (!empty($content['pagination']['count'])) {
                $pagination->setCount($content['pagination']['count']);
            }
        }

        // Create response
        $response = new Response;
        $response->setMeta($meta);
        $response->setData($data);
        $response->setPagination($pagination);

        // Set to current response
        $this->setLastResponse($response);

        return $response;
    }
public function proceed()
    {
        // Get request
        $request = $this->getLastRequest();

        // Build parameters
        $parameters = [];
        if ($request->getFullResults()) {
            $parameters['full'] = true;
        }
        if ($request->getFilters()) {
            $parameters['filters'] = $request->getFilters();
        }
        if ($request->getFields()) {
            $parameters['fields'] = $request->getFields();
        }
        if ($request->getCurrentPage()) {
            $parameters['page'] = $request->getCurrentPage();
        }
        if ($request->getPaginationLimit()) {
            $parameters['limit'] = $request->getPaginationLimit();
        }

        // Create browser
        $browser = $this->getBrowser();
        $headers = ['X-API-Key' => $this->getAuthenticationKey()];
        $url     = $this->getBaseUri() . $request->getResourceName();
        if ($request->getIdentifier()) {
            $url .= '/' . $request->getIdentifier();
        }
        if ($parameters) {
            $url .= '?' . http_build_query($parameters);
        }

        $content = http_build_query($request->getFields());

        switch ($request->getMode()) {
            default:
            case Request::MODE_READ:
                $response = $browser->get($url, $headers);
                break;
            case Request::MODE_CREATE:
                $response = $browser->post($url, $headers, $content);
                break;
            case Request::MODE_UPDATE:
                $response = $browser->put($url, $headers, $content);
                break;
            case Request::MODE_DELETE:
                $response = $browser->delete($url, $headers);
                break;
        }

        // Content
        $content = $response->getContent();
        $content = json_decode($content, true);

        // Create meta
        $meta = new Response\Meta;
        if (!empty($content['meta'])) {
            if (isset($content['meta']['status'])) {
                $meta->setStatus($content['meta']['status']);
            }
            if (isset($content['meta']['message'])) {
                $meta->setMessage($content['meta']['message']);
            }
            if (isset($content['meta']['filters'])) {
                $meta->setFilters($content['meta']['filters']);
            }
        }

        // Create data
        $data = new Response\Data;
        if (!empty($content['data'])) {
            $data->setData($content['data']);
        }

        // Create pagination
        $pagination = new Response\Pagination;
        if (!empty($content['pagination'])) {

            if (!empty($content['pagination']['page'])) {
                $pagination->setPage($content['pagination']['page']);
            }
            if (!empty($content['pagination']['pages'])) {
                $pagination->setPages($content['pagination']['pages']);
            }
            if (!empty($content['pagination']['limit'])) {
                $pagination->setLimit($content['pagination']['limit']);
            }
            if (!empty($content['pagination']['count'])) {
                $pagination->setCount($content['pagination']['count']);
            }
        }

        // Create response
        $response = new Response;
        $response->setMeta($meta);
        $response->setData($data);
        $response->setPagination($pagination);

        // Set to current response
        $this->setLastResponse($response);

        return $response;
    }
Send request

@return Response