1: <?php
2:
3: /**
4: * Create a plan
5: * @see https://app.syspay.com/docs/api/merchant_subscription.html#create-a-plan
6: */
7: class Syspay_Merchant_PlanRequest extends Syspay_Merchant_Request
8: {
9: const METHOD = 'POST';
10: const PATH = '/api/v1/merchant/plan';
11:
12: /**
13: * @var Syspay_Merchant_Entity_Plan
14: */
15: private $plan;
16:
17: /**
18: * {@inheritDoc}
19: */
20: public function getMethod()
21: {
22: return self::METHOD;
23: }
24:
25: /**
26: * {@inheritDoc}
27: */
28: public function getPath()
29: {
30: return self::PATH;
31: }
32:
33: /**
34: * {@inheritDoc}
35: */
36: public function buildResponse(stdClass $response)
37: {
38: if (!isset($response->plan)) {
39: throw new Syspay_Merchant_UnexpectedResponseException(
40: 'Unable to retrive "plan" data from response',
41: $response
42: );
43: }
44:
45: $plan = Syspay_Merchant_Entity_Plan::buildFromResponse($response->plan);
46: return $plan;
47: }
48:
49: /**
50: * {@inheritDoc}
51: */
52: public function getData()
53: {
54: $data = array();
55: if (false === empty($this->plan)) {
56: $data = $this->plan->toArray();
57: }
58: return $data;
59: }
60:
61:
62: /**
63: * Gets the value of plan.
64: *
65: * @return Syspay_Merchant_Entity_Plan
66: */
67: public function getPlan()
68: {
69: return $this->plan;
70: }
71:
72: /**
73: * Sets the value of plan.
74: *
75: * @param Syspay_Merchant_Entity_Plan $plan the plan
76: *
77: * @return self
78: */
79: public function setPlan(Syspay_Merchant_Entity_Plan $plan)
80: {
81: $this->plan = $plan;
82:
83: return $this;
84: }
85: }
86: