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 support for ScheduledQueryRun #501

Merged
merged 1 commit into from
Jul 28, 2018
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
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 = 'sqr_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);
}
}