/** * Get last user conversations * * @return array|bool */ public function last() { $data = Request::createRequestData(); $query = UrlHelper::buildRequestString($data); $response = $this->request->exec(UrlHelper::RESOURCE_GET_LAST_CONVERSATIONS . '?' . $query); return $this->response->getData($response); }
/** * @param array $data * @param string $url * @param string $sourceUrl * @param array $bookmarks * @return array */ public function getData($data, $url, $sourceUrl, $bookmarks = []) { $data['options'] = $data; $get = Request::createRequestData($data, $sourceUrl, $bookmarks); $getString = UrlHelper::buildRequestString($get); $response = $this->getRequest()->exec($url . '?' . $getString); return $this->getResponse()->getPaginationData($response); }
/** * Get user's latest news array * * @return array */ public function latest() { $data = ["options" => ['allow_state' => true]]; $request = Request::createRequestData($data); $getString = UrlHelper::buildRequestString($request); $response = $this->request->exec(UrlHelper::RESOURCE_GET_LATEST_NEWS . "?{$getString}"); return $this->response->getData($response); }
/** * Executes a POST request to Pinterest API * * @param array $requestOptions * @param string $resourceUrl * @param bool $returnData * @return mixed */ public function callPostRequest($requestOptions, $resourceUrl, $returnData = null) { $data = array("options" => $requestOptions); $request = Request::createRequestData($data); $postString = UrlHelper::buildRequestString($request); $response = $this->request->exec($resourceUrl, $postString); if ($returnData) { return $this->response->getData($response); } return $this->response->checkResponse($response); }
/** * Creates Pinterest API search request * * @param $query * @param $scope * @param array $bookmarks * @return array */ public function createSearchRequest($query, $scope, $bookmarks = []) { $options = ["scope" => $scope, "query" => $query]; $dataJson = ["options" => $options]; if (!empty($bookmarks)) { $dataJson['options']['bookmarks'] = $bookmarks; } else { $dataJson = array_merge($dataJson, ['module' => ["name" => $this->moduleSearchPage, "options" => $options]]); } return Request::createRequestData($dataJson, "/search/{$scope}/?q=" . $query); }
/** * Creates Pinterest API search request. * * @param string $query * @param string $scope * @param array $bookmarks * * @return string */ protected function createSearchQuery($query, $scope, $bookmarks = []) { $dataJson = $this->appendBookMarks($bookmarks, ['scope' => $scope, 'query' => $query]); $request = Request::createRequestData($dataJson, $bookmarks); return UrlBuilder::buildRequestString($request); }
/** * Get information of a pin by PinID * * @param int $pinId * @return array|bool */ public function info($pinId) { $requestOptions = ["field_set_key" => "detailed", "id" => $pinId, "pin_id" => $pinId, "allow_stale" => true]; $data = array("options" => $requestOptions); $request = Request::createRequestData($data); $url = UrlHelper::RESOURCE_PIN_INFO . '?' . UrlHelper::buildRequestString($request); $response = $this->request->exec($url); return $this->response->checkResponse($response); }
/** * Creates Pinterest API request to login * * @param string $username * @param string $password * @return array */ public static function createLoginRequest($username, $password) { $dataJson = ["options" => ["username_or_email" => $username, "password" => $password]]; return Request::createRequestData($dataJson, "/login/"); }
/** * @param int $boardId * @param array $bookmarks * @return array|bool */ protected function getPinsFromBoard($boardId, $bookmarks = []) { $get = Request::createRequestData(['options' => ['board_id' => $boardId]], '', $bookmarks); return $this->boardsGetCall($get, UrlHelper::RESOURCE_GET_BOARD_FEED, true); }
/** * Returns HttpClient object for setting user-agent string or * other CURL available options. * * @return HttpClient */ public function getHttpClient() { return $this->request->getHttpClient(); }
/** @test */ public function it_returns_http_client_instance() { $this->request->shouldReceive('getHttpClient')->andReturn(new CurlHttpClient(new Cookies())); $this->assertInstanceOf(HttpClient::class, $this->container->getHttpClient()); }
/** * @param string|null $sourceUrl * @param array $data * @return array */ public static function createPinRequestData($data, $sourceUrl = null) { if ($sourceUrl === null) { reset($data); $sourceUrl = "/pin/" . end($data["options"]) . "/"; } return Request::createRequestData($data, $sourceUrl); }
/** * Creates Pinterest API search request * * @param $query * @param $scope * @param array $bookmarks * @return array */ public function createSearchRequest($query, $scope, $bookmarks = []) { $options = ["scope" => $scope, "query" => $query]; $dataJson = $this->appendBookMarks($bookmarks, $options); return Request::createRequestData($dataJson, "/search/{$scope}/?q=" . $query); }
/** * @return bool */ public function isLoggedIn() { return $this->request->isLoggedIn(); }