1: <?php
 2: 
 3: /**
 4:  * Get information about a refund
 5:  * @see  https://app.syspay.com/bundles/emiuser/doc/merchant_api.html#get-refund-information
 6:  */
 7: class Syspay_Merchant_RefundInfoRequest extends Syspay_Merchant_Request
 8: {
 9:     const METHOD = 'GET';
10:     const PATH   = '/api/v1/merchant/refund/%d';
11: 
12:     /**
13:      * @var integer
14:      */
15:     private $refundId;
16: 
17:     public function __construct($refundId = null)
18:     {
19:         if (null !== $refundId) {
20:             $this->setRefundId($refundId);
21:         }
22:     }
23: 
24:     /**
25:      * {@inheritDoc}
26:      */
27:     public function getMethod()
28:     {
29:         return self::METHOD;
30:     }
31: 
32:     /**
33:      * {@inheritDoc}
34:      */
35:     public function getPath()
36:     {
37:         return sprintf(self::PATH, $this->refundId);
38:     }
39: 
40:     /**
41:      * Gets the value of refundId.
42:      *
43:      * @return integer
44:      */
45:     public function getRefundId()
46:     {
47:         return $this->refundId;
48:     }
49: 
50:     /**
51:      * Sets the value of refundId.
52:      *
53:      * @param integer $refundId the refundId
54:      *
55:      * @return self
56:      */
57:     public function setRefundId($refundId)
58:     {
59:         $this->refundId = $refundId;
60: 
61:         return $this;
62:     }
63: 
64:     /**
65:      * {@inheritDoc}
66:      */
67:     public function buildResponse(stdClass $response)
68:     {
69:         if (!isset($response->refund)) {
70:             throw new Syspay_Merchant_UnexpectedResponseException(
71:                 'Unable to retrieve "refund" data from response',
72:                 $response
73:             );
74:         }
75: 
76:         $refund = Syspay_Merchant_Entity_Refund::buildFromResponse($response->refund);
77: 
78:         return $refund;
79:     }
80: }
81: