ravelin 0.1.43 → 0.1.45

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
  SHA256:
3
- metadata.gz: 7934d6f3c5b99aeb5fc663fffe9396dc9f9ad1c92573a6751e6a081191d8c2d4
4
- data.tar.gz: 42cc39932a8bbe15a5b1d14fd4252f6c3cd24801f56bb6e5f68872d278c90d68
3
+ metadata.gz: 7a3514532779deaa212f87e620c7416dc75446a16b777ed1750e8fe174eb21d5
4
+ data.tar.gz: 438c09cb122986b0241e2b2f1880f132570c437a6ea455f875340af128d94bf4
5
5
  SHA512:
6
- metadata.gz: 205bf6a447c2144c02c5427fa16e0e275a334cd774f520bba2459ffd9d0342616757d3827ab2fa9715f6a44c31782f53ba6376262684971e92a4955304a0c4c1
7
- data.tar.gz: 99d0e83f09f997b4af4907adb0f7c6851c51144528d6f56513962ab52404efdef1d6b72a4aedcaffa34b56b044288313d4447a3c93c25960ebf957c613cd9b98
6
+ metadata.gz: 6cb12db77f6197ef025b3576488348cba1b51e7c245722d795206cf21bbc706909d3d3030d7dc55b5679bf90087e79383ee45995a54be7a69e0e2c774f03c346
7
+ data.tar.gz: 7d7c78def62d790084669e4f373c7ae7b0f27bc4c15f61c1125a11516f49c288481f291ebb36d4de2b1991c882d027bbc9a01275356f32a62cf7ffab09bbda38
@@ -20,5 +20,9 @@ module Ravelin
20
20
  def sms_code=(mechanism)
21
21
  @sms_code = Ravelin::AuthenticationMechanisms::SmsCode.new(mechanism)
22
22
  end
23
+
24
+ def magic_link=(mechanism)
25
+ @magic_link = Ravelin::AuthenticationMechanisms::MagicLink.new(mechanism)
26
+ end
23
27
  end
24
28
  end
@@ -0,0 +1,35 @@
1
+ module Ravelin
2
+ module AuthenticationMechanisms
3
+ class MagicLink < RavelinObject
4
+ TRANSPORTATION_MECHANISM = %w(email sms)
5
+ FAILURE_REASONS = %w(INVALID_LINK TIMEOUT INTERNAL_ERROR RATE_LIMIT BANNED_USER)
6
+
7
+ attr_accessor :transport, :success, :email, :phone_number, :failure_reason
8
+ attr_required :transport, :success
9
+
10
+ def failure_reason=(reason)
11
+ @failure_reason = reason.to_s.upcase
12
+ end
13
+
14
+ def validate
15
+ super
16
+
17
+ if !success && !FAILURE_REASONS.include?(failure_reason)
18
+ raise ArgumentError.new("Failure reason value must be one of #{FAILURE_REASONS.join(', ')}")
19
+ end
20
+
21
+ if !TRANSPORTATION_MECHANISM.include?(transport)
22
+ raise ArgumentError.new("Transportation mechanism value must be one of #{TRANSPORTATION_MECHANISM.join(', ')}")
23
+ end
24
+
25
+ if transport == 'email' && email.nil?
26
+ raise ArgumentError.new("email must be present for email transportation mechanism")
27
+ end
28
+
29
+ if transport == 'sms' && phone_number.nil?
30
+ raise ArgumentError.new("phone_number must be present for sms transportation mechanism")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/ravelin/event.rb CHANGED
@@ -17,6 +17,8 @@ module Ravelin
17
17
 
18
18
  if v.is_a?(Ravelin::RavelinObject)
19
19
  [k, v.serializable_hash]
20
+ elsif v.is_a?(Array)
21
+ [k, v.map { |elem| elem.respond_to?(:serializable_hash) ? elem.serializable_hash : elem }]
20
22
  else
21
23
  [k, v]
22
24
  end
@@ -39,7 +41,9 @@ module Ravelin
39
41
  password: Password,
40
42
  social: AuthenticationMechanisms::Social,
41
43
  sms_code: AuthenticationMechanisms::SmsCode,
44
+ magic_link: AuthenticationMechanisms::MagicLink,
42
45
  payment_method: PaymentMethod,
