Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TransferBuilder.php
Go to the documentation of this file.
1 <?php
7 
14 {
18  private $clientConfig = [];
19 
23  private $headers = [];
24 
28  private $method;
29 
33  private $body = [];
34 
38  private $uri = '';
39 
43  private $encode = false;
44 
48  private $auth = [Transfer::AUTH_USERNAME => null, Transfer::AUTH_PASSWORD => null];
49 
54  public function setClientConfig(array $clientConfig)
55  {
56  $this->clientConfig = $clientConfig;
57 
58  return $this;
59  }
60 
65  public function setHeaders(array $headers)
66  {
67  $this->headers = $headers;
68 
69  return $this;
70  }
71 
76  public function setBody($body)
77  {
78  $this->body = $body;
79 
80  return $this;
81  }
82 
87  public function setAuthUsername($username)
88  {
89  $this->auth[Transfer::AUTH_USERNAME] = $username;
90 
91  return $this;
92  }
93 
98  public function setAuthPassword($password)
99  {
100  $this->auth[Transfer::AUTH_PASSWORD] = $password;
101 
102  return $this;
103  }
104 
109  public function setMethod($method)
110  {
111  $this->method = $method;
112 
113  return $this;
114  }
115 
120  public function setUri($uri)
121  {
122  $this->uri = $uri;
123 
124  return $this;
125  }
126 
131  public function shouldEncode($encode)
132  {
133  $this->encode = $encode;
134 
135  return $this;
136  }
137 
141  public function build()
142  {
143  return new Transfer(
144  $this->clientConfig,
145  $this->headers,
146  $this->body,
147  $this->auth,
148  $this->method,
149  $this->uri,
150  $this->encode
151  );
152  }
153 }