public static function convertToConektaObject($resp)
 {
     $types = self::$types;
     if (is_array($resp)) {
         if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
             $class = $types[$resp['object']];
             $instance = new $class();
             $instance->loadFromArray($resp);
             return $instance;
         }
         if (isset($resp['street1']) || isset($resp['street2'])) {
             $class = "Conekta_Address";
             $instance = new $class();
             $instance->loadFromArray($resp);
             return $instance;
         }
         if (current($resp)) {
             $instance = new Conekta_Object();
             $instance->loadFromArray($resp);
             return $instance;
         }
         return new Conekta_Object();
     }
     return $resp;
 }
Esempio n. 2
0
 protected static function _scpWhere($class, $params)
 {
     $instance = new Conekta_Object();
     $requestor = new Conekta_Requestor();
     $url = self::classUrl($class);
     $response = $requestor->request('get', $url, $params);
     $instance->loadFromArray($response);
     return $instance;
 }
Esempio n. 3
0
 public static function convertToConektaObject($resp, $apiKey)
 {
     $types = array('card' => 'Conekta_Card', 'charge' => 'Conekta_Charge', 'customer' => 'Conekta_Customer', 'list' => 'Conekta_List', 'invoice' => 'Conekta_Invoice', 'invoiceitem' => 'Conekta_InvoiceItem', 'event' => 'Conekta_Event', 'transfer' => 'Conekta_Transfer', 'plan' => 'Conekta_Plan', 'recipient' => 'Conekta_Recipient');
     //if (self::isList($resp)) {
     //$mapped = array();
     //foreach ($resp as $i)
     //array_push($mapped, self::convertToConektaObject($i, $apiKey));
     //return $mapped;
     //} else
     if (is_array($resp)) {
         if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
             $class = $types[$resp['object']];
         } else {
             $class = 'Conekta_Object';
         }
         return Conekta_Object::scopedConstructFrom($class, $resp, $apiKey);
     } else {
         return $resp;
     }
 }
 public function testKeys()
 {
     $s = new Conekta_Object();
     $s->foo = 'a';
     $this->assertEqual($s->keys(), array('foo'));
 }
Esempio n. 5
0
 public static function init()
 {
     self::$_permanentAttributes = new Conekta_Util_Set(array('_apiKey', 'id'));
 }