public function testIsList() { $list = array(5, 'nstaoush', array()); $this->assertTrue(Conekta_Util::isList($list)); $notlist = array(5, 'nstaoush', array(), 'bar' => 'baz'); $this->assertFalse(Conekta_Util::isList($notlist)); }
public static function upcoming($params = null, $apiKey = null) { $requestor = new Conekta_ApiRequestor($apiKey); $url = self::classUrl(get_class()) . '/upcoming'; list($response, $apiKey) = $requestor->request('get', $url, $params); return Conekta_Util::convertToConektaObject($response, $apiKey); }
public function testRetrieve() { authorizeFromEnv(); $d = Conekta_Balance::retrieve(); $this->assertEqual($d->object, "balance"); $this->assertTrue(Conekta_Util::isList($d->available)); $this->assertTrue(Conekta_Util::isList($d->pending)); }
protected static function _scopedCreate($class, $params = null, $apiKey = null) { self::_validateCall('create', $params, $apiKey); $requestor = new Conekta_ApiRequestor($apiKey); $url = self::_scopedLsb($class, 'classUrl', $class); list($response, $apiKey) = $requestor->request('post', $url, $params); return Conekta_Util::convertToConektaObject($response, $apiKey); }
public function retrieve($id, $params = null) { $requestor = new Conekta_ApiRequestor($this->_apiKey); $base = $this['url']; $id = Conekta_ApiRequestor::utf8($id); $extn = urlencode($id); list($response, $apiKey) = $requestor->request('get', "{$base}/{$extn}", $params); return Conekta_Util::convertToConektaObject($response, $apiKey); }
public function loadFromArray($values) { foreach ($values as $k => $v) { if (is_array($v)) { $v = Conekta_Util::convertToConektaObject($v); } if (strpos(get_class($this), "Conekta_Object") !== false) { $this[$k] = $v; } else { $this->{$k} = $v; } $this->_setVal($k, $v); } }
protected function _delete($parent = null, $member = null) { self::_customAction('delete', null, null); if (isset($parent) && isset($member)) { $obj = $this->{$parent}->{$member}; if (strpos(get_class($obj), 'Conekta_Object') !== false) { foreach ($this->{$parent}->{$member} as $k => $v) { if (strpos($v->id, $this->id) !== false) { $this->{$parent}->{$member}->_values = Conekta_Util::shiftArray($this->{$parent}->{$member}->_values, $k); $this->{$parent}->{$member}->loadFromArray($this->{$parent}->{$member}->_values); $this->{$parent}->{$member}->offsetUnset(count($this->{$parent}->{$member}) - 1); break; } } } else { unset($this->{$parent}->{$member}); } } return $this; }
public function __toArray($recursive = false) { if ($recursive) { return Conekta_Util::convertConektaObjectToArray($this->_values); } else { return $this->_values; } }