Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RevRec POBs support #792

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Tests/Recurly/PerformanceObligation_List_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class Recurly_PerformanceObligationListTest extends Recurly_TestCase
{
public function testPerformanceObligationListAll() {
$this->client->addResponse(
'GET',
'/performance_obligations',
'performance_obligations/list-200.xml'
);

$performance_obligations = Recurly_PerformanceObligationList::get(null, $this->client);
$this->assertInstanceOf('Recurly_PerformanceObligationList', $performance_obligations);

$performance_obligation = $performance_obligations->current();
$this->assertInstanceOf('Recurly_PerformanceObligation', $performance_obligation);

$this->assertEquals(iterator_count($performance_obligations), 3);
}
}
20 changes: 20 additions & 0 deletions Tests/Recurly/PerformanceObligation_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class Recurly_PerformanceObligationTest extends Recurly_TestCase
{
function defaultResponses() {
return array(
array('GET', '/performance_obligations/6', 'performance_obligations/show-200.xml'),
);
}

public function testPerformanceObligation() {
$pob = Recurly_PerformanceObligation::get('6', $this->client);

$this->assertInstanceOf('Recurly_PerformanceObligation', $pob);
$this->assertEquals('Over Time (Daily)', $pob->name);
$this->assertEquals('6', $pob->id);
$this->assertInstanceOf('DateTime', $pob->created_at);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason you omitted testing for updated_at? 🤔

$this->assertInstanceOf('DateTime', $pob->updated_at);
}
}
24 changes: 24 additions & 0 deletions Tests/fixtures/performance_obligations/list-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<performance_obligations type="array">
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/6">
<id>6</id>
<name>Over Time (Daily)</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/5">
<id>5</id>
<name>Over Time (Partial Monthly)</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/4">
<id>4</id>
<name>Point in Time</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
</performance_obligations>
10 changes: 10 additions & 0 deletions Tests/fixtures/performance_obligations/show-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/6">
<id>6</id>
<name>Over Time (Daily)</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
2 changes: 2 additions & 0 deletions lib/recurly.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
require_once(__DIR__ . '/recurly/note.php');
require_once(__DIR__ . '/recurly/note_list.php');
require_once(__DIR__ . '/recurly/percentage_tier.php');
require_once(__DIR__ . '/recurly/performance_obligation.php');
require_once(__DIR__ . '/recurly/performance_obligation_list.php');
require_once(__DIR__ . '/recurly/plan.php');
require_once(__DIR__ . '/recurly/plan_list.php');
require_once(__DIR__ . '/recurly/ramp_interval.php');
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Recurly_Client
const PATH_EXTERNAL_ACCOUNTS = 'external_accounts';
const PATH_BUSINESS_ENTITIES = 'business_entities';
const PATH_GENERAL_LEDGER_ACCOUNTS = 'general_ledger_accounts';
const PATH_PERFORMANCE_OBLIGATIONS = 'performance_obligations';

/**
* Create a new Recurly Client
Expand Down
34 changes: 34 additions & 0 deletions lib/recurly/performance_obligation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* Class Recurly PerformanceObligation
* @property string $id
* @property string $name The name of the POB.
* @property DateTime $created_at The date and time the gla was created in Recurly.
* @property DateTime $updated_at The date and time the gla was last updated.
*/

class Recurly_PerformanceObligation extends Recurly_Resource
{
/**
* @param string $id
* @param Recurly_Client $client
* @return Recurly_PerformanceObligation
* @throws Recurly_Error
*/
public static function get($id, $client = null) {
return Recurly_Base::_get(Recurly_PerformanceObligation::uriForPerformanceObligation($id), $client);
}

protected static function uriForPerformanceObligation($id) {
return self::_safeUri(Recurly_Client::PATH_PERFORMANCE_OBLIGATIONS, $id);
}

protected function getNodeName() {
return 'performance_obligation';
}

protected function getWriteableAttributes() {
return array();
}
}
13 changes: 13 additions & 0 deletions lib/recurly/performance_obligation_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class Recurly_PerformanceObligationList extends Recurly_Pager
{
public static function get($params = null, $client = null) {
$uri = self::_uriWithParams(Recurly_Client::PATH_PERFORMANCE_OBLIGATIONS, $params);
return new self($uri, $client);
}

protected function getNodeName() {
return 'performance_obligations';
}
}
2 changes: 2 additions & 0 deletions lib/recurly/util/xml_tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class XmlTools
'measured_units' => 'Recurly_MeasuredUnitList',
'note' => 'Recurly_Note',
'notes' => 'Recurly_NoteList',
'performance_obligation' => 'Recurly_PerformanceObligation',
'performance_obligations' => 'Recurly_PerformanceObligationList',
'plan' => 'Recurly_Plan',
'plans' => 'Recurly_PlanList',
'plan_code' => 'string',
Expand Down
Loading