46
+ payment_methods: PaymentMethods,
43
47
  supplier: Supplier,
44
48
  voucher_redemption: VoucherRedemption,
45
49
  transaction: transaction,
@@ -48,6 +52,12 @@ module Ravelin
48
52
  }
49
53
  end
50
54
 
55
+ def plural_object_classes
56
+ {
57
+ transactions: transaction
58
+ }
59
+ end
60
+
51
61
  def transaction
52
62
  case name
53
63
  when :pretransaction
@@ -139,8 +149,10 @@ module Ravelin
139
149
  k = k.to_sym
140
150
  v = Ravelin.convert_ids_to_strings(k, v)
141
151
 
142
- if v.is_a?(Hash) && klass = object_classes[k]
152
+ if (v.is_a?(Hash) || v.is_a?(Array)) && (klass = object_classes[k])
143
153
  [k, klass.new(v)]
154
+ elsif v.is_a?(Array) && (klass = plural_object_classes[k])
155
+ [k, v.map { |elem| klass.new(elem) }]
144
156
  else
145
157
  [k, v]
146
158
  end
@@ -0,0 +1,13 @@
1
+ module Ravelin
2
+ class PaymentMethods < RavelinObject
3
+ attr_reader :methods
4
+
5
+ def initialize(methods)
6
+ @methods = methods
7
+ end
8
+
9
+ def serializable_hash
10
+ methods.map(&:serializable_hash)
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Ravelin
2
- VERSION = '0.1.43'
2
+ VERSION = '0.1.45'
3
3
  end
data/lib/ravelin.rb CHANGED
@@ -25,6 +25,7 @@ require 'ravelin/login'
25
25
  require 'ravelin/order'
26
26
  require 'ravelin/app'
27
27
  require 'ravelin/payment_method'
28
+ require 'ravelin/payment_methods'
28
29
  require 'ravelin/password'
29
30
  require 'ravelin/pre_transaction'
30
31
  require 'ravelin/supplier'
@@ -42,6 +43,7 @@ require 'ravelin/proxy_client'
42
43
 
43
44
  require 'ravelin/authentication_mechanisms/social'
44
45
  require 'ravelin/authentication_mechanisms/sms_code'
46
+ require 'ravelin/authentication_mechanisms/magic_link'
45
47
 
46
48
 
47
49
  module Ravelin
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.43
4
+ version: 0.1.45
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: 2021-12-13 00:00:00.000000000 Z
14
+ date: 2022-10-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -61,14 +61,14 @@ dependencies:
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '10.0'
64
+ version: '13.0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: '10.0'
71
+ version: '13.0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rspec
74
74
  requirement: !ruby/object:Gem::Requirement
@@ -89,14 +89,14 @@ dependencies:
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '2.3'
92
+ version: '3.18'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: '2.3'
99
+ version: '3.18'
100
100
  description: Ravelin is a fraud detection tool. See https://www.ravelin.com for details.
101
101
  email:
102
102
  - sam.levy@deliveroo.co.uk
@@ -112,6 +112,7 @@ files:
112
112
  - lib/ravelin/ato_login.rb
113
113
  - lib/ravelin/ato_reclaim.rb
114
114
  - lib/ravelin/authentication_mechanism.rb
115
+ - lib/ravelin/authentication_mechanisms/magic_link.rb
115
116
  - lib/ravelin/authentication_mechanisms/sms_code.rb
116
117
  - lib/ravelin/authentication_mechanisms/social.rb
117
118
  - lib/ravelin/chargeback.rb
@@ -132,6 +133,7 @@ files:
132
133
  - lib/ravelin/order.rb
133
134
  - lib/ravelin/password.rb
134
135
  - lib/ravelin/payment_method.rb
136
+ - lib/ravelin/payment_methods.rb
135
137
  - lib/ravelin/pre_transaction.rb
136
138
  - lib/ravelin/proxy_client.rb
137
139
  - lib/ravelin/ravelin_object.rb
@@ -162,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
164
  - !ruby/object:Gem::Version
163
165
  version: '0'
164
166
  requirements: []
165
- rubygems_version: 3.0.9
167
+ rubygems_version: 3.3.23
166
168
  signing_key:
167
169
  specification_version: 4
168
170
  summary: Ruby bindings for the Ravelin API