Skip to content

Commit

Permalink
Add support for Review resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Nov 28, 2018
1 parent 5452040 commit ff82a3f
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ php:

env:
global:
- STRIPE_MOCK_VERSION=0.37.0
- STRIPE_MOCK_VERSION=0.38.0
matrix:
- AUTOLOAD=1
- AUTOLOAD=0
Expand Down
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportType.php');
require(dirname(__FILE__) . '/lib/Review.php');
require(dirname(__FILE__) . '/lib/SKU.php');
require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php');
require(dirname(__FILE__) . '/lib/Source.php');
Expand Down
38 changes: 38 additions & 0 deletions lib/Review.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Stripe;

/**
* Class Review
*
* @property string $id
* @property string $object
* @property string $charge
* @property int $created
* @property bool $livemode
* @property bool $open
* @property sring $payment_intent
* @property string $reason
*
* @package Stripe
*/
class Review extends \Stripe\ApiResource
{
const OBJECT_NAME = "review";

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

/**
* @param array|string|null $options
*
* @return Review The approved review.
*/
public function approve($params = null, $options = null)
{
$url = $this->instanceUrl() . '/approve';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}
1 change: 1 addition & 0 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public static function convertToStripeObject($resp, $opts)
\Stripe\Refund::OBJECT_NAME => 'Stripe\\Refund',
\Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun',
\Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType',
\Stripe\Review::OBJECT_NAME => 'Stripe\\Review',
\Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU',
\Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun',
\Stripe\Source::OBJECT_NAME => 'Stripe\\Source',
Expand Down
40 changes: 40 additions & 0 deletions tests/Stripe/ReviewTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Stripe;

class ReviewTest extends \Stripe\TestCase
{
const TEST_RESOURCE_ID = 'prv_123';

public function testIsApprovable()
{
$resource = Review::retrieve(self::TEST_RESOURCE_ID);
$this->expectsRequest(
'post',
'/v1/reviews/' . self::TEST_RESOURCE_ID . '/approve'
);
$resource->approve();
$this->assertInstanceOf("Stripe\\Review", $resource);
}

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

public function testIsRetrievable()
{
$this->expectsRequest(
'get',
'/v1/reviews/' . self::TEST_RESOURCE_ID
);
$resource = Review::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf("Stripe\\Review", $resource);
}
}
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define("MOCK_MINIMUM_VERSION", "0.37.0");
define("MOCK_MINIMUM_VERSION", "0.38.0");
define("MOCK_PORT", getenv("STRIPE_MOCK_PORT") ?: 12111);

// Send a request to stripe-mock
Expand Down

0 comments on commit ff82a3f

Please sign in to comment.