Skip to content

Commit

Permalink
Fix \Stripe\Tax\Settings::update (#1647)
Browse files Browse the repository at this point in the history
* test

* Impl
  • Loading branch information
richardm-stripe authored Feb 13, 2024
1 parent f5c5a4d commit ecec695
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/Tax/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,27 @@ class Settings extends \Stripe\SingletonApiResource
const OBJECT_NAME = 'tax.settings';

use \Stripe\ApiOperations\SingletonRetrieve;
use \Stripe\ApiOperations\Update;

const STATUS_ACTIVE = 'active';
const STATUS_PENDING = 'pending';

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return static the updated resource
*/
public static function update($params = null, $opts = null)
{
self::_validateParams($params);
$url = '/v1/tax/settings';

list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return $obj;
}
}
26 changes: 26 additions & 0 deletions tests/Stripe/Tax/SettingsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Stripe\Tax;

/**
* @internal
* @covers \Stripe\Terminal\ConnectionToken
*/
final class SettingsTest extends \Stripe\TestCase
{
use \Stripe\TestHelper;

public function testIsUpdateable()
{
$this->expectsRequest(
'post',
'/v1/tax/settings'
);
$resource = Settings::update([
'defaults' => [
'tax_behavior' => 'exclusive',
],
]);
static::assertInstanceOf(\Stripe\Tax\Settings::class, $resource);
}
}

0 comments on commit ecec695

Please sign in to comment.