1: <?php
2:
3: /**
4: * Get the available banks to process AstroPay payments with.
5: */
6: class Syspay_Merchant_AstroPayBanksRequest extends Syspay_Merchant_Request
7: {
8: const METHOD = 'GET';
9: const PATH = '/api/v1/merchant/astropay/banks/%s';
10:
11: /**
12: * @var string
13: */
14: private $country;
15:
16: public function __construct($country = null)
17: {
18: if (null !== $country) {
19: $this->setCountry($country);
20: }
21: }
22:
23: /**
24: * {@inheritDoc}
25: */
26: public function getMethod()
27: {
28: return self::METHOD;
29: }
30:
31: /**
32: * {@inheritDoc}
33: */
34: public function getPath()
35: {
36: return sprintf(self::PATH, $this->country);
37: }
38:
39:
40: /**
41: * {@inheritDoc}
42: */
43: public function buildResponse(stdClass $response)
44: {
45: if (!isset($response->banks) || !is_array($response->banks)) {
46: throw new Syspay_Merchant_UnexpectedResponseException(
47: 'Unable to retrieve "banks" data from response',
48: $response
49: );
50: }
51:
52: $banks = array();
53: foreach ($response->banks as $bank) {
54: array_push(
55: $banks,
56: Syspay_Merchant_Entity_AstroPayBank::buildFromResponse($bank)
57: );
58: }
59:
60: return $banks;
61: }
62:
63: /**
64: * Gets the value of country.
65: *
66: * @return string
67: */
68: public function getCountry()
69: {
70: return $this->country;
71: }
72:
73: /**
74: * Sets the value of country.
75: *
76: * @param string $country the country
77: *
78: * @return self
79: */
80: public function setCountry($country)
81: {
82: $this->country = strtoupper($country);
83:
84: return $this;
85: }
86: }
87: