ClientInterface.php 2.99 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Framework\HTTP;

/**
 * Interface for HTTP clients
 *
 * @api
 * @since 100.0.2
 */
interface ClientInterface
{
    /**
     * Set request timeout
     *
     * @param int $value value in seconds
     * @return void
     */
    public function setTimeout($value);

    /**
     * Set request headers from hash
     *
     * @param array $headers an array of header names as keys and header values as values
     * @return void
     */
    public function setHeaders($headers);

    /**
     * Add header to request
     *
     * @param string $name name of the HTTP header
     * @param string $value value of the HTTP header
     * @return void
     */
    public function addHeader($name, $value);

    /**
     * Remove header from request
     *
     * @param string $name name of the HTTP header
     * @return void
     */
    public function removeHeader($name);

    /**
     * Set login credentials for basic authentication.
     *
     * @param string $login user identity/name
     * @param string $pass user password
     * @return void
     */
    public function setCredentials($login, $pass);

    /**
     * Add cookie to request
     *
     * @param string $name name of the cookie
     * @param string $value value of the cookie
     * @return void
     */
    public function addCookie($name, $value);

    /**
     * Remove cookie from request
     *
     * @param string $name name of the cookie
     * @return void
     */
    public function removeCookie($name);

    /**
     * Set request cookies from hash
     *
     * @param array $cookies an array of cookies with cookie names as keys and cookie values as value
     * @return void
     */
    public function setCookies($cookies);

    /**
     * Remove cookies from request
     *
     * @return void
     */
    public function removeCookies();

    /**
     * Make GET request
     *
     * @param string $uri full uri
     * @return array
     */
    public function get($uri);

    /**
     * Make POST request
     *
     * @param string $uri full uri
     * @param array|string $params POST fields array or string in case of JSON or XML data
     * @return void
     */
    public function post($uri, $params);

    /**
     * Get response headers
     *
     * @return array
     */
    public function getHeaders();

    /**
     * Get response body
     *
     * @return string
     */
    public function getBody();

    /**
     * Get response status code
     *
     * @return int
     */
    public function getStatus();

    /**
     * Get response cookies (k=>v)
     *
     * @return array
     */
    public function getCookies();

    /**
     * Set additional option
     *
     * @param string $key
     * @param string $value
     * @return void
     */
    public function setOption($key, $value);

    /**
     * Set additional options
     *
     * @param array $arr
     * @return void
     */
    public function setOptions($arr);
}