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

Fix \Stripe\Tax\Settings::update #1647

Merged
merged 3 commits into from
Feb 13, 2024
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
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);
}
}
Loading