/** * Magic method for static calls * @param string $name * @param array $arguments * @return mixed */ public static function __callstatic($name, $arguments) { // Get global services or entity services $services = Client::getServices(isset($arguments['context']) ? $arguments['context'] : null); if (array_key_exists($name, $services)) { $service = $services[$name]; switch ($service['type']) { case 'collection': return new Cursor($service, Client::getInstance(), isset($arguments['context']) ? $arguments['context'] : null); break; case 'entity': return new Entity($service, Client::getInstance(), isset($arguments[0]) ? $arguments[0] : null); break; // $name represents an action on an entity // $name represents an action on an entity case 'action': return new Action($service, $arguments['context'], Client::getInstance()); break; default: throw new \Exception("Don't know of any service type named '{$name}'"); break; } } else { throw new \Exception("can't find service definition for '{$name}'"); } }
/** * Test the services list retrieval */ public function testGetv1Endpoints() { xAC::setApiVersion(1); xAC::initServices(true); $this->assertArrayHasKey('transactions', xAC::getServices()); $this->assertArrayHasKey('customer', xAC::getServices()); }