Skip to content

Commit

Permalink
Merge pull request #14 from chartmogul/cancellation_dates
Browse files Browse the repository at this point in the history
Add setCancellationDates; simple docker travis build config
  • Loading branch information
pkopac authored Feb 13, 2017
2 parents e86f8c9 + ec651cc commit e455fc1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo: required

services:
- docker

script:
- make test
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,16 @@ $subscriptions = $cus->subscriptions();
```php
$canceldate = '2016-01-01T10:00:00.000Z';
$cus = new ChartMogul\Import\Customer([
"uuid" => "cus_uuid"
'uuid' => 'cus_uuid'
]);
$subscription = $subscriptions->last()->cancel($canceldate);
```

Or set the cancellation dates:
```php
$cancellationDates = ['2016-01-01T10:00:00.000Z', '2017-01-01T10:00:00.000Z']
$subscription = $subscriptions->last()->setCancellationDates($cancellationDates)
```

### Metrics API

Expand Down
38 changes: 29 additions & 9 deletions src/Import/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Subscription extends AbstractResource

use \ChartMogul\Service\CreateTrait;
use \ChartMogul\Service\AllTrait;

/**
* @ignore
*/
Expand All @@ -36,23 +36,43 @@ class Subscription extends AbstractResource
protected $plan_uuid;
protected $data_source_uuid;



private function cancellation($payload)
{
$response = $this->getClient()->send(
'/v1/import/subscriptions/'.$this->uuid,
'PATCH',
$payload
);
$this->cancellation_dates = $response['cancellation_dates'];
return $this;
}

/**
* Cancels a subscription that was generated from an imported invoice.
* @param string $cancelledAt The time at which the subscription was cancelled.
* @return Subscription
*/
public function cancel($cancelledAt)
{
$response = $this->getClient()->send(
'/v1/import/subscriptions/'.$this->uuid,
'PATCH',
[
return $this->cancellation([
'cancelled_at' => $cancelledAt
]
);
$this->cancellation_dates = $response['cancellation_dates'];
return $this;
]);
}

/**
* Changes dates of cancellation for a subscription.
* @param array $cancellationDates The array of times (strings) at which the subscription was cancelled.
* @return Subscription
*/
public function setCancellationDates($cancellationDates)
{
return $this->cancellation([
'cancellation_dates' => $cancellationDates
]);
}

/**
* @param array $data
* @param ClientInterface|null $client
Expand Down

0 comments on commit e455fc1

Please sign in to comment.