Skip to content

Commit

Permalink
TMONE-894 - Add parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
dimanovoseltsev committed Feb 6, 2025
1 parent bb97d17 commit 7038ee5
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 56 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.

## [1.1.0] - 2025-02-07
### Added
- Add discounts and products list in subscriptions
- Add parameters discounts, products and cartId list in subscriptions

## [1.0.9] - 2025-02-06
### Added
Expand Down
121 changes: 69 additions & 52 deletions src/API2Client/Entities/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,201 +69,204 @@ class Order
*/
protected $paymentOptions;

/**
* @var string
*/
protected $cartId;

/**
* @param float $amount
*/
public function setAmount ($amount)
public function setAmount($amount)
{
$this->amount = $amount;
}

/**
* @return float
*/
public function getAmount ()
public function getAmount()
{
return $this->amount;
}

/**
* @param \API2Client\Entities\Order\BillingInfo $billingInfo
* @param BillingInfo $billingInfo
*/
public function setBillingInfo (BillingInfo $billingInfo)
public function setBillingInfo(BillingInfo $billingInfo)
{
$this->billingInfo = $billingInfo;
}

/**
* @return \API2Client\Entities\Order\BillingInfo
* @return BillingInfo
*/
public function getBillingInfo ()
public function getBillingInfo()
{
return $this->billingInfo ? $this->billingInfo : new BillingInfo ();
return $this->billingInfo ? $this->billingInfo : new BillingInfo();
}

/**
* @param float $bonusesAmount
*/
public function setBonusesAmount ($bonusesAmount)
public function setBonusesAmount($bonusesAmount)
{
$this->bonusesAmount = $bonusesAmount;
}

/**
* @return float
*/
public function getBonusesAmount ()
public function getBonusesAmount()
{
return $this->bonusesAmount;
}

/**
* @param $discountInfo
*/
public function addDiscountInfo ($discountInfo)
public function addDiscountInfo($discountInfo)
{
$this->discountInfoList [] = $discountInfo;
}

/**
* @return array
*/
public function getDiscountInfoList ()
public function getDiscountInfoList()
{
return $this->discountInfoList;
}

/**
* @param \API2Client\Entities\Order\PaymentInfo $paymentInfo
* @param PaymentInfo $paymentInfo
*/
public function setPaymentInfo ($paymentInfo)
public function setPaymentInfo($paymentInfo)
{
$this->paymentInfo = $paymentInfo;
}

/**
* @return \API2Client\Entities\Order\PaymentInfo
* @return PaymentInfo
*/
public function getPaymentInfo ()
public function getPaymentInfo()
{
return $this->paymentInfo;
}

/**
* @param ProductInfo $productInfo
*/
public function addProductInfo (ProductInfo $productInfo)
public function addProductInfo(ProductInfo $productInfo)
{
$this->productInfoList[] = $productInfo;
}

/**
* @return array
*/
public function getProductInfoList ()
public function getProductInfoList()
{
return $this->productInfoList;
}

/**
* @param int $projectId
*/
public function setProjectId ($projectId)
public function setProjectId($projectId)
{
$this->projectId = $projectId;
}

/**
* @return float
*/
public function getProjectId ()
public function getProjectId()
{
return $this->projectId;
}

/**
* @param mixed TrackingInfo $trackingInfo
*/
public function setTrackingInfo (TrackingInfo $trackingInfo)
public function setTrackingInfo(TrackingInfo $trackingInfo)
{
$this->trackingInfo = $trackingInfo;
}

/**
* @return TrackingInfo
*/
public function getTrackingInfo ()
public function getTrackingInfo()
{
return $this->trackingInfo ? $this->trackingInfo : new TrackingInfo ();
}

/**
* @return boolean
*/
public function isGift ()
public function isGift()
{
return $this->gift;
}

/**
* @param boolean $gift
*/
public function setGift ($gift)
public function setGift($gift)
{
$this->gift = $gift;
}

/**
* @return array
*/
protected function getPaymentWithGift ()
protected function getPaymentWithGift()
{
if ($this->isGift () === true)
{
if ($this->isGift() === true) {
$paymentData = new PaymentInfo ();

return $paymentData
->setCurrencyId (0)
->setCurrencyRate (1)
->setPaymentId (Payment::GIFT_METHOD)
->toArray ();
->setCurrencyId(0)
->setCurrencyRate(1)
->setPaymentId(Payment::GIFT_METHOD)
->toArray();
}

return $this->getPaymentInfo ()->toArray ();
return $this->getPaymentInfo()->toArray();
}

/**
* @return array
*/
public function toArray ()
public function toArray()
{
$data = array(
'projectId' => $this->getProjectId (),
'amount' => $this->getAmount (),
'bonusesAmount' => $this->getBonusesAmount (),
'billingInfo' => $this->getBillingInfo ()->toArray (),
'paymentInfo' => $this->getPaymentWithGift (),
'trackingInfo' => $this->getTrackingInfo ()->toArray (),
'discountInfoList' => array (),
'payment_options' => $this->getPaymentOptions(),
$data = array(
'projectId' => $this->getProjectId(),
'amount' => $this->getAmount(),
'bonusesAmount' => $this->getBonusesAmount(),
'billingInfo' => $this->getBillingInfo()->toArray(),
'paymentInfo' => $this->getPaymentWithGift(),
'trackingInfo' => $this->getTrackingInfo()->toArray(),
'discountInfoList' => array(),
'payment_options' => $this->getPaymentOptions(),
'cartId' => $this->getCartId()
);

$data['productInfoList'] = array ();
$data['productInfoList'] = array();

/**
* @var ProductInfo $productInfo
*/
foreach ($this->getProductInfoList () as $productInfo)
{
$data['productInfoList'][] = $productInfo->toArray ();
foreach ($this->getProductInfoList() as $productInfo) {
$data['productInfoList'][] = $productInfo->toArray();
}

$discountList = array ();
$discountList = array();

/** @var DiscountInfo $discount */
foreach ($this->getDiscountInfoList () as $discount)
{
$discountList = array_merge ($discountList, $discount->toArray ());
foreach ($this->getDiscountInfoList() as $discount) {
$discountList = array_merge($discountList, $discount->toArray());
}

$data['discountInfoList'] = $discountList;
Expand All @@ -286,6 +289,20 @@ public function setPaymentOptions($paymentOptions)
{
$this->paymentOptions = $paymentOptions;
}


}

/**
* @param string $cartId
*/
public function setCartId($cartId)
{
$this->cartId = $cartId;
}

/**
* @return string
*/
public function getCartId()
{
return $this->cartId;
}
}
23 changes: 20 additions & 3 deletions src/API2Client/Entities/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ class Subscription
*/
protected $productInfoList = array();

/**
* @var string
*/
protected $cartId;

/**
* @return string
Expand Down Expand Up @@ -644,6 +648,21 @@ public function getProductInfoList()
return $this->productInfoList;
}

/**
* @param string $cartId
*/
public function setCartId($cartId)
{
$this->cartId = $cartId;
}

/**
* @return string
*/
public function getCartId()
{
return $this->cartId;
}

/**
* @return array
Expand Down Expand Up @@ -674,13 +693,11 @@ public function toArray()
'customer_local_time' => $this->getCustomerLocalTime(),
'affiliate_name' => $this->getAffiliateName(),
'payment_options' => $this->getPaymentOptions(),
'cartId' => $this->getCartId(),
'discountInfoList' => array(),
'productInfoList' => array(),
);

/**
* @var ProductInfo $productInfo
*/
foreach ($this->getProductInfoList() as $productInfo) {
$data['productInfoList'][] = $productInfo->toArray();
}
Expand Down

0 comments on commit 7038ee5

Please sign in to comment.