Skip to content

Commit c08c8d5

Browse files
Make customer reference optionnal
1 parent 410110e commit c08c8d5

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/Message/CancelSubscriptionRequest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public function getData()
5252

5353
public function getEndpoint()
5454
{
55-
return $this->endpoint.'/subscriptions/'.$this->getSubscriptionReference();
55+
return $this->getCustomerReference() ?
56+
$this->endpoint
57+
.'/customers/'.$this->getCustomerReference()
58+
.'/subscriptions/'.$this->getSubscriptionReference() :
59+
$this->endpoint.'/subscriptions/'.$this->getSubscriptionReference();
5660
}
5761

5862
public function getHttpMethod()

src/Message/FetchSubscriptionRequest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ public function setSubscriptionReference($value)
3636

3737
public function getData()
3838
{
39-
$this->validate('customerReference', 'subscriptionReference');
39+
$this->validate('subscriptionReference');
4040

4141
return array();
4242
}
4343

4444
public function getEndpoint()
4545
{
46-
return $this->endpoint.'/customers/'.$this->getCustomerReference()
47-
.'/subscriptions/'.$this->getSubscriptionReference();
46+
return $this->getCustomerReference() ?
47+
$this->endpoint.'/customers/'.$this->getCustomerReference()
48+
.'/subscriptions/'.$this->getSubscriptionReference() :
49+
$this->endpoint.'/subscriptions/'.$this->getSubscriptionReference();
4850
}
4951

5052
public function getHttpMethod()

src/Message/UpdateSubscriptionRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ public function getData()
9999

100100
public function getEndpoint()
101101
{
102-
return $this->endpoint.'/subscriptions/'.$this->getSubscriptionReference();
102+
return $this->getCustomerReference() ?
103+
$this->endpoint.'/customers/'.$this->getCustomerReference()
104+
.'/subscriptions/'.$this->getSubscriptionReference() :
105+
$this->endpoint.'/subscriptions/'.$this->getSubscriptionReference();
103106
}
104107
}

0 commit comments

Comments
 (0)