diff --git a/lib/stripe.rb b/lib/stripe.rb index b26a307fb..00701d590 100644 --- a/lib/stripe.rb +++ b/lib/stripe.rb @@ -83,6 +83,7 @@ require "stripe/reporting/report_run" require "stripe/reporting/report_type" require "stripe/reversal" +require "stripe/review" require "stripe/sigma/scheduled_query_run" require "stripe/sku" require "stripe/source" diff --git a/lib/stripe/review.rb b/lib/stripe/review.rb new file mode 100644 index 000000000..8e090e820 --- /dev/null +++ b/lib/stripe/review.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Stripe + class Review < APIResource + extend Stripe::APIOperations::List + + OBJECT_NAME = "review".freeze + + def approve(params = {}, opts = {}) + resp, opts = request(:post, resource_url + "/approve", params, opts) + initialize_from(resp.data, opts) + end + end +end diff --git a/lib/stripe/util.rb b/lib/stripe/util.rb index b1933687a..d6b40a16f 100644 --- a/lib/stripe/util.rb +++ b/lib/stripe/util.rb @@ -93,6 +93,7 @@ def self.object_classes # rubocop:disable Metrics/MethodLength Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun, Reporting::ReportType::OBJECT_NAME => Reporting::ReportType, Reversal::OBJECT_NAME => Reversal, + Review::OBJECT_NAME => Review, SKU::OBJECT_NAME => SKU, Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun, Source::OBJECT_NAME => Source, diff --git a/test/stripe/review_test.rb b/test/stripe/review_test.rb new file mode 100644 index 000000000..65eeb13f0 --- /dev/null +++ b/test/stripe/review_test.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require ::File.expand_path("../../test_helper", __FILE__) + +module Stripe + class ReviewTest < Test::Unit::TestCase + should "be listable" do + reviews = Stripe::Review.review + assert_requested :get, "#{Stripe.api_base}/v1/reviews" + assert reviews.data.is_a?(Array) + assert reviews.first.is_a?(Stripe::Review) + end + + should "be retrievable" do + review = Stripe::Review.retrieve("prv_123") + assert_requested :get, "#{Stripe.api_base}/v1/reviews/prv_123" + assert review.is_a?(Stripe::Review) + end + + should "be approvable" do + review = Stripe::Review.retrieve("prv_123") + review.approve + assert_requested :post, "#{Stripe.api_base}/v1/reviews/prv_123/approve" + assert review.is_a?(Stripe::Review) + end + end +end