public static function upcoming($params = null, $apiKey = null) { $requestor = new ApiRequestor($apiKey); $url = self::classUrl(get_class()) . '/upcoming'; list($response, $apiKey) = $requestor->request('get', $url, $params); return Util::convertToStripeObject($response, $apiKey); }
public function cancelSubscription($params = null) { $requestor = new ApiRequestor($this->_apiKey); $url = $this->instanceUrl() . '/subscription'; list($response, $apiKey) = $requestor->request('delete', $url, $params); $this->refreshFrom(array('subscription' => $response), $apiKey, true); return $this->subscription; }
public function capture($params = null) { $requestor = new ApiRequestor($this->_apiKey); $url = $this->instanceUrl() . '/capture'; list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey); return $this; }
protected static function _staticRequest($method, $url, $params, $options) { $opts = Util\RequestOptions::parse($options); $requestor = new ApiRequestor($opts->apiKey, static::baseUrl()); list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); foreach ($opts->headers as $k => $v) { if (!array_key_exists($k, self::$HEADERS_TO_PERSIST)) { unset($opts->headers[$k]); } } return array($response, $opts); }
public function retrieve($id, $params = null, $opts = null) { list($url, $params) = $this->extractPathAndUpdateParams($params); $id = ApiRequestor::utf8($id); $extn = urlencode($id); list($response, $opts) = $this->_request('get', "{$url}/{$extn}", $params, $opts); return Util\Util::convertToPingppObject($response, $opts); }
private function setUpMockRequest() { if (!$this->mock) { self::authorizeFromEnv(); $this->mock = $this->getMock('\\Stripe\\HttpClient\\ClientInterface'); ApiRequestor::setHttpClient($this->mock); } return $this->mock; }
/** * @return string The API URL for this Stripe refund. */ public function instanceUrl() { $id = $this['id']; $fee = $this['fee']; if (!$id) { throw new Error\InvalidRequest("Could not determine which URL to request: " . "class instance has invalid ID: {$id}", null); } $id = ApiRequestor::utf8($id); $fee = ApiRequestor::utf8($fee); $base = ApplicationFee::classUrl(); $feeExtn = urlencode($fee); $extn = urlencode($id); return "{$base}/{$feeExtn}/refunds/{$extn}"; }
/** * @return string The API URL for this Stripe subscription. */ public function instanceUrl() { $id = $this['id']; $customer = $this['customer']; if (!$id) { throw new Error\InvalidRequest("Could not determine which URL to request: " . "class instance has invalid ID: {$id}", null); } $id = ApiRequestor::utf8($id); $customer = ApiRequestor::utf8($customer); $base = Customer::classUrl(); $customerExtn = urlencode($customer); $extn = urlencode($id); return "{$base}/{$customerExtn}/subscriptions/{$extn}"; }
/** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. */ public function instanceUrl() { $id = $this['id']; if (!$id) { $class = get_class($this); $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}"; throw new Error\InvalidRequest($msg, null); } $id = ApiRequestor::utf8($id); $extn = urlencode($id); if (!$this['customer']) { $base = BitcoinReceiver::classUrl(); return "{$base}/{$extn}"; } else { $base = Customer::classUrl(); $parent = ApiRequestor::utf8($this['customer']); $parentExtn = urlencode($parent); return "{$base}/{$parentExtn}/sources/{$extn}"; } }
/** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. */ public function instanceUrl() { $id = $this['id']; if (!$id) { $class = get_class($this); $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}"; throw new Error\InvalidRequest($msg, null); } if (isset($this['customer'])) { $parent = $this['customer']; $base = Customer::classUrl(); } elseif (isset($this['recipient'])) { $parent = $this['recipient']; $base = Recipient::classUrl(); } else { return null; } $parent = ApiRequestor::utf8($parent); $id = ApiRequestor::utf8($id); $parentExtn = urlencode($parent); $extn = urlencode($id); return "{$base}/{$parentExtn}/cards/{$extn}"; }
protected static function _staticRequest($method, $url, $params) { $requestor = new ApiRequestor(static::baseUrl()); list($response) = $requestor->request($method, $url, $params); return array($response); }
/** * Delete an object * * @return bool True when successful * @throws Error An appropriate error object */ public function delete($params = null) { self::_validateCall('delete'); $requestor = new ApiRequestor(); $url = '/' . $this->getType() . '/' . $this->id; return $requestor->request('delete', $url, $params); }
/** * @param string $method The HTTP method to use. * @param string $url The URL to use. * @param array|string|null $params The parameters to use for the request. * @param array|null $options The options to use for the response. * * @return JSON The response from the BlockScore API. */ public static function _makeRequest($method, $url, $params = null, $options = null) { $request = new ApiRequestor(BlockScore::$apiKey, BlockScore::$apiEndpoint); $response = $request->execute($method, $url, $params, $options); return $response; }
private function httpClient() { if (!self::$_httpClient) { self::$_httpClient = HttpClient\CurlClient::instance(); } return self::$_httpClient; }
protected function _scopedDelete($class, $params = null) { self::_validateCall('delete'); $requestor = new ApiRequestor($this->_apiKey); $url = $this->instanceUrl(); list($response, $apiKey) = $requestor->request('delete', $url, $params); $this->refreshFrom($response, $apiKey); return $this; }