Skip to content

Commit

Permalink
Merge pull request #666 from stripe/remi-add-sigma-scheduled-query-run
Browse files Browse the repository at this point in the history
Add support for ScheduledQueryRun
  • Loading branch information
brandur-stripe authored Jul 28, 2018
2 parents ec5c51c + 4c39c35 commit 42839f8
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ Metrics/LineLength:
# Offense count: 32
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 54
Max: 55

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 314
Max: 315

# Offense count: 6
# Configuration parameters: CountKeywordArgs.
Expand Down
1 change: 1 addition & 0 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
require "stripe/recipient_transfer"
require "stripe/refund"
require "stripe/reversal"
require "stripe/sigma/scheduled_query_run"
require "stripe/sku"
require "stripe/source"
require "stripe/source_transaction"
Expand Down
15 changes: 15 additions & 0 deletions lib/stripe/sigma/scheduled_query_run.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Stripe
module Sigma
class ScheduledQueryRun < Stripe::APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "scheduled_query_run".freeze

def self.resource_url
"/v1/sigma/scheduled_query_runs"
end
end
end
end
103 changes: 52 additions & 51 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,57 +45,58 @@ def self.object_classes
ListObject::OBJECT_NAME => ListObject,

# business objects
Account::OBJECT_NAME => Account,
AlipayAccount::OBJECT_NAME => AlipayAccount,
ApplePayDomain::OBJECT_NAME => ApplePayDomain,
ApplicationFee::OBJECT_NAME => ApplicationFee,
ApplicationFeeRefund::OBJECT_NAME => ApplicationFeeRefund,
Balance::OBJECT_NAME => Balance,
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
BankAccount::OBJECT_NAME => BankAccount,
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
Card::OBJECT_NAME => Card,
Charge::OBJECT_NAME => Charge,
CountrySpec::OBJECT_NAME => CountrySpec,
Coupon::OBJECT_NAME => Coupon,
Customer::OBJECT_NAME => Customer,
Dispute::OBJECT_NAME => Dispute,
EphemeralKey::OBJECT_NAME => EphemeralKey,
Event::OBJECT_NAME => Event,
ExchangeRate::OBJECT_NAME => ExchangeRate,
FileUpload::OBJECT_NAME => FileUpload,
Invoice::OBJECT_NAME => Invoice,
InvoiceItem::OBJECT_NAME => InvoiceItem,
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
IssuerFraudRecord::OBJECT_NAME => IssuerFraudRecord,
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
Issuing::Card::OBJECT_NAME => Issuing::Card,
Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
LoginLink::OBJECT_NAME => LoginLink,
Order::OBJECT_NAME => Order,
OrderReturn::OBJECT_NAME => OrderReturn,
PaymentIntent::OBJECT_NAME => PaymentIntent,
Payout::OBJECT_NAME => Payout,
Plan::OBJECT_NAME => Plan,
Product::OBJECT_NAME => Product,
Recipient::OBJECT_NAME => Recipient,
RecipientTransfer::OBJECT_NAME => RecipientTransfer,
Refund::OBJECT_NAME => Refund,
Reversal::OBJECT_NAME => Reversal,
SKU::OBJECT_NAME => SKU,
Source::OBJECT_NAME => Source,
SourceTransaction::OBJECT_NAME => SourceTransaction,
Subscription::OBJECT_NAME => Subscription,
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
ThreeDSecure::OBJECT_NAME => ThreeDSecure,
Token::OBJECT_NAME => Token,
Topup::OBJECT_NAME => Topup,
Transfer::OBJECT_NAME => Transfer,
UsageRecord::OBJECT_NAME => UsageRecord,
Account::OBJECT_NAME => Account,
AlipayAccount::OBJECT_NAME => AlipayAccount,
ApplePayDomain::OBJECT_NAME => ApplePayDomain,
ApplicationFee::OBJECT_NAME => ApplicationFee,
ApplicationFeeRefund::OBJECT_NAME => ApplicationFeeRefund,
Balance::OBJECT_NAME => Balance,
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
BankAccount::OBJECT_NAME => BankAccount,
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
Card::OBJECT_NAME => Card,
Charge::OBJECT_NAME => Charge,
CountrySpec::OBJECT_NAME => CountrySpec,
Coupon::OBJECT_NAME => Coupon,
Customer::OBJECT_NAME => Customer,
Dispute::OBJECT_NAME => Dispute,
EphemeralKey::OBJECT_NAME => EphemeralKey,
Event::OBJECT_NAME => Event,
ExchangeRate::OBJECT_NAME => ExchangeRate,
FileUpload::OBJECT_NAME => FileUpload,
Invoice::OBJECT_NAME => Invoice,
InvoiceItem::OBJECT_NAME => InvoiceItem,
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
IssuerFraudRecord::OBJECT_NAME => IssuerFraudRecord,
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
Issuing::Card::OBJECT_NAME => Issuing::Card,
Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
LoginLink::OBJECT_NAME => LoginLink,
Order::OBJECT_NAME => Order,
OrderReturn::OBJECT_NAME => OrderReturn,
PaymentIntent::OBJECT_NAME => PaymentIntent,
Payout::OBJECT_NAME => Payout,
Plan::OBJECT_NAME => Plan,
Product::OBJECT_NAME => Product,
Recipient::OBJECT_NAME => Recipient,
RecipientTransfer::OBJECT_NAME => RecipientTransfer,
Refund::OBJECT_NAME => Refund,
Reversal::OBJECT_NAME => Reversal,
SKU::OBJECT_NAME => SKU,
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
Source::OBJECT_NAME => Source,
SourceTransaction::OBJECT_NAME => SourceTransaction,
Subscription::OBJECT_NAME => Subscription,
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
ThreeDSecure::OBJECT_NAME => ThreeDSecure,
Token::OBJECT_NAME => Token,
Topup::OBJECT_NAME => Topup,
Transfer::OBJECT_NAME => Transfer,
UsageRecord::OBJECT_NAME => UsageRecord,
}
end

Expand Down
2 changes: 0 additions & 2 deletions test/stripe/api_operations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class MainResource < APIResource
OBJECT_NAME = "mainresource".freeze
nested_resource_class_methods :nested,
operations: %i[create retrieve update delete list]

OBJECT_NAME = "mainresource".freeze
end

should "define a create method" do
Expand Down
27 changes: 27 additions & 0 deletions test/stripe/sigma/scheduled_query_run_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

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

module Stripe
module Issuing
class ScheduledQueryRunTest < Test::Unit::TestCase
should "be listable" do
stub_request(:get, "#{Stripe.api_base}/v1/sigma/scheduled_query_runs")
.to_return(body: JSON.generate(object: "list", data: [{ id: "sqr_123", object: "scheduled_query_run" }]))

runs = Stripe::Sigma::ScheduledQueryRun.list
assert_requested :get, "#{Stripe.api_base}/v1/sigma/scheduled_query_runs"
assert runs.data.is_a?(Array)
assert runs.data[0].is_a?(Stripe::Sigma::ScheduledQueryRun)
end

should "be retrievable" do
stub_request(:get, "#{Stripe.api_base}/v1/sigma/scheduled_query_runs/sqr_123")
.to_return(body: JSON.generate(id: "sqr_123", object: "scheduled_query_run"))
run = Stripe::Sigma::ScheduledQueryRun.retrieve("sqr_123")
assert_requested :get, "#{Stripe.api_base}/v1/sigma/scheduled_query_runs/sqr_123"
assert run.is_a?(Stripe::Sigma::ScheduledQueryRun)
end
end
end
end

0 comments on commit 42839f8

Please sign in to comment.