ravelin 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b248ecddc8dd466d77736a5b37960ebd6312f30
4
- data.tar.gz: 3fbde0a73dcb74135b4722c42568e9136978283b
3
+ metadata.gz: 9c386b1036368c92c7f077bbefccf8e42addf9b6
4
+ data.tar.gz: 5129f6ff9570d295569498722cc0ce7f3488588d
5
5
  SHA512:
6
- metadata.gz: 80709c4159f06bd611eaa7400c538b35b1e9fda246fa5cd67b5b6e5e6b6e910513dd7953a20d833ad3eac9d811ddda3104e95fc90f5094c710ad5dd83b24a622
7
- data.tar.gz: 9d838d99ec670371d6405be97abc6b846b2fb506ebbd78a81339b8f7803919931a318b091c04eabec6c29b7d88ebda8261e87037a5a017d3134f6a8403a93ec6
6
+ metadata.gz: dad24150d4298d44d139f696f4c9f608d968e21aef21e572e299ec73a65b87b213e29ed4eb65d768b8927de70978dfe405c7871207ffbbc38bbba5acae2eec49
7
+ data.tar.gz: 655c9c5577f278fa94777bc5dbc2e146fe0fb016bea995167688d82498076a1a1dc993ccf7898db50030bc5934a92dc48d081fdfd57bd8135d6ae988b4a34652
data/lib/ravelin.rb CHANGED
@@ -37,6 +37,7 @@ module Ravelin
37
37
  attr_accessor :faraday_adapter, :faraday_timeout
38
38
 
39
39
  def camelize(str)
40
+ return '3ds' if str == :three_d_secure # hack to get around Ruby not support 3ds an attribute.
40
41
  str.to_s.gsub(/_(.)/) { |e| $1.upcase }
41
42
  end
42
43
 
data/lib/ravelin/event.rb CHANGED
@@ -11,7 +11,7 @@ module Ravelin
11
11
  end
12
12
 
13
13
  def serializable_hash
14
- payload_hash = hash_map(self.payload) do |k, v|
14
+ payload_hash = hash_map(payload) do |k, v|
15
15
  k = Ravelin.camelize(k)
16
16
 
17
17
  if v.is_a?(Ravelin::RavelinObject)
@@ -33,7 +33,7 @@ module Ravelin
33
33
  order: Order,
34
34
  payment_method: PaymentMethod,
35
35
  voucher_redemption: VoucherRedemption,
36
- transaction: self.name == :pretransaction ? PreTransaction : Transaction,
36
+ transaction: name == :pretransaction ? PreTransaction : Transaction,
37
37
  label: Label,
38
38
  voucher: Voucher,
39
39
  }
@@ -44,56 +44,52 @@ module Ravelin
44
44
  def validate_top_level_payload_params
45
45
  validate_customer_id_presence_on :order, :paymentmethod,
46
46
  :pretransaction, :transaction, :label
47
- case self.name
48
- when :customer
49
- validate_payload_inclusion_of :customer
50
- when :voucher
51
- validate_payload_inclusion_of :voucher
52
- when :'paymentmethod/voucher'
53
- validate_payload_inclusion_of :'voucher_redemption'
54
- when :pretransaction, :transaction
55
- validate_payload_must_include_one_of(
56
- :payment_method_id, :payment_method
57
- )
58
- validate_payload_inclusion_of :order_id
59
- when :login
60
- validate_payload_inclusion_of :customer_id, :temp_customer_id
61
- when :checkout
62
- validate_payload_inclusion_of :customer, :order,
63
- :payment_method, :transaction
47
+ case name
48
+ when :customer
49
+ validate_payload_inclusion_of :customer
50
+ when :voucher
51
+ validate_payload_inclusion_of :voucher
52
+ when :'paymentmethod/voucher'
53
+ validate_payload_inclusion_of :'voucher_redemption'
54
+ when :pretransaction, :transaction
55
+ validate_payload_must_include_one_of(
56
+ :payment_method_id, :payment_method
57
+ )
58
+ validate_payload_inclusion_of :order_id
59
+ when :login
60
+ validate_payload_inclusion_of :customer_id
61
+ when :checkout
62
+ validate_payload_inclusion_of :customer, :order,
63
+ :payment_method, :transaction
64
64
  end
65
65
  end
66
66
 
67
67
  def validate_customer_id_presence_on(*events)
68
- if events.include?(self.name) && !payload_customer_reference_present?
69
- raise ArgumentError.
70
- new(%q{payload missing customer_id or temp_customer_id parameter})
68
+ if events.include?(name) && !payload_customer_reference_present?
69
+ raise ArgumentError, 'payload missing customer_id or temp_customer_id parameter'
71
70
  end
72
71
  end
73
72
 
74
73
  def validate_payload_inclusion_of(*required_keys)
75
- missing = required_keys - self.payload.keys
74
+ missing = required_keys - payload.keys
76
75
 
77
76
  if missing.any?
78
- raise ArgumentError.
79
- new(%Q{payload missing parameters: #{missing.join(', ')}})
77
+ raise ArgumentError, "payload missing parameters: #{missing.join(', ')}"
80
78
  end
81
79
  end
82
80
 
83
81
  def validate_payload_must_include_one_of(*mutually_exclusive_keys)
84
- intersection = mutually_exclusive_keys & self.payload.keys
82
+ intersection = mutually_exclusive_keys & payload.keys
85
83
 
86
84
  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(', ')}})
85
+ raise ArgumentError, "parameters are mutally exclusive: #{mutually_exclusive_keys.join(', ')}"
86
+ elsif intersection.empty?
87
+ raise ArgumentError, "payload must include one of: #{mutually_exclusive_keys.join(', ')}"
92
88
  end
93
89
  end
94
90
 
95
91
  def payload_customer_reference_present?
96
- self.payload.keys.any? {|k| %i(customer_id temp_customer_id).include? k }
92
+ payload.keys.any? { |k| %i[customer_id temp_customer_id].include? k }
97
93
  end
98
94
 
99
95
  def convert_to_epoch(val)
@@ -102,7 +98,7 @@ module Ravelin
102
98
  elsif val.is_a?(Integer)
103
99
  val
104
100
  else
105
- raise TypeError.new(%Q{timestamp requires a Time or epoch Integer})
101
+ raise TypeError, 'timestamp requires a Time or epoch Integer'
106
102
  end
107
103
  end
108
104
 
@@ -1,27 +1,38 @@
1
1
  module Ravelin
2
2
  class Transaction < RavelinObject
3
3
  attr_accessor :transaction_id,
4
- :email,
5
- :currency,
6
- :debit,
7
- :credit,
8
- :gateway,
9
- :custom,
10
- :success,
11
- :auth_code,
12
- :decline_code,
13
- :gateway_reference,
14
- :avs_result_code,
15
- :cvv_result_code,
16
- :type,
17
- :time
4
+ :email,
5
+ :currency,
6
+ :debit,
7
+ :credit,
8
+ :gateway,
9
+ :custom,
10
+ :success,
11
+ :auth_code,
12
+ :decline_code,
13
+ :gateway_reference,
14
+ :avs_result_code,
15
+ :cvv_result_code,
16
+ :type,
17
+ :time,
18
+ :three_d_secure
18
19
 
19
20
  attr_required :transaction_id,
20
- :currency,
21
- :debit,
22
- :credit,
23
- :gateway,
24
- :gateway_reference,
25
- :success
21
+ :currency,
22
+ :debit,
23
+ :credit,
24
+ :gateway,
25
+ :gateway_reference,
26
+ :success
27
+
28
+ def initialize(params)
29
+ three_d_secure_data = params['3ds']
30
+ unless three_d_secure_data.nil?
31
+ self.three_d_secure = three_d_secure_data
32
+ params.delete('3ds')
33
+ end
34
+
35
+ super(params)
36
+ end
26
37
  end
27
38
  end
@@ -1,3 +1,3 @@
1
1
  module Ravelin
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
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: 2017-03-07 00:00:00.000000000 Z
14
+ date: 2017-07-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday