Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 399 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 399 Revision 621
Zeile 7... Zeile 7...
7
use GuzzleHttp\Cookie\CookieJar;
7
use GuzzleHttp\Cookie\CookieJar;
8
use GuzzleHttp\Exception\ConnectException;
8
use GuzzleHttp\Exception\ConnectException;
9
use GuzzleHttp\Exception\RequestException;
9
use GuzzleHttp\Exception\RequestException;
10
use GuzzleHttp\Exception\TransferException;
10
use GuzzleHttp\Exception\TransferException;
11
use GuzzleHttp\HandlerStack;
11
use GuzzleHttp\HandlerStack;
-
 
12
use GuzzleHttp\UriTemplate\UriTemplate;
12
use Illuminate\Contracts\Support\Arrayable;
13
use Illuminate\Contracts\Support\Arrayable;
13
use Illuminate\Http\Client\Events\ConnectionFailed;
14
use Illuminate\Http\Client\Events\ConnectionFailed;
14
use Illuminate\Http\Client\Events\RequestSending;
15
use Illuminate\Http\Client\Events\RequestSending;
15
use Illuminate\Http\Client\Events\ResponseReceived;
16
use Illuminate\Http\Client\Events\ResponseReceived;
16
use Illuminate\Support\Arr;
17
use Illuminate\Support\Arr;
Zeile 55... Zeile 56...
55
     * @var string
56
     * @var string
56
     */
57
     */
57
    protected $baseUrl = '';
58
    protected $baseUrl = '';
Zeile 58... Zeile 59...
58
 
59
 
-
 
60
    /**
-
 
61
     * The parameters that can be substituted into the URL.
-
 
62
     *
-
 
63
     * @var array
-
 
64
     */
-
 
65
    protected $urlParameters = [];
-
 
66
 
59
    /**
67
    /**
60
     * The request body format.
68
     * The request body format.
61
     *
69
     *
62
     * @var string
70
     * @var string
63
     */
71
     */
Zeile 341... Zeile 349...
341
     * @param  string  $contentType
349
     * @param  string  $contentType
342
     * @return $this
350
     * @return $this
343
     */
351
     */
344
    public function contentType(string $contentType)
352
    public function contentType(string $contentType)
345
    {
353
    {
346
        return $this->withHeaders(['Content-Type' => $contentType]);
354
        $this->options['headers']['Content-Type'] = $contentType;
-
 
355
 
-
 
356
        return $this;
347
    }
357
    }
Zeile 348... Zeile 358...
348
 
358
 
349
    /**
359
    /**
350
     * Indicate that JSON should be returned by the server.
360
     * Indicate that JSON should be returned by the server.
Zeile 436... Zeile 446...
436
            $this->options['headers']['User-Agent'] = trim($userAgent);
446
            $this->options['headers']['User-Agent'] = trim($userAgent);
437
        });
447
        });
438
    }
448
    }
Zeile 439... Zeile 449...
439
 
449
 
-
 
450
    /**
-
 
451
     * Specify the URL parameters that can be substituted into the request URL.
-
 
452
     *
-
 
453
     * @param  array  $parameters
-
 
454
     * @return $this
-
 
455
     */
-
 
456
    public function withUrlParameters(array $parameters = [])
-
 
457
    {
-
 
458
        return tap($this, function () use ($parameters) {
-
 
459
            $this->urlParameters = $parameters;
-
 
460
        });
-
 
461
    }
-
 
462
 
440
    /**
463
    /**
441
     * Specify the cookies that should be included with the request.
464
     * Specify the cookies that should be included with the request.
442
     *
465
     *
443
     * @param  array  $cookies
466
     * @param  array  $cookies
444
     * @param  string  $domain
467
     * @param  string  $domain
Zeile 711... Zeile 734...
711
     *
734
     *
712
     * @param  string  $url
735
     * @param  string  $url
713
     * @param  array  $data
736
     * @param  array  $data
714
     * @return \Illuminate\Http\Client\Response
737
     * @return \Illuminate\Http\Client\Response
715
     */
738
     */
716
    public function patch($url, $data = [])
739
    public function patch(string $url, $data = [])
717
    {
740
    {
718
        return $this->send('PATCH', $url, [
741
        return $this->send('PATCH', $url, [
719
            $this->bodyFormat => $data,
742
            $this->bodyFormat => $data,
720
        ]);
743
        ]);
721
    }
744
    }
Zeile 725... Zeile 748...
725
     *
748
     *
726
     * @param  string  $url
749
     * @param  string  $url
727
     * @param  array  $data
750
     * @param  array  $data
728
     * @return \Illuminate\Http\Client\Response
751
     * @return \Illuminate\Http\Client\Response
729
     */
752
     */
730
    public function put($url, $data = [])
753
    public function put(string $url, $data = [])
731
    {
754
    {
732
        return $this->send('PUT', $url, [
755
        return $this->send('PUT', $url, [
733
            $this->bodyFormat => $data,
756
            $this->bodyFormat => $data,
734
        ]);
757
        ]);
735
    }
758
    }
Zeile 739... Zeile 762...
739
     *
762
     *
740
     * @param  string  $url
763
     * @param  string  $url
741
     * @param  array  $data
764
     * @param  array  $data
742
     * @return \Illuminate\Http\Client\Response
765
     * @return \Illuminate\Http\Client\Response
743
     */
766
     */
744
    public function delete($url, $data = [])
767
    public function delete(string $url, $data = [])
745
    {
768
    {
746
        return $this->send('DELETE', $url, empty($data) ? [] : [
769
        return $this->send('DELETE', $url, empty($data) ? [] : [
747
            $this->bodyFormat => $data,
770
            $this->bodyFormat => $data,
748
        ]);
771
        ]);
749
    }
772
    }
Zeile 781... Zeile 804...
781
    {
804
    {
782
        if (! Str::startsWith($url, ['http://', 'https://'])) {
805
        if (! Str::startsWith($url, ['http://', 'https://'])) {
783
            $url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
806
            $url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
784
        }
807
        }
Zeile -... Zeile 808...
-
 
808
 
-
 
809
        $url = $this->expandUrlParameters($url);
785
 
810
 
Zeile 786... Zeile 811...
786
        $options = $this->parseHttpOptions($options);
811
        $options = $this->parseHttpOptions($options);
Zeile 787... Zeile 812...
787
 
812
 
Zeile 837... Zeile 862...
837
            return $result;
862
            return $result;
838
        });
863
        });
839
    }
864
    }
Zeile 840... Zeile 865...
840
 
865
 
-
 
866
    /**
-
 
867
     * Substitute the URL parameters in the given URL.
-
 
868
     *
-
 
869
     * @param  string  $url
-
 
870
     * @return string
-
 
871
     */
-
 
872
    protected function expandUrlParameters(string $url)
-
 
873
    {
-
 
874
        return UriTemplate::expand($url, $this->urlParameters);
-
 
875
    }
-
 
876
 
841
    /**
877
    /**
842
     * Parse the given HTTP options and set the appropriate additional options.
878
     * Parse the given HTTP options and set the appropriate additional options.
843
     *
879
     *
844
     * @param  array  $options
880
     * @param  array  $options
845
     * @return array
881
     * @return array