diff --git a/src/Requests/OrderRequest.php b/src/Requests/OrderRequest.php index 69c3972..8b14c22 100644 --- a/src/Requests/OrderRequest.php +++ b/src/Requests/OrderRequest.php @@ -54,9 +54,9 @@ public function get(string $orderId): ?Order * @return mixed|null * @throws \GuzzleHttp\Exception\GuzzleException */ - public function create(\stdClass $options) + public function create(\stdClass $options, $isMock = false ): mixed { - $response = $this->postRequest('/v1/orders', $options ); + $response = $this->postRequest('/v1/orders' . ( $isMock ? "?isMock=1" : "" ), $options ); if ($response->getStatusCode() == 200) return json_decode($response->getBody()); diff --git a/src/Requests/SubscriptionRequest.php b/src/Requests/SubscriptionRequest.php index e3b609f..e24df91 100644 --- a/src/Requests/SubscriptionRequest.php +++ b/src/Requests/SubscriptionRequest.php @@ -44,4 +44,19 @@ public function get(string $subscriptionId ): ?Subscription else return null; } + + public function update( string $subscriptionId, int $quantity ): ?Subscription + { + $data = new \stdClass(); + $data->quantity = $quantity; + $data->startdate = date("Y-m-d"); + $data->billingTerm = "Monthly"; + + $response = $this->putRequest('/v1/subscriptions/' . $subscriptionId, $data ); + + if ($response->getStatusCode() == 200) + return Subscription::parse(json_decode( $response->getBody() ) ); + else + return null; + } } diff --git a/src/Responses/OrderLine.php b/src/Responses/OrderLine.php index 87227b9..99e875b 100644 --- a/src/Responses/OrderLine.php +++ b/src/Responses/OrderLine.php @@ -6,15 +6,19 @@ class OrderLine extends AbstractResponse { - protected string $productId; + public string $productId; - protected string $subscriptionId; + public string $subscriptionId; - protected Carbon $provisionStartDate; + public Carbon $provisionStartDate; - protected string $billingTerm; + public array $provisioningDetails; - protected int $quantity; + public string $billingTerm; + + public string $commitmentTermId; + + public int $quantity; /** * @param string $productId @@ -67,7 +71,7 @@ public function setProvisionStartDate(Carbon $provisionStartDate): OrderLine */ public function getProvisionStartDate(): Carbon { - return $this->provisionStartDate; + return $this->provisionStartDate->toDateString(); } /** @@ -88,6 +92,24 @@ public function getBillingTerm(): string return $this->billingTerm; } + /** + * @param string $commitmentTermId + * @return $this + */ + public function setCommitmentTermId(string $commitmentTermId): OrderLine + { + $this->commitmentTermId = $commitmentTermId; + return $this; + } + + /** + * @return string + */ + public function getCommitmentTermId(): string + { + return $this->commitmentTermId; + } + /** * @param int $quantity * @return OrderLine @@ -105,4 +127,20 @@ public function getQuantity(): int { return $this->quantity; } + + /** + * @param string $key + * @param string|array $values + * @return $this + */ + public function add(string $key, string|array $values ): OrderLine + { + $line = new \stdClass(); + $line->key = $key; + $line->values = is_string( $values ) ? [$values] : $values; + + $this->provisioningDetails[] = $line; + + return $this; + } }