1: <?php
 2: 
 3: /**
 4:  * Get information about a plan
 5:  * @see  https://app.syspay.com/bundles/emiuser/doc/merchant_subscription.html#get-plan-information
 6:  */
 7: class Syspay_Merchant_PlanInfoRequest extends Syspay_Merchant_Request
 8: {
 9:     const METHOD = 'GET';
10:     const PATH   = '/api/v1/merchant/plan/%d';
11: 
12:     /**
13:      * @var integer
14:      */
15:     private $planId;
16: 
17:     public function __construct($planId = null)
18:     {
19:         if (null !== $planId) {
20:             $this->setPlanId($planId);
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->planId);
38:     }
39: 
40:     /**
41:      * Gets the value of planId.
42:      *
43:      * @return integer
44:      */
45:     public function getPlanId()
46:     {
47:         return $this->planId;
48:     }
49: 
50:     /**
51:      * Sets the value of planId.
52:      *
53:      * @param integer $planId the planId
54:      *
55:      * @return self
56:      */
57:     public function setPlanId($planId)
58:     {
59:         $this->planId = $planId;
60: 
61:         return $this;
62:     }
63: 
64:     /**
65:      * {@inheritDoc}
66:      */
67:     public function buildResponse(stdClass $response)
68:     {
69:         if (!isset($response->plan)) {
70:             throw new Syspay_Merchant_UnexpectedResponseException(
71:                 'Unable to retrieve "plan" data from response',
72:                 $response
73:             );
74:         }
75: 
76:         $plan = Syspay_Merchant_Entity_Plan::buildFromResponse($response->plan);
77: 
78:         return $plan;
79:     }
80: }
81: