-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bindings for Terminal endpoints (#523)
* Bindings for Terminal endpoints * Linting fixes * Bump StripeMock version * connection_token property -> secret
- Loading branch information
1 parent
6f226e4
commit 514eaf8
Showing
10 changed files
with
244 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,17 @@ | ||
<?php | ||
|
||
namespace Stripe\Terminal; | ||
|
||
/** | ||
* Class ConnectionToken | ||
* | ||
* @property string $secret | ||
* | ||
* @package Stripe\Terminal | ||
*/ | ||
class ConnectionToken extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "terminal.connection_token"; | ||
|
||
use \Stripe\ApiOperations\Create; | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Stripe\Terminal; | ||
|
||
/** | ||
* Class Location | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property string $display_name | ||
* @property string $address_city | ||
* @property string $address_country | ||
* @property string $address_line1 | ||
* @property string $address_line2 | ||
* @property string $address_state | ||
* @property string $address_postal_code | ||
* | ||
* @package Stripe\Terminal | ||
*/ | ||
class Location extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "terminal.location"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
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,25 @@ | ||
<?php | ||
|
||
namespace Stripe\Terminal; | ||
|
||
/** | ||
* Class Reader | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property string $device_type | ||
* @property string $serial_number | ||
* @property string $label | ||
* @property string $ip_address | ||
* | ||
* @package Stripe\Terminal | ||
*/ | ||
class Reader extends \Stripe\ApiResource | ||
{ | ||
const OBJECT_NAME = "terminal.reader"; | ||
|
||
use \Stripe\ApiOperations\All; | ||
use \Stripe\ApiOperations\Create; | ||
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
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,16 @@ | ||
<?php | ||
|
||
namespace Stripe\Terminal; | ||
|
||
class ConnectionTokenTest extends \Stripe\TestCase | ||
{ | ||
public function testIsCreatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/connection_tokens' | ||
); | ||
$resource = ConnectionToken::create(); | ||
$this->assertInstanceOf("Stripe\\Terminal\\ConnectionToken", $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,84 @@ | ||
<?php | ||
|
||
namespace Stripe\Terminal; | ||
|
||
class LocationTest extends \Stripe\TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'loc_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/terminal/locations' | ||
); | ||
$resources = Location::all(); | ||
$this->assertTrue(is_array($resources->data)); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Location", $resources->data[0]); | ||
} | ||
|
||
public function testIsRetrievable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/terminal/locations/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = Location::retrieve(self::TEST_RESOURCE_ID); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); | ||
} | ||
|
||
public function testIsSaveable() | ||
{ | ||
$resource = Location::retrieve(self::TEST_RESOURCE_ID); | ||
$resource->display_name = "new-name"; | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/locations/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource->save(); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); | ||
} | ||
|
||
public function testIsUpdatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/locations/' . self::TEST_RESOURCE_ID, | ||
["display_name" => "new-name"] | ||
); | ||
$resource = Location::update(self::TEST_RESOURCE_ID, [ | ||
"display_name" => "new-name", | ||
]); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Location", $resource); | ||
} | ||
|
||
public function testIsCreatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/locations', | ||
[ | ||
"display_name" => "name", | ||
"address" => [ | ||
"line1" => "line1", | ||
"country" => "US", | ||
"state" => "CA", | ||
"postal_code" => "12345", | ||
"city" => "San Francisco" | ||
] | ||
] | ||
); | ||
$resource = Location::create([ | ||
"display_name" => "name", | ||
"address" => [ | ||
"line1" => "line1", | ||
"country" => "US", | ||
"state" => "CA", | ||
"postal_code" => "12345", | ||
"city" => "San Francisco" | ||
] | ||
]); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Location", $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,66 @@ | ||
<?php | ||
|
||
namespace Stripe\Terminal; | ||
|
||
class ReaderTest extends \Stripe\TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'rdr_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/terminal/readers' | ||
); | ||
$resources = Reader::all(); | ||
$this->assertTrue(is_array($resources->data)); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Reader", $resources->data[0]); | ||
} | ||
|
||
public function testIsRetrievable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/terminal/readers/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = Reader::retrieve(self::TEST_RESOURCE_ID); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); | ||
} | ||
|
||
public function testIsSaveable() | ||
{ | ||
$resource = Reader::retrieve(self::TEST_RESOURCE_ID); | ||
$resource->label = "new-name"; | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/readers/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource->save(); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); | ||
} | ||
|
||
public function testIsUpdatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/readers/' . self::TEST_RESOURCE_ID, | ||
["label" => "new-name"] | ||
); | ||
$resource = Reader::update(self::TEST_RESOURCE_ID, [ | ||
"label" => "new-name", | ||
]); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Reader", $resource); | ||
} | ||
|
||
public function testIsCreatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/terminal/readers', | ||
["registration_code" => "a-b-c"] | ||
); | ||
$resource = Reader::create(['registration_code' => 'a-b-c']); | ||
$this->assertInstanceOf("Stripe\\Terminal\\Reader", $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