self::$service->bearer_token]); config(['crm.password' => self::$service->bearer_pwd]); config(['crm.endpoint' => 'http://127.0.0.1:8888']); } /** * @return array */ protected static function getCustomer(bool $status = true) { /** @var \App\Models\Costumer $customer */ $customer = Customer::whereHas('logins', function ($q) use ($status) { $q->where('status', $status); })->inRandomOrder()->firstOrFail(); /** @var \App\Models\Brand $brand */ $login = $customer->logins()->where('status', $status)->firstOrFail(); /** @var \App\Models\CustomerLogin $login */ $brand = $login->brand; /** @var \App\Models\Service $service */ $service = $brand->services()->firstOrFail(); // get customer info $info = $customer->info($brand, Customer::FIRST_OR_FAIL); // regen bearer token to get the pwd in clear $bearer_token = $service->generateBearerToken(); $bearer_pwd = $service->bearer_pwd; $service->saveOrFail(); $service->bearer_token = $bearer_token; $service->bearer_pwd = $bearer_pwd; return compact('customer', 'service', 'brand', 'login', 'info'); } /** * Parse routes.json and return routes list * * @return array */ protected function getClientRoutes(): array { return \json_decode(\file_get_contents(__DIR__ . '/../../clients/V2/src/routes.json'), true); } }