Skip to content
Browse files

add query methods for related transaction types

  • Loading branch information...
1 parent b9de14e commit 59f85bbafbd16025a1895f2b24ddc90b7249e8a4 @cainlevy cainlevy committed
Showing with 16 additions and 1 deletion.
  1. +1 −1 lib/amazon_flex_pay.rb
  2. +8 −0 lib/amazon_flex_pay/data_types.rb
  3. +7 −0 test/data_types_test.rb
View
2 lib/amazon_flex_pay.rb
@@ -10,8 +10,8 @@
require 'amazon_flex_pay/signing'
require 'amazon_flex_pay/model'
-require 'amazon_flex_pay/data_types'
require 'amazon_flex_pay/enumerations'
+require 'amazon_flex_pay/data_types'
require 'amazon_flex_pay/api'
require 'amazon_flex_pay/pipelines'
View
8 lib/amazon_flex_pay/data_types.rb
@@ -48,6 +48,14 @@ class PrepaidBalance < AmazonFlexPay::Model #:nodoc:
class RelatedTransaction < AmazonFlexPay::Model #:nodoc:
attribute :relation_type, :enumeration => :relation_type
attribute :transaction_id
+
+ AmazonFlexPay::Enumerations::RelationType.each do |relation|
+ class_eval <<-END
+ def #{relation.underscore}?
+ relation_type == '#{relation}'
+ end
+ END
+ end
end
class StatusHistory < AmazonFlexPay::Model #:nodoc:
View
7 test/data_types_test.rb
@@ -9,4 +9,11 @@ class AmazonFlexPayTest < AmazonFlexPay::Test
assert detail.respond_to?(:related_transactions)
assert_equal detail.related_transactions, detail.related_transaction
end
+
+ should "support RelatedTransaction relation type query methods" do
+ related = RelatedTransaction.new(:relation_type => 'MarketplaceFee', :transaction_id => 'abc123')
+ assert related.respond_to?(:marketplace_fee?)
+ assert related.marketplace_fee?
+ assert !related.refund?
+ end
end

0 comments on commit 59f85bb

Please sign in to comment.
Something went wrong with that request. Please try again.