示例#1
0
 public static function send($url, $authString, $payload, $method)
 {
     $jsonPayload = NULL;
     $request = NULL;
     switch ($method) {
         case "POST":
             $request = Request::post($url);
             break;
         case "GET":
             $request = Request::get($url);
             break;
         case "PUT":
             $request = Request::put($url);
             break;
         case "DELETE":
             $request = Request::delete($url);
             break;
     }
     if (NULL !== $payload && TRUE === is_array($payload)) {
         $jsonPayload = json_encode($payload);
         $request->sendsJson()->body($jsonPayload);
     }
     if (NULL !== self::$userAgent) {
         $request->addHeader("User-Agent", self::$userAgent);
     }
     $request->timeout((int) ceil(self::$timeout / 1000));
     $response = $request->addHeader("Authorization", $authString)->send();
     $responsePayload = $response->body;
     return $responsePayload;
 }
示例#2
0
 /**
  * Deactivate one recurrent payment
  * @param mixed $recurrentId 
  */
 public function reactivate($recurrentId, $amount)
 {
     $uri = Braspag::$apiBase . "RecurrentPayment/{$recurrentId}/Reactivate";
     $response = Request::put($uri)->addHeaders($this->headers)->addHeader("content-type", "text/json")->send();
     if ($response->code == HttpStatus::BadRequest) {
         Utils::handleApiError($response);
     }
     return $response->code;
 }
示例#3
0
 /**
  * Factory style constructor works nicer for chaining.  This
  * should also really only be used internally.  The Request::get,
  * Request::post syntax is preferred as it is more readable.
  * @param string $method Http Method
  * @param string $mime Mime Type to Use
  * @return Request
  */
 public static function initialize($method = null, $mime = null)
 {
     // Setup our handlers, can call it here as it's idempotent
     \HttpFull\Bootstrap::initialize();
     // Setup the default template if need be
     if (!isset(self::$_template)) {
         self::_initializeDefaults();
     }
     $request = new Request();
     return $request->_setDefaults()->method($method)->sendsType($mime)->expectsType($mime);
 }
示例#4
0
 public function patch($url, $headers = array(), $options = array())
 {
     return Method::patch($url, $options)->addHeaders($headers)->send();
 }