private function create(): CookieAuthSession
    {
        $response = $this->request($this->endpoint . $this->path, [
            RequestOptions::JSON => [
                'username' => $this->username,
                'password' => $this->password,
            ],
        ]);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $contents = json_decode($contents, true);

        if (isset($contents['session']['name'], $contents['session']['value'])) {
            return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
        }

        throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
    }
private function create(): CookieAuthSession
    {
        $response = $this->request($this->endpoint . $this->path, [
            RequestOptions::JSON => [
                'username' => $this->username,
                'password' => $this->password,
            ],
        ]);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $contents = json_decode($contents, true);

        if (isset($contents['session']['name'], $contents['session']['value'])) {
            return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
        }

        throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
    }
private function create ( ) : CookieAuthSession { $ response = $ this -> request ( $ this -> endpoint . $ this -> path , [ RequestOptions :: JSON => [ 'username' => $ this -> username , 'password' => $ this -> password , ] , ] ) ; $ body = $ response -> getBody ( ) ; $ body -> seek ( 0 ) ; $ contents = $ body -> getContents ( ) ; $ contents = json_decode ( $ contents , true ) ; if ( isset ( $ contents [ 'session' ] [ 'name' ] , $ contents [ 'session' ] [ 'value' ] ) ) { return new CookieAuthSession ( $ contents [ 'session' ] [ 'name' ] , $ contents [ 'session' ] [ 'value' ] ) ; } throw new \ Exception ( 'Failed to create ' . CookieAuthSession :: class . '.' ) ; }
Creates cookie auth session

@return CookieAuthSession
@throws \Exception If failed to create object
Creates cookie auth session