From 0d4f603dd53ad7477c170a5d5e06fa9db2afe856 Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Mon, 30 Sep 2024 12:28:23 -0400 Subject: [PATCH 1/2] Fix related object fetch --- .../V1BillingMeterErrorReportTriggeredEvent.php | 14 ++++---------- lib/Events/V1BillingMeterNoMeterFoundEvent.php | 8 +++----- tests/Stripe/V2/CollectionTest.php | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php b/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php index fc965b9a3..b0edb6cfd 100644 --- a/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php +++ b/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php @@ -4,20 +4,14 @@ namespace Stripe\Events; +/** + * @property \Stripe\RelatedObject Object containing the reference to API resource relevant to the event + * @property \Stripe\EventData\V1BillingMeterErrorReportTriggeredEventData data associated with the event + */ class V1BillingMeterErrorReportTriggeredEvent extends \Stripe\V2\Event { const LOOKUP_TYPE = 'v1.billing.meter.error_report_triggered'; - /** - * @var \Stripe\EventData\V1BillingMeterErrorReportTriggeredEventData data associated with the event - */ - public $data; - - /** - * @var \Stripe\RelatedObject Object containing the reference to API resource relevant to the event - */ - public $related_object; - /** * Retrieves the related object from the API. Make an API request on every call. * diff --git a/lib/Events/V1BillingMeterNoMeterFoundEvent.php b/lib/Events/V1BillingMeterNoMeterFoundEvent.php index f98286876..9515328cb 100644 --- a/lib/Events/V1BillingMeterNoMeterFoundEvent.php +++ b/lib/Events/V1BillingMeterNoMeterFoundEvent.php @@ -4,12 +4,10 @@ namespace Stripe\Events; +/** + * @property \Stripe\EventData\V1BillingMeterNoMeterFoundEventData data associated with the event + */ class V1BillingMeterNoMeterFoundEvent extends \Stripe\V2\Event { const LOOKUP_TYPE = 'v1.billing.meter.no_meter_found'; - - /** - * @var \Stripe\EventData\V1BillingMeterNoMeterFoundEventData data associated with the event - */ - public $data; } diff --git a/tests/Stripe/V2/CollectionTest.php b/tests/Stripe/V2/CollectionTest.php index a37d5d9c4..0b8bf0c3b 100644 --- a/tests/Stripe/V2/CollectionTest.php +++ b/tests/Stripe/V2/CollectionTest.php @@ -24,6 +24,7 @@ public function setUpFixture() ['id' => 'pm_456', 'object' => 'pageablemodel'], ], 'next_page_url' => '/v2/pageablemodel?page=page_2', + 'previous_page_url' => null, ], ['api_key' => 'sk_test', 'stripe_context' => 'wksp_123'], 'v2'); } @@ -52,7 +53,8 @@ public function testCanIterate() { $collection = \Stripe\V2\Collection::constructFrom([ 'data' => [['id' => '1'], ['id' => '2'], ['id' => '3']], - 'next_page' => null, + 'next_page_url' => null, + 'previous_page_url' => null, ]); $seen = []; @@ -67,7 +69,8 @@ public function testCanIterateBackwards() { $collection = \Stripe\V2\Collection::constructFrom([ 'data' => [['id' => '1'], ['id' => '2'], ['id' => '3']], - 'next_page' => null, + 'next_page_url' => null, + 'previous_page_url' => null, ]); $seen = []; @@ -96,7 +99,8 @@ public function testAutoPagingIteratorSupportsOnePage() ['id' => '2'], ['id' => '3'], ], - 'next_page' => null, + 'next_page_url' => null, + 'previous_page_url' => null, ]); $seen = []; @@ -114,6 +118,7 @@ public function testAutoPagingIteratorSupportsTwoPages() ['id' => '1'], ], 'next_page_url' => '/v2/pageablemodel?foo=bar&page=page_2', + 'previous_page_url' => null, ]); $this->stubRequest( @@ -128,6 +133,7 @@ public function testAutoPagingIteratorSupportsTwoPages() ['id' => '3'], ], 'next_page_url' => null, + 'previous_page_url' => null, ] ); @@ -150,6 +156,7 @@ public function testAutoPagingIteratorSupportsIteratorToArray() [ 'data' => [['id' => 'pm_789']], 'next_page_url' => null, + 'previous_page_url' => null, ] ); @@ -170,11 +177,11 @@ public function testForwardsRequestOpts() $curlClientStub->method('executeRequestWithRetries') ->willReturnOnConsecutiveCalls([ - '{"data": [{"id": "pm_777"}], "next_page_url": "page_3"}', + '{"data": [{"id": "pm_777"}], "next_page_url": "/v2/pageablemodel?page_3", "previous_page_url": "/v2/pageablemodel?page_1"}', 200, [], ], [ - '{"data": [{"id": "pm_888"}], "next_page_url": null}', + '{"data": [{"id": "pm_888"}], "next_page_url": null, "previous_page_url": "/v2/pageablemodel?page_2"}', 200, [], ]) From 5b9e7a16cf0bfd8c1880298f7c4ad1433fa3bf2b Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Mon, 30 Sep 2024 12:42:05 -0400 Subject: [PATCH 2/2] Fix phpstan --- lib/Events/V1BillingMeterErrorReportTriggeredEvent.php | 4 ++-- lib/Events/V1BillingMeterNoMeterFoundEvent.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php b/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php index b0edb6cfd..baf95f333 100644 --- a/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php +++ b/lib/Events/V1BillingMeterErrorReportTriggeredEvent.php @@ -5,8 +5,8 @@ namespace Stripe\Events; /** - * @property \Stripe\RelatedObject Object containing the reference to API resource relevant to the event - * @property \Stripe\EventData\V1BillingMeterErrorReportTriggeredEventData data associated with the event + * @property \Stripe\RelatedObject $related_object Object containing the reference to API resource relevant to the event + * @property \Stripe\EventData\V1BillingMeterErrorReportTriggeredEventData $data data associated with the event */ class V1BillingMeterErrorReportTriggeredEvent extends \Stripe\V2\Event { diff --git a/lib/Events/V1BillingMeterNoMeterFoundEvent.php b/lib/Events/V1BillingMeterNoMeterFoundEvent.php index 9515328cb..39528eaf2 100644 --- a/lib/Events/V1BillingMeterNoMeterFoundEvent.php +++ b/lib/Events/V1BillingMeterNoMeterFoundEvent.php @@ -5,7 +5,7 @@ namespace Stripe\Events; /** - * @property \Stripe\EventData\V1BillingMeterNoMeterFoundEventData data associated with the event + * @property \Stripe\EventData\V1BillingMeterNoMeterFoundEventData $data data associated with the event */ class V1BillingMeterNoMeterFoundEvent extends \Stripe\V2\Event {