Skip to content

Commit

Permalink
Add support for the Reporting resources
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Aug 30, 2018
1 parent 1bbbfd4 commit 0f3b0cf
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
require "stripe/recipient"
require "stripe/recipient_transfer"
require "stripe/refund"
require "stripe/reporting/report_run"
require "stripe/reporting/report_type"
require "stripe/reversal"
require "stripe/sigma/scheduled_query_run"
require "stripe/sku"
Expand Down
12 changes: 12 additions & 0 deletions lib/stripe/reporting/report_run.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Stripe
module Reporting
class ReportRun < Stripe::APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List

OBJECT_NAME = "reporting.report_run".freeze
end
end
end
12 changes: 12 additions & 0 deletions lib/stripe/reporting/report_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Stripe
module Reporting
class ReportType < Stripe::APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List

OBJECT_NAME = "reporting.report_type".freeze
end
end
end
2 changes: 2 additions & 0 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def self.object_classes # rubocop:disable Metrics/MethodLength
Recipient::OBJECT_NAME => Recipient,
RecipientTransfer::OBJECT_NAME => RecipientTransfer,
Refund::OBJECT_NAME => Refund,
Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun,
Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
Reversal::OBJECT_NAME => Reversal,
SKU::OBJECT_NAME => SKU,
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
Expand Down
33 changes: 33 additions & 0 deletions test/stripe/reporting/report_run_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require ::File.expand_path("../../../test_helper", __FILE__)

module Stripe
module Reporting
class ReportRunTest < Test::Unit::TestCase
should "be creatable" do
report_run = Stripe::Reporting::ReportRun.create(
report_type: "activity.summary.1",
parameters: {
connected_account: "acct_123",
},
)
assert_requested :post, "#{Stripe.api_base}/v1/reporting/report_runs"
assert report_run.is_a?(Stripe::Reporting::ReportRun)
end

should "be listable" do
report_runs = Stripe::Reporting::ReportRun.list
assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_runs"
assert report_runs.data.is_a?(Array)
assert report_runs.data[0].is_a?(Stripe::Reporting::ReportRun)
end

should "be retrievable" do
report_run = Stripe::Reporting::ReportRun.retrieve("frr_123")
assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_runs/frr_123"
assert report_run.is_a?(Stripe::Reporting::ReportRun)
end
end
end
end
22 changes: 22 additions & 0 deletions test/stripe/reporting/report_type_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require ::File.expand_path("../../../test_helper", __FILE__)

module Stripe
module Reporting
class ReportTypeTest < Test::Unit::TestCase
should "be listable" do
report_types = Stripe::Reporting::ReportType.list
assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_types"
assert report_types.data.is_a?(Array)
assert report_types.data[0].is_a?(Stripe::Reporting::ReportType)
end

should "be retrievable" do
report_type = Stripe::Reporting::ReportType.retrieve("activity.summary.1")
assert_requested :get, "#{Stripe.api_base}/v1/reporting/report_types/activity.summary.1"
assert report_type.is_a?(Stripe::Reporting::ReportType)
end
end
end
end

0 comments on commit 0f3b0cf

Please sign in to comment.