-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Radar List and ListItem resources
- Loading branch information
1 parent
77eb5bb
commit bd5e99b
Showing
8 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Stripe\Radar; | ||
|
||
/** | ||
* Class ValueList | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property string $alias | ||
* @property int $created | ||
* @property string $created_by | ||
* @property string $item_type | ||
* @property Collection $list_items | ||
* @property bool $livemode | ||
* @property StripeObject $metadata | ||
* @property mixed $name | ||
* @property int $updated | ||
* @property string $updated_by | ||
* | ||
* @package Stripe\Radar | ||
*/ | ||
class ValueList extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "radar.value_list"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Delete; | ||
use \Stripe\ApiOperations\Retrieve; | ||
use \Stripe\ApiOperations\Update; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Stripe\Radar; | ||
|
||
/** | ||
* Class ValueListItem | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property int $created | ||
* @property string $created_by | ||
* @property string $list | ||
* @property bool $livemode | ||
* @property string $value | ||
* | ||
* @package Stripe\Radar | ||
*/ | ||
class ValueListItem extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "radar.value_list_item"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
use \Stripe\ApiOperations\Delete; | ||
use \Stripe\ApiOperations\Retrieve; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Stripe\Radar; | ||
|
||
class ValueListItemTest extends \Stripe\TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'rsli_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/radar/value_list_items' | ||
); | ||
$resources = ValueListItem::all([ | ||
"value_list" => "rsl_123", | ||
]); | ||
$this->assertTrue(is_array($resources->data)); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueListItem", $resources->data[0]); | ||
} | ||
|
||
public function testIsRetrievable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/radar/value_list_items/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = ValueListItem::retrieve(self::TEST_RESOURCE_ID); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueListItem", $resource); | ||
} | ||
|
||
public function testIsCreatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/radar/value_list_items' | ||
); | ||
$resource = ValueListItem::create([ | ||
"value_list" => "rsl_123", | ||
"value" => "value", | ||
]); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueListItem", $resource); | ||
} | ||
|
||
public function testIsDeletable() | ||
{ | ||
$resource = ValueListItem::retrieve(self::TEST_RESOURCE_ID); | ||
$this->expectsRequest( | ||
'delete', | ||
'/v1/radar/value_list_items/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource->delete(); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueListItem", $resource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Stripe\Radar; | ||
|
||
class ValueListTest extends \Stripe\TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'rsl_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/radar/value_lists' | ||
); | ||
$resources = ValueList::all(); | ||
$this->assertTrue(is_array($resources->data)); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueList", $resources->data[0]); | ||
} | ||
|
||
public function testIsRetrievable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/radar/value_lists/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = ValueList::retrieve(self::TEST_RESOURCE_ID); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueList", $resource); | ||
} | ||
|
||
public function testIsCreatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/radar/value_lists' | ||
); | ||
$resource = ValueList::create([ | ||
"alias" => "alias", | ||
"name" => "name", | ||
]); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueList", $resource); | ||
} | ||
|
||
public function testIsSaveable() | ||
{ | ||
$resource = ValueList::retrieve(self::TEST_RESOURCE_ID); | ||
$resource->metadata["key"] = "value"; | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/radar/value_lists/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource->save(); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueList", $resource); | ||
} | ||
|
||
public function testIsUpdatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/radar/value_lists/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = ValueList::update(self::TEST_RESOURCE_ID, [ | ||
"metadata" => ["key" => "value"], | ||
]); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueList", $resource); | ||
} | ||
|
||
public function testIsDeletable() | ||
{ | ||
$resource = ValueList::retrieve(self::TEST_RESOURCE_ID); | ||
$this->expectsRequest( | ||
'delete', | ||
'/v1/radar/value_lists/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource->delete(); | ||
$this->assertInstanceOf("Stripe\\Radar\\ValueList", $resource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters