Skip to content

Commit

Permalink
Add support for subcription sets (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Carney authored and pkopac committed Sep 23, 2019
1 parent a8b7666 commit ccaef43
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ $cus = ChartMogul\Customer::all()->first();

$line_itme_1 = new ChartMogul\LineItems\Subscription([
'subscription_external_id' => "sub_0001",
'subscription_set_external_id' => 'set_0001',
'plan_uuid' => $plan->uuid,
'service_period_start' => "2015-11-01 00:00:00",
'service_period_end' => "2015-12-01 00:00:00",
Expand Down
1 change: 1 addition & 0 deletions src/LineItems/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Subscription extends AbstractLineItem

public $type = 'subscription';
public $subscription_external_id;
public $subscription_set_external_id;
public $service_period_start;
public $service_period_end;
public $cancelled_at;
Expand Down
2 changes: 2 additions & 0 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/**
* @property-read string $uuid
* @property-read string $external_id
* @property-read string $subscription_set_external_id
* @property-read string $cancellation_dates
* @property-read string $plan_uuid
* @property-read string $data_source_uuid
Expand All @@ -33,6 +34,7 @@ class Subscription extends AbstractResource

protected $uuid;
protected $external_id;
protected $subscription_set_external_id;
protected $cancellation_dates;

protected $plan_uuid;
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/SubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SubscriptionTest extends \PHPUnit\Framework\TestCase
{
"uuid": "sub_dd169c42-e127-4637-8b8f-a239b248e3cd",
"external_id": "abc",
"subscription_set_external_id": "set_001",
"cancellation_dates": [],
"plan_uuid": "pl_d6fe6904-8319-11e7-82b4-ffedd86c182a",
"data_source_uuid": "ds_637442a6-8319-11e7-a280-1f28ec01465c"
Expand Down Expand Up @@ -49,6 +50,7 @@ public function testAllSubscriptions()
$this->assertTrue($result[0] instanceof Subscription);
$this->assertEquals("cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", $result->customer_uuid);
$this->assertEquals("sub_dd169c42-e127-4637-8b8f-a239b248e3cd", $result[0]->uuid);
$this->assertEquals("set_001", $result[0]->subscription_set_external_id);
$this->assertEquals(2, $result->current_page);
$this->assertEquals(3, $result->total_pages);
}
Expand Down

0 comments on commit ccaef43

Please sign in to comment.