public function create_scan_form($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/scan_form'; list($response, $apiKey) = $requestor->request('post', $url, $params); return Util::convertToEasyPostObject($response, $apiKey); }
/** * retrieve item reference * * @param mixed $params * @param string $apiKey * @return array */ public static function retrieve_reference($params = null, $apiKey = null) { $class = get_class(); $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('get', $url . '/retrieve_reference', $params); return Util::convertToEasyPostObject($response, $apiKey); }
/** * cancel a pickup * * @param mixed $params * @return $this * @throws \EasyPost\Error */ public function cancel($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/cancel'; list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey, true); return $this; }
/** * create a list of trackers * * @param mixed $params * @param string $apiKey * @return mixed */ public static function create_list($params = null, $apiKey = null) { $class = get_class(); if (!isset($params['trackers']) || !is_array($params['trackers'])) { $clone = $params; unset($params); $params['trackers'] = $clone; } $requestor = new Requestor($apiKey); $url = self::classUrl($class); list($response, $apiKey) = $requestor->request('post', $url . '/create_list', $params); }
public function buy($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/buy'; if ($params instanceof Rate) { $clone = $params; unset($params); $params['carrier'] = $clone->carrier; $params['service'] = $clone->service; } list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey, false); return $this; }
public function verify($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/verify'; list($response, $apiKey) = $requestor->request('get', $url, $params); if (isset($response['address'])) { $verified_address = Util::convertToEasyPostObject($response['address'], $apiKey); if (!empty($response['message'])) { $verified_address->message = $response['message']; $verified_address->_immutableValues[] = 'message'; } return $verified_address; } else { return Util::convertToEasyPostObject($response, $apiKey); } }
protected function _delete($class, $params = null) { self::_validate('delete'); $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl(); list($response, $apiKey) = $requestor->request('delete', $url, $params); $this->refreshFrom($response, $apiKey); return $this; }
/** * insure the shipment * * @param mixed $params * @return $this * @throws \EasyPost\Error */ public function insure($params = null) { $requestor = new Requestor($this->_apiKey); $url = $this->instanceUrl() . '/insure'; if (!isset($params['amount'])) { $clone = $params; unset($params); $params['amount'] = $clone; } list($response, $apiKey) = $requestor->request('post', $url, $params); $this->refreshFrom($response, $apiKey); return $this; }
/** * get types of carrier account * * @param mixed $params * @param string $apiKey * @return mixed */ public static function types($params = null, $apiKey = null) { $requestor = new Requestor($apiKey); list($response, $apiKey) = $requestor->request('get', '/carrier_types', $params); return Util::convertToEasyPostObject($response, $apiKey); }
public function testRequestResponseException() { $server = new TestServer(new TestProtocolResponder(AvroProtocol::parse($this->protocol))); $client = TestTransceiver::getTestClient($server); $requestor = new Requestor(AvroProtocol::parse($this->protocol), $client); $exception_raised = false; try { $response = $requestor->request('testRequestResponseException', array("exception" => array("cause" => "callback"))); } catch (AvroRemoteException $e) { $exception_raised = true; $exception_datum = $e->getDatum(); $this->assertEquals("raised on callback cause", $exception_datum["exception"]); } $this->assertTrue($exception_raised); $exception_raised = false; try { $response = $requestor->request('testRequestResponseException', array("exception" => array("cause" => "system"))); } catch (AvroRemoteException $e) { $exception_raised = true; $exception_datum = $e->getDatum(); $this->assertEquals("System exception", $exception_datum); } $this->assertTrue($exception_raised); }
"testNotification": { "doc" : "Notification : one-way message", "request": [{"name": "notification", "type": "Notification"}], "one-way": true }, "testRequestResponseException": { "doc" : "Request Response with Exception", "request": [{"name": "exception", "type": "RaiseException"}], "response" : "NeverSend", "errors" : ["AlwaysRaised"] } } } PROTO; $client = NettyFramedSocketTransceiver::create('127.0.0.1', 1411); $requestor = new Requestor(AvroProtocol::parse($protocol), $client); try { $response = $requestor->request('testSimpleRequestResponse', array("message" => array("subject" => "pong"))); echo "Response received: " . json_encode($response) . "\n"; $response = $requestor->request('testSimpleRequestResponse', array("message" => array("subject" => "ping"))); echo "Response received: " . json_encode($response) . "\n"; } catch (AvroRemoteException $e) { echo "Exception received: " . json_encode($e->getDatum()) . "\n"; } try { $response = $requestor->request('testSimpleRequestWithoutParameters', array()); echo "Response received: " . json_encode($response) . "\n"; } catch (AvroRemoteException $e) { echo "Exception received: " . json_encode($e->getDatum()) . "\n"; } try {
public static function all_api_keys($apiKey = null) { $requestor = new Requestor($apiKey); list($response, $apiKey) = $requestor->request('get', '/api_keys'); return Util::convertToEasyPostObject($response, $apiKey); }
public function __construct($host, $port) { $client = \NettyFramedSocketTransceiver::create($host, $port); parent::__construct(\AvroProtocol::parse(self::$json_protocol), $client); }