/** * Creates and returns the default SDK endpoint provider. * * @return callable */ public static function defaultProvider($modelsDir) { $data = \Api\load_compiled_json($modelsDir . '/endpoints.json'); return new PatternEndpointProvider($data['endpoints']); }
/** * Execute the the provider. * * @param string $type Type of data ('api', 'waiter', 'paginator'). * @param string $service Service name. * @param string $version API version. * * @return array|null */ public function __invoke($type, $service, $version) { // Resolve the type or return null. if (isset(self::$typeMap[$type])) { $type = self::$typeMap[$type]; } else { return null; } // Resolve the version or return null. if (!isset($this->manifest)) { $this->buildVersionsList($service); } if (!isset($this->manifest[$service]['versions'][$version])) { return null; } $version = $this->manifest[$service]['versions'][$version]; $path = "{$this->modelsDir}/{$service}/{$version}/{$type}.json"; try { return \Api\load_compiled_json($path); } catch (\InvalidArgumentException $e) { return null; } }