ravelin 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89ecd05f211df024a040670b38688b4c5ac65ac1
4
- data.tar.gz: 8c440378be06ab8ffc0a7a07f371af1adae51532
3
+ metadata.gz: 4b248ecddc8dd466d77736a5b37960ebd6312f30
4
+ data.tar.gz: 3fbde0a73dcb74135b4722c42568e9136978283b
5
5
  SHA512:
6
- metadata.gz: d9d07afce70b9323ed5bc5290985a4aad5dd237d3931932e59dc469dd239d03f695265f8e24e88cc22b72949d2062a8f99ac94ef85b2c5efa68011921c4860d2
7
- data.tar.gz: 6a4ca09861bc3b6dcd5bb330da9b145b2e78e3d0b0b44fb8664ea0b7222b833281e649a60a183a7277c2e639a3862d3483ec7e86d08e09f81abc5da5f4c841ed
6
+ metadata.gz: 80709c4159f06bd611eaa7400c538b35b1e9fda246fa5cd67b5b6e5e6b6e910513dd7953a20d833ad3eac9d811ddda3104e95fc90f5094c710ad5dd83b24a622
7
+ data.tar.gz: 9d838d99ec670371d6405be97abc6b846b2fb506ebbd78a81339b8f7803919931a318b091c04eabec6c29b7d88ebda8261e87037a5a017d3134f6a8403a93ec6
data/lib/ravelin/event.rb CHANGED
@@ -52,7 +52,10 @@ module Ravelin
52
52
  when :'paymentmethod/voucher'
53
53
  validate_payload_inclusion_of :'voucher_redemption'
54
54
  when :pretransaction, :transaction
55
- validate_payload_inclusion_of :order_id, :payment_method_id
55
+ validate_payload_must_include_one_of(
56
+ :payment_method_id, :payment_method
57
+ )
58
+ validate_payload_inclusion_of :order_id
56
59
  when :login
57
60
  validate_payload_inclusion_of :customer_id, :temp_customer_id
58
61
  when :checkout
@@ -77,6 +80,18 @@ module Ravelin
77
80
  end
78
81
  end
79
82
 
83
+ def validate_payload_must_include_one_of(*mutually_exclusive_keys)
84
+ intersection = mutually_exclusive_keys & self.payload.keys
85
+
86
+ if intersection.size > 1
87
+ raise ArgumentError
88
+ .new(%Q{parameters are mutally exclusive: #{mutually_exclusive_keys.join(', ')}})
89
+ elsif intersection.size == 0
90
+ raise ArgumentError
91
+ .new(%Q{payload must include one of: #{mutually_exclusive_keys.join(', ')}})
92
+ end
93
+ end
94
+
80
95
  def payload_customer_reference_present?
81
96
  self.payload.keys.any? {|k| %i(customer_id temp_customer_id).include? k }
82
97
  end
@@ -1,3 +1,3 @@
1
1
  module Ravelin
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ravelin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Levy
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2016-11-28 00:00:00.000000000 Z
14
+ date: 2017-03-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday