Skip to content

Commit

Permalink
Add support for the Reporting resources
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Aug 31, 2018
1 parent 40dc4fb commit 12c85cc
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
2 changes: 2 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
require(dirname(__FILE__) . '/lib/Recipient.php');
require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportType.php');
require(dirname(__FILE__) . '/lib/SKU.php');
require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php');
require(dirname(__FILE__) . '/lib/Source.php');
Expand Down
27 changes: 27 additions & 0 deletions lib/Reporting/ReportRun.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Stripe\Reporting;

/**
* Class ReportRun
*
* @property string $id
* @property string $object
* @property int $created
* @property string $error
* @property mixed $parameters
* @property string $report_type
* @property mixed $result
* @property string $status
* @property int $succeeded_at
*
* @package Stripe\Reporting
*/
class ReportRun extends \Stripe\ApiResource
{
const OBJECT_NAME = "reporting.report_run";

use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;
}
27 changes: 27 additions & 0 deletions lib/Reporting/ReportType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Stripe\Reporting;

/**
* Class ReportType
*
* @property string $id
* @property string $object
* @property int $data_available_end
* @property int $data_available_start
* @property string $name
* @property int $updated
* @property string $version
* @property mixed $result
* @property string $status
* @property int $succeeded_at
*
* @package Stripe\Reporting
*/
class ReportType extends \Stripe\ApiResource
{
const OBJECT_NAME = "reporting.report_type";

use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;
}
2 changes: 2 additions & 0 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public static function convertToStripeObject($resp, $opts)
\Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient',
\Stripe\RecipientTransfer::OBJECT_NAME => 'Stripe\\RecipientTransfer',
\Stripe\Refund::OBJECT_NAME => 'Stripe\\Refund',
\Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun',
\Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType',
\Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU',
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun',
\Stripe\Source::OBJECT_NAME => 'Stripe\\Source',
Expand Down
47 changes: 47 additions & 0 deletions tests/Stripe/Reporting/ReportRunTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Stripe\Reporting;

class ReportRunTest extends \Stripe\TestCase
{
const TEST_RESOURCE_ID = 'frr_123';

public function testIsCreatable()
{
$params = [
"parameters" => [
"connected_account" => "acct_123"
],
"report_type" => "activity.summary.1",
];

$this->expectsRequest(
'post',
'/v1/reporting/report_runs',
$params
);
$resource = ReportRun::create($params);
$this->assertInstanceOf("Stripe\\Reporting\\ReportRun", $resource);
}

public function testIsListable()
{
$this->expectsRequest(
'get',
'/v1/reporting/report_runs'
);
$resources = ReportRun::all();
$this->assertTrue(is_array($resources->data));
$this->assertInstanceOf("Stripe\\Reporting\\ReportRun", $resources->data[0]);
}

public function testIsRetrievable()
{
$this->expectsRequest(
'get',
'/v1/reporting/report_runs/' . self::TEST_RESOURCE_ID
);
$resource = ReportRun::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf("Stripe\\Reporting\\ReportRun", $resource);
}
}
29 changes: 29 additions & 0 deletions tests/Stripe/Reporting/ReportTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Stripe\Reporting;

class ReportTypeTest extends \Stripe\TestCase
{
const TEST_RESOURCE_ID = 'activity.summary.1';

public function testIsListable()
{
$this->expectsRequest(
'get',
'/v1/reporting/report_types'
);
$resources = ReportType::all();
$this->assertTrue(is_array($resources->data));
$this->assertInstanceOf("Stripe\\Reporting\\ReportType", $resources->data[0]);
}

public function testIsRetrievable()
{
$this->expectsRequest(
'get',
'/v1/reporting/report_types/' . self::TEST_RESOURCE_ID
);
$resource = ReportType::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf("Stripe\\Reporting\\ReportType", $resource);
}
}

0 comments on commit 12c85cc

Please sign in to comment.