ravelin 0.1.18 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ravelin.rb +4 -0
- data/lib/ravelin/ato_login.rb +13 -0
- data/lib/ravelin/authentication_mechanism.rb +16 -0
- data/lib/ravelin/client.rb +12 -6
- data/lib/ravelin/event.rb +5 -2
- data/lib/ravelin/login.rb +14 -0
- data/lib/ravelin/password.rb +27 -0
- data/lib/ravelin/response.rb +2 -1
- data/lib/ravelin/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c03b8b4f3c315eb905c4061c5819e11267dd1b9750989061f44dda88a650664e
|
4
|
+
data.tar.gz: ccefafc7f05b9c211e9342ee5972a34a3e19a02a538849dbb8d579b620dc1131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fab44608dd40abc7080a29afa76cccd38b00a4b82529410aa1b2634a0b514ef4c5ee93ab642ec0d1bc7ed2b20bf751b900554aac0d6d6c8f922bdae5f164fe1
|
7
|
+
data.tar.gz: 4740c6b585a3256af94bc33c536b3344bb50a5d00b18ef874a954f9a966935043cf229186a65707ca8b263538b3faea4afcdd2c0e7c83dd0cc09db5fd1c0ff79
|
data/lib/ravelin.rb
CHANGED
@@ -12,13 +12,17 @@ require 'ravelin/errors/rate_limit_error'
|
|
12
12
|
require 'ravelin/errors/invalid_label_value_error'
|
13
13
|
|
14
14
|
require 'ravelin/ravelin_object'
|
15
|
+
require 'ravelin/authentication_mechanism'
|
16
|
+
require 'ravelin/ato_login'
|
15
17
|
require 'ravelin/chargeback'
|
16
18
|
require 'ravelin/customer'
|
17
19
|
require 'ravelin/device'
|
18
20
|
require 'ravelin/item'
|
19
21
|
require 'ravelin/location'
|
22
|
+
require 'ravelin/login'
|
20
23
|
require 'ravelin/order'
|
21
24
|
require 'ravelin/payment_method'
|
25
|
+
require 'ravelin/password'
|
22
26
|
require 'ravelin/pre_transaction'
|
23
27
|
require 'ravelin/three_d_secure'
|
24
28
|
require 'ravelin/transaction'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ravelin
|
2
|
+
class AuthenticationMechanism < RavelinObject
|
3
|
+
attr_accessor :password,
|
4
|
+
:social,
|
5
|
+
:one_time_code,
|
6
|
+
:u2f,
|
7
|
+
:rsa_key,
|
8
|
+
:sms_code,
|
9
|
+
:magic_link,
|
10
|
+
:recaptcha
|
11
|
+
|
12
|
+
def password=(passwd)
|
13
|
+
@password = Ravelin::Password.new(passwd)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/ravelin/client.rb
CHANGED
@@ -11,9 +11,12 @@ module Ravelin
|
|
11
11
|
class Client
|
12
12
|
API_BASE = 'https://api.ravelin.com'
|
13
13
|
|
14
|
-
def initialize(api_key:)
|
14
|
+
def initialize(api_key:, api_version: 2)
|
15
15
|
@api_key = api_key
|
16
16
|
|
17
|
+
raise ArgumentError.new("api_version must be 2 or 3") unless [2,3].include? api_version
|
18
|
+
@api_version = api_version
|
19
|
+
|
17
20
|
@connection = Faraday.new(API_BASE, faraday_options) do |conn|
|
18
21
|
conn.response :json, context_type: /\bjson$/
|
19
22
|
conn.adapter Ravelin.faraday_adapter
|
@@ -26,7 +29,7 @@ module Ravelin
|
|
26
29
|
|
27
30
|
score_param = score ? "?score=true" : nil
|
28
31
|
|
29
|
-
post("/
|
32
|
+
post("/v#{@api_version}/#{event.name}#{score_param}", event.serializable_hash)
|
30
33
|
end
|
31
34
|
|
32
35
|
def send_backfill_event(**args)
|
@@ -36,13 +39,13 @@ module Ravelin
|
|
36
39
|
|
37
40
|
event = Event.new(**args)
|
38
41
|
|
39
|
-
post("/
|
42
|
+
post("/v#{@api_version}/backfill/#{event.name}", event.serializable_hash)
|
40
43
|
end
|
41
44
|
|
42
45
|
def send_tag(**args)
|
43
46
|
tag = Tag.new(**args)
|
44
47
|
|
45
|
-
post("/
|
48
|
+
post("/v#{@api_version}/tag/customer", tag.serializable_hash)
|
46
49
|
end
|
47
50
|
|
48
51
|
def delete_tag(**args)
|
@@ -50,19 +53,22 @@ module Ravelin
|
|
50
53
|
customer_id = tag["customerId"]
|
51
54
|
tags = tag["tagNames"].join(",")
|
52
55
|
|
53
|
-
delete("/
|
56
|
+
delete("/v#{@api_version}/tag/customer?customerId=#{customer_id}&tagName=#{tags}")
|
54
57
|
end
|
55
58
|
|
56
59
|
def get_tag(**args)
|
57
60
|
tag = Tag.new(**args).serializable_hash
|
58
61
|
customer_id = tag["customerId"]
|
59
62
|
|
60
|
-
get("/
|
63
|
+
get("/v#{@api_version}/tag/customer/#{customer_id}")
|
61
64
|
end
|
62
65
|
|
63
66
|
private
|
64
67
|
|
65
68
|
def post(url, payload)
|
69
|
+
p url
|
70
|
+
require 'pp'
|
71
|
+
pp payload
|
66
72
|
response = @connection.post(url, payload.to_json)
|
67
73
|
|
68
74
|
if response.success?
|
data/lib/ravelin/event.rb
CHANGED
@@ -26,11 +26,15 @@ module Ravelin
|
|
26
26
|
|
27
27
|
def object_classes
|
28
28
|
{
|
29
|
+
ato_login: AtoLogin,
|
30
|
+
authentication_mechanism: AuthenticationMechanism,
|
29
31
|
chargeback: Chargeback,
|
30
32
|
customer: Customer,
|
31
33
|
device: Device,
|
32
34
|
location: Location,
|
35
|
+
login: Login,
|
33
36
|
order: Order,
|
37
|
+
password: Password,
|
34
38
|
payment_method: PaymentMethod,
|
35
39
|
voucher_redemption: VoucherRedemption,
|
36
40
|
transaction: name == :pretransaction ? PreTransaction : Transaction,
|
@@ -56,8 +60,6 @@ module Ravelin
|
|
56
60
|
:payment_method_id, :payment_method
|
57
61
|
)
|
58
62
|
validate_payload_inclusion_of :order_id
|
59
|
-
when :login
|
60
|
-
validate_payload_inclusion_of :customer_id
|
61
63
|
when :checkout
|
62
64
|
validate_payload_inclusion_of :customer, :order,
|
63
65
|
:payment_method, :transaction
|
@@ -119,6 +121,7 @@ module Ravelin
|
|
119
121
|
underscore_mapping = {
|
120
122
|
payment_method: :paymentmethod,
|
121
123
|
pre_transaction: :pretransaction,
|
124
|
+
ato_login: :login,
|
122
125
|
label: 'label/customer'.to_sym
|
123
126
|
}
|
124
127
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ravelin
|
2
|
+
class Login < RavelinObject
|
3
|
+
attr_accessor :username,
|
4
|
+
:customer_id,
|
5
|
+
:success,
|
6
|
+
:authentication_mechanism
|
7
|
+
|
8
|
+
attr_required :username, :customer_id, :success, :authentication_mechanism
|
9
|
+
|
10
|
+
def authentication_mechanism=(authm)
|
11
|
+
@authentication_mechanism = Ravelin::AuthenticationMechanism.new(authm)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
3
|
+
module Ravelin
|
4
|
+
class Password < RavelinObject
|
5
|
+
attr_accessor :success, :failure_reason, :password_hashed
|
6
|
+
attr_required :success
|
7
|
+
|
8
|
+
# Alternative interface, because when the attr is called "password_hashed",
|
9
|
+
# the end user might think they need to hash the password themselves
|
10
|
+
def password=(passwd)
|
11
|
+
@password_hashed = Digest::SHA256.hexdigest(passwd)
|
12
|
+
end
|
13
|
+
|
14
|
+
def password_hashed=(passwd)
|
15
|
+
@password_hashed = passwd
|
16
|
+
end
|
17
|
+
|
18
|
+
FAILURE_REASONS = %w(BAD_PASSWORD UNKNOWN_USERNAME INTERNAL_ERROR RATE_LIMIT)
|
19
|
+
|
20
|
+
def validate
|
21
|
+
super
|
22
|
+
if !success && !FAILURE_REASONS.include?(failure_reason)
|
23
|
+
raise ArgumentError.new("Failure reason value must be one of #{FAILURE_REASONS.join(', ')}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ravelin/response.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Ravelin
|
2
2
|
class Response
|
3
3
|
attr_reader :customer_id,
|
4
|
+
:ato,
|
4
5
|
:action,
|
5
6
|
:client_reviewed_status,
|
6
7
|
:score,
|
@@ -28,7 +29,7 @@ module Ravelin
|
|
28
29
|
def event(response_body)
|
29
30
|
data = response_body.fetch('data', {})
|
30
31
|
|
31
|
-
@
|
32
|
+
@ato = data['ato']
|
32
33
|
@action = data['action']
|
33
34
|
@score = data['score']
|
34
35
|
@score_id = data['scoreId']
|
data/lib/ravelin/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.19
|
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: 2019-
|
14
|
+
date: 2019-05-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0.
|
22
|
+
version: '0.15'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.15'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: faraday_middleware
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,8 @@ extensions: []
|
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
110
|
- lib/ravelin.rb
|
111
|
+
- lib/ravelin/ato_login.rb
|
112
|
+
- lib/ravelin/authentication_mechanism.rb
|
111
113
|
- lib/ravelin/chargeback.rb
|
112
114
|
- lib/ravelin/client.rb
|
113
115
|
- lib/ravelin/customer.rb
|
@@ -121,7 +123,9 @@ files:
|
|
121
123
|
- lib/ravelin/item.rb
|
122
124
|
- lib/ravelin/label.rb
|
123
125
|
- lib/ravelin/location.rb
|
126
|
+
- lib/ravelin/login.rb
|
124
127
|
- lib/ravelin/order.rb
|
128
|
+
- lib/ravelin/password.rb
|
125
129
|
- lib/ravelin/payment_method.rb
|
126
130
|
- lib/ravelin/pre_transaction.rb
|
127
131
|
- lib/ravelin/ravelin_object.rb
|
@@ -152,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
156
|
version: '0'
|
153
157
|
requirements: []
|
154
158
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.7.9
|
156
160
|
signing_key:
|
157
161
|
specification_version: 4
|
158
162
|
summary: Ruby bindings for the Ravelin API
|