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

Add support for ScheduledQueryRun #666

Merged
merged 1 commit into from
Jul 28, 2018
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
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes are getting a little bit annoying. We're basically incrementing each time and making those rules irrelevant. Wanted to flag as we likely should disable the rule for the 2 specific parts of code we care about.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should just kill these. I can do it.


# 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of nice/lucky that this wasn't brought in until you'd established the new namespacing convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full disclosure, I saw that resource once and tried on a week end, and failed and thought "well no one has asked for it so it's okay" 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol! Well, pretty nice that it's a piece of cake nowadays right?

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a weird warning today. This likely should have been caught by the test suite though so it's worth investigating what caused it to not be seen though it's just in tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arg yes, I've run into this type of thing before.

Unfortunately, there doesn't seem to be any easy way to have Ruby treat warnings as errors (I don't really want to monkeypatch Kernel although I suppose we could consider it).

These don't come up that often though, so I'm not sure it's a huge problem.

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