Skip to content

Commit

Permalink
Backport compatibility changes from 3.0 (#304)
Browse files Browse the repository at this point in the history
* Remove Lead Sources from Subscriptions, Transactions, Invoices (#289)

* Refactor LeadSources usage

* Only remove unnecessary lead sources in this PR

* Fix codestyle

* Add changelog

* Add formatting

* Add plan items property to Subscription, remove deprecated ones (#297)

* Remove deprecated attributes and a bit order methods

* Refactor Subscription

* Add SubscriptionTest

* Add items to Subscriptions

* Refactor SubscriptionTest

* Update CHANGELOG

* Add fake generator for new property

* Fix CS

* Add PlanItemTest

* Adjust LeadSource to latest changes (#298)

* Adjust LeadSource to latest changes

* Redo test

* Remove wrong imports

* Fix test

* Add changelog

* Remove ipAddress

* Add getCustomer in Transaction (#299)

* Remove EmailNotifications code (#300)

* Adjust CHANGELOG.md file (#301)

* Remove LeadSources endpoint and service (#296)

* Add missing coupons restriction (#302)

* Add missing coupons restriction

* Small fix

* Remove deprecated initialInvoiceId property from Subscription (#303)

* Remove declartions of strict mode

* Fix tests

* Remove const visibility
  • Loading branch information
slavcodev authored Oct 7, 2018
1 parent 5b8a8a4 commit 5636880
Show file tree
Hide file tree
Showing 26 changed files with 865 additions and 1,326 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@ _TBD_

### Added
- [x] Added new properties to `Plan`: `pricing`, `recurringInterval`, `trial`, `setup`
- [x] Added new property to `Subscription`: `items`
- [x] Added new property to `LeadSource`: `original`

### Changed
- [x] Replaced magic methods like `get`, `post` with explicit defined methods.

### Removed
- [x] Removed deprecated Plan properties: `expiredTime`, `recurringAmount`, `trialAmount`, `setupAmount`,
- [x] Removed deprecated `Plan` properties: `expiredTime`, `recurringAmount`, `trialAmount`, `setupAmount`,
`recurringPeriodUnit`, `recurringPeriodLength`, `recurringPeriodLimit`, `trialPeriodUnit`, `trialPeriodLength`,
`contractTermUnit`, `contractTermLength`, `minQuantity`, `maxQuantity`
`contractTermUnit`, `contractTermLength`, `minQuantity`, `maxQuantity`
- [x] Removed `LeadSources` in **Transactions**, **Invoices** and **Subscriptions**
- [x] Removed `LeadSources` endpoint and service. Adding Lead Sources now only possible via **Tokens** and **Customers**
- [x] Removed deprecated `Subscription` properties: `planId`, `quantity`,
`billingContactId`, `billingContact`, `deliveryContactId`, `deliveryContact`
- [x] Removed deprecated `LeadSource` property: `ipAddress`
- [x] Removed `Notification`, `EmailNotification` and `EmailNotificationTracking`.
- [x] Deprecate setting `initialInvoiceId` property when creating a `Subscription`.

## [2.2.0] 2018-08-14

Expand Down
4 changes: 0 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
* @method Services\ValuesListService lists()
* @method Services\ValuesListTrackingService listsTracking()
* @method Services\WebhookTrackingService webhooksTracking()
* @method Services\EmailNotificationService emailNotifications()
* @method Services\EmailNotificationTrackingService emailNotificationsTracking()
* @method Services\GatewayAccountDowntimeService gatewayDowntimes()
* @method Services\PaymentInstrumentValidationService paymentInstrumentValidation()
* @method Services\KycService kycDocuments()
Expand Down Expand Up @@ -142,8 +140,6 @@ final class Client
'listsTracking' => Services\ValuesListTrackingService::class,
'shippingZones' => Services\ShippingZoneService::class,
'webhooksTracking' => Services\WebhookTrackingService::class,
'emailNotifications' => Services\EmailNotificationService::class,
'emailNotificationsTracking' => Services\EmailNotificationTrackingService::class,
'gatewayDowntimes' => Services\GatewayAccountDowntimeService::class,
'paymentInstrumentValidation' => Services\PaymentInstrumentValidationService::class,
'kycDocuments' => Services\KycService::class,
Expand Down
14 changes: 14 additions & 0 deletions src/Entities/Coupons/Restriction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ abstract class Restriction extends Resource
const TYPE_RESTRICT_TO_PLANS = 'restrict-to-plans';
const TYPE_RESTRICT_TO_SUBSCRIPTIONS = 'restrict-to-subscriptions';

const TYPE_TOTAL_REDEMPTIONS = 'total-redemptions';

const TYPE_MINIMUM_ORDER_AMOUNT = 'minimum-order-amount';

protected static $supportedTypes = [
self::TYPE_DISCOUNTS_PER_REDEMPTION,
self::TYPE_REDEMPTIONS_PER_CUSTOMER,
self::TYPE_RESTRICT_TO_INVOICES,
self::TYPE_RESTRICT_TO_PLANS,
self::TYPE_RESTRICT_TO_SUBSCRIPTIONS,
self::TYPE_TOTAL_REDEMPTIONS,
self::TYPE_MINIMUM_ORDER_AMOUNT,
];

/**
Expand Down Expand Up @@ -69,6 +75,14 @@ public static function createFromData(array $data)
break;
case self::TYPE_RESTRICT_TO_SUBSCRIPTIONS:
$restriction = new Restrictions\RestrictToSubscriptions($data);
break;
case self::TYPE_TOTAL_REDEMPTIONS:
$restriction = new Restrictions\TotalRedemptions($data);

break;
case self::TYPE_MINIMUM_ORDER_AMOUNT:
$restriction = new Restrictions\MinimumOrderAmount($data);

break;
default:
throw new DomainException(
Expand Down
61 changes: 61 additions & 0 deletions src/Entities/Coupons/Restrictions/MinimumOrderAmount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

namespace Rebilly\Entities\Coupons\Restrictions;

use Rebilly\Entities\Coupons\Restriction;

class MinimumOrderAmount extends Restriction
{
/**
* @return int
*/
public function getQuantity()
{
return $this->getAttribute('quantity');
}

/**
* @return string
*/
public function getCurrency()
{
return $this->getAttribute('currency');
}

/**
* @param int $value
*
* @return $this
*/
public function setQuantity($value)
{
return $this->setAttribute('quantity', $value);
}

/**
* @param string $value
*
* @return $this
*/
public function setCurrency($value)
{
return $this->setAttribute('currency', $value);
}

/**
* @return string
*/
protected function restrictionType()
{
return self::TYPE_MINIMUM_ORDER_AMOUNT;
}
}
43 changes: 43 additions & 0 deletions src/Entities/Coupons/Restrictions/TotalRedemptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

namespace Rebilly\Entities\Coupons\Restrictions;

use Rebilly\Entities\Coupons\Restriction;

class TotalRedemptions extends Restriction
{
/**
* @return int
*/
public function getQuantity()
{
return $this->getAttribute('quantity');
}

/**
* @param int $value
*
* @return $this
*/
public function setQuantity($value)
{
return $this->setAttribute('quantity', $value);
}

/**
* @return string
*/
protected function restrictionType()
{
return self::TYPE_TOTAL_REDEMPTIONS;
}
}
184 changes: 0 additions & 184 deletions src/Entities/EmailNotifications/EmailNotification.php

This file was deleted.

Loading

0 comments on commit 5636880

Please sign in to comment.