Transfer.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Gateway\Http;
  7. /**
  8. * Class Transfer
  9. */
  10. class Transfer implements TransferInterface
  11. {
  12. /**
  13. * Name of Auth username field
  14. */
  15. const AUTH_USERNAME = 'username';
  16. /**
  17. * Name of Auth password field
  18. */
  19. const AUTH_PASSWORD = 'password';
  20. /**
  21. * @var array
  22. */
  23. private $clientConfig;
  24. /**
  25. * @var array
  26. */
  27. private $headers;
  28. /**
  29. * @var string
  30. */
  31. private $method;
  32. /**
  33. * @var array|string
  34. */
  35. private $body;
  36. /**
  37. * @var string
  38. */
  39. private $uri;
  40. /**
  41. * @var bool
  42. */
  43. private $encode;
  44. /**
  45. * @var array
  46. */
  47. private $auth;
  48. /**
  49. * @param array $clientConfig
  50. * @param array $headers
  51. * @param array|string $body
  52. * @param array $auth
  53. * @param string $method
  54. * @param string $uri
  55. * @param bool $encode
  56. */
  57. public function __construct(
  58. array $clientConfig,
  59. array $headers,
  60. $body,
  61. array $auth,
  62. $method,
  63. $uri,
  64. $encode
  65. ) {
  66. $this->clientConfig = $clientConfig;
  67. $this->headers = $headers;
  68. $this->body = $body;
  69. $this->auth = $auth;
  70. $this->method = $method;
  71. $this->uri = $uri;
  72. $this->encode = $encode;
  73. }
  74. /**
  75. * Returns gateway client configuration
  76. *
  77. * @return array
  78. */
  79. public function getClientConfig()
  80. {
  81. return $this->clientConfig;
  82. }
  83. /**
  84. * Returns method used to place request
  85. *
  86. * @return string|int
  87. */
  88. public function getMethod()
  89. {
  90. return (string)$this->method;
  91. }
  92. /**
  93. * Returns headers
  94. *
  95. * @return array
  96. */
  97. public function getHeaders()
  98. {
  99. return $this->headers;
  100. }
  101. /**
  102. * Returns request body
  103. *
  104. * @return array|string
  105. */
  106. public function getBody()
  107. {
  108. return $this->body;
  109. }
  110. /**
  111. * Returns URI
  112. *
  113. * @return string
  114. */
  115. public function getUri()
  116. {
  117. return (string)$this->uri;
  118. }
  119. /**
  120. * @return boolean
  121. */
  122. public function shouldEncode()
  123. {
  124. return $this->encode;
  125. }
  126. /**
  127. * Returns Auth username
  128. *
  129. * @return string
  130. */
  131. public function getAuthUsername()
  132. {
  133. return $this->auth[self::AUTH_USERNAME];
  134. }
  135. /**
  136. * Returns Auth password
  137. *
  138. * @return string
  139. */
  140. public function getAuthPassword()
  141. {
  142. return $this->auth[self::AUTH_PASSWORD];
  143. }
  144. }