public function send($method, $endpoint, $data = [])
    {
        $method = strtolower($method);

        if ($method !== 'get' && $this->isUserLoggedIn()) {
            $this->generateCSRFToken();
        }

        $csfrToken = '-';

        // load csfr token from cookies
        /** @var CookieJar $cookies */
        $cookies = $this->client->getConfig()['cookies'];
        foreach($cookies->toArray() as $cookie) {
            if ($cookie['Name'] === 'CSRF_TOKEN') {
                $csfrToken = $cookie['Value'];
                break;
            }
        }

        // set auth data and post data
        $options = [
            'body' => $method === 'post' || $method === 'put' ? json_encode($data) : null,
            'headers' => [
                'Content-Type' => 'application/json',
                'Cookie' => 'CSRF_TOKEN=' . $csfrToken,
                'X-CSRF-TOKEN' => $csfrToken,
            ]
        ];

        return $this->client->$method($endpoint, $options);
    }
public function send($method, $endpoint, $data = [])
    {
        $method = strtolower($method);

        if ($method !== 'get' && $this->isUserLoggedIn()) {
            $this->generateCSRFToken();
        }

        $csfrToken = '-';

        // load csfr token from cookies
        /** @var CookieJar $cookies */
        $cookies = $this->client->getConfig()['cookies'];
        foreach($cookies->toArray() as $cookie) {
            if ($cookie['Name'] === 'CSRF_TOKEN') {
                $csfrToken = $cookie['Value'];
                break;
            }
        }

        // set auth data and post data
        $options = [
            'body' => $method === 'post' || $method === 'put' ? json_encode($data) : null,
            'headers' => [
                'Content-Type' => 'application/json',
                'Cookie' => 'CSRF_TOKEN=' . $csfrToken,
                'X-CSRF-TOKEN' => $csfrToken,
            ]
        ];

        return $this->client->$method($endpoint, $options);
    }
public function send ( $ method , $ endpoint , $ data = [ ] ) { $ method = strtolower ( $ method ) ; if ( $ method !== 'get' && $ this -> isUserLoggedIn ( ) ) { $ this -> generateCSRFToken ( ) ; } $ csfrToken = '-' ; // load csfr token from cookies /** @var CookieJar $cookies */ $ cookies = $ this -> client -> getConfig ( ) [ 'cookies' ] ; foreach ( $ cookies -> toArray ( ) as $ cookie ) { if ( $ cookie [ 'Name' ] === 'CSRF_TOKEN' ) { $ csfrToken = $ cookie [ 'Value' ] ; break ; } } // set auth data and post data $ options = [ 'body' => $ method === 'post' || $ method === 'put' ? json_encode ( $ data ) : null , 'headers' => [ 'Content-Type' => 'application/json' , 'Cookie' => 'CSRF_TOKEN=' . $ csfrToken , 'X-CSRF-TOKEN' => $ csfrToken , ] ] ; return $ this -> client -> $ method ( $ endpoint , $ options ) ; }
Send request to Endomondo API.

@param $method string http method
@param $endpoint string Endomondo endpoint
@param array $data
@return ResponseInterface;
Send request to Endomondo API .