Skip to content

Commit

Permalink
Add support for ScheduledQueryRun
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Jul 27, 2018
1 parent 473592b commit 577ca67
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/SKU.php');
require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php');
require(dirname(__FILE__) . '/lib/Source.php');
require(dirname(__FILE__) . '/lib/SourceTransaction.php');
require(dirname(__FILE__) . '/lib/Subscription.php');
Expand Down
33 changes: 33 additions & 0 deletions lib/Sigma/ScheduledQueryRun.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Stripe\Sigma;

/**
* Class Authorization
*
* @property string $id
* @property string $object
* @property int $created
* @property int $data_load_time
* @property string $error
* @property \Stripe\FileUpload $file
* @property bool $livemode
* @property int $result_available_until
* @property string $sql
* @property string $status
* @property string $title
*
* @package Stripe\Sigma
*/
class ScheduledQueryRun extends \Stripe\ApiResource
{
const OBJECT_NAME = "scheduled_query_run";

use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;

public static function classUrl()
{
return "/v1/sigma/scheduled_query_runs";
}
}
1 change: 1 addition & 0 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public static function convertToStripeObject($resp, $opts)
\Stripe\RecipientTransfer::OBJECT_NAME => 'Stripe\\RecipientTransfer',
\Stripe\Refund::OBJECT_NAME => 'Stripe\\Refund',
\Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU',
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun',
\Stripe\Source::OBJECT_NAME => 'Stripe\\Source',
\Stripe\SourceTransaction::OBJECT_NAME => 'Stripe\\SourceTransaction',
\Stripe\Subscription::OBJECT_NAME => 'Stripe\\Subscription',
Expand Down
57 changes: 57 additions & 0 deletions tests/Stripe/Sigma/ScheduledQueryRunTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Stripe\Sigma;

class AuthorizationTest extends \Stripe\TestCase
{
const TEST_RESOURCE_ID = 'iauth_123';

// stripe-mock does not support /v1/sigma/scheduled_query_runs yet so we stub it
// and create a fixture for it
public function createFixture()
{
$base = [
'id' => self::TEST_RESOURCE_ID,
'object' => 'scheduled_query_run',
'metadata' => [],
];
return ScheduledQueryRun::constructFrom(
$base,
new \Stripe\Util\RequestOptions()
);
}

public function testIsListable()
{
$this->stubRequest(
'get',
'/v1/sigma/scheduled_query_runs',
[],
null,
false,
[
"object" => "list",
"data" => [
$this->createFixture()
]
]
);
$resources = ScheduledQueryRun::all();
$this->assertTrue(is_array($resources->data));
$this->assertInstanceOf("Stripe\\Sigma\\ScheduledQueryRun", $resources->data[0]);
}

public function testIsRetrievable()
{
$this->stubRequest(
'get',
'/v1/sigma/scheduled_query_runs/' . self::TEST_RESOURCE_ID,
[],
null,
false,
$this->createFixture()
);
$resource = ScheduledQueryRun::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf("Stripe\\Sigma\\ScheduledQueryRun", $resource);
}
}

0 comments on commit 577ca67

Please sign in to comment